From 85b7de74cb58505680c0d6700d7171bd2136b177 Mon Sep 17 00:00:00 2001 From: Aaron Plave Date: Mon, 18 Mar 2024 13:46:06 -0700 Subject: [PATCH] Fix editing of plan tags (#1166) * Restore plan update permissions entry --- src/components/plan/PlanForm.svelte | 1 - src/utilities/permissions.ts | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/plan/PlanForm.svelte b/src/components/plan/PlanForm.svelte index 387895bc1a..c69e37444e 100644 --- a/src/components/plan/PlanForm.svelte +++ b/src/components/plan/PlanForm.svelte @@ -34,7 +34,6 @@ let hasPlanUpdatePermission: boolean = false; $: permissionError = $planReadOnly ? PlanStatusMessages.READ_ONLY : 'You do not have permission to edit this plan.'; - $: { if (plan && user) { hasPlanUpdatePermission = featurePermissions.plan.canUpdate(user, plan) && !$planReadOnly; diff --git a/src/utilities/permissions.ts b/src/utilities/permissions.ts index 83ff189df5..72d0597853 100644 --- a/src/utilities/permissions.ts +++ b/src/utilities/permissions.ts @@ -762,6 +762,9 @@ const queryPermissions = { isUserAdmin(user) || (getPermission(['update_expansion_rule_by_pk'], user) && isUserOwner(user, expansionRule)) ); }, + UPDATE_PLAN: (user: User | null, plan: PlanWithOwners): boolean => { + return isUserAdmin(user) || (getPermission(['update_plan_by_pk'], user) && isPlanOwner(user, plan)); + }, UPDATE_PLAN_SNAPSHOT: (user: User | null): boolean => { return getPermission(['update_plan_snapshot_by_pk'], user); }, @@ -1021,7 +1024,7 @@ const featurePermissions: FeaturePermissions = { canCreate: user => queryPermissions.CREATE_PLAN(user), canDelete: (user, plan) => queryPermissions.DELETE_PLAN(user, plan), canRead: user => queryPermissions.GET_PLAN(user), - canUpdate: () => false, // no feature to update plan exists + canUpdate: (user, plan) => queryPermissions.UPDATE_PLAN(user, plan), }, planBranch: { canCreateBranch: (user, plan, model) => queryPermissions.DUPLICATE_PLAN(user, plan, model),