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) => {