Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ACL): extract 'isGranted' method [YTFRONT-4560] #918

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
}
Loading