Skip to content

Commit

Permalink
HPC-9344: Add permissions for add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
enxtur committed Jan 9, 2024
1 parent 33756b1 commit 9343ba2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/auth/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export const AUTH_PERMISSIONS = {
* Can edit measurements of any plan
*/
EDIT_ANY_MEASUREMENT: 'canEditAnyMeasurement',
/**
* Add comment to any project
*/
ADD_COMMENT_TO_ANY_PROJECT: 'canAddCommentToAnyProject',
},
operation: {
/**
Expand Down Expand Up @@ -184,6 +188,10 @@ export const AUTH_PERMISSIONS = {
* Can edit measurements under this plan
*/
EDIT_MEASUREMENTS: 'canEditMeasurements',
/**
* Can add comment to any project under this plan
*/
ADD_COMMENT_TO_PROJECTS: 'canAddCommentToProjects',
},
project: {
MODIFY_ACCESS_AND_PERMISSIONS: 'canModifyAccessAndPermissions',
Expand All @@ -197,6 +205,10 @@ export const AUTH_PERMISSIONS = {
*/
CLONE: 'clone',
DELETE: 'canDelete',
/**
* Owner can add comment to the project
*/
ADD_COMMENT: 'canAddComment',
},
governingEntity: {
/**
Expand All @@ -221,6 +233,10 @@ export const AUTH_PERMISSIONS = {
* Can edit measurements with the governing entity
*/
EDIT_MEASUREMENTS: 'canEditMeasurements',
/**
* Can add comment to any project under this governing entity
*/
ADD_COMMENT_TO_PROJECTS: 'canAddCommentToProjects',
},
} as const;

Expand Down
4 changes: 4 additions & 0 deletions src/auth/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const calculatePermissionsFromRolesGrant = async <
} else if (role === 'projectsAdmin') {
// New Permissions
global.add(P.global.PROJECT_WORKFLOW_MOVE_TO_ANY_STEP);
global.add(P.global.ADD_COMMENT_TO_ANY_PROJECT);
} else if (role === 'swaps') {
global.add(P.global.MODIFY_OPERATION_ACCESS_AND_PERMISSIONS);
global.add(P.global.ADD_OPERATION);
Expand Down Expand Up @@ -286,6 +287,7 @@ export const calculatePermissionsFromRolesGrant = async <
planSet.add(P.plan.DELETE_PROJECTS);
planSet.add(P.plan.CLONE_PROJECTS);
planSet.add(P.plan.MAKE_VISIBLE_IN_PROJECTS);
planSet.add(P.plan.ADD_COMMENT_TO_PROJECTS);
}
}
} else if (grant.type === 'project') {
Expand All @@ -303,6 +305,7 @@ export const calculatePermissionsFromRolesGrant = async <
projectSet.add(P.project.DELETE);
projectSet.add(P.project.MODIFY_ACCESS_AND_PERMISSIONS);
projectSet.add(P.project.VIEW_DATA);
projectSet.add(P.project.ADD_COMMENT);
}
}
} else if (grant.type === 'governingEntity') {
Expand Down Expand Up @@ -339,6 +342,7 @@ export const calculatePermissionsFromRolesGrant = async <
geSet.add(P.governingEntity.EDIT_MEASUREMENTS);
geSet.add(P.governingEntity.PROJECT_WORKFLOW_MOVE_IF_PLAN_UNLOCKED);
geSet.add(P.governingEntity.MODIFY_ACCESS_AND_PERMISSIONS_OF_PROJECTS);
geSet.add(P.governingEntity.ADD_COMMENT_TO_PROJECTS);
planSet.add(P.plan.VIEW_DATA);
}
}
Expand Down

0 comments on commit 9343ba2

Please sign in to comment.