1
0
forked from baron/baron-sso

feat: implement role-based UI filtering for overview and navigation

This commit is contained in:
2026-03-04 14:01:12 +09:00
parent 20a8a19e12
commit 145b807ebf
2 changed files with 41 additions and 28 deletions

View File

@@ -52,9 +52,15 @@ function AppLayout() {
const isTenantAdmin = profile?.role === "tenant_admin";
const manageableCount = profile?.manageableTenants?.length ?? 0;
// Filter out restricted items for non-super admins
const filteredItems = items.filter(item => {
if (item.to === "/api-keys") return isSuperAdmin;
return true;
});
if (isSuperAdmin) {
// Super Admin sees everything
items.splice(1, 0, {
filteredItems.splice(1, 0, {
label: "ui.admin.nav.tenants",
to: "/tenants",
icon: Building2,
@@ -62,14 +68,14 @@ function AppLayout() {
} else if (isTenantAdmin) {
if (manageableCount <= 1 && profile?.tenantId) {
// Direct link if only one (or zero in array but has tenantId) tenant
items.splice(1, 0, {
filteredItems.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, {
filteredItems.splice(1, 0, {
label: "ui.admin.nav.tenants",
to: "/tenants",
icon: Building2,
@@ -77,7 +83,7 @@ function AppLayout() {
}
}
return items;
return filteredItems;
}, [profile]);
const handleLogout = () => {