Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed pin data in executions when pinData is null. #3787

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-actionable: Would be nice if Vue.set() were smart enough to create missing intermediate properties to avoid the boilerplate. Also I wish TS were able to pick up that state.workflow.pinData is defined via Vue.set().

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 || {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: setWorkflowPinData(state, pinData: IPinData = {}) { ... } instead of setting them below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, maybe null does not trigger the default arg.


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