Skip to content

Commit

Permalink
Fix permissions
Browse files Browse the repository at this point in the history
In general, just tried to follow suit of project workflow
  • Loading branch information
CarsonF committed Jul 9, 2024
1 parent 8eb8647 commit 97d6ca6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import * as FA from './financial-analyst.policy';
).edit,
]),
r.ProjectWorkflowEvent.transitions(FA.projectTransitions).execute,
r.EngagementWorkflowEvent.transitions(FA.engagementTransitions).execute,
r.ProjectMember.edit.create.delete,
])
export class FinancialAnalystLeadPolicy {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EngagementWorkflow } from '../../../engagement/workflow/engagement-workflow';
import { ProjectWorkflow } from '../../../project/workflow/project-workflow';
import {
inherit,
Expand All @@ -16,6 +17,9 @@ export const projectTransitions = () =>
'Complete',
);

export const engagementTransitions = () =>
EngagementWorkflow.pickNames('Not Ready for Completion', 'Complete');

// NOTE: There could be other permissions for this role from other policies
@Policy(
[Role.FinancialAnalyst, Role.LeadFinancialAnalyst, Role.Controller],
Expand All @@ -31,9 +35,9 @@ export const projectTransitions = () =>
]),
r.LanguageEngagement.specifically((p) => p.paratextRegistryId.none),
),
r.EngagementWorkflowEvent.read.transitions(
'Not Ready for Completion',
'Complete',
r.EngagementWorkflowEvent.read.whenAll(
member,
r.EngagementWorkflowEvent.isTransitions(engagementTransitions),
).execute,
r.FieldRegion.read,
r.FieldZone.read,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { takeWhile } from 'lodash';
import { EngagementWorkflow } from '../../../engagement/workflow/engagement-workflow';
import { ProjectStep } from '../../../project/dto';
import { ProjectWorkflow } from '../../../project/workflow/project-workflow';
import {
Expand Down Expand Up @@ -57,6 +58,22 @@ export const momentumProjectsTransitions = () =>
'Consultant Opposes Proposal',
);

export const engagementTransitions = () =>
EngagementWorkflow.pickNames(
'End Proposal',
'Discuss Change To Plan',
'Discuss Suspension out of Change to Plan Discussion',
'End Change To Plan Discussion',
'Discuss Suspension',
'End Suspension Discussion',
'Discuss Reactivation',
'Discuss Termination',
'End Termination Discussion',
'Finalize Completion',
'Not Ready for Completion',
'Complete',
);

// NOTE: There could be other permissions for this role from other policies
@Policy(
[Role.ProjectManager, Role.RegionalDirector, Role.FieldOperationsDirector],
Expand All @@ -82,22 +99,9 @@ export const momentumProjectsTransitions = () =>
p.paratextRegistryId.when(member).read,
]),
),
r.EngagementWorkflowEvent.read.transitions(
'Discuss Change To Plan',
'Discuss Suspension',
'Discuss Termination',
'Finalize Completion',
'Approve Change To Plan',
'End Change To Plan Discussion',
'Discuss Suspension out of Change to Plan Discussion',
'End Suspension Discussion',
'Approve Suspension',
'Approve Reactivation',
'Discuss Reactivation',
'End Termination Discussion',
'Approve Termination',
'Not Ready for Completion',
'Complete',
r.EngagementWorkflowEvent.read.whenAll(
member,
r.EngagementWorkflowEvent.isTransitions(engagementTransitions),
).execute,
r.EthnologueLanguage.read,
r.FieldRegion.read,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ import * as PM from './project-manager.policy';
'Request Changes for Termination',
'End Termination Discussion By Approver',
).execute,
r.EngagementWorkflowEvent.transitions(
PM.engagementTransitions,
'Reject Proposal',
'Approve Suspension',
'Approve Reactivation',
'Approve Termination',
).execute,
])
export class RegionalDirectorPolicy {}
1 change: 1 addition & 0 deletions src/components/engagement/workflow/engagement-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const EngagementWorkflow = defineWorkflow({
Status.Active,
Status.ActiveChangedPlan,
Status.DiscussingReactivation,
Status.DiscussingSuspension,
Status.Suspended,
),
label: 'Will Not Terminate',
Expand Down

0 comments on commit 97d6ca6

Please sign in to comment.