Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPC-9344: Allow for adding comments for project owners, cluster leads and administrators #136

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unocha/hpc-api-core",
"version": "7.2.0",
"version": "7.3.0",
"description": "Core libraries supporting HPC.Tools API Backend",
"license": "Apache-2.0",
"private": false,
Expand Down
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',
/**
* Can add comments 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',
/**
* Can add comments 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