Skip to content

Commit

Permalink
chore(ACL): extract 'isGranted' method [YTFRONT-4560]
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-efremoff committed Dec 16, 2024
1 parent d61ff09 commit 9906dcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ui/src/ui/containers/ACL/ACL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {ObjectPermissionRowWithExpand, PreparedApprover} from '../../store/selec

import {SegmentControl, SegmentControlItem} from '../../components/SegmentControl/SegmentControl';
import WithStickyToolbar from '../../components/WithStickyToolbar/WithStickyToolbar';
import {PreparedRole} from '../../utils/acl';
import {PreparedRole, isGranted} from '../../utils/acl';
import {AclModeControl} from './AclModeControl';
import {ExpandButton} from '../../components/ExpandButton';
import {AclColumnsCell} from './AclColumnsCell';
Expand Down Expand Up @@ -601,7 +601,7 @@ class ACL extends Component<Props> {
UIFactory.getAclPermissionsSettings()[idmKind];

function toSegmentItem(name: string, role?: boolean | PreparedRole, invert?: boolean) {
const value = 'boolean' === typeof role ? role : role?.state === 'granted';
const value = isGranted(role);
return {
name,
value: invert ? !value : value,
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/ui/utils/acl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,7 @@ export function convertFromUIPermission(permission: YTPermissionTypeUI): {
}
return {permission};
}

export function isGranted(role: boolean | PreparedRole | undefined) {
return 'boolean' === typeof role ? role : role?.state === 'granted';
}

0 comments on commit 9906dcb

Please sign in to comment.