From b50d8058cfcb3491777a4304421e7a7df9f2676f Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Thu, 4 Jan 2024 11:22:56 +0200 Subject: [PATCH] feat(editor): Migrate pinData mixin to usePinnedData composable (no-changelog) (#8207) ## Summary Required as part of NodeView refactoring: - Migrates `pinData` mixin to `usePinnedData` composable. - Adds `useActiveNode` and `useNodeType` composables ## Related tickets and issues https://linear.app/n8n/issue/N8N-6355/pindata ## Review / Merge checklist - [x] PR title and summary are descriptive. **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** ([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md)) - [x] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created. - [x] Tests included. > A bug is not considered fixed, unless a test is added to prevent it from happening again. > A feature is not complete without tests. --- .../completions/jsonField.completions.ts | 2 +- .../editor-ui/src/components/InputPanel.vue | 2 +- packages/editor-ui/src/components/Node.vue | 17 +- .../Node/NodeCreator/ItemTypes/NodeItem.vue | 17 +- .../src/components/NodeDetailsView.vue | 16 +- .../src/components/NodeExecuteButton.vue | 15 +- .../editor-ui/src/components/OutputPanel.vue | 34 ++- packages/editor-ui/src/components/RunData.vue | 68 +++-- .../src/components/RunDataJsonActions.vue | 14 +- .../src/components/__tests__/RunData.test.ts | 4 +- .../__tests__/useActiveNode.test.ts | 43 +++ .../composables/__tests__/useNodeType.test.ts | 51 ++++ .../__tests__/usePinnedData.test.ts | 136 ++++++++++ .../src/composables/useActiveNode.ts | 17 ++ .../src/composables/useNodeHelpers.ts | 2 +- .../editor-ui/src/composables/useNodeType.ts | 46 ++++ .../src/composables/usePinnedData.ts | 253 ++++++++++++++++++ packages/editor-ui/src/mixins/nodeBase.ts | 1 + .../editor-ui/src/mixins/workflowHelpers.ts | 4 +- .../editor-ui/src/stores/workflows.store.ts | 4 +- packages/editor-ui/src/views/NodeView.vue | 24 +- 21 files changed, 678 insertions(+), 92 deletions(-) create mode 100644 packages/editor-ui/src/composables/__tests__/useActiveNode.test.ts create mode 100644 packages/editor-ui/src/composables/__tests__/useNodeType.test.ts create mode 100644 packages/editor-ui/src/composables/__tests__/usePinnedData.test.ts create mode 100644 packages/editor-ui/src/composables/useActiveNode.ts create mode 100644 packages/editor-ui/src/composables/useNodeType.ts create mode 100644 packages/editor-ui/src/composables/usePinnedData.ts diff --git a/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts b/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts index bf0207da2..8e81e26d0 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/completions/jsonField.completions.ts @@ -286,7 +286,7 @@ export const jsonFieldCompletions = defineComponent({ nodeName = quotedNodeName.replace(/^"/, '').replace(/"$/, ''); } - const pinData: IPinData | undefined = this.workflowsStore.getPinData; + const pinData: IPinData | undefined = this.workflowsStore.pinnedWorkflowData; const nodePinData = pinData?.[nodeName]; diff --git a/packages/editor-ui/src/components/InputPanel.vue b/packages/editor-ui/src/components/InputPanel.vue index e1ebfd26d..e0d50a2ba 100644 --- a/packages/editor-ui/src/components/InputPanel.vue +++ b/packages/editor-ui/src/components/InputPanel.vue @@ -1,6 +1,6 @@