Skip to content

Commit c84ef4c

Browse files
committed
Fix permissions
In general, just tried to follow suit of project workflow
1 parent b05ace6 commit c84ef4c

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

dbschema/migrations/00012-m1pqxkv.edgeql renamed to dbschema/migrations/00012-m1vbhai.edgeql

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/authorization/policies/by-role/financial-analyst-lead.policy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import * as FA from './financial-analyst.policy';
3737
).edit,
3838
]),
3939
r.ProjectWorkflowEvent.transitions(FA.projectTransitions).execute,
40+
r.EngagementWorkflowEvent.transitions(FA.engagementTransitions).execute,
4041
r.ProjectMember.edit.create.delete,
4142
])
4243
export class FinancialAnalystLeadPolicy {}

src/components/authorization/policies/by-role/financial-analyst.policy.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EngagementWorkflow } from '../../../engagement/workflow/engagement-workflow';
12
import { ProjectWorkflow } from '../../../project/workflow/project-workflow';
23
import {
34
inherit,
@@ -16,6 +17,9 @@ export const projectTransitions = () =>
1617
'Complete',
1718
);
1819

20+
export const engagementTransitions = () =>
21+
EngagementWorkflow.pickNames('Not Ready for Completion', 'Complete');
22+
1923
// NOTE: There could be other permissions for this role from other policies
2024
@Policy(
2125
[Role.FinancialAnalyst, Role.LeadFinancialAnalyst, Role.Controller],
@@ -31,9 +35,9 @@ export const projectTransitions = () =>
3135
]),
3236
r.LanguageEngagement.specifically((p) => p.paratextRegistryId.none),
3337
),
34-
r.EngagementWorkflowEvent.read.transitions(
35-
'Not Ready for Completion',
36-
'Complete',
38+
r.EngagementWorkflowEvent.read.whenAll(
39+
member,
40+
r.EngagementWorkflowEvent.isTransitions(engagementTransitions),
3741
).execute,
3842
r.FieldRegion.read,
3943
r.FieldZone.read,

src/components/authorization/policies/by-role/project-manager.policy.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { takeWhile } from 'lodash';
2+
import { EngagementWorkflow } from '../../../engagement/workflow/engagement-workflow';
23
import { ProjectStep } from '../../../project/dto';
34
import { ProjectWorkflow } from '../../../project/workflow/project-workflow';
45
import {
@@ -57,6 +58,22 @@ export const momentumProjectsTransitions = () =>
5758
'Consultant Opposes Proposal',
5859
);
5960

61+
export const engagementTransitions = () =>
62+
EngagementWorkflow.pickNames(
63+
'End Proposal',
64+
'Discuss Change To Plan',
65+
'Discuss Suspension out of Change to Plan Discussion',
66+
'End Change To Plan Discussion',
67+
'Discuss Suspension',
68+
'End Suspension Discussion',
69+
'Discuss Reactivation',
70+
'Discuss Termination',
71+
'End Termination Discussion',
72+
'Finalize Completion',
73+
'Not Ready for Completion',
74+
'Complete',
75+
);
76+
6077
// NOTE: There could be other permissions for this role from other policies
6178
@Policy(
6279
[Role.ProjectManager, Role.RegionalDirector, Role.FieldOperationsDirector],
@@ -82,22 +99,9 @@ export const momentumProjectsTransitions = () =>
8299
p.paratextRegistryId.when(member).read,
83100
]),
84101
),
85-
r.EngagementWorkflowEvent.read.transitions(
86-
'Discuss Change To Plan',
87-
'Discuss Suspension',
88-
'Discuss Termination',
89-
'Finalize Completion',
90-
'Approve Change To Plan',
91-
'End Change To Plan Discussion',
92-
'Discuss Suspension out of Change to Plan Discussion',
93-
'End Suspension Discussion',
94-
'Approve Suspension',
95-
'Approve Reactivation',
96-
'Discuss Reactivation',
97-
'End Termination Discussion',
98-
'Approve Termination',
99-
'Not Ready for Completion',
100-
'Complete',
102+
r.EngagementWorkflowEvent.read.whenAll(
103+
member,
104+
r.EngagementWorkflowEvent.isTransitions(engagementTransitions),
101105
).execute,
102106
r.EthnologueLanguage.read,
103107
r.FieldRegion.read,

src/components/authorization/policies/by-role/regional-director.policy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,12 @@ import * as PM from './project-manager.policy';
3434
'Request Changes for Termination',
3535
'End Termination Discussion By Approver',
3636
).execute,
37+
r.EngagementWorkflowEvent.transitions(
38+
PM.engagementTransitions,
39+
'Reject Proposal',
40+
'Approve Suspension',
41+
'Approve Reactivation',
42+
'Approve Termination',
43+
).execute,
3744
])
3845
export class RegionalDirectorPolicy {}

src/components/engagement/workflow/engagement-workflow.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const EngagementWorkflow = defineWorkflow({
115115
Status.Active,
116116
Status.ActiveChangedPlan,
117117
Status.DiscussingReactivation,
118+
Status.DiscussingSuspension,
118119
Status.Suspended,
119120
),
120121
label: 'Will Not Terminate',

0 commit comments

Comments
 (0)