Skip to content

Commit

Permalink
Merge pull request #129 from UN-OCHA/HPC-9131
Browse files Browse the repository at this point in the history
HPC-9131: Introduce new permissions for update measurements
  • Loading branch information
Pl217 authored Oct 3, 2023
2 parents 47b0b15 + 35b8637 commit 98dc0e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/auth/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
/**
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions src/auth/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 98dc0e1

Please sign in to comment.