Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
f2b8a4c
feat: add new workflow data structures and update related data sources
Dec 22, 2025
29ab668
feat: rename and refactor status changing events handling in workflow…
Dec 22, 2025
b18f078
fix: throw error when status changing event is not found in database
Dec 22, 2025
23b55ba
feat: overhaul workflow status handling by renaming and refactoring r…
Dec 22, 2025
9e33025
feat: overhaul workflow data structures and connections by refactorin…
Dec 24, 2025
2d3b0b6
feat: update WorkflowStatus model and related components to use workf…
Dec 29, 2025
a34a1eb
fix: comment out validation schema for deleteWorkflowStatus and add T…
Dec 29, 2025
3cc35a9
feat: refactor workflow connection handling by renaming methods and i…
Dec 29, 2025
e52d957
feat: update WorkflowEditor to use workflowStatusId for source and ta…
Dec 29, 2025
5d30bee
feat: add ON DELETE CASCADE to foreign key constraints in workflow_st…
Dec 29, 2025
26ef94b
fix: update edge identification logic to use connection ID directly
Dec 29, 2025
f9d1e68
feat: overhaul workflow data structures by removing status changing e…
Dec 29, 2025
ccbcb18
feat: rename and update connection status actions mutation to setStat…
Dec 30, 2025
56b3eb1
refactor: update workflow connection action identifiers to use new na…
Dec 30, 2025
110979a
feat: add ON DELETE CASCADE to foreign key constraints in workflow da…
Dec 30, 2025
51cd7a2
feat: add xstate for workflow state management and implement getWorkf…
Dec 30, 2025
8c563af
feat: enhance workflow management by adding workflow status handling …
Dec 31, 2025
af465b5
refactor: rename updateProposalStatus to updateProposalWfStatus for c…
Dec 31, 2025
b7551ab
feat: overhaul workflow guards by implementing IGuard interface and r…
Dec 31, 2025
50cf348
feat: enhance workflow management by adding default workflow status h…
Dec 31, 2025
ad2becb
refactor: remove unused getProposalWorkflowByCallId function and log …
Jan 1, 2026
d21d38b
feat: overhaul workflow management by replacing IGuard interface with…
Jan 1, 2026
bfd5265
refactor: remove guardNames from WorkflowDataSource and related mock …
Jan 1, 2026
72d06a1
feat: implement workflow machine and guards with refactored state man…
Jan 1, 2026
4f2c8af
feat: enhance workflow management by adding guards and refactoring ev…
Jan 2, 2026
05d2f5a
feat: update workflow and status action data sources to use workflowS…
Jan 2, 2026
44fae96
feat: enhance FapQueries to include review data source and implement …
Jan 2, 2026
dfb2811
refactor: remove unused ProposalEventsRecord interface and clean up w…
Jan 6, 2026
8f56861
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 6, 2026
ba5da92
fix: update join table in CallDataSource to use workflow_has_statuses…
Jan 6, 2026
9e359b5
fix: update edge style logic in WorkflowEdge component for better vis…
Jan 6, 2026
12f1d50
fix: adjust edge style in WorkflowEdge component for improved visibility
Jan 6, 2026
d5695b7
feat: implement ProposalWorkflowEngine and integrate into dependency …
Jan 7, 2026
69322c9
Add guards for proposal workflow validation
Jan 9, 2026
bbec4d3
Refactor status handling in experiments and proposals
Jan 13, 2026
0e66af0
refactor: remove shortCode from Status and related data sources
Jan 14, 2026
e14e955
refactor: replace shortCode with id in status-related data structures…
Jan 14, 2026
6d5ead1
refactor: update workflow and status handling to use 'id' instead of …
Jan 15, 2026
5bb81f9
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 15, 2026
ecce077
refactor: update WorkflowEdge and StatusNode to use 'id' instead of '…
Jan 15, 2026
2301406
feat: add sourceHandle and targetHandle to workflow connections and r…
Jan 15, 2026
b427eef
fix: update status_id to use draftWfStatus for accurate workflow stat…
Jan 15, 2026
606d8de
fix: update workflow handling to use 'id' instead of 'shortCode' for …
Jan 15, 2026
79a7d8b
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 16, 2026
64b3c0b
feat: integrate confirmation dialog for status deletion in StatusNode…
Jan 16, 2026
5ea8316
fix: update status handling to replace 'shortCode' with 'statusId' in…
Jan 21, 2026
809fd48
refactor: overhaul workflow handling by replacing StatusDataSource wi…
Jan 22, 2026
af34c88
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 22, 2026
1876021
Refactor workflow status handling in Cypress tests
Jan 26, 2026
445fee0
refactor: update validation schemas in StatusMutations and WorkflowMu…
Jan 26, 2026
13866d9
refactor: enhance event handling by adding guards for proposal and ca…
Jan 27, 2026
e0052f4
refactor: update proposal and status handling by renaming fields and …
Jan 27, 2026
1aaf880
refactor: update status filter values to use descriptive strings inst…
Jan 27, 2026
206ac10
refactor: update EdgeData interface to use status IDs instead of shor…
Jan 27, 2026
5b99b9f
refactor: update duo-validation package to version 6.0.0 in frontend …
Jan 27, 2026
949c1d0
refactor: overhaul workflow management by enhancing status handling, …
Jan 28, 2026
127255c
refactor: update workflow status handling in FAPs tests to use dynami…
Jan 29, 2026
37aa065
refactor: enhance workflow status management in technique proposal te…
Jan 29, 2026
9ef2bc7
refactor: enable technique proposal and advanced tests by removing skip
Jan 29, 2026
bc91909
refactor: update proposal status input IDs to use 'selectedWorkflowSt…
Jan 29, 2026
64d0ba9
refactor: update proposal status handling to use 'selectedWorkflowSta…
Jan 29, 2026
c452215
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Jan 29, 2026
01c669e
refactor: remove 'only' from create Proposal status test to enable ex…
Jan 29, 2026
4bc3edd
refactor: add status to workflow in proposal tests for improved coverage
Jan 29, 2026
97291fd
refactor: update workflow data structures to link proposals and exper…
Jan 29, 2026
2299355
refactor: enhance workflow status handling by adding 'Feasibility' st…
Jan 29, 2026
5aa2107
refactor: add 'Feasibility' status to workflow and integrate into ins…
Jan 29, 2026
db22382
refactor: add updated_at column to workflows and enhance workflow str…
Jan 29, 2026
d51dd3e
refactor: enhance statusName column rendering with clickable link for…
Jan 29, 2026
5999195
refactor: overhaul workflow data structures and integrate workflow st…
Feb 2, 2026
e7add2d
refactor: streamline workflow status handling by removing position pa…
Feb 3, 2026
112c671
refactor: streamline workflow status handling by removing position pa…
Feb 3, 2026
7d5e3c0
Merge branch 'SWAP-4949-workflow-overhaul' of github.com:UserOfficePr…
Feb 3, 2026
1269421
test: enable proposal allocation time unit test
Feb 3, 2026
09b265a
refactor: optimize SQL query for average grade calculation in proposa…
Feb 3, 2026
7ec3f95
fix: add ORDER BY clause to proposal_pk in status migration query
Feb 3, 2026
db48864
refactor: remove unused event bus publishing functions and caching lo…
Feb 3, 2026
61f310b
fix: cleanup
Feb 3, 2026
0879b7a
fix: update workflow status ID reference in settings tests
Feb 3, 2026
255e798
fix: improve error message for connecting statuses from different wor…
Feb 4, 2026
4426e45
refactor: streamline proposal status handling in settings tests
Feb 4, 2026
0165c16
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Feb 7, 2026
e3685bb
refactor: enhance workflow status handling in settings tests
Feb 8, 2026
a44cb1e
feat: add callEnded parameter to updateCall mutation
Feb 8, 2026
4ddee5a
refactor: update workflow status handling and improve notification me…
Feb 8, 2026
a89838d
refactor: skip proposal status update test for conditional checks
Feb 8, 2026
838d807
test: enable only the proposal workflow status removal test
Feb 8, 2026
6fcab29
refactor: update proposalStatusId handling to support 'ALL' filter
Feb 8, 2026
1f94e5d
feat: enhance proposal status update to validate workflow status befo…
Feb 8, 2026
065411f
feat: add new workflow statuses for Instrument Scientist Review and u…
Feb 8, 2026
9d9b35e
refactor: update workflow status identifiers in tests and components
Feb 8, 2026
eb231c6
feat: add 'EDITABLE_SUBMITTED_INTERNAL' status to workflow and adjust…
Feb 8, 2026
58b49f4
feat: update workflow statuses for Instrument Scientist Review and ad…
Feb 9, 2026
bfc8832
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Feb 13, 2026
a0daa99
feat: rename new workflow data structures and migration scripts for i…
Feb 13, 2026
8d7b5f5
fix: enable setting workflow status ID in ExperimentDataSourceMock
Feb 13, 2026
7bf0eae
feat: refactor StfcProposalDataSource to streamline constructor param…
Feb 13, 2026
7f1d48c
feat: rename 'getDefaultStatus' and 'getDefaultWorkflowStatus' to 'ge…
Feb 13, 2026
8245b1c
fix: change access modifiers for callDataSource and statusDataSource …
Feb 13, 2026
814b407
feat: add notes for workflow status handling and update interface for…
Feb 13, 2026
e89e464
refactor: simplify updated proposals type and remove unnecessary chec…
Feb 13, 2026
83e90fd
feat: expand WorkflowRunInput type to include array of WorkflowRunSin…
Feb 13, 2026
3864a49
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Feb 17, 2026
80f1f66
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Feb 19, 2026
ec5051d
refactor: simplify createWorkflowConnection parameters for improved r…
Feb 22, 2026
3822870
refactor: update validation schemas to use string for IDs and improve…
Feb 22, 2026
03cc3f6
refactor: rename variable for initial workflow status in createExperi…
Feb 22, 2026
e244a61
refactor: remove unused StatusDataSourceMock and update proposal mock…
Feb 22, 2026
399a8f4
refactor: rename newStatus to newWorkflowStatus for clarity in logCon…
Feb 22, 2026
cd603ae
refactor: simplify creation of new proposal workflow connection for i…
Feb 22, 2026
8f94c54
refactor: remove xstate dependency from package.json and package-lock…
Feb 22, 2026
8b888c5
refactor: simplify return statement in getStatusEngineReadyProposals …
Feb 22, 2026
32955c0
refactor: remove hover scaling effect from StyledHandle for consistency
Feb 22, 2026
5d97311
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Feb 24, 2026
232760d
refactor: enhance StyledHandle visibility logic based on connection s…
Feb 24, 2026
86e1256
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Mar 3, 2026
8333670
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 16, 2026
88a2a54
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 16, 2026
3a7ca72
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 16, 2026
6108815
Merge branch 'SWAP-4949-workflow-overhaul' of github.com:UserOfficePr…
yoganandaness Mar 20, 2026
c5a49eb
fix failing unit tests
yoganandaness Mar 20, 2026
d9f7830
fixing failing e2e
yoganandaness Mar 20, 2026
9afac60
fixing failed e2e
yoganandaness Mar 20, 2026
bba29a7
Merge branch 'develop' of github.com:UserOfficeProject/user-office-co…
yoganandaness Mar 20, 2026
7df97cc
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Mar 20, 2026
671e3f6
ix: technique proposal table status handling
yoganandaness Mar 23, 2026
81107b6
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Mar 23, 2026
2b4d729
fix: show proposal ids
Mar 24, 2026
27d2c36
fix: clone proposal bug
Mar 24, 2026
4bdc221
refactor: update event handling in ProposalWorkflowEngine and Actor t…
Mar 26, 2026
c5a3324
fix: correct formatting of warning alert for status change to DRAFT
Mar 26, 2026
359a30e
refactor: streamline state transition tests and enhance guard handling
Mar 26, 2026
5a8b6ae
feat: add workflowConnectionId to change proposals status mutation an…
Mar 27, 2026
79a250f
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Mar 31, 2026
3314913
refactor: rename workflow status connection tables for consistency
Apr 1, 2026
2d95a6d
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 1, 2026
ad9709d
fix: adding check to make sure the migration stops in case of invalid…
Apr 8, 2026
90609df
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 8, 2026
b308e2d
Merge branch 'develop' into SWAP-4949-workflow-overhaul
Apr 12, 2026
dc0e490
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 12, 2026
6b8fe43
refactor: simplify instrument and technique insertion statements in S…
Apr 12, 2026
705b369
Merge branch 'SWAP-4949-workflow-overhaul' of https://github.com/User…
Apr 12, 2026
69e5a02
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 20, 2026
ec0ae14
refactor: update patch name for clarity in RenameShortCodeToStatusId.sql
Apr 20, 2026
4cbaea5
refactor: update addStatusToWorkflow method to use AddStatusToWorkflo…
Apr 20, 2026
7cf294c
refactor: remove updateProposalWfStatus method and replace with chang…
Apr 20, 2026
a7105b3
refactor: streamline migration script by removing redundant pre-check…
Apr 20, 2026
89936ac
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins Apr 20, 2026
074279f
refactor: make workflow structure properties readonly for better immu…
Apr 20, 2026
8fc53f4
Merge branch 'SWAP-4949-workflow-overhaul' of https://github.com/User…
Apr 20, 2026
308c995
refactor: remove obsolete triggers and functions related to workflow …
Apr 21, 2026
638902f
fix: add getStatusByWorkflowStatusId method to StatusDataSource and i…
Apr 21, 2026
00a19c9
fix: remove status_id from proposals
Apr 21, 2026
1632bef
fix: fix tests
Apr 21, 2026
a890877
fix: fix seeds
Apr 22, 2026
89f0df6
fix: include reference to proposal_status
Apr 22, 2026
20f27a4
fix: remove status_id from ExperimentSafety and related data sources
Apr 22, 2026
4453450
fix: skip migration for experiment_safety as it no longer uses status_id
Apr 22, 2026
e2826bb
fix: simplify logic in UserAuthorization and FapQueries, streamline W…
Apr 22, 2026
81daaee
fix: initialize statusId as an empty string in createExperimentSafety…
Apr 22, 2026
38fd5e5
Merge branch 'develop' into SWAP-4949-workflow-overhaul
yoganandaness Apr 27, 2026
63b4247
fix: update guard names
Apr 27, 2026
45e0129
fix: format code for isEveryFapInstrumentMeetingSubmittedForProposalG…
Apr 29, 2026
7a8222a
fix: enable test for updating proposal status multiple times if condi…
Apr 29, 2026
5f6b2e4
fix: rename variables for consistency and clarity in createWorkflowMa…
Apr 29, 2026
cc9dbfe
fix: rename workflow status variables for consistency across Proposal…
Apr 29, 2026
a1d78df
fix: rename draft workflow status variable for consistency in setting…
Apr 29, 2026
e6ef06b
fix: move status creation to beforeEach for Instruments tests to avoi…
Apr 29, 2026
2a0c8f2
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins May 2, 2026
fcf287c
Merge branch 'develop' into SWAP-4949-workflow-overhaul
jekabs-karklins May 4, 2026
7e34408
fix: performance tweak
May 4, 2026
cc12911
fix: rename workflow status variables for clarity in WorkflowEditor
May 4, 2026
c44ce5d
fix: clarify comments regarding workflow status removal in WorkflowEd…
May 4, 2026
82a3bb9
Merge develop into SWAP-5434-as-a-user-officer-i-want-to-specify-whic…
May 12, 2026
49164c5
fix: update imports from simpleStateMachine to stateMachine
May 20, 2026
8f0af22
fix: remove unused reducer middleware from WorkflowEditor and Workflo…
May 20, 2026
f41567f
fix: replace hardcoded 'EXPIRED' status with StatusCode.EXPIRED in Te…
May 20, 2026
2abf267
fix: rename type StfcRolesToEssRole to StfcRolesToSystemRole for cons…
May 20, 2026
fb901d5
Merge branch 'develop' into SWAP-4949-workflow-overhaul
May 20, 2026
fd79ace
fix: remove unused dummyProposalEvents and update getStatusByWorkflow…
May 20, 2026
206c2ce
fix: correct import paths for stateMachine module across guards and r…
May 21, 2026
962fcc2
Merge branch 'develop' into SWAP-4949-workflow-overhaul
bolmsten May 22, 2026
a43d562
feat: add workflowConnectionId to change proposals status mutation an…
Mar 27, 2026
4d5decd
Merge branch 'SWAP-5434-as-a-user-officer-i-want-to-specify-which-act…
May 27, 2026
d5f7ace
Merge branch 'develop'
May 27, 2026
b8dfe71
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
jekabs-karklins Jun 2, 2026
002bf3b
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
jekabs-karklins Jun 3, 2026
827aced
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
Jun 10, 2026
bb03de3
fix: give more descriptive name for the param
Jun 10, 2026
3152fab
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
jekabs-karklins Jun 19, 2026
5ae0e3d
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
jekabs-karklins Jun 23, 2026
c680944
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
Jun 25, 2026
71b956f
fix: add events and actions
Jun 25, 2026
d52279b
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
jekabs-karklins Jun 29, 2026
29f106a
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
simonfernandes Jul 1, 2026
4aa9ea6
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
mutambaraf Jul 1, 2026
834c31b
revert: revertign accidentally deleted test
Jul 1, 2026
ffab49e
refactor: remove unused workflow connection fetching and clean up code
Jul 1, 2026
5c01c50
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
simonfernandes Jul 2, 2026
6467114
fix: fix flaky test, when sometimes label is covering the edge
Jul 2, 2026
d90aff5
add workflow connection id to technique proposal table
mutambaraf Jul 2, 2026
01a2147
we do not want to continue if selectedWorkflowStatus is empty
mutambaraf Jul 2, 2026
fc9b154
fix permission with workflow
mutambaraf Jul 2, 2026
9ed809f
Merge branch 'SWAP-5434-as-a-user-officer-i-want-to-specify-which-act…
jekabs-karklins Jul 3, 2026
53744be
Fix xpress workflow (#1620)
jekabs-karklins Jul 3, 2026
a0e0c32
Merge branch 'develop' into SWAP-5434-as-a-user-officer-i-want-to-spe…
jekabs-karklins Jul 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 42 additions & 33 deletions apps/backend/src/mutations/ProposalMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,51 +541,60 @@ export default class ProposalMutations {
agent: UserWithRole | null,
args: ChangeProposalsStatusInput
): Promise<Proposals | Rejection> {
const { workflowStatusId: statusId, proposalPks } = args;
const {
workflowStatusId: statusId,
proposalPks,
statusActionsWorkflowConnectionId,
} = args;

const result = await this.proposalDataSource.changeProposalsWorkflowStatus(
statusId,
proposalPks.map((proposalPk) => proposalPk)
);

if (result.proposals.length === proposalPks.length) {
const fullProposals = await Promise.all(
proposalPks.map(async (proposalPk) => {
const fullProposal = result.proposals.find(
(updatedProposal) => updatedProposal.primaryKey === proposalPk
);

if (!fullProposal) {
return null;
}

const proposalWorkflow =
await this.callDataSource.getProposalWorkflowByCall(
fullProposal.callId
// Only run status actions if a specific workflow connection was provided
if (statusActionsWorkflowConnectionId) {
const fullProposals = await Promise.all(
proposalPks.map(async (proposalPk) => {
const fullProposal = result.proposals.find(
(updatedProposal) => updatedProposal.primaryKey === proposalPk
);

if (!proposalWorkflow) {
return rejection(
`No propsal workflow found for the specific proposal call with id: ${fullProposal.callId}`,
{
agent,
args,
}
);
}
if (!fullProposal) {
return null;
}

return {
...fullProposal,
};
})
);
const proposalWorkflow =
await this.callDataSource.getProposalWorkflowByCall(
fullProposal.callId
);

if (!proposalWorkflow) {
return rejection(
`No propsal workflow found for the specific proposal call with id: ${fullProposal.callId}`,
{
agent,
args,
}
);
}

const statusEngineReadyProposals = fullProposals.filter(
(item): item is WorkflowEngineProposalType => !!item
);
return {
...fullProposal,
prevStatusId: fullProposal.workflowStatusId,
workflowStatusConnectionId: statusActionsWorkflowConnectionId,
};
})
);

// NOTE: After proposal status change we need to run the status engine and execute the actions on the selected status.
proposalStatusActionEngine(statusEngineReadyProposals);
const statusEngineReadyProposals = fullProposals.filter(
(item): item is WorkflowEngineProposalType => !!item
);

// NOTE: After proposal status change we need to run the status engine and execute the actions on the selected status.
proposalStatusActionEngine(statusEngineReadyProposals);
}
} else {
rejection('Could not change statuses to all of the selected proposals', {
result,
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/queries/StatusActionQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class StatusActionQueries {
public emailTemplateDataSource: EmailTemplateDataSource
) {}

@Authorized([Roles.USER_OFFICER])
@Authorized([Roles.USER_OFFICER, Roles.INSTRUMENT_SCIENTIST])
async getStatusAction(agent: UserWithRole | null, actionId: number) {
const statusAction = await this.dataSource.getStatusAction(actionId);

Expand All @@ -42,15 +42,15 @@ export default class StatusActionQueries {
return statusActions;
}

@Authorized([Roles.USER_OFFICER])
@Authorized([Roles.USER_OFFICER, Roles.INSTRUMENT_SCIENTIST])
async getConnectionStatusActions(
agent: UserWithRole | null,
{ workflowConnectionId }: { workflowConnectionId: number }
) {
return this.dataSource.getConnectionStatusActions(workflowConnectionId);
}

@Authorized([Roles.USER_OFFICER])
@Authorized([Roles.USER_OFFICER, Roles.INSTRUMENT_SCIENTIST])
async getStatusActionConfig(
agent: UserWithRole | null,
statusAction: StatusAction
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/queries/WorkflowQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class WorkflowQueries {
public emailService: MailService
) {}

@Authorized([Roles.USER_OFFICER])
@Authorized([Roles.USER_OFFICER, Roles.INSTRUMENT_SCIENTIST])
async getWorkflow(
agent: UserWithRole | null,
id: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export class ChangeProposalsStatusInput {

@Field(() => [Int])
public proposalPks: number[];

/**
* The workflow connection whose status actions (emails, RabbitMQ messages,
* PDF generation) should run after the status change. Omit to change the
* proposal status WITHOUT running any status actions.
*/
@Field(() => Int, { nullable: true })
public statusActionsWorkflowConnectionId?: number;
}

@Resolver()
Expand Down
76 changes: 76 additions & 0 deletions apps/e2e/cypress/e2e/proposals.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { faker } from '@faker-js/faker';
import {
AllocationTimeUnits,
DataType,
EmailStatusActionRecipients,
FeatureId,
ProposalEndStatus,
SettingsId,
StatusActionType,
TemplateCategoryId,
TemplateGroupId,
WorkflowType,
Expand Down Expand Up @@ -143,6 +145,7 @@ context('Proposal tests', () => {
cy.addStatusToWorkflow({
statusId: initialDBData.proposalStatuses.feasibilityReview.id,
workflowId: result.createWorkflow.id,
posY: 200,
});
createdWorkflowId = result.createWorkflow.id;
}
Expand Down Expand Up @@ -896,6 +899,79 @@ context('Proposal tests', () => {
);
});

it('User officer should be able to opt-in to run status actions when changing status', () => {
const statusActionConfig = {
recipientsWithEmailTemplate: [
{
recipient: {
name: EmailStatusActionRecipients.PI,
description: '',
},
emailTemplate: {
id: initialDBData.emailTemplates.template1.id,
name: initialDBData.emailTemplates.template1.name,
},
combineEmails: true,
},
],
};

// Add a status with a connection from DRAFT and attach a status action
cy.addStatusToWorkflow({
statusId: initialDBData.proposalStatuses.feasibilityReview.id,
workflowId: initialDBData.workflows.defaultWorkflow.id,
prevId:
initialDBData.workflows.defaultWorkflow.workflowStatuses.draft.id,
posX: 0,
posY: 200,
}).then((result) => {
cy.addConnectionStatusActions({
actions: [
{
actionId: 1,
actionType: StatusActionType.EMAIL,
config: JSON.stringify(statusActionConfig),
},
],
connectionId: result.createWorkflowConnection.id,
workflowId: initialDBData.workflows.defaultWorkflow.id,
});
});

cy.login('officer');
cy.visit('/');

cy.contains(newProposalTitle).parent().find('[type="checkbox"]').check();

cy.get('[data-cy="change-proposal-status"]').click();

cy.finishedLoading();

cy.get('[role="presentation"] .MuiDialogContent-root').as('dialog');

// Select the status that has a connection with actions
cy.get('@dialog').find('#selectedWorkflowStatusId-input').click();
cy.get('[role="listbox"]')
.contains(initialDBData.proposalStatuses.feasibilityReview.name)
.click();

// The run status actions checkbox should appear and be unchecked
cy.get('[data-cy="run-status-actions-checkbox"] input')
.should('exist')
.should('not.be.checked');

// Check it to opt-in to running status actions
cy.get('[data-cy="run-status-actions-checkbox"] input').check();

// Should be able to submit the status change
cy.get('[data-cy="submit-proposal-status-change"]').click();

cy.notification({
variant: 'success',
text: 'status changed successfully',
});
});

it('Should be able to delete proposal', () => {
cy.login('user1', initialDBData.roles.user);
cy.visit('/');
Expand Down
10 changes: 7 additions & 3 deletions apps/e2e/cypress/e2e/settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ context('Settings tests', () => {
cy.get('[data-cy^="status_ESF_IS_REVIEW"]').should('exist');
});

it('User Officer should be able to select events that are triggering change to ESF workflow status', () => {
it.only('User Officer should be able to select events that are triggering change to ESF workflow status', () => {
cy.login('officer');
cy.visit('/');

Expand Down Expand Up @@ -1625,7 +1625,9 @@ context('Settings tests', () => {

cy.reload();

cy.get(`[aria-label="Edge from AWAITING_ESF to ESF_IS_REVIEW"]`).click();
cy.get(`[aria-label="Edge from AWAITING_ESF to ESF_IS_REVIEW"]`).click({
force: true,
});

cy.get('[data-cy="status-events-and-actions-modal"]').should('exist');
cy.contains(Event.EXPERIMENT_ESF_SUBMITTED).click();
Expand All @@ -1642,7 +1644,9 @@ context('Settings tests', () => {
.contains(Event.EXPERIMENT_ESF_SUBMITTED)
.should('exist');

cy.get(`[aria-label="Edge from AWAITING_ESF to ESF_IS_REVIEW"]`).click();
cy.get(`[aria-label="Edge from AWAITING_ESF to ESF_IS_REVIEW"]`).click({
force: true,
});

cy.get('[data-cy="status-events-and-actions-modal"]').should('exist');
cy.contains(Event.EXPERIMENT_ESF_APPROVED_BY_IS).click();
Expand Down
Loading
Loading