From 53d8b3ce2c440b4c72ad082650797b2b38f72be7 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Wed, 25 Feb 2026 22:58:56 +0000 Subject: [PATCH] working on the visualiser --- .../components/VisualisetTab.tsx | 95 +++++++++++++++---- 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/src/modules/manager/workflowTemplates/components/VisualisetTab.tsx b/src/modules/manager/workflowTemplates/components/VisualisetTab.tsx index 3bbb3c3..a3dc24c 100644 --- a/src/modules/manager/workflowTemplates/components/VisualisetTab.tsx +++ b/src/modules/manager/workflowTemplates/components/VisualisetTab.tsx @@ -29,16 +29,6 @@ const VisualiserTab: React.FC = ({ max: allColumns.length > 0 ? Math.max(...allColumns) : 0, }; - // Debug logging - if (allColumns.length > 0 && process.env.NODE_ENV === "development") { - const columnMap: Record = {}; - tasks.forEach((task) => { - columnMap[(task.config.name as string) || task.type] = - taskColumnMap.current.get(task.config.guid as string) ?? 0; - }); - console.log("Column assignments:", columnMap, "Range:", columnRange); - } - if (tasks.length > 0) { const byGuid = new Map(); tasks.forEach((task) => { @@ -193,14 +183,76 @@ const VisualiserTab: React.FC = ({ return found?.positions ?? []; }; - const renderConnector = (count: number, positions?: number[]) => { + // Calculate connector positions based on grid columns + const getConnectorPositionsByColumn = ( + levelTasks: CreateWorkflowTemplateVersion["tasks"][], + ): number[] => { + const numColumns = columnRange.max - columnRange.min + 1; + if (numColumns <= 1) return [50]; + + return levelTasks.map((task) => { + const taskColumn = + taskColumnMap.current.get(task.config.guid as string) ?? 0; + const gridCol = taskColumn - columnRange.min; + // Map grid column to percentage (e.g., 2 columns: col 0 = 25%, col 1 = 75%) + return ((gridCol + 0.5) / numColumns) * 100; + }); + }; + + const renderConnector = ( + count: number, + positions?: number[], + predecessorPositions?: number[], + ) => { if (count <= 1) { + // For a single child, use predecessor position if available + let startX = 50; + let endX = 50; + + // If single child with predecessor positions, connect from the appropriate predecessor + if (positions && positions.length === 1) { + endX = positions[0]; + + if (predecessorPositions && predecessorPositions.length > 0) { + // Find the closest predecessor position to the child position + const closest = predecessorPositions.reduce((prev, curr) => + Math.abs(curr - endX) < Math.abs(prev - endX) ? curr : prev, + ); + startX = closest; + } + } + + // If start and end are the same, use simple vertical connector + if (!predecessorPositions || predecessorPositions.length === 0) { + return ( +