Skip to content

Commit

Permalink
Add access control version check for roles
Browse files Browse the repository at this point in the history
  • Loading branch information
zlwaterfield committed Jan 29, 2025
1 parent 357ee83 commit 5f2f520
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
4 changes: 0 additions & 4 deletions frontend/src/scenes/settings/environment/teamMembersLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ export const teamMembersLogic = kea<teamMembersLogicType>([
(explicitMembersLoading, organizationMembersLoading) =>
explicitMembersLoading || organizationMembersLoading,
],
// isUpdateAccessControlVersionLoading: [
// (s) => [s.updateAccessControlVersionLoading],
// (updateAccessControlVersionLoading) => updateAccessControlVersionLoading,
// ],
admins: [
(s) => [s.allMembers],
(allMembers: FusedTeamMemberType[]) => allMembers.filter(({ level }) => level >= TeamMembershipLevel.Admin),
Expand Down
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 />
</>
)
}

0 comments on commit 5f2f520

Please sign in to comment.