mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ 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:
parent
7ea515c840
commit
5a97dbf4c5
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue