Fix use as draft (#9718)

- remove delete serverless function when archiving workflow version
- update copy serverless function to reset serverless function to old
version
- remove createNewWorkflowVersion and use createDraftFromWorkflowVersion
- fix step update issue and optimistic rendering when generate draft
from active version
This commit is contained in:
martmull
2025-01-21 15:44:52 +01:00
committed by GitHub
parent d8815d7ebf
commit ed7c48e12a
22 changed files with 207 additions and 309 deletions

View File

@ -198,37 +198,27 @@ export class WorkflowVersionStepWorkspaceService {
step: WorkflowAction;
workspaceId: string;
}): Promise<WorkflowAction> {
const newStepId = v4();
switch (step.type) {
case WorkflowActionType.CODE: {
const copiedServerlessFunction =
await this.serverlessFunctionService.copyOneServerlessFunction({
serverlessFunctionToCopyId:
step.settings.input.serverlessFunctionId,
serverlessFunctionToCopyVersion:
step.settings.input.serverlessFunctionVersion,
workspaceId,
});
await this.serverlessFunctionService.usePublishedVersionAsDraft({
id: step.settings.input.serverlessFunctionId,
version: step.settings.input.serverlessFunctionVersion,
workspaceId,
});
return {
...step,
id: newStepId,
settings: {
...step.settings,
input: {
...step.settings.input,
serverlessFunctionId: copiedServerlessFunction.id,
serverlessFunctionVersion: copiedServerlessFunction.latestVersion,
serverlessFunctionVersion: 'draft',
},
},
};
}
default: {
return {
...step,
id: newStepId,
};
return step;
}
}
}
@ -473,17 +463,6 @@ export class WorkflowVersionStepWorkspaceService {
assertWorkflowVersionIsDraft(draftWorkflowVersion);
if (Array.isArray(draftWorkflowVersion.steps)) {
await Promise.all(
draftWorkflowVersion.steps.map((step) =>
this.runWorkflowVersionStepDeletionSideEffects({
step,
workspaceId,
}),
),
);
}
const newWorkflowVersionTrigger = workflowVersionToCopy.trigger;
const newWorkflowVersionSteps: WorkflowAction[] = [];
@ -500,6 +479,8 @@ export class WorkflowVersionStepWorkspaceService {
steps: newWorkflowVersionSteps,
trigger: newWorkflowVersionTrigger,
});
return draftWorkflowVersion.id;
}
private async runWorkflowVersionStepDeletionSideEffects({