refactor: move web utils to packages (#7145)
* refactor: move web utils to packages * fix: build and lint errors * chore: update drag handle plugin * chore: update table cell type to fix build errors * fix: build errors * chore: sync few changes * fix: build errors * chore: minor fixes related to duplicate assets imports * fix: build errors * chore: minor changes
This commit is contained in:
parent
dffcc6dc10
commit
2014400bed
614 changed files with 1999 additions and 3030 deletions
1
packages/utils/src/permission/index.ts
Normal file
1
packages/utils/src/permission/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./role";
|
||||
25
packages/utils/src/permission/role.ts
Normal file
25
packages/utils/src/permission/role.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// plane imports
|
||||
import { EUserProjectRoles, EUserWorkspaceRoles, EUserPermissions } from "@plane/constants";
|
||||
|
||||
export const getUserRole = (role: EUserPermissions | EUserWorkspaceRoles | EUserProjectRoles) => {
|
||||
switch (role) {
|
||||
case EUserPermissions.GUEST:
|
||||
return "GUEST";
|
||||
case EUserPermissions.MEMBER:
|
||||
return "MEMBER";
|
||||
case EUserPermissions.ADMIN:
|
||||
return "ADMIN";
|
||||
}
|
||||
};
|
||||
|
||||
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