diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 87f342de6..38d41ac15 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -32,6 +32,17 @@ function ProtectedRoute({ children }: { children: React.ReactNode }) { return <>{children}; } +function EnterpriseAdminRoute({ children }: { children: React.ReactNode }) { + const user = useAuthStore((s) => s.user); + const canAccessEnterpriseSettings = + user?.role === 'org_admin' || + user?.role === 'platform_admin' || + !!user?.is_platform_admin; + + if (!canAccessEnterpriseSettings) return ; + return <>{children}; +} + /* ─── Notification Bar ─── */ type NotificationBarConfig = { enabled: boolean; text: string }; type NotificationBarUpdateEvent = CustomEvent; @@ -213,7 +224,7 @@ export default function App() { } /> } /> } /> - } /> + } /> } /> } /> } /> diff --git a/frontend/src/pages/Layout.tsx b/frontend/src/pages/Layout.tsx index 9d202d829..bd5aa80d4 100644 --- a/frontend/src/pages/Layout.tsx +++ b/frontend/src/pages/Layout.tsx @@ -255,6 +255,7 @@ export default function Layout() { const activeAgentRootMatch = useMatch('/agents/:id'); const activeAgentId = activeAgentNestedMatch?.params.id || activeAgentRootMatch?.params.id; const canAccessPlatformSettings = user?.role === 'platform_admin' || !!(user as any)?.is_platform_admin; + const canAccessEnterpriseSettings = user?.role === 'org_admin' || user?.role === 'platform_admin' || !!(user as any)?.is_platform_admin; const [showAccountSettings, setShowAccountSettings] = useState(false); const [showAccountMenu, setShowAccountMenu] = useState(false); @@ -810,17 +811,19 @@ export default function Layout() { {isChinese ? '创建或加入新公司' : 'Create or join company'} - + {canAccessEnterpriseSettings && ( + + )} )}