mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
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.
This commit is contained in:
@@ -135,7 +135,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { mapStores, storeToRefs } from 'pinia';
|
||||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
import type {
|
||||
INodeConnections,
|
||||
@@ -163,7 +163,6 @@ import {
|
||||
STICKY_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
import { workflowActivate } from '@/mixins/workflowActivate';
|
||||
import { pinData } from '@/mixins/pinData';
|
||||
import { dataPinningEventBus } from '@/event-bus';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
@@ -174,6 +173,7 @@ import { useDeviceSupport } from 'n8n-design-system/composables/useDeviceSupport
|
||||
import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
||||
import { useMessage } from '@/composables/useMessage';
|
||||
import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||
import { usePinnedData } from '@/composables/usePinnedData';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'NodeDetailsView',
|
||||
@@ -184,7 +184,7 @@ export default defineComponent({
|
||||
NDVDraggablePanels,
|
||||
TriggerPanel,
|
||||
},
|
||||
mixins: [workflowHelpers, workflowActivate, pinData],
|
||||
mixins: [workflowHelpers, workflowActivate],
|
||||
props: {
|
||||
readOnly: {
|
||||
type: Boolean,
|
||||
@@ -198,12 +198,16 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props, ctx) {
|
||||
const ndvStore = useNDVStore();
|
||||
const externalHooks = useExternalHooks();
|
||||
const nodeHelpers = useNodeHelpers();
|
||||
const { activeNode } = storeToRefs(ndvStore);
|
||||
const pinnedData = usePinnedData(activeNode);
|
||||
|
||||
return {
|
||||
externalHooks,
|
||||
nodeHelpers,
|
||||
pinnedData,
|
||||
...useDeviceSupport(),
|
||||
...useMessage(),
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
@@ -301,12 +305,10 @@ export default defineComponent({
|
||||
return [];
|
||||
},
|
||||
parentNode(): string | undefined {
|
||||
const pinData = this.workflowsStore.getPinData;
|
||||
|
||||
// Return the first parent node that contains data
|
||||
for (const parentNodeName of this.parentNodes) {
|
||||
// Check first for pinned data
|
||||
if (pinData[parentNodeName]) {
|
||||
if (this.workflowsStore.pinnedWorkflowData[parentNodeName]) {
|
||||
return parentNodeName;
|
||||
}
|
||||
|
||||
@@ -689,7 +691,7 @@ export default defineComponent({
|
||||
if (shouldPinDataBeforeClosing === MODAL_CONFIRM) {
|
||||
const { value } = this.outputPanelEditMode;
|
||||
try {
|
||||
this.setPinData(this.activeNode, jsonParse(value), 'on-ndv-close-modal');
|
||||
this.pinnedData.setData(jsonParse(value), 'on-ndv-close-modal');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user