From 35b86374061a77f6aa2e75b29475b30840f19598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AD=D0=BD=D1=85=D1=82=D3=A9=D1=80?= Date: Wed, 27 Sep 2023 21:08:20 +0800 Subject: [PATCH] HPC-9131: Introduce new permissions for updating measurements --- src/auth/permissions.ts | 12 ++++++++++++ src/auth/roles.ts | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/auth/permissions.ts b/src/auth/permissions.ts index e6b06220..017a39bd 100644 --- a/src/auth/permissions.ts +++ b/src/auth/permissions.ts @@ -90,6 +90,10 @@ export const AUTH_PERMISSIONS = { */ CHANGE_ANY_PLAN_VISIBILITY_IN_PROJECTS: 'canChangeAnyPlanVisiblityInProjects', + /** + * Can edit measurements of any plan + */ + EDIT_ANY_MEASUREMENT: 'canEditAnyMeasurement', }, operation: { /** @@ -175,6 +179,10 @@ export const AUTH_PERMISSIONS = { * Can make plan visible to projects, in Projects Module */ MAKE_VISIBLE_IN_PROJECTS: 'canMakeVisibleInProjects', + /** + * Can edit measurements under this plan + */ + EDIT_MEASUREMENTS: 'canEditMeasurements', }, project: { MODIFY_ACCESS_AND_PERMISSIONS: 'canModifyAccessAndPermissions', @@ -208,6 +216,10 @@ export const AUTH_PERMISSIONS = { */ MODIFY_ACCESS_AND_PERMISSIONS_OF_PROJECTS: 'canModifyAccessAndPermissionsOfProjects', + /** + * Can edit measurements with the governing entity + */ + EDIT_MEASUREMENTS: 'canEditMeasurements', }, } as const; diff --git a/src/auth/roles.ts b/src/auth/roles.ts index 95661ced..befeb550 100644 --- a/src/auth/roles.ts +++ b/src/auth/roles.ts @@ -177,6 +177,7 @@ export const calculatePermissionsFromRolesGrant = async < // New Permissions global.add(P.global.VIEW_ANY_PLAN_DATA); global.add(P.global.EDIT_ANY_PLAN_DATA); + global.add(P.global.EDIT_ANY_MEASUREMENT); global.add(P.global.CHANGE_ANY_PLAN_VISIBILITY_IN_PROJECTS); } else if (role === 'ftsAdmin') { // New Permissions @@ -274,6 +275,7 @@ export const calculatePermissionsFromRolesGrant = async < planSet.add(P.plan.PROJECT_WORKFLOW_MOVE_TO_ANY_STEP); planSet.add(P.plan.VIEW_DATA); planSet.add(P.plan.EDIT_DATA); + planSet.add(P.plan.EDIT_MEASUREMENTS); planSet.add(P.plan.MODIFY_ACCESS_AND_PERMISSIONS_OF_PROJECTS); planSet.add(P.plan.EDIT_PROJECTS); planSet.add(P.plan.DELETE_PROJECTS); @@ -329,6 +331,7 @@ export const calculatePermissionsFromRolesGrant = async < if (role === 'clusterLead') { geSet.add(P.governingEntity.EDIT_DATA); geSet.add(P.governingEntity.EDIT_PROJECTS); + 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); planSet.add(P.plan.VIEW_DATA);