Graph: place capability labels beside the target node (ENB-22)
CI / integration (push) Successful in 14s
CI / check (push) Successful in 18s

Edge labels sat at each curve's midpoint, where edges leaving one policy bunch
up and overlap. Policy->path edges now use a custom edge that puts a clickable
label just before the target, stacked apart when several edges share a target,
and the path column is moved right to leave room for longer labels.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-20 12:59:59 +01:00
1 parent b55259c492
commit 0882d35123
4 files changed
+82 -14

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import { BaseEdge, EdgeLabelRenderer, getBezierPath, type EdgeProps } from '@xyflow/react'
export interface GrantEdgeData {
label: string
/** Vertical nudge so labels on edges into the same node don't sit on top of each other. */
offset: number
onSelect: () => void
}
/**
* A policy -> path edge. The capability label sits just before the target node, where edges have
* fanned out to different rows, instead of at the midpoint where edges from one policy bunch up.
*/
export function GrantEdge({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, selected, data }: EdgeProps) {
const { label, offset, onSelect } = data as unknown as GrantEdgeData
const [path] = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition })
return (
<>
<BaseEdge id={id} path={path} markerEnd={markerEnd} />
<EdgeLabelRenderer>
<button
type="button"
className={`nodrag nopan edge-label${selected ? ' edge-label-selected' : ''}`}
style={{ transform: `translate(-100%, -50%) translate(${targetX - 18}px, ${targetY + offset}px)` }}
onClick={onSelect}
>
{label}
</button>
</EdgeLabelRenderer>
</>
)
}