Skip to content

Commit 1bd9d1c

Browse files
authored
Merge pull request #3267 from SeedCompany/drop-old-project-step-mutation
2 parents 51773d7 + c89326a commit 1bd9d1c

File tree

8 files changed

+9
-70
lines changed

8 files changed

+9
-70
lines changed

src/components/project/dto/create-project.dto.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
} from '~/common';
1818
import { type Location } from '../../location/dto';
1919
import { ReportPeriod } from '../../periodic-report/dto';
20-
import { ProjectStep } from './project-step.enum';
2120
import { ProjectType } from './project-type.enum';
2221
import { IProject, type Project } from './project.dto';
2322

@@ -69,9 +68,6 @@ export abstract class CreateProject {
6968
@DateField({ nullable: true })
7069
readonly estimatedSubmission?: CalendarDate;
7170

72-
@Field(() => ProjectStep, { nullable: true })
73-
readonly step?: ProjectStep;
74-
7571
@SensitivityField({
7672
description: 'Defaults to High, only available on internship projects',
7773
nullable: true,

src/components/project/dto/update-project.dto.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
import { ChangesetIdField } from '../../changeset';
1919
import { type Location } from '../../location/dto';
2020
import { ReportPeriod } from '../../periodic-report/dto';
21-
import { ProjectStep } from './project-step.enum';
2221
import { IProject, type Project } from './project.dto';
2322

2423
@InputType()
@@ -64,11 +63,6 @@ export abstract class UpdateProject {
6463
@DateField({ nullable: true })
6564
readonly estimatedSubmission?: CalendarDate | null;
6665

67-
@OptionalField(() => ProjectStep, {
68-
deprecationReason: 'Use `transitionProject` mutation instead',
69-
})
70-
readonly step?: ProjectStep;
71-
7266
@SensitivityField({
7367
description: 'Update only available to internship projects',
7468
optional: true,

src/components/project/project.repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class ProjectRepository extends CommonRepository {
157157
}
158158

159159
async create(input: CreateProject) {
160-
const step = input.step ?? ProjectStep.EarlyConversations;
160+
const step = ProjectStep.EarlyConversations;
161161
const now = DateTime.local();
162162
const {
163163
primaryLocationId,

src/components/project/project.service.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ import {
2323
type UnsecuredDto,
2424
} from '~/common';
2525
import { isAdmin } from '~/common/session';
26-
import {
27-
ConfigService,
28-
HandleIdLookup,
29-
IEventBus,
30-
ILogger,
31-
Logger,
32-
} from '~/core';
26+
import { HandleIdLookup, IEventBus, ILogger, Logger } from '~/core';
3327
import { Transactional } from '~/core/database';
3428
import { type AnyChangesOf } from '~/core/database/changes';
3529
import { Privileges } from '../authorization';
@@ -46,7 +40,6 @@ import {
4640
type LocationListInput,
4741
type SecuredLocationList,
4842
} from '../location/dto';
49-
import { PartnerService } from '../partner';
5043
import { PartnershipService } from '../partnership';
5144
import {
5245
type PartnershipListInput,
@@ -84,7 +77,6 @@ import {
8477
type SecuredProjectMemberList,
8578
} from './project-member/dto';
8679
import { ProjectRepository } from './project.repository';
87-
import { ProjectWorkflowService } from './workflow/project-workflow.service';
8880

8981
@Injectable()
9082
export class ProjectService {
@@ -97,12 +89,8 @@ export class ProjectService {
9789
private readonly partnerships: PartnershipService & {},
9890
@Inject(forwardRef(() => EngagementService))
9991
private readonly engagementService: EngagementService & {},
100-
@Inject(forwardRef(() => PartnerService))
101-
private readonly partnerService: PartnerService & {},
102-
private readonly config: ConfigService,
10392
private readonly privileges: Privileges,
10493
private readonly eventBus: IEventBus,
105-
private readonly workflow: ProjectWorkflowService,
10694
private readonly repo: ProjectRepository,
10795
private readonly projectChangeRequests: ProjectChangeRequestService,
10896
@Logger('project:service') private readonly logger: ILogger,
@@ -293,29 +281,16 @@ export class ProjectService {
293281
);
294282
}
295283

296-
const { step: changedStep, ...changes } = this.repo.getActualChanges(
297-
currentProject,
298-
input,
299-
);
284+
const changes = this.repo.getActualChanges(currentProject, input);
300285
this.privileges
301286
.for(session, resolveProjectType(currentProject), currentProject)
302287
.verifyChanges(changes, { pathPrefix: 'project' });
303-
if (!changedStep && Object.keys(changes).length === 0) {
288+
if (Object.keys(changes).length === 0) {
304289
return await this.readOneUnsecured(input.id, session, changeset);
305290
}
306291

307292
ProjectDateRangeException.throwIfInvalid(currentProject, changes);
308293

309-
let updated = currentProject;
310-
if (changedStep) {
311-
await this.workflow.executeTransitionLegacy(
312-
this.secure(currentProject, session),
313-
changedStep,
314-
session,
315-
);
316-
updated = await this.readOneUnsecured(input.id, session, changeset);
317-
}
318-
319294
if (changes.primaryLocationId) {
320295
try {
321296
const location = await this.locationService.readOne(
@@ -347,7 +322,7 @@ export class ProjectService {
347322
'Field region not found',
348323
);
349324

350-
updated = await this.repo.update(updated, changes, changeset);
325+
const updated = await this.repo.update(currentProject, changes, changeset);
351326

352327
const prevMissing = RequiredWhen.calc(IProject, currentProject);
353328
const nowMissing = RequiredWhen.calc(IProject, updated);

src/components/project/workflow/dto/workflow-transition.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ObjectType } from '@nestjs/graphql';
22
import { WorkflowTransition } from '../../../workflow/dto';
33
import { ProjectStep } from '../../dto';
44

5-
@ObjectType('ProjectStepTransition', {
5+
@ObjectType({
66
description: WorkflowTransition.descriptionFor('project'),
77
})
88
export abstract class ProjectWorkflowTransition extends WorkflowTransition(

src/components/project/workflow/migrations/step-history-to-workflow-events.migration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class StepHistoryToWorkflowEventsMigration extends BaseMigration {
7777
{
7878
project: fakeProject,
7979
moduleRef: this.moduleRef,
80+
// @ts-expect-error removed from src, but keeping this file for reference for now.
8081
migrationPrevSteps: prev,
8182
},
8283
project,

src/components/project/workflow/project-workflow.service.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
findTransition,
1414
WorkflowService,
1515
} from '../../workflow/workflow.service';
16-
import { IProject, type Project, type ProjectStep } from '../dto';
16+
import { IProject, type Project } from '../dto';
1717
import { ProjectService } from '../project.service';
1818
import {
1919
type ExecuteProjectTransitionInput,
@@ -110,27 +110,4 @@ export class ProjectWorkflowService extends WorkflowService(
110110

111111
return this.projects.secure(event.project, session);
112112
}
113-
114-
/** @deprecated */
115-
async executeTransitionLegacy(
116-
currentProject: Project,
117-
step: ProjectStep,
118-
session: Session,
119-
) {
120-
const transitions = await this.getAvailableTransitions(
121-
currentProject,
122-
session,
123-
);
124-
// Pick the first matching to step.
125-
// Lack of detail is one of the reasons why this is legacy logic.
126-
const transition = transitions.find((t) => t.to === step);
127-
128-
await this.executeTransition(
129-
{
130-
project: currentProject.id,
131-
...(transition ? { transition: transition.key } : { bypassTo: step }),
132-
},
133-
session,
134-
);
135-
}
136113
}

src/components/project/workflow/transitions/dynamic-step.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@ export interface ResolveParams {
88
project: MaybeSecured<Project>;
99
previousStep?: Step;
1010
moduleRef: ModuleRef;
11-
migrationPrevSteps?: ProjectStep[];
1211
}
1312

1413
export const BackTo = (
1514
...steps: ProjectStep[]
1615
): DynamicState<Step, ResolveParams> => ({
1716
description: 'Back',
1817
relatedStates: steps,
19-
async resolve({ project, moduleRef, migrationPrevSteps }) {
20-
if (migrationPrevSteps) {
21-
return migrationPrevSteps.find((s) => steps.includes(s)) ?? steps[0];
22-
}
18+
async resolve({ project, moduleRef }) {
2319
const repo = moduleRef.get(ProjectWorkflowRepository);
2420
const found = await repo.mostRecentStep(project.id, steps);
2521
return found ?? steps[0] ?? ProjectStep.EarlyConversations;

0 commit comments

Comments
 (0)