fix(editor): Fix duplicate bug when new workflow is open (#4559)

fix(editor): fix duplicate bug when new worklfow
This commit is contained in:
Mutasem Aldmour 2022-11-09 16:09:58 +01:00 committed by GitHub
parent b3cd62d866
commit 536c834313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,7 +41,7 @@
import Vue from "vue";
import mixins from "vue-typed-mixins";
import { MAX_WORKFLOW_NAME_LENGTH } from "@/constants";
import { MAX_WORKFLOW_NAME_LENGTH, PLACEHOLDER_EMPTY_WORKFLOW_ID } from "@/constants";
import { workflowHelpers } from "@/components/mixins/workflowHelpers";
import { showMessage } from "@/components/mixins/showMessage";
import TagsDropdown from "@/components/TagsDropdown.vue";
@ -50,6 +50,7 @@ import {restApi} from "@/components/mixins/restApi";
import { mapStores } from "pinia";
import { useSettingsStore } from "@/stores/settings";
import { useWorkflowsStore } from "@/stores/workflows";
import { IWorkflowDataUpdate } from "@/Interface";
export default mixins(showMessage, workflowHelpers, restApi).extend({
components: { TagsDropdown, Modal },
@ -121,10 +122,15 @@ export default mixins(showMessage, workflowHelpers, restApi).extend({
this.isSaving = true;
const { createdAt, updatedAt, ...workflow } = await this.restApi().getWorkflow(this.data.id);
let workflowToUpdate: IWorkflowDataUpdate | undefined;
if (currentWorkflowId !== PLACEHOLDER_EMPTY_WORKFLOW_ID) {
const { createdAt, updatedAt, ...workflow } = await this.restApi().getWorkflow(this.data.id);
workflowToUpdate = workflow;
}
const saved = await this.saveAsNewWorkflow({
name,
data: workflow,
data: workflowToUpdate,
tags: this.currentTagIds,
resetWebhookUrls: true,
openInNewWindow: true,