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:
Alex Grozav
2024-01-04 11:22:56 +02:00
committed by GitHub
parent f4092a9e49
commit b50d8058cf
21 changed files with 678 additions and 92 deletions

View File

@@ -12,7 +12,7 @@
@dragend="onDragEnd"
>
<template #icon>
<div v-if="isSubNode" :class="$style.subNodeBackground"></div>
<div v-if="isSubNodeType" :class="$style.subNodeBackground"></div>
<NodeIcon :class="$style.nodeIcon" :node-type="nodeType" />
</template>
@@ -57,7 +57,7 @@ import NodeIcon from '@/components/NodeIcon.vue';
import { useActions } from '../composables/useActions';
import { useI18n } from '@/composables/useI18n';
import { useTelemetry } from '@/composables/useTelemetry';
import { NodeHelpers, NodeConnectionType } from 'n8n-workflow';
import { useNodeType } from '@/composables/useNodeType';
export interface Props {
nodeType: SimplifiedNodeType;
@@ -74,6 +74,9 @@ const telemetry = useTelemetry();
const { actions } = useNodeCreatorStore();
const { getAddedNodesAndConnections } = useActions();
const { isSubNodeType } = useNodeType({
nodeType: props.nodeType,
});
const dragging = ref(false);
const draggablePosition = ref({ x: -100, y: -100 });
@@ -124,16 +127,6 @@ const displayName = computed<string>(() => {
});
});
const isSubNode = computed<boolean>(() => {
if (!props.nodeType.outputs || typeof props.nodeType.outputs === 'string') {
return false;
}
const outputTypes = NodeHelpers.getConnectionTypes(props.nodeType.outputs);
return outputTypes
? outputTypes.filter((output) => output !== NodeConnectionType.Main).length > 0
: false;
});
const isTrigger = computed<boolean>(() => {
return props.nodeType.group.includes('trigger') && !hasActions.value;
});