[WEB-3964] refactor: permission layer (#7094)
* refactor: permission layer * refactor: add original_role to project member serializer * chore: minor fixes related to permission layer * fix: strict type checking while checking user permissions
This commit is contained in:
parent
322af8c436
commit
67cbe94d4a
64 changed files with 719 additions and 428 deletions
|
|
@ -8,9 +8,10 @@ export * from "./emoji";
|
|||
export * from "./file";
|
||||
export * from "./get-icon-for-link";
|
||||
export * from "./issue";
|
||||
export * from "./permission";
|
||||
export * from "./state";
|
||||
export * from "./string";
|
||||
export * from "./subscription";
|
||||
export * from "./theme";
|
||||
export * from "./work-item";
|
||||
export * from "./workspace";
|
||||
export * from "./workspace";
|
||||
13
packages/utils/src/permission.ts
Normal file
13
packages/utils/src/permission.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { EUserPermissions, EUserProjectRoles, EUserWorkspaceRoles } from "@plane/constants";
|
||||
|
||||
type TSupportedRole = EUserPermissions | EUserProjectRoles | EUserWorkspaceRoles;
|
||||
|
||||
/**
|
||||
* @description Returns the highest role from an array of supported roles
|
||||
* @param { TSupportedRole[] } roles
|
||||
* @returns { TSupportedRole | undefined }
|
||||
*/
|
||||
export const getHighestRole = <T extends TSupportedRole>(roles: T[]): T | undefined => {
|
||||
if (!roles || roles.length === 0) return undefined;
|
||||
return roles.reduce((highest, current) => (current > highest ? current : highest));
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue