From af8716a7778c8769917d0573b09ff0773453a232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AD=D0=BD=D1=85=D1=82=D3=A9=D1=80?= Date: Tue, 9 Jan 2024 19:38:59 +0800 Subject: [PATCH 1/2] HPC-9344: Add permissions for add comment --- src/auth/permissions.ts | 16 ++++++++++++++++ src/auth/roles.ts | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/auth/permissions.ts b/src/auth/permissions.ts index 69ebb1b7..57b805bd 100644 --- a/src/auth/permissions.ts +++ b/src/auth/permissions.ts @@ -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: { /** @@ -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', @@ -197,6 +205,10 @@ export const AUTH_PERMISSIONS = { */ CLONE: 'clone', DELETE: 'canDelete', + /** + * Can add comments to the project + */ + ADD_COMMENT: 'canAddComment', }, governingEntity: { /** @@ -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; diff --git a/src/auth/roles.ts b/src/auth/roles.ts index 9fda6321..abd618f2 100644 --- a/src/auth/roles.ts +++ b/src/auth/roles.ts @@ -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); @@ -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') { @@ -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') { @@ -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); } } From d12cec840eee66897abce9491370b5c645d1f85b Mon Sep 17 00:00:00 2001 From: Pl217 Date: Tue, 5 Mar 2024 15:54:05 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=96=20Bump=20version=20to=20`v7.3.?= =?UTF-8?q?0`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e34b648..0178df07 100644 --- a/package.json +++ b/package.json @@ -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,