Skip to content

Commit

Permalink
fix(editor): Fix pin data in executions when pinData is null. (#3787)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgrozav authored Jul 27, 2022
1 parent 3496a39 commit 30c0f21
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/editor-ui/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,23 @@ export const store = new Vuex.Store({

// Pin data
pinData(state, payload: { node: INodeUi, data: IPinData[string] }) {
if (state.workflow.pinData) {
Vue.set(state.workflow.pinData, payload.node.name, payload.data);
if (!state.workflow.pinData) {
Vue.set(state.workflow, 'pinData', {});
}

Vue.set(state.workflow.pinData!, payload.node.name, payload.data);
state.stateIsDirty = true;

dataPinningEventBus.$emit('pin-data', { [payload.node.name]: payload.data });
},
unpinData(state, payload: { node: INodeUi }) {
if (state.workflow.pinData) {
Vue.set(state.workflow.pinData, payload.node.name, undefined);
delete state.workflow.pinData[payload.node.name];
if (!state.workflow.pinData) {
Vue.set(state.workflow, 'pinData', {});
}

Vue.set(state.workflow.pinData!, payload.node.name, undefined);
delete state.workflow.pinData![payload.node.name];

state.stateIsDirty = true;

dataPinningEventBus.$emit('unpin-data', { [payload.node.name]: undefined });
Expand Down Expand Up @@ -478,7 +481,7 @@ export const store = new Vuex.Store({
}

if (data.removePinData) {
state.workflow.pinData = {};
Vue.set(state.workflow, 'pinData', {});
}

state.workflow.nodes.splice(0, state.workflow.nodes.length);
Expand Down Expand Up @@ -652,9 +655,9 @@ export const store = new Vuex.Store({
},

setWorkflowPinData(state, pinData: IPinData) {
Vue.set(state.workflow, 'pinData', pinData);
Vue.set(state.workflow, 'pinData', pinData || {});

dataPinningEventBus.$emit('pin-data', pinData);
dataPinningEventBus.$emit('pin-data', pinData || {});
},

setWorkflowTagIds(state, tags: string[]) {
Expand Down Expand Up @@ -909,7 +912,7 @@ export const store = new Vuex.Store({
return state.workflow.pinData;
},
pinDataByNodeName: (state) => (nodeName: string) => {
return state.workflow.pinData && state.workflow.pinData[nodeName];
return state.workflow.pinData ? state.workflow.pinData[nodeName] : undefined;
},
pinDataSize: (state) => {
return state.workflow.nodes
Expand Down

0 comments on commit 30c0f21

Please sign in to comment.