Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / shared / lib / drive / permissions.ts
blob154f9677a70c233284fbc5ce8ab4091862c1a463
1 import { hasBit } from '@proton/shared/lib/helpers/bitset';
3 // This is deprecated, so we don't put it in enum SHARE_MEMBER_PERMISSIONS
4 const EXEC = 1;
6 export enum DRIVE_PERMISSIONS {
7     READ = 4,
8     WRITE = 2,
9     ADMIN = 16,
10     SUPER_ADMIN = 32,
13 const { READ, WRITE, ADMIN, SUPER_ADMIN } = DRIVE_PERMISSIONS;
15 export enum SHARE_URL_PERMISSIONS {
16     VIEWER = READ,
17     EDITOR = EXEC + WRITE + READ, //TODO: Remove this when this ticket is done: DRVBE-868
20 export enum SHARE_MEMBER_PERMISSIONS {
21     OWNER = EXEC + READ + WRITE + ADMIN + SUPER_ADMIN,
22     VIEWER = READ,
23     EDITOR = WRITE + READ,
24     ADMIN_EDITOR = WRITE + READ + ADMIN,
27 export const getCanWrite = (permissions: SHARE_MEMBER_PERMISSIONS | SHARE_URL_PERMISSIONS) => {
28     return hasBit(permissions, DRIVE_PERMISSIONS.WRITE);
31 export const getCanAdmin = (permissions: SHARE_MEMBER_PERMISSIONS) => {
32     return hasBit(permissions, DRIVE_PERMISSIONS.ADMIN);
35 export const getIsOwner = (permissions: SHARE_MEMBER_PERMISSIONS) => {
36     return permissions === SHARE_MEMBER_PERMISSIONS.OWNER;