From fab5c035a5ff9218393d216f066c0c1be6ac29aa Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Sun, 12 Oct 2025 12:17:47 +0200 Subject: [PATCH] feat: improve connection display with reusable component and instant actor type updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creates reusable ConnectionDisplay component and enhances connection visualization in both Actor and Relation properties panels. Changes: - Add ConnectionDisplay component for consistent connection visualization - Shows source and target actors with icons, labels, and type names - Includes direction indicators (→, ↔, —) based on directionality - Provides tooltips with node IDs on hover - Enhance Actor Properties connections section - Display full actor information instead of just node IDs - Show edge type badges with color indicators - Include custom labels when different from type labels - Use ConnectionDisplay component for rich connection details - Refactor Relation Properties to use ConnectionDisplay - Eliminates duplicate connection rendering code - Maintains consistent UI across panels - Change actor type updates to apply instantly - Remove debounce delay for actor type dropdown changes - Provides immediate visual feedback when changing types - Consistent with relation type and directionality behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/Common/ConnectionDisplay.tsx | 79 ++++++++++++++ src/components/Panels/RightPanel.tsx | 115 ++++++++------------ 2 files changed, 124 insertions(+), 70 deletions(-) create mode 100644 src/components/Common/ConnectionDisplay.tsx diff --git a/src/components/Common/ConnectionDisplay.tsx b/src/components/Common/ConnectionDisplay.tsx new file mode 100644 index 0000000..07717c7 --- /dev/null +++ b/src/components/Common/ConnectionDisplay.tsx @@ -0,0 +1,79 @@ +import { Tooltip } from '@mui/material'; +import { getIconComponent } from '../../utils/iconUtils'; +import type { Actor, NodeTypeConfig, EdgeDirectionality } from '../../types'; + +/** + * ConnectionDisplay - Reusable component for displaying actor connections + * + * Shows source and target actors with: + * - Node type icon + * - Node label + * - Node type label + * - Direction indicator based on directionality + */ + +interface ConnectionDisplayProps { + sourceNode: Actor | undefined; + targetNode: Actor | undefined; + nodeTypes: NodeTypeConfig[]; + directionality: EdgeDirectionality; +} + +const ConnectionDisplay = ({ + sourceNode, + targetNode, + nodeTypes, + directionality +}: ConnectionDisplayProps) => { + const sourceType = nodeTypes.find(nt => nt.id === sourceNode?.data?.type); + const targetType = nodeTypes.find(nt => nt.id === targetNode?.data?.type); + const SourceIcon = sourceType ? getIconComponent(sourceType.icon) : null; + const TargetIcon = targetType ? getIconComponent(targetType.icon) : null; + + return ( +
+ {/* Source Actor */} + +
+ {SourceIcon && ( +
+ +
+ )} + + {sourceNode?.data?.label || sourceNode?.id || 'Unknown'} + + + ({sourceType?.label || 'Unknown'}) + +
+
+ + {/* Direction Indicator */} + + {directionality === 'directed' && '→'} + {directionality === 'bidirectional' && '↔'} + {directionality === 'undirected' && '—'} + + + {/* Target Actor */} + +
+ + ({targetType?.label || 'Unknown'}) + + + {targetNode?.data?.label || targetNode?.id || 'Unknown'} + + {TargetIcon && ( +
+ +
+ )} +
+
+
+ ); +}; + +export default ConnectionDisplay; diff --git a/src/components/Panels/RightPanel.tsx b/src/components/Panels/RightPanel.tsx index a521763..da574b2 100644 --- a/src/components/Panels/RightPanel.tsx +++ b/src/components/Panels/RightPanel.tsx @@ -12,7 +12,7 @@ import { useGraphWithHistory } from '../../hooks/useGraphWithHistory'; import { useDocumentHistory } from '../../hooks/useDocumentHistory'; import { useConfirm } from '../../hooks/useConfirm'; import GraphMetrics from '../Common/GraphMetrics'; -import { getIconComponent } from '../../utils/iconUtils'; +import ConnectionDisplay from '../Common/ConnectionDisplay'; import type { Actor, Relation, EdgeDirectionality } from '../../types'; /** @@ -264,8 +264,18 @@ const RightPanel = ({ selectedNode, selectedEdge, onClose }: Props) => {