Skip to content

Commit 58d081c

Browse files
author
Andre Turner
committed
define engagement workflow transitions
1 parent ff284ad commit 58d081c

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import { defineContext, defineWorkflow } from '../../workflow/define-workflow';
2+
import { TransitionType as Type } from '../../workflow/dto';
3+
import { EngagementStatus as Step } from '../dto';
4+
import { EngagementWorkflowEvent } from './dto';
5+
import {
6+
BackTo,
7+
BackToActive,
8+
ResolveParams,
9+
} from './transitions/dynamic-step';
10+
11+
// This also controls the order shown in the UI.
12+
// Therefore, these should generally flow down.
13+
// "Back" transitions should come before/above "forward" transitions.
14+
export const EngagementWorkflow = defineWorkflow({
15+
id: '01903b47-c5fe-7e4b-a1a0-72638ca64760',
16+
name: 'Engagement',
17+
states: Step,
18+
event: EngagementWorkflowEvent,
19+
context: defineContext<ResolveParams>,
20+
})({
21+
Reject: {
22+
from: Step.InDevelopment,
23+
to: Step.Rejected,
24+
label: 'Reject',
25+
type: Type.Reject,
26+
},
27+
'End Development': {
28+
from: Step.InDevelopment,
29+
to: Step.DidNotDevelop,
30+
label: 'End Development',
31+
type: Type.Reject,
32+
},
33+
'Approve to Active': {
34+
from: Step.InDevelopment,
35+
to: Step.Active,
36+
label: 'Approve',
37+
type: Type.Approve,
38+
},
39+
'Discuss Change To Plan': {
40+
from: [Step.Active, Step.ActiveChangedPlan],
41+
to: Step.DiscussingChangeToPlan,
42+
label: 'Discuss Change to Plan',
43+
type: Type.Neutral,
44+
},
45+
'Discuss Suspension': {
46+
from: [Step.Active, Step.ActiveChangedPlan, Step.DiscussingChangeToPlan],
47+
to: Step.DiscussingSuspension,
48+
label: 'Discuss Susupension',
49+
type: Type.Neutral,
50+
},
51+
'Discuss Termination': {
52+
from: [
53+
Step.Active,
54+
Step.ActiveChangedPlan,
55+
Step.DiscussingSuspension,
56+
Step.Suspended,
57+
Step.DiscussingReactivation,
58+
],
59+
to: Step.DiscussingTermination,
60+
label: 'Discuss Termination',
61+
type: Type.Neutral,
62+
},
63+
'Finalize Completion': {
64+
from: [Step.Active, Step.ActiveChangedPlan],
65+
to: Step.FinalizingCompletion,
66+
label: 'Finalize Completion',
67+
type: Type.Approve,
68+
},
69+
'Approve Change to Plan': {
70+
from: Step.DiscussingChangeToPlan,
71+
to: Step.ActiveChangedPlan,
72+
label: 'Approve Change to Plan',
73+
type: Type.Approve,
74+
},
75+
'Will Not Change Plan': {
76+
from: Step.DiscussingChangeToPlan,
77+
to: BackToActive,
78+
label: 'Will Not Change Plan',
79+
type: Type.Neutral,
80+
},
81+
'Approve Suspension': {
82+
from: Step.DiscussingSuspension,
83+
to: Step.Suspended,
84+
label: 'Approve Suspension',
85+
type: Type.Approve,
86+
},
87+
'Will Not Suspend': {
88+
from: Step.DiscussingSuspension,
89+
to: BackToActive,
90+
label: 'Will Not Suspend',
91+
type: Type.Neutral,
92+
},
93+
'Discuss Reactivation': {
94+
from: Step.Suspended,
95+
to: Step.DiscussingReactivation,
96+
label: 'Discuss Reactivation',
97+
type: Type.Neutral,
98+
},
99+
'Approve Reactivation': {
100+
from: Step.DiscussingReactivation,
101+
to: Step.ActiveChangedPlan,
102+
label: 'Approve Reactivation',
103+
type: Type.Approve,
104+
},
105+
'End Termination Discussion': {
106+
from: Step.DiscussingTermination,
107+
to: BackTo(
108+
Step.Active,
109+
Step.ActiveChangedPlan,
110+
Step.DiscussingReactivation,
111+
Step.Suspended,
112+
),
113+
label: 'Will Not Terminate',
114+
type: Type.Neutral,
115+
},
116+
'Approve Termination': {
117+
from: Step.DiscussingTermination,
118+
to: Step.Terminated,
119+
label: 'Approve Termination',
120+
type: Type.Approve,
121+
},
122+
'Not Ready for Completion': {
123+
from: Step.FinalizingCompletion,
124+
to: BackToActive,
125+
label: 'Still Working',
126+
type: Type.Neutral,
127+
},
128+
Complete: {
129+
from: Step.FinalizingCompletion,
130+
to: Step.Completed,
131+
label: 'Complete 🎉',
132+
type: Type.Approve,
133+
},
134+
});

0 commit comments

Comments
 (0)