forked from baron/baron-sso
feat: handle multiple manageable tenants for tenant admin
This commit is contained in:
@@ -50,25 +50,33 @@ function AppLayout() {
|
||||
const items = [...staticNavItems];
|
||||
const isSuperAdmin = profile?.role === "super_admin";
|
||||
const isTenantAdmin = profile?.role === "tenant_admin";
|
||||
const manageableCount = profile?.manageableTenants?.length ?? 0;
|
||||
|
||||
if (isSuperAdmin) {
|
||||
// Insert Tenants at index 1 for Super Admin
|
||||
// Super Admin sees everything
|
||||
items.splice(1, 0, {
|
||||
label: "ui.admin.nav.tenants",
|
||||
to: "/tenants",
|
||||
icon: Building2,
|
||||
});
|
||||
} else if (isTenantAdmin && profile?.tenantId) {
|
||||
// Insert My Tenant link for Tenant Admin
|
||||
items.splice(1, 0, {
|
||||
label: "ui.admin.nav.my_tenant",
|
||||
to: `/tenants/${profile.tenantId}`,
|
||||
icon: Building2,
|
||||
});
|
||||
} else if (isTenantAdmin) {
|
||||
if (manageableCount === 1 && profile?.tenantId) {
|
||||
// Direct link if only one tenant
|
||||
items.splice(1, 0, {
|
||||
label: "ui.admin.nav.my_tenant",
|
||||
to: `/tenants/${profile.tenantId}`,
|
||||
icon: Building2,
|
||||
});
|
||||
} else if (manageableCount > 1) {
|
||||
// Show list menu if multiple tenants
|
||||
items.splice(1, 0, {
|
||||
label: "ui.admin.nav.tenants",
|
||||
to: "/tenants",
|
||||
icon: Building2,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Tenant Admin should not see global API keys or global audit logs (unless allowed)
|
||||
// For now, let's keep them but they might return 403
|
||||
return items;
|
||||
}, [profile]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user