Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
feat: allow editor to change project settings (#10383)
Browse files Browse the repository at this point in the history
Co-authored-by: Hanzla Mateen <[email protected]>
  • Loading branch information
jose-galvan and hanzlamateen authored Jun 14, 2024
1 parent 40bd008 commit f620847
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/client-core/src/user/useUserProjectPermission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ export const useProjectPermissions = (project: string): ProjectPermissionType =>
const [permission] = data
return permission
}

/**
*
* @param {ProjectPermissionType} userPermission current user permission
* @param {string | string[]} required required permission
* @returns {boolean} whether the user has or not the required permission
*/
export const userHasProjectPermission = (
userPermission: ProjectPermissionType,
required: string[] | string
): boolean => {
if (!userPermission?.type) {
return false
}

if (!Array.isArray(required)) {
return userPermission.type === required
}
return required.includes(userPermission.type)
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
iffElse(
checkScope('projects', 'write'),
[],
[verifyScope('editor', 'write'), verifyProjectPermission(['owner'])]
[verifyScope('editor', 'write'), verifyProjectPermission(['owner', 'editor'])]
)
)
],
Expand Down

0 comments on commit f620847

Please sign in to comment.