From 9465653fabd51b98513a1109c685a1efe1c3d7d3 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 4 Nov 2020 13:04:40 +0100 Subject: [PATCH] :zap: Improve editor-UI dirty checking --- .../src/components/mixins/moveNodeWorkflow.ts | 4 ++-- .../src/components/mixins/workflowRun.ts | 1 - packages/editor-ui/src/store.ts | 20 ------------------- packages/editor-ui/src/views/NodeView.vue | 6 ++++++ 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/packages/editor-ui/src/components/mixins/moveNodeWorkflow.ts b/packages/editor-ui/src/components/mixins/moveNodeWorkflow.ts index b1250003fd..7aca13623d 100644 --- a/packages/editor-ui/src/components/mixins/moveNodeWorkflow.ts +++ b/packages/editor-ui/src/components/mixins/moveNodeWorkflow.ts @@ -33,7 +33,7 @@ export const moveNodeWorkflow = mixins( const nodeViewOffsetPositionX = offsetPosition[0] + (position.x - this.moveLastPosition[0]); const nodeViewOffsetPositionY = offsetPosition[1] + (position.y - this.moveLastPosition[1]); - this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true}); + this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY]}); // Update the last position this.moveLastPosition[0] = position.x; @@ -101,7 +101,7 @@ export const moveNodeWorkflow = mixins( const offsetPosition = this.$store.getters.getNodeViewOffsetPosition; const nodeViewOffsetPositionX = offsetPosition[0] - normalized.pixelX; const nodeViewOffsetPositionY = offsetPosition[1] - normalized.pixelY; - this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true}); + this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY]}); }, }, }); diff --git a/packages/editor-ui/src/components/mixins/workflowRun.ts b/packages/editor-ui/src/components/mixins/workflowRun.ts index 08ac66a110..ea375f7399 100644 --- a/packages/editor-ui/src/components/mixins/workflowRun.ts +++ b/packages/editor-ui/src/components/mixins/workflowRun.ts @@ -29,7 +29,6 @@ export const workflowRun = mixins( // because then it can not receive the data as it executes. throw new Error('No active connection to server. It is maybe down.'); } - const workflow = this.getWorkflow(); this.$store.commit('addActiveAction', 'workflowRunning'); diff --git a/packages/editor-ui/src/store.ts b/packages/editor-ui/src/store.ts index 0ad38d81f3..8275908fc0 100644 --- a/packages/editor-ui/src/store.ts +++ b/packages/editor-ui/src/store.ts @@ -96,7 +96,6 @@ export const store = new Vuex.Store({ // Active Executions addActiveExecution (state, newActiveExecution: IExecutionsCurrentSummaryExtended) { - state.stateIsDirty = true; // Check if the execution exists already const activeExecution = state.activeExecutions.find(execution => { return execution.idActive === newActiveExecution.idActive; @@ -113,7 +112,6 @@ export const store = new Vuex.Store({ state.activeExecutions.unshift(newActiveExecution); }, finishActiveExecution (state, finishedActiveExecution: IPushDataExecutionFinished) { - state.stateIsDirty = true; // Find the execution to set to finished const activeExecution = state.activeExecutions.find(execution => { return execution.idActive === finishedActiveExecution.executionIdActive; @@ -132,7 +130,6 @@ export const store = new Vuex.Store({ Vue.set(activeExecution, 'stoppedAt', finishedActiveExecution.data.stoppedAt); }, setActiveExecutions (state, newActiveExecutions: IExecutionsCurrentSummaryExtended[]) { - state.stateIsDirty = true; Vue.set(state, 'activeExecutions', newActiveExecutions); }, @@ -165,7 +162,6 @@ export const store = new Vuex.Store({ state.selectedNodes.push(node); }, removeNodeFromSelection (state, node: INodeUi) { - state.stateIsDirty = true; let index; for (index in state.selectedNodes) { if (state.selectedNodes[index].name === node.name) { @@ -377,7 +373,6 @@ export const store = new Vuex.Store({ // Set/Overwrite the value Vue.set(node.issues!, nodeIssueData.type, nodeIssueData.value); - state.stateIsDirty = true; } return true; @@ -466,7 +461,6 @@ export const store = new Vuex.Store({ state.nodeIndex.push(nodeName); }, setNodeIndex (state, newData: { index: number, name: string | null}) { - state.stateIsDirty = true; state.nodeIndex[newData.index] = newData.name; }, resetNodeIndex (state) { @@ -478,9 +472,6 @@ export const store = new Vuex.Store({ state.nodeViewMoveInProgress = value; }, setNodeViewOffsetPosition (state, data) { - if (data.setStateDirty === true) { - state.stateIsDirty = true; - } state.nodeViewOffsetPosition = data.newOffset; }, @@ -541,16 +532,6 @@ export const store = new Vuex.Store({ Vue.set(state, 'oauthCallbackUrls', urls); }, - addNodeType (state, typeData: INodeTypeDescription) { - if (!typeData.hasOwnProperty('name')) { - // All node-types have to have a name - // TODO: Check if there is an error or whatever that is supposed to be returned - return; - } - state.stateIsDirty = true; - state.nodeTypes.push(typeData); - }, - setActiveNode (state, nodeName: string) { state.activeNode = nodeName; }, @@ -573,7 +554,6 @@ export const store = new Vuex.Store({ if (state.workflowExecutionData.data.resultData.runData[pushData.nodeName] === undefined) { Vue.set(state.workflowExecutionData.data.resultData.runData, pushData.nodeName, []); } - state.stateIsDirty = true; state.workflowExecutionData.data.resultData.runData[pushData.nodeName].push(pushData.data); }, diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 2cf41645eb..fff03cb087 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1006,6 +1006,8 @@ export default mixins( await this.addNodes([newNodeData]); + this.$store.commit('setStateDirty', true); + // Automatically deselect all nodes and select the current one and also active // current node this.deselectAllNodes(); @@ -1500,6 +1502,8 @@ export default mixins( await this.addNodes([newNodeData]); + this.$store.commit('setStateDirty', true); + // Automatically deselect all nodes and select the current one and also active // current node this.deselectAllNodes(); @@ -1834,6 +1838,8 @@ export default mixins( // Add the nodes with the changed node names, expressions and connections await this.addNodes(Object.values(tempWorkflow.nodes), tempWorkflow.connectionsBySourceNode); + this.$store.commit('setStateDirty', true); + return { nodes: Object.values(tempWorkflow.nodes), connections: tempWorkflow.connectionsBySourceNode,