From 82dbbcd2e0e19861d720bc5a3ffa7326844188b0 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Thu, 19 Aug 2021 10:51:27 +0200 Subject: [PATCH] Changed the webhook id change code placement --- .../src/components/DuplicateWorkflowDialog.vue | 11 +---------- .../src/components/mixins/workflowHelpers.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue b/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue index d24776a60e..2f570c4ea7 100644 --- a/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue +++ b/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue @@ -44,8 +44,6 @@ import { workflowHelpers } from "@/components/mixins/workflowHelpers"; import { showMessage } from "@/components/mixins/showMessage"; import TagsDropdown from "@/components/TagsDropdown.vue"; import Modal from "./Modal.vue"; -import { v4 as uuidv4} from 'uuid'; -import { INodeUi } from "../Interface"; export default mixins(showMessage, workflowHelpers).extend({ components: { TagsDropdown, Modal }, @@ -109,16 +107,9 @@ export default mixins(showMessage, workflowHelpers).extend({ return; } - const allNodes = this.$store.getters.allNodes; - allNodes.forEach((node: INodeUi) => { - if (node.webhookId) { - node.webhookId = uuidv4(); - } - }); - this.$data.isSaving = true; - const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds}); + const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds, updateWebhookUrls: true}); if (saved) { this.closeDialog(); diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index ec4acf820c..4521523c69 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -39,6 +39,7 @@ import { showMessage } from '@/components/mixins/showMessage'; import { isEqual } from 'lodash'; import mixins from 'vue-typed-mixins'; +import { v4 as uuidv4} from 'uuid'; export const workflowHelpers = mixins( externalHooks, @@ -435,13 +436,20 @@ export const workflowHelpers = mixins( } }, - async saveAsNewWorkflow ({name, tags}: {name?: string, tags?: string[]} = {}): Promise { + async saveAsNewWorkflow ({name, tags, updateWebhookUrls}: {name?: string, tags?: string[], updateWebhookUrls?: boolean} = {}): Promise { try { this.$store.commit('addActiveAction', 'workflowSaving'); const workflowDataRequest: IWorkflowDataUpdate = await this.getWorkflowDataToSave(); // make sure that the new ones are not active workflowDataRequest.active = false; + if (updateWebhookUrls) { + workflowDataRequest.nodes!.forEach(node => { + if (node.webhookId) { + node.webhookId = uuidv4(); + } + }); + } if (name) { workflowDataRequest.name = name.trim(); @@ -452,10 +460,8 @@ export const workflowHelpers = mixins( } const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest); - this.$store.commit('setActive', workflowData.active || false); - this.$store.commit('setWorkflowId', workflowData.id); + this.$store.commit('setWorkflow', workflowData); this.$store.commit('setWorkflowName', {newName: workflowData.name, setStateDirty: false}); - this.$store.commit('setWorkflowSettings', workflowData.settings || {}); this.$store.commit('setStateDirty', false); const createdTags = (workflowData.tags || []) as ITag[];