Skip to content

Commit

Permalink
fix: allow tenant right update for admin user without tenant rights
Browse files Browse the repository at this point in the history
Fix #889
  • Loading branch information
helakaraa authored Oct 18, 2024
1 parent 2ac0bb2 commit 3135559
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions izanami-frontend/src/components/RightSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,14 @@ export function RightSelector(props: {
if (tenantQuery.isLoading) {
return <Loader message="Loading tenants.." />;
} else if (tenantQuery.data) {
const tenants = tenantQuery.data.map((t) => t.name);
const selectorChoices = tenants.filter((item) => {
return !selectedTenants.includes(item);
});
const tenants = props.tenant
? [props.tenant]
: tenantQuery.data.map((t) => t.name);
const selectorChoices = props.tenant
? [props.tenant]
: tenants.filter((item) => {
return !selectedTenants.includes(item);
});

return (
<div>
Expand Down Expand Up @@ -491,14 +495,30 @@ export function RightSelector(props: {
</>
)}
</>
{!props.tenant &&
!creating &&
selectedTenants.length < tenantQuery.data.length && (
{!creating &&
selectedTenants.length < tenants.length &&
!(
props.tenant &&
defaultValue?.tenants &&
props.tenant in defaultValue.tenants
) && (
<button
className="btn btn-primary mt-2"
onClick={() => setCreating(true)}
onClick={() => {
if (props.tenant) {
setCreating(false);
dispatch({
type: EventType.SelectTenant,
name: props.tenant,
});
} else {
setCreating(true);
}
}}
>
Add another tenant
{props.tenant
? `Add specific ${props.tenant} right`
: "Add another tenant"}
</button>
)}
</div>
Expand Down

0 comments on commit 3135559

Please sign in to comment.