-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add access control version check for roles
- Loading branch information
1 parent
357ee83
commit 5f2f520
Showing
2 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 28 additions & 1 deletion
29
frontend/src/scenes/settings/organization/Permissions/RoleBasedAccess.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
// NOTE: This is only to allow testing the new RBAC system | ||
|
||
import { LemonBanner } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag' | ||
import { teamLogic } from 'scenes/teamLogic' | ||
|
||
import { RolesAndResourceAccessControls } from '~/layout/navigation-3000/sidepanel/panels/access_control/RolesAndResourceAccessControls' | ||
|
||
import { PermissionsGrid } from './PermissionsGrid' | ||
|
||
export function RoleBasedAccess(): JSX.Element { | ||
const { currentTeam } = useValues(teamLogic) | ||
const { updateAccessControlVersion } = useActions(teamLogic) | ||
const newAccessControl = useFeatureFlag('ROLE_BASED_ACCESS_CONTROL') | ||
return newAccessControl ? <RolesAndResourceAccessControls noAccessControls /> : <PermissionsGrid /> | ||
|
||
if (newAccessControl && currentTeam?.access_control_version === 'v2') { | ||
return <RolesAndResourceAccessControls noAccessControls /> | ||
} | ||
|
||
return ( | ||
<> | ||
{newAccessControl && ( | ||
<LemonBanner | ||
className="mb-4" | ||
type="warning" | ||
action={{ | ||
children: 'Upgrade now', | ||
onClick: () => updateAccessControlVersion(), | ||
}} | ||
> | ||
You're eligible to upgrade to our new access control system. This will allow you to better manage | ||
your roles across more resources on PostHog. | ||
</LemonBanner> | ||
)} | ||
<PermissionsGrid /> | ||
</> | ||
) | ||
} |