fix: Update remaining Canvas usages

This commit is contained in:
Alex Grozav 2025-03-04 15:11:07 +02:00
parent f667c3ec48
commit 9401214700
3 changed files with 22 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import { N8nTooltip } from '@n8n/design-system';
import { createEventBus } from '@n8n/utils/event-bus';
import { computed, onMounted, ref, useCssModule } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import type { INodeTypeDescription } from 'n8n-workflow';
const workflowsStore = useWorkflowsStore();
const nodeTypesStore = useNodeTypesStore();
@ -51,6 +52,23 @@ const { nodes: mappedNodes, connections: mappedConnections } = useCanvasMapping(
connections,
workflowObject,
});
const nodeTypeDescriptions = computed(() => {
return nodes.value.reduce<Record<string, INodeTypeDescription>>((acc, node) => {
const key = `${node.type}@${node.typeVersion}`;
if (acc[key]) {
return acc;
}
const nodeTypeDescription = nodeTypesStore.getNodeType(node.type, node.typeVersion);
if (nodeTypeDescription) {
acc[key] = nodeTypeDescription;
}
return acc;
}, {});
});
async function loadData() {
workflowsStore.resetState();
resetWorkspace();
@ -141,6 +159,7 @@ onMounted(loadData);
:class="{ [$style.canvas]: true }"
:nodes="mappedNodes"
:connections="mappedConnections"
:node-type-descriptions="nodeTypeDescriptions"
:show-bug-reporting-button="false"
:read-only="true"
:event-bus="eventBus"

View file

@ -97,8 +97,8 @@ const props = withDefaults(
defineProps<{
id?: string;
nodes: CanvasNode[];
nodeTypeDescriptions: Record<string, INodeTypeDescription>;
connections: CanvasConnection[];
nodeTypeDescriptions?: Record<string, INodeTypeDescription>;
controlsPosition?: PanelPosition;
eventBus?: EventBus<CanvasEventBusEvents>;
readOnly?: boolean;
@ -110,6 +110,7 @@ const props = withDefaults(
id: 'canvas',
nodes: () => [],
connections: () => [],
nodeTypeDescriptions: () => ({}),
controlsPosition: PanelPosition.BottomLeft,
eventBus: () => createEventBus(),
readOnly: false,

View file

@ -99,8 +99,8 @@ onNodesInitialized(() => {
v-if="workflow"
:id="id"
:nodes="mappedNodes"
:node-type-descriptions="nodeTypeDescriptions"
:connections="mappedConnections"
:node-type-descriptions="nodeTypeDescriptions"
:event-bus="eventBus"
:read-only="readOnly"
v-bind="$attrs"