mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
⚡ Deconstructed store mutation data parameters for better readability
This commit is contained in:
parent
6961050a42
commit
17ab16d248
|
@ -398,7 +398,7 @@ export default mixins(
|
|||
return;
|
||||
}
|
||||
|
||||
this.$store.commit('setWorkflowName', {newName: workflowName, setStateDirty: true});
|
||||
this.$store.commit('setWorkflowName', {name: workflowName, setStateDirty: true});
|
||||
|
||||
this.$showMessage({
|
||||
title: 'Workflow renamed',
|
||||
|
|
|
@ -31,7 +31,7 @@ export const moveNodeWorkflow = mixins(nodeIndex).extend({
|
|||
|
||||
const nodeViewOffsetPositionX = offsetPosition[0] + (e.pageX - this.moveLastPosition[0]);
|
||||
const nodeViewOffsetPositionY = offsetPosition[1] + (e.pageY - this.moveLastPosition[1]);
|
||||
this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true});
|
||||
this.$store.commit('setNodeViewOffsetPosition', {offset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true});
|
||||
|
||||
// Update the last position
|
||||
this.moveLastPosition[0] = e.pageX;
|
||||
|
@ -87,7 +87,7 @@ export const moveNodeWorkflow = mixins(nodeIndex).extend({
|
|||
const offsetPosition = this.$store.getters.getNodeViewOffsetPosition;
|
||||
const nodeViewOffsetPositionX = offsetPosition[0] - e.deltaX;
|
||||
const nodeViewOffsetPositionY = offsetPosition[1] - e.deltaY;
|
||||
this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true});
|
||||
this.$store.commit('setNodeViewOffsetPosition', {offset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -420,7 +420,7 @@ export const workflowHelpers = mixins(
|
|||
|
||||
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', {name: workflowData.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowSettings', workflowData.settings || {});
|
||||
} else {
|
||||
// Workflow exists already so update it
|
||||
|
|
|
@ -74,7 +74,7 @@ export const workflowSave = mixins(
|
|||
|
||||
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', {name: workflowData.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowSettings', workflowData.settings || {});
|
||||
} else {
|
||||
// Workflow exists already so update it
|
||||
|
|
|
@ -183,19 +183,19 @@ export const store = new Vuex.Store({
|
|||
},
|
||||
|
||||
// Connections
|
||||
addConnection (state, data) {
|
||||
if (data.connection.length !== 2) {
|
||||
addConnection (state, {connection, setStateDirty}) {
|
||||
if (connection.length !== 2) {
|
||||
// All connections need two entries
|
||||
// TODO: Check if there is an error or whatever that is supposed to be returned
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.setStateDirty === true) {
|
||||
if (setStateDirty === true) {
|
||||
state.stateIsDirty = true;
|
||||
}
|
||||
|
||||
const sourceData: IConnection = data.connection[0];
|
||||
const destinationData: IConnection = data.connection[1];
|
||||
const sourceData: IConnection = connection[0];
|
||||
const destinationData: IConnection = connection[1];
|
||||
|
||||
// Check if source node and type exist already and if not add them
|
||||
if (!state.workflow.connections.hasOwnProperty(sourceData.node)) {
|
||||
|
@ -388,11 +388,11 @@ export const store = new Vuex.Store({
|
|||
},
|
||||
|
||||
// Name
|
||||
setWorkflowName (state, data) {
|
||||
if (data.setStateDirty === true) {
|
||||
setWorkflowName (state, {name, setStateDirty}) {
|
||||
if (setStateDirty === true) {
|
||||
state.stateIsDirty = true;
|
||||
}
|
||||
state.workflow.name = data.newName;
|
||||
state.workflow.name = name;
|
||||
},
|
||||
|
||||
// Nodes
|
||||
|
@ -476,11 +476,11 @@ export const store = new Vuex.Store({
|
|||
setNodeViewMoveInProgress (state, value: boolean) {
|
||||
state.nodeViewMoveInProgress = value;
|
||||
},
|
||||
setNodeViewOffsetPosition (state, data) {
|
||||
if (data.setStateDirty === true) {
|
||||
setNodeViewOffsetPosition (state, {offset, setStateDirty}) {
|
||||
if (setStateDirty === true) {
|
||||
state.stateIsDirty = true;
|
||||
}
|
||||
state.nodeViewOffsetPosition = data.newOffset;
|
||||
state.nodeViewOffsetPosition = offset;
|
||||
},
|
||||
|
||||
// Node-Types
|
||||
|
|
|
@ -325,7 +325,7 @@ export default mixins(
|
|||
throw new Error(`Execution with id "${executionId}" could not be found!`);
|
||||
}
|
||||
|
||||
this.$store.commit('setWorkflowName', {newName: data.workflowData.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowName', {name: data.workflowData.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowId', PLACEHOLDER_EMPTY_WORKFLOW_ID);
|
||||
|
||||
this.$store.commit('setWorkflowExecutionData', data);
|
||||
|
@ -349,7 +349,7 @@ export default mixins(
|
|||
|
||||
this.$store.commit('setActive', data.active || false);
|
||||
this.$store.commit('setWorkflowId', workflowId);
|
||||
this.$store.commit('setWorkflowName', {newName: data.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowName', {name: data.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowSettings', data.settings || {});
|
||||
|
||||
await this.addNodes(data.nodes, data.connections);
|
||||
|
@ -1388,10 +1388,9 @@ export default mixins(
|
|||
detachable: !this.isReadOnly,
|
||||
});
|
||||
} else {
|
||||
const connectionProperties = {connection, setStateDirty: false};
|
||||
// When nodes get connected it gets saved automatically to the storage
|
||||
// so if we do not connect we have to save the connection manually
|
||||
this.$store.commit('addConnection', connectionProperties);
|
||||
this.$store.commit('addConnection', {connection, setStateDirty: false});
|
||||
}
|
||||
},
|
||||
__removeConnection (connection: [IConnection, IConnection], removeVisualConnection = false) {
|
||||
|
@ -1876,7 +1875,7 @@ export default mixins(
|
|||
|
||||
this.$store.commit('setActive', false);
|
||||
this.$store.commit('setWorkflowId', PLACEHOLDER_EMPTY_WORKFLOW_ID);
|
||||
this.$store.commit('setWorkflowName', {newName: '', setStateDirty: false});
|
||||
this.$store.commit('setWorkflowName', {name: '', setStateDirty: false});
|
||||
this.$store.commit('setWorkflowSettings', {});
|
||||
|
||||
this.$store.commit('setActiveExecutionId', null);
|
||||
|
@ -1887,7 +1886,7 @@ export default mixins(
|
|||
this.$store.commit('resetNodeIndex');
|
||||
this.$store.commit('resetSelectedNodes');
|
||||
|
||||
this.$store.commit('setNodeViewOffsetPosition', {newOffset: [0, 0], setStateDirty: false});
|
||||
this.$store.commit('setNodeViewOffsetPosition', {offset: [0, 0], setStateDirty: false});
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue