From 5a97dbf4c54c7e10230e7eb72a5c85742c29b910 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Fri, 27 Aug 2021 19:32:21 +0200 Subject: [PATCH] :zap: Fix canvas update on workflow duplication (#2119) * Reverting some changes in the way the canvas is updated so that conext is not lost when duplicating a workflow * Removed unnecessary if --- .../src/components/mixins/workflowHelpers.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index 4c0c167749..3eda0d42ac 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -33,6 +33,7 @@ import { IWorkflowDataUpdate, XYPositon, ITag, + IUpdateInformation, } from '../../Interface'; import { externalHooks } from '@/components/mixins/externalHooks'; @@ -452,10 +453,12 @@ export const workflowHelpers = mixins( const workflowDataRequest: IWorkflowDataUpdate = await this.getWorkflowDataToSave(); // make sure that the new ones are not active workflowDataRequest.active = false; + const changedNodes = {} as IDataObject; if (resetWebhookUrls) { workflowDataRequest.nodes = workflowDataRequest.nodes!.map(node => { if (node.webhookId) { node.webhookId = uuidv4(); + changedNodes[node.name] = node.webhookId; } return node; }); @@ -470,10 +473,20 @@ export const workflowHelpers = mixins( } const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest); - this.$store.commit('setWorkflow', workflowData); + this.$store.commit('setActive', workflowData.active || false); + this.$store.commit('setWorkflowId', workflowData.id); this.$store.commit('setWorkflowName', {newName: workflowData.name, setStateDirty: false}); + this.$store.commit('setWorkflowSettings', workflowData.settings || {}); this.$store.commit('setStateDirty', false); - + Object.keys(changedNodes).forEach((nodeName) => { + const changes = { + key: 'webhookId', + value: changedNodes[nodeName], + name: nodeName, + } as IUpdateInformation; + this.$store.commit('setNodeValue', changes); + }); + const createdTags = (workflowData.tags || []) as ITag[]; const tagIds = createdTags.map((tag: ITag): string => tag.id); this.$store.commit('setWorkflowTagIds', tagIds);