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
This commit is contained in:
Omar Ajoue 2021-08-27 19:32:21 +02:00 committed by GitHub
parent 7ea515c840
commit 5a97dbf4c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,6 +33,7 @@ import {
IWorkflowDataUpdate, IWorkflowDataUpdate,
XYPositon, XYPositon,
ITag, ITag,
IUpdateInformation,
} from '../../Interface'; } from '../../Interface';
import { externalHooks } from '@/components/mixins/externalHooks'; import { externalHooks } from '@/components/mixins/externalHooks';
@ -452,10 +453,12 @@ export const workflowHelpers = mixins(
const workflowDataRequest: IWorkflowDataUpdate = await this.getWorkflowDataToSave(); const workflowDataRequest: IWorkflowDataUpdate = await this.getWorkflowDataToSave();
// make sure that the new ones are not active // make sure that the new ones are not active
workflowDataRequest.active = false; workflowDataRequest.active = false;
const changedNodes = {} as IDataObject;
if (resetWebhookUrls) { if (resetWebhookUrls) {
workflowDataRequest.nodes = workflowDataRequest.nodes!.map(node => { workflowDataRequest.nodes = workflowDataRequest.nodes!.map(node => {
if (node.webhookId) { if (node.webhookId) {
node.webhookId = uuidv4(); node.webhookId = uuidv4();
changedNodes[node.name] = node.webhookId;
} }
return node; return node;
}); });
@ -470,10 +473,20 @@ export const workflowHelpers = mixins(
} }
const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest); 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('setWorkflowName', {newName: workflowData.name, setStateDirty: false});
this.$store.commit('setWorkflowSettings', workflowData.settings || {});
this.$store.commit('setStateDirty', false); 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 createdTags = (workflowData.tags || []) as ITag[];
const tagIds = createdTags.map((tag: ITag): string => tag.id); const tagIds = createdTags.map((tag: ITag): string => tag.id);
this.$store.commit('setWorkflowTagIds', tagIds); this.$store.commit('setWorkflowTagIds', tagIds);