[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:
Prateek Shourya 2025-05-30 19:57:07 +05:30 committed by GitHub
parent 322af8c436
commit 67cbe94d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 719 additions and 428 deletions

View file

@ -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";

View 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));
};