feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
import { useCallback, useRef, useState } from 'react';
|
|
|
|
|
import type { NodeAction } from './types';
|
2026-03-27 16:33:24 +01:00
|
|
|
import styles from './ProcessDiagram.module.css';
|
feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
|
|
|
|
|
const HIDE_DELAY = 150;
|
|
|
|
|
|
|
|
|
|
interface NodeToolbarProps {
|
|
|
|
|
nodeId: string;
|
2026-03-27 16:33:24 +01:00
|
|
|
/** Screen-space position (already transformed by zoom/pan) */
|
|
|
|
|
screenX: number;
|
|
|
|
|
screenY: number;
|
feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
onAction: (nodeId: string, action: NodeAction) => void;
|
|
|
|
|
onMouseEnter: () => void;
|
|
|
|
|
onMouseLeave: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 16:33:24 +01:00
|
|
|
const ACTIONS: { icon: string; action: NodeAction; title: string }[] = [
|
|
|
|
|
{ icon: '\uD83D\uDD0D', action: 'inspect', title: 'Inspect' },
|
|
|
|
|
{ icon: 'T', action: 'toggle-trace', title: 'Toggle tracing' },
|
|
|
|
|
{ icon: '\u270E', action: 'configure-tap', title: 'Configure tap' },
|
|
|
|
|
{ icon: '\u22EF', action: 'copy-id', title: 'Copy ID' },
|
feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function NodeToolbar({
|
2026-03-27 16:33:24 +01:00
|
|
|
nodeId, screenX, screenY, onAction, onMouseEnter, onMouseLeave,
|
feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
}: NodeToolbarProps) {
|
|
|
|
|
return (
|
2026-03-27 16:33:24 +01:00
|
|
|
<div
|
|
|
|
|
className={styles.nodeToolbar}
|
|
|
|
|
style={{ left: screenX, top: screenY }}
|
feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
onMouseEnter={onMouseEnter}
|
|
|
|
|
onMouseLeave={onMouseLeave}
|
|
|
|
|
>
|
2026-03-27 16:33:24 +01:00
|
|
|
{ACTIONS.map(a => (
|
|
|
|
|
<button
|
|
|
|
|
key={a.action}
|
|
|
|
|
className={styles.nodeToolbarBtn}
|
|
|
|
|
title={a.title}
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
onAction(nodeId, a.action);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{a.icon}
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
feat: add interactive ProcessDiagram SVG component (sub-project 1/3)
New interactive route diagram component with SVG rendering using
server-computed ELK layout coordinates. TIBCO BW5-inspired top-bar
card node style with zoom/pan, hover toolbars, config badges, and
error handler sections below the main flow.
Backend: add direction query parameter (LR/TB) to diagram render
endpoints, defaulting to left-to-right layout.
Frontend: 14-file ProcessDiagram component in ui/src/components/
with DiagramNode, CompoundNode, DiagramEdge, ConfigBadge, NodeToolbar,
ErrorSection, ZoomControls, and supporting hooks. Dev test page at
/dev/diagram for validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:55:29 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Hook to manage toolbar visibility with hide delay */
|
|
|
|
|
export function useToolbarHover() {
|
|
|
|
|
const [hoveredNodeId, setHoveredNodeId] = useState<string | null>(null);
|
|
|
|
|
const hideTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
|
|
|
|
|
|
|
|
const onNodeEnter = useCallback((nodeId: string) => {
|
|
|
|
|
if (hideTimer.current) {
|
|
|
|
|
clearTimeout(hideTimer.current);
|
|
|
|
|
hideTimer.current = null;
|
|
|
|
|
}
|
|
|
|
|
setHoveredNodeId(nodeId);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const onNodeLeave = useCallback(() => {
|
|
|
|
|
hideTimer.current = setTimeout(() => {
|
|
|
|
|
setHoveredNodeId(null);
|
|
|
|
|
hideTimer.current = null;
|
|
|
|
|
}, HIDE_DELAY);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const onToolbarEnter = useCallback(() => {
|
|
|
|
|
if (hideTimer.current) {
|
|
|
|
|
clearTimeout(hideTimer.current);
|
|
|
|
|
hideTimer.current = null;
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const onToolbarLeave = useCallback(() => {
|
|
|
|
|
hideTimer.current = setTimeout(() => {
|
|
|
|
|
setHoveredNodeId(null);
|
|
|
|
|
hideTimer.current = null;
|
|
|
|
|
}, HIDE_DELAY);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return { hoveredNodeId, onNodeEnter, onNodeLeave, onToolbarEnter, onToolbarLeave };
|
|
|
|
|
}
|