Skip to content

Commit

Permalink
Merge branch 'develop' into SWAP-4396-user-officer-experiment-safety-…
Browse files Browse the repository at this point in the history
…review-workflow
  • Loading branch information
yoganandaness committed Jan 30, 2025
2 parents ce1eeef + 4bd7218 commit 302773a
Show file tree
Hide file tree
Showing 111 changed files with 471 additions and 553 deletions.
9 changes: 5 additions & 4 deletions apps/backend/db_patches/0168_ExperimentWorkflow.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ BEGIN
BEGIN
-- Insert the Workflow Statuses
INSERT INTO statuses (name, short_code, description, entity_type, is_default) VALUES ('AWAITING ESF', 'AWAITING_ESF', 'When an Experiment is created, the default status will be AWAITING_ESF. This means that the experimenter needs to submit the ESF(Experiment Safety Form).', 'experiment', true);
INSERT INTO statuses (name, short_code, description, entity_type) VALUES ('ESF IS REVIEW', 'ESF_IS_REVIEW', 'IS(Instrument Scientist) needs to review the ESF.', 'experiment');
INSERT INTO statuses (name, short_code, description, entity_type) VALUES ('ESF ESR REVIEW', 'ESF_ESR_REVIEW', 'ESR(Experiment Safety Reviewer) needs to review the ESF.', 'experiment');
INSERT INTO statuses (name, short_code, description, entity_type) VALUES ('ESF REJECTED', 'ESF_REJECTED', 'ESF rejected.', 'experiment');
INSERT INTO statuses (name, short_code, description, entity_type) VALUES ('ESF APROVED', 'ESF_APROVED', 'ESF approved.', 'experiment');
INSERT INTO statuses (name, short_code, description, entity_type, is_default) VALUES ('ESF IS REVIEW', 'ESF_IS_REVIEW', 'IS(Instrument Scientist) needs to review the ESF.', 'experiment', true);
INSERT INTO statuses (name, short_code, description, entity_type, is_default) VALUES ('ESF ESR REVIEW', 'ESF_ESR_REVIEW', 'ESR(Experiment Safety Reviewer) needs to review the ESF.', 'experiment', true);
INSERT INTO statuses (name, short_code, description, entity_type, is_default) VALUES ('ESF REJECTED', 'ESF_REJECTED', 'ESF rejected.', 'experiment', true);
INSERT INTO statuses (name, short_code, description, entity_type, is_default) VALUES ('ESF APROVED', 'ESF_APROVED', 'ESF approved.', 'experiment', true);
END;

END IF;
END;
$$
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/auth/ProposalAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { ProposalDataSource } from '../datasources/ProposalDataSource';
import { ReviewDataSource } from '../datasources/ReviewDataSource';
import { StatusDataSource } from '../datasources/StatusDataSource';
import { VisitDataSource } from '../datasources/VisitDataSource';
import { ProposalStatusDefaultShortCodes } from '../models/ProposalStatus';
import { Roles } from '../models/Role';
import { ProposalStatusDefaultShortCodes } from '../models/Status';
import { UserWithRole } from '../models/User';
import { Proposal } from '../resolvers/types/Proposal';
import { UserDataSource } from './../datasources/UserDataSource';
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/config/dependencyConfigDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import PostgresPredefinedMessageDataSource from '../datasources/postgres/Predefi
import PostgresProposalDataSource from '../datasources/postgres/ProposalDataSource';
import PostgresProposalEsiDataSource from '../datasources/postgres/ProposalEsiDataSource';
import PostgresProposalInternalCommentsDataSource from '../datasources/postgres/ProposalInternalCommentsDataSource';
import PostgresProposalSettingsDataSource from '../datasources/postgres/ProposalSettingsDataSource';
import PostgresQuestionaryDataSource from '../datasources/postgres/QuestionaryDataSource';
import PostgresRedeemCodesDataSource from '../datasources/postgres/RedeemCodesDataSource';
import PostgresReviewDataSource from '../datasources/postgres/ReviewDataSource';
Expand Down Expand Up @@ -77,7 +76,6 @@ mapClass(Tokens.InternalReviewDataSource, PostgresInternalReviewDataSource);
mapClass(Tokens.PdfTemplateDataSource, PostgresPdfTemplateDataSource);
mapClass(Tokens.ProposalDataSource, PostgresProposalDataSource);
mapClass(Tokens.ProposalEsiDataSource, PostgresProposalEsiDataSource);
mapClass(Tokens.ProposalSettingsDataSource, PostgresProposalSettingsDataSource);
mapClass(
Tokens.ProposalInternalCommentsDataSource,
PostgresProposalInternalCommentsDataSource
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/config/dependencyConfigE2E.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import PostgresPredefinedMessageDataSource from '../datasources/postgres/Predefi
import PostgresProposalDataSource from '../datasources/postgres/ProposalDataSource';
import PostgresProposalEsiDataSource from '../datasources/postgres/ProposalEsiDataSource';
import PostgresProposalInternalCommentsDataSource from '../datasources/postgres/ProposalInternalCommentsDataSource';
import PostgresProposalSettingsDataSource from '../datasources/postgres/ProposalSettingsDataSource';
import PostgresQuestionaryDataSource from '../datasources/postgres/QuestionaryDataSource';
import PostgresRedeemCodesDataSource from '../datasources/postgres/RedeemCodesDataSource';
import PostgresReviewDataSource from '../datasources/postgres/ReviewDataSource';
Expand Down Expand Up @@ -69,7 +68,6 @@ mapClass(Tokens.InternalReviewDataSource, PostgresInternalReviewDataSource);
mapClass(Tokens.PdfTemplateDataSource, PostgresPdfTemplateDataSource);
mapClass(Tokens.ProposalDataSource, PostgresProposalDataSource);
mapClass(Tokens.ProposalEsiDataSource, PostgresProposalEsiDataSource);
mapClass(Tokens.ProposalSettingsDataSource, PostgresProposalSettingsDataSource);
mapClass(
Tokens.ProposalInternalCommentsDataSource,
PostgresProposalInternalCommentsDataSource
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/config/dependencyConfigELI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import PostgresPredefinedMessageDataSource from '../datasources/postgres/Predefi
import PostgresProposalDataSource from '../datasources/postgres/ProposalDataSource';
import PostgresProposalEsiDataSource from '../datasources/postgres/ProposalEsiDataSource';
import PostgresProposalInternalCommentsDataSource from '../datasources/postgres/ProposalInternalCommentsDataSource';
import PostgresProposalSettingsDataSource from '../datasources/postgres/ProposalSettingsDataSource';
import PostgresQuestionaryDataSource from '../datasources/postgres/QuestionaryDataSource';
import PostgresRedeemCodesDataSource from '../datasources/postgres/RedeemCodesDataSource';
import PostgresReviewDataSource from '../datasources/postgres/ReviewDataSource';
Expand Down Expand Up @@ -70,7 +69,6 @@ mapClass(Tokens.RoleInviteDataSource, PostgresRoleInviteDataSource);
mapClass(Tokens.PdfTemplateDataSource, PostgresPdfTemplateDataSource);
mapClass(Tokens.ProposalDataSource, PostgresProposalDataSource);
mapClass(Tokens.ProposalEsiDataSource, PostgresProposalEsiDataSource);
mapClass(Tokens.ProposalSettingsDataSource, PostgresProposalSettingsDataSource);
mapClass(
Tokens.ProposalInternalCommentsDataSource,
PostgresProposalInternalCommentsDataSource
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/config/dependencyConfigESS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import PostgresPredefinedMessageDataSource from '../datasources/postgres/Predefi
import PostgresProposalDataSource from '../datasources/postgres/ProposalDataSource';
import PostgresProposalEsiDataSource from '../datasources/postgres/ProposalEsiDataSource';
import PostgresProposalInternalCommentsDataSource from '../datasources/postgres/ProposalInternalCommentsDataSource';
import PostgresProposalSettingsDataSource from '../datasources/postgres/ProposalSettingsDataSource';
import PostgresQuestionaryDataSource from '../datasources/postgres/QuestionaryDataSource';
import PostgresRedeemCodesDataSource from '../datasources/postgres/RedeemCodesDataSource';
import PostgresReviewDataSource from '../datasources/postgres/ReviewDataSource';
Expand Down Expand Up @@ -70,7 +69,6 @@ mapClass(Tokens.RoleInviteDataSource, PostgresRoleInviteDataSource);
mapClass(Tokens.PdfTemplateDataSource, PostgresPdfTemplateDataSource);
mapClass(Tokens.ProposalDataSource, PostgresProposalDataSource);
mapClass(Tokens.ProposalEsiDataSource, PostgresProposalEsiDataSource);
mapClass(Tokens.ProposalSettingsDataSource, PostgresProposalSettingsDataSource);
mapClass(
Tokens.ProposalInternalCommentsDataSource,
PostgresProposalInternalCommentsDataSource
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/config/dependencyConfigSTFC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import PostgresPdfTemplateDataSource from '../datasources/postgres/PdfTemplateDa
import PostgresPredefinedMessageDataSource from '../datasources/postgres/PredefinedMessageDataSource';
import PostgresProposalEsiDataSource from '../datasources/postgres/ProposalEsiDataSource';
import PostgresProposalInternalCommentsDataSource from '../datasources/postgres/ProposalInternalCommentsDataSource';
import PostgresProposalSettingsDataSource from '../datasources/postgres/ProposalSettingsDataSource';
import PostgresQuestionaryDataSource from '../datasources/postgres/QuestionaryDataSource';
import PostgresRedeemCodesDataSource from '../datasources/postgres/RedeemCodesDataSource';
import PostgresReviewDataSource from '../datasources/postgres/ReviewDataSource';
Expand Down Expand Up @@ -68,7 +67,6 @@ mapClass(Tokens.RoleInviteDataSource, PostgresRoleInviteDataSource);
mapClass(Tokens.PdfTemplateDataSource, PostgresPdfTemplateDataSource);
mapClass(Tokens.ProposalDataSource, StfcProposalDataSource);
mapClass(Tokens.ProposalEsiDataSource, PostgresProposalEsiDataSource);
mapClass(Tokens.ProposalSettingsDataSource, PostgresProposalSettingsDataSource);
mapClass(
Tokens.ProposalInternalCommentsDataSource,
PostgresProposalInternalCommentsDataSource
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/config/dependencyConfigTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { PdfTemplateDataSourceMock } from '../datasources/mockups/PdfTemplateDat
import { ProposalDataSourceMock } from '../datasources/mockups/ProposalDataSource';
import { ProposalEsiDataSourceMock } from '../datasources/mockups/ProposalEsiDataSource';
import { PostgresProposalInternalCommentsDataSourceMock } from '../datasources/mockups/ProposalInternalCommentsDataSource';
import { ProposalSettingsDataSourceMock } from '../datasources/mockups/ProposalSettingsDataSource';
import { QuestionaryDataSourceMock } from '../datasources/mockups/QuestionaryDataSource';
import { RedeemDataSourceMock } from '../datasources/mockups/RedeemDataSource';
import { ReviewDataSourceMock } from '../datasources/mockups/ReviewDataSource';
Expand Down Expand Up @@ -63,7 +62,6 @@ mapClass(Tokens.InternalReviewDataSource, InternalReviewDataSourceMock);
mapClass(Tokens.PdfTemplateDataSource, PdfTemplateDataSourceMock);
mapClass(Tokens.ProposalDataSource, ProposalDataSourceMock);
mapClass(Tokens.ProposalEsiDataSource, ProposalEsiDataSourceMock);
mapClass(Tokens.ProposalSettingsDataSource, ProposalSettingsDataSourceMock);
mapClass(
Tokens.ProposalInternalCommentsDataSource,
PostgresProposalInternalCommentsDataSourceMock
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/datasources/CallDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Call } from '../models/Call';
import { CallHasInstrument } from '../models/CallHasInstrument';
import { Workflow } from '../models/Workflow';
import { CreateCallInput } from '../resolvers/mutations/CreateCallMutation';
import {
UpdateCallInput,
Expand Down Expand Up @@ -29,4 +30,5 @@ export interface CallDataSource {
isCallEnded(callId: number, checkIfInternalEnded: boolean): Promise<boolean>;
isCallEnded(callId: number): Promise<boolean>;
getCallByAnswerIdProposal(answerId: number): Promise<Call>;
getProposalWorkflowByCall(callId: number): Promise<Workflow | null>;
}
5 changes: 0 additions & 5 deletions apps/backend/src/datasources/ProposalSettingsDataSource.ts

This file was deleted.

10 changes: 5 additions & 5 deletions apps/backend/src/datasources/StatusActionsDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
ConnectionHasStatusAction,
StatusAction,
} from '../models/ProposalStatusAction';
} from '../models/StatusAction';
import { AddConnectionStatusActionsInput } from '../resolvers/mutations/settings/AddConnectionStatusActionsMutation';

export interface StatusActionsDataSource {
getConnectionStatusActions(
proposalWorkflowConnectionId: number,
proposalWorkflowId: number
workflowConnectionId: number,
workflowId: number
): Promise<ConnectionHasStatusAction[]>;
getConnectionStatusAction(
proposalWorkflowConnectionId: number,
proposalStatusActionId: number
workflowConnectionId: number,
statusActionId: number
): Promise<ConnectionHasStatusAction>;
updateConnectionStatusAction(
data: ConnectionHasStatusAction
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/datasources/StatusDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Status } from '../models/ProposalStatus'; //TODO: Create a new file for the Status model
import { Status } from '../models/Status';

export interface StatusDataSource {
createStatus(
newStatusInput: Omit<Status, 'id' | 'isDefault'>
): Promise<Status>;
getStatus(statusId: number): Promise<Status | null>;
getAllStatuses(entityType: Status['entityType']): Promise<Status[]>;
updateStatus(proposalStatus: Omit<Status, 'entityType'>): Promise<Status>;
updateStatus(status: Omit<Status, 'entityType'>): Promise<Status>;
deleteStatus(statusId: number): Promise<Status>;
}
4 changes: 2 additions & 2 deletions apps/backend/src/datasources/WorkflowDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Status } from '../models/ProposalStatus';
import { Workflow } from '../models/ProposalWorkflow';
import { Status } from '../models/Status';
import { StatusChangingEvent } from '../models/StatusChangingEvent';
import { Workflow } from '../models/Workflow';
import {
NextAndPreviousStatuses,
WorkflowConnection,
Expand Down
13 changes: 13 additions & 0 deletions apps/backend/src/datasources/mockups/CallDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AllocationTimeUnits, Call } from '../../models/Call';
import { CallHasInstrument } from '../../models/CallHasInstrument';
import { Workflow, WorkflowType } from '../../models/Workflow';
import { CreateCallInput } from '../../resolvers/mutations/CreateCallMutation';
import {
AssignInstrumentsToCallInput,
Expand All @@ -10,6 +11,13 @@ import {
import { CallDataSource } from '../CallDataSource';
import { CallsFilter } from './../../resolvers/queries/CallsQuery';

export const dummyWorkflow = new Workflow(
1,
'Test workflow',
'This is description',
WorkflowType.PROPOSAL
);

export const dummyCallFactory = (values?: Partial<Call>) => {
return new Call(
values?.id || 1,
Expand Down Expand Up @@ -183,7 +191,12 @@ export class CallDataSourceMock implements CallDataSource {
async isCallEnded(callId: number): Promise<boolean> {
return callId !== 1;
}

async getCallByAnswerIdProposal(answer_id: number) {
return dummyCall;
}

async getProposalWorkflowByCall(callId: number): Promise<Workflow | null> {
return dummyWorkflow;
}
}
66 changes: 0 additions & 66 deletions apps/backend/src/datasources/mockups/ProposalSettingsDataSource.ts

This file was deleted.

12 changes: 6 additions & 6 deletions apps/backend/src/datasources/mockups/StatusActionsDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ConnectionHasStatusAction,
StatusAction,
StatusActionType,
} from '../../models/ProposalStatusAction';
} from '../../models/StatusAction';
import { AddConnectionStatusActionsInput } from '../../resolvers/mutations/settings/AddConnectionStatusActionsMutation';
import { StatusActionsDataSource } from '../StatusActionsDataSource';

Expand Down Expand Up @@ -35,20 +35,20 @@ export const dummyStatusActions = [dummyStatusAction, anotherDummyStatusAction];

export class StatusActionsDataSourceMock implements StatusActionsDataSource {
async getConnectionStatusAction(
proposalWorkflowConnectionId: number,
proposalStatusActionId: number
workflowConnectionId: number,
statusActionId: number
): Promise<ConnectionHasStatusAction> {
return dummyConnectionHasStatusAction;
}
async getConnectionStatusActions(
proposalWorkflowConnectionId: number,
proposalWorkflowId: number
workflowConnectionId: number,
workflowId: number
): Promise<ConnectionHasStatusAction[]> {
return [dummyConnectionHasStatusAction];
}

async updateConnectionStatusAction(
proposalStatusAction: ConnectionHasStatusAction
statusAction: ConnectionHasStatusAction
): Promise<ConnectionHasStatusAction> {
return dummyConnectionHasStatusAction;
}
Expand Down
9 changes: 5 additions & 4 deletions apps/backend/src/datasources/mockups/StatusDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Status } from '../../models/ProposalStatus';
import { Status } from '../../models/Status';
import { WorkflowType } from '../../models/Workflow';
import { StatusDataSource } from '../StatusDataSource';

export const dummyStatuses = [
new Status(1, 'DRAFT', 'Draft', '', true, 'proposal'),
new Status(1, 'DRAFT', 'Draft', '', true, WorkflowType.PROPOSAL),
new Status(
2,
'FEASIBILITY_REVIEW',
'Feasibility review',
'',
true,
'proposal'
WorkflowType.PROPOSAL
),
];

Expand All @@ -27,7 +28,7 @@ export class StatusDataSourceMock implements StatusDataSource {
return dummyStatuses;
}
async updateStatus(status: Omit<Status, 'entityType'>): Promise<Status> {
return { ...status, entityType: 'proposal' };
return { ...status, entityType: WorkflowType.PROPOSAL };
}
async deleteStatus(statusId: number): Promise<Status> {
return dummyStatuses.splice(
Expand Down
Loading

0 comments on commit 302773a

Please sign in to comment.