diff --git a/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue b/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue index 839e00efa..be8375b51 100644 --- a/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue +++ b/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue @@ -109,7 +109,7 @@ export default mixins(showMessage, workflowHelpers).extend({ this.$data.isSaving = true; - const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds}); + const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds, resetWebhookUrls: 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 ec4acf820..656737358 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,21 @@ export const workflowHelpers = mixins( } }, - async saveAsNewWorkflow ({name, tags}: {name?: string, tags?: string[]} = {}): Promise { + async saveAsNewWorkflow ({name, tags, resetWebhookUrls}: {name?: string, tags?: string[], resetWebhookUrls?: 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 (resetWebhookUrls) { + workflowDataRequest.nodes = workflowDataRequest.nodes!.map(node => { + if (node.webhookId) { + node.webhookId = uuidv4(); + } + return node; + }); + } if (name) { workflowDataRequest.name = name.trim(); @@ -452,10 +461,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[];