import { Link } from "react-router-dom" import { ArrowUpRight, ArrowDownLeft } from "lucide-react" import { useGraph } from "@/services/api/hooks" import { KindBadge } from "@/components/KindBadge" import { detailPath } from "@/lib/labels" /** One end of a `requires` edge, resolved to a navigable deployment. */ interface Related { name: string kind: string | null // null → not a local node (e.g. a remote reference) bind: string | null } // Kinds with a local detail page. A `reference` (external service on another node) // has none, so it's shown inert rather than linking to a route that 404s. const NAVIGABLE = new Set(["service", "static", "tool", "job"]) /** * The dependency edges of a deployment, both directions, as links. "Depends on" = * outgoing `requires` edges (this → target); "Required by" = incoming (peer → this). * Only deployment-kind edges are navigable — system (package) requirements aren't * entities. Renders nothing when the node sits on no edges. Data: GET /graph. */ export function RelatedDeployments({ name }: { name: string }) { const { data: graph } = useGraph() if (!graph) return null const nodeKind = (n: string) => graph.nodes.find((x) => x.name === n)?.kind ?? null const edges = graph.edges.filter((e) => e.kind === "deployment") const dependsOn: Related[] = edges .filter((e) => e.src === name) .map((e) => ({ name: e.dst, kind: nodeKind(e.dst), bind: e.bind })) const requiredBy: Related[] = edges .filter((e) => e.dst === name) .map((e) => ({ name: e.src, kind: nodeKind(e.src), bind: e.bind })) if (dependsOn.length === 0 && requiredBy.length === 0) return null return (
How this deployment connects to others (declared requires).