fix: system admin bypasses workspace filter in sidebar

This commit is contained in:
Agent Zero
2026-07-30 01:25:29 +02:00
parent 8d5f272ba5
commit 49c8b740e4
+5 -1
View File
@@ -1,5 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { useMyWorkspaces, useWorkspaceContext, type WorkspaceContext } from '@/api/hooks/workspaces';
import { useAuthStore } from '@/store/authStore';
const STORAGE_KEY = 'leocrm-active-workspace';
@@ -47,7 +48,10 @@ export function useWorkspace() {
// Check if a module is visible in the current workspace
const isModuleVisible = useCallback((moduleKey: string): boolean => {
// If no workspace context, show all (backward compatible)
// System admins see all modules regardless of workspace
const user = useAuthStore.getState().user;
if (user?.is_system_admin) return true;
// If no workspace context, show all (backward compatible)
if (!context?.workspace_id || !context?.modules?.length) return true;
return visibleModuleKeys.has(moduleKey);
}, [context, visibleModuleKeys]);