diff --git a/packages/components/src/RBACProvider/RBACProvider.tsx b/packages/components/src/RBACProvider/RBACProvider.tsx index 4a6d78d1f..66710db11 100644 --- a/packages/components/src/RBACProvider/RBACProvider.tsx +++ b/packages/components/src/RBACProvider/RBACProvider.tsx @@ -19,15 +19,15 @@ const hasAccessWithUserPermissions = (userPermissions: (Access | string)[], chec }; export interface RBACProviderProps { - appName: string; - checkResourceDefinitions: boolean; + appName?: string | null; + checkResourceDefinitions?: boolean; } export const RBACProvider: React.FunctionComponent = ({ appName, checkResourceDefinitions = false, children }) => { const [permissionState, setPermissionState] = useState(initialPermissions); const fetchPermissions = async () => { - const { isOrgAdmin, permissions: userPermissions } = await getRBAC(appName, true); + const { isOrgAdmin, permissions: userPermissions } = await getRBAC(appName === null ? '' : appName, true); setPermissionState((currentPerms) => ({ ...currentPerms, @@ -38,8 +38,14 @@ export const RBACProvider: React.FunctionComponent = ({ appNa }; useEffect(() => { - if (appName) { + // if null or string - then fetch the permissions + if (appName !== undefined) { fetchPermissions(); + } else { + setPermissionState((currentPerms) => ({ + ...currentPerms, + isLoading: false, + })); } }, [appName]);