Fix permissions handling with react context
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -65,3 +65,4 @@ export { fileType, fileSize } from "./file";
|
||||
export { formatDatetime, formatDate } from "./date";
|
||||
export { getLogoUrl, getTrustCenterUrl } from "./trustCenter";
|
||||
export { formatError, type GraphQLError } from "./error";
|
||||
export { Role, getAssignableRoles } from "./roles";
|
||||
|
||||
19
packages/helpers/src/roles.ts
Normal file
19
packages/helpers/src/roles.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export enum Role {
|
||||
OWNER = "OWNER",
|
||||
ADMIN = "ADMIN",
|
||||
VIEWER = "VIEWER",
|
||||
}
|
||||
|
||||
export function getAssignableRoles(currentRole: Role): string[] {
|
||||
if (!currentRole) return [];
|
||||
|
||||
if (currentRole === "OWNER") {
|
||||
return ["OWNER", "ADMIN", "VIEWER"];
|
||||
}
|
||||
|
||||
if (currentRole === "ADMIN") {
|
||||
return ["ADMIN", "VIEWER"];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
Reference in New Issue
Block a user