Skip to content

Commit dc4f011

Browse files
authored
Merge pull request #3241 from SeedCompany/project-workflow
Project Workflow v2 Polish - Transition Names & Auth
2 parents 6756446 + 60d07a1 commit dc4f011

30 files changed

+381
-286
lines changed

dbschema/migrations/00011-m1ohpds.edgeql

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

dbschema/project-workflow.esdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Project {
2-
type WorkflowEvent {
2+
type WorkflowEvent extending ContextAware {
33
required project: default::Project {
44
readonly := true;
55
on target delete delete source;

dbschema/project.esdl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ module default {
88
Mixin::Pinnable,
99
Mixin::Taggable
1010
{
11+
type := <Project::Type>.__type__.name[9:-7];
12+
1113
overloaded name {
1214
constraint exclusive;
1315
};
14-
16+
1517
overloaded required ownSensitivity: Sensitivity {
1618
annotation description := "The sensitivity of the project. \
1719
This is user settable for internships and calculated for translation projects";

dbschema/seeds/008.projects.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ export default (async function ({ e, db, print }) {
140140

141141
if (step !== 'EarlyConversations') {
142142
await e
143-
.insert(e.Project.WorkflowEvent, { project: projectRef, to: step })
143+
.insert(e.Project.WorkflowEvent, {
144+
project: projectRef,
145+
projectContext: projectRef.projectContext,
146+
to: step,
147+
})
144148
.run(db);
145149
}
146150
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { member, Policy, Role, sensMediumOrLower, sensOnlyLow } from '../util';
2+
import * as Consultant from './consultant.policy';
23

34
// NOTE: There could be other permissions for this role from other policies
45
@Policy(Role.ConsultantManager, (r) => [
@@ -28,7 +29,6 @@ import { member, Policy, Role, sensMediumOrLower, sensOnlyLow } from '../util';
2829
]),
2930
r.Project.read
3031
.specifically((p) => [
31-
p.many('step', 'stepChangedAt').edit,
3232
p
3333
.many(
3434
'financialReportPeriod',
@@ -41,6 +41,7 @@ import { member, Policy, Role, sensMediumOrLower, sensOnlyLow } from '../util';
4141
p.rootDirectory.whenAny(member, sensMediumOrLower).edit,
4242
])
4343
.children((c) => [c.posts.edit]),
44+
r.ProjectWorkflowEvent.transitions(Consultant.projectTransitions).execute,
4445
[
4546
r.PeriodicReport,
4647
r.ProgressReportCommunityStory,

src/components/authorization/policies/by-role/consultant.policy.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import { ProjectWorkflow } from '../../../project/workflow/project-workflow';
12
import { member, Policy, Role } from '../util';
23

4+
export const projectTransitions = () =>
5+
ProjectWorkflow.pickNames(
6+
'Consultant Endorses Proposal',
7+
'Consultant Opposes Proposal',
8+
);
9+
310
// NOTE: There could be other permissions for this role from other policies
411
@Policy([Role.Consultant, Role.ConsultantManager], (r) => [
512
[
@@ -33,14 +40,12 @@ import { member, Policy, Role } from '../util';
3340
r.NarrativeReport.when(member).edit.create,
3441
r.Organization.specifically((p) => p.address.none),
3542
r.Partner.specifically((p) => p.pointOfContact.none),
36-
r.Project.when(member).specifically((p) => [
37-
p.many('step', 'stepChangedAt', 'rootDirectory').edit,
38-
]),
43+
r.Project.when(member).specifically((p) => p.rootDirectory.edit),
3944
r.Unavailability.read,
4045
r.User.read.create,
41-
r.ProjectWorkflowEvent.read.transitions(
42-
'Pending Consultant Endorsement -> Prep for Financial Endorsement With Consultant Endorsement',
43-
'Pending Consultant Endorsement -> Prep for Financial Endorsement Without Consultant Endorsement',
46+
r.ProjectWorkflowEvent.read.whenAll(
47+
member,
48+
r.ProjectWorkflowEvent.isTransitions(projectTransitions),
4449
).execute,
4550
])
4651
export class ConsultantPolicy {}

src/components/authorization/policies/by-role/controller.policy.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { Policy, Role } from '../util';
66
r.Organization.delete,
77
r.Partner.delete,
88
r.ProjectWorkflowEvent.read.transitions(
9-
'Pending & On Hold Finance Confirmation -> Active',
10-
'Pending Finance Confirmation -> Pending Regional Director Approval',
11-
'Pending Finance Confirmation -> Did Not Develop',
12-
'Pending Finance Confirmation -> On Hold Finance Confirmation',
13-
'Pending & On Hold Finance Confirmation -> Finalizing Proposal',
14-
'Pending & On Hold Finance Confirmation -> Rejected',
15-
'Pending Change To Plan Confirmation -> Discussing Change To Plan',
16-
'Pending Change To Plan Confirmation -> Active Changed Plan',
17-
'Pending Change To Plan Confirmation -> Back To Active',
9+
'Finance Approves Proposal',
10+
'Finance Holds for Confirmation',
11+
'Finance Requests Proposal Changes',
12+
'Finance Requests Multiplication Changes',
13+
'Finance Rejects Proposal',
14+
'Finance Ends Development',
15+
'Finance Approves Change To Plan',
16+
'Finance Requests Changes for Change To Plan',
17+
'Finance Rejects Change To Plan',
1818
).execute,
1919
])
2020
export class ControllerPolicy {}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import { Policy, Role } from '../util';
1616
r.Project.edit,
1717
r.ProjectMember.edit.create.delete,
1818
r.ProjectWorkflowEvent.read.transitions(
19-
'Pending Zone Director Approval -> Pending Finance Confirmation',
20-
'Pending Zone Director Approval -> Finalizing Proposal',
21-
'Pending Zone Director Approval -> Rejected',
19+
'Field Ops Approves Proposal',
20+
'Field Ops Requests Proposal Changes',
21+
'Field Ops Rejects Proposal',
2222
).execute,
2323
r.PeriodicReport.edit,
2424
r.StepProgress.edit,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { member, Policy, Role, sensMediumOrLower } from '../util';
2+
import * as FA from './financial-analyst.policy';
23

34
// NOTE: There could be other permissions for this role from other policies
45
@Policy([Role.LeadFinancialAnalyst, Role.Controller], (r) => [
@@ -35,6 +36,7 @@ import { member, Policy, Role, sensMediumOrLower } from '../util';
3536
'financialReportReceivedAt',
3637
).edit,
3738
]),
39+
r.ProjectWorkflowEvent.transitions(FA.projectTransitions).execute,
3840
r.ProjectMember.edit.create.delete,
3941
])
4042
export class FinancialAnalystLeadPolicy {}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ProjectWorkflow } from '../../../project/workflow/project-workflow';
12
import {
23
inherit,
34
member,
@@ -7,6 +8,14 @@ import {
78
sensOnlyLow,
89
} from '../util';
910

11+
export const projectTransitions = () =>
12+
ProjectWorkflow.pickNames(
13+
'Finance Endorses Proposal',
14+
'Finance Opposes Proposal',
15+
'Not Ready for Completion',
16+
'Complete',
17+
);
18+
1019
// NOTE: There could be other permissions for this role from other policies
1120
@Policy(
1221
[Role.FinancialAnalyst, Role.LeadFinancialAnalyst, Role.Controller],
@@ -61,11 +70,9 @@ import {
6170
])
6271
.children((c) => c.posts.edit),
6372
r.ProjectMember.read.when(member).edit.create.delete,
64-
r.ProjectWorkflowEvent.read.transitions(
65-
'Pending Financial Endorsement -> Finalizing Proposal With Financial Endorsement',
66-
'Pending Financial Endorsement -> Finalizing Proposal Without Financial Endorsement',
67-
'Finalizing Completion -> Back To Active',
68-
'Finalizing Completion -> Completed',
73+
r.ProjectWorkflowEvent.read.whenAll(
74+
member,
75+
r.ProjectWorkflowEvent.isTransitions(projectTransitions),
6976
).execute,
7077
r.PeriodicReport.read.when(member).edit,
7178
r.StepProgress.read,

0 commit comments

Comments
 (0)