Frontend addresses flows and dashboards by id: routes /flows/$flowId, /dashboards/$id and /view/$id, query keys, saves, lists, device pickers, search, brain and endpoint links and generated results dashboards go by id, while live values, issues, pauses and message names keep the key; tabs take the title from the document; creating uses POST and opens the issued id; the flow and dashboard panels show key and id with a copy button and a served HTTP or WebSocket node shows its hook URL under the flow id; specs create by POST and ids.spec.ts exercises issued ids

This commit is contained in:
2026-11-02 19:57:43 +01:00
parent fd637e0f1e
commit fa15522cb0
65 changed files with 1380 additions and 784 deletions
@@ -312,14 +312,15 @@ function Dashboards({
}) {
const { data } = useQuery(dashboardsQueryOptions())
const known = data?.data ?? []
// Dashboard ids: a device keeps showing a dashboard whatever it is called.
const assigned = device.dashboards ?? []
const byName = new Map(known.map((dashboard) => [dashboard.name, dashboard]))
const free = known.filter((dashboard) => !assigned.includes(dashboard.name))
const byId = new Map(known.map((dashboard) => [dashboard.id, dashboard]))
const free = known.filter((dashboard) => !assigned.includes(dashboard.id!))
const set = (dashboards: string[]) => onChange({ dashboards })
const move = (from: number, by: number) => {
const next = [...assigned]
const [name] = next.splice(from, 1)
next.splice(from + by, 0, name)
const [id] = next.splice(from, 1)
next.splice(from + by, 0, id)
set(next)
}
@@ -334,13 +335,13 @@ function Dashboards({
</p>
) : (
<ol className="grid gap-1" data-testid="device-dashboards">
{assigned.map((name, index) => {
const dashboard = byName.get(name)
const title = dashboard?.title || name
{assigned.map((id, index) => {
const dashboard = byId.get(id)
const title = dashboard?.title || dashboard?.name || id
// What this dashboard draws on the rail.
const Glyph = resolveIcon(dashboard?.icon ?? "")
return (
<li key={name} className="flex items-center gap-2 text-sm">
<li key={id} className="flex items-center gap-2 text-sm">
<span className="w-4 shrink-0 text-xs text-muted-foreground">
{index + 1}
</span>
@@ -352,8 +353,8 @@ function Dashboards({
</span>
{dashboard ? (
<Link
to="/dashboards/$name"
params={{ name }}
to="/dashboards/$id"
params={{ id }}
className="min-w-0 flex-1 truncate hover:underline"
>
{title}
@@ -361,7 +362,7 @@ function Dashboards({
) : (
// Deleted since: the device skips it.
<span className="min-w-0 flex-1 truncate text-muted-foreground line-through">
{name}
{id}
</span>
)}
{canEdit ? (
@@ -391,7 +392,7 @@ function Dashboards({
size="icon-touch"
className="text-muted-foreground"
aria-label={`Remove ${title}`}
onClick={() => set(assigned.filter((n) => n !== name))}
onClick={() => set(assigned.filter((n) => n !== id))}
>
<X />
</Button>
@@ -403,7 +404,7 @@ function Dashboards({
</ol>
)}
{canEdit && free.length > 0 ? (
<Select value="" onValueChange={(name) => set([...assigned, name])}>
<Select value="" onValueChange={(id) => set([...assigned, id])}>
<SelectTrigger
className="justify-self-start"
aria-label="Add a dashboard"
@@ -413,7 +414,7 @@ function Dashboards({
</SelectTrigger>
<SelectContent>
{free.map((dashboard) => (
<SelectItem key={dashboard.name} value={dashboard.name}>
<SelectItem key={dashboard.id} value={dashboard.id!}>
{dashboard.title || dashboard.name}
</SelectItem>
))}
@@ -778,8 +779,8 @@ function Capabilities({
{wired.map((binding) => (
<Link
key={`${binding.flow}.${binding.node}.${binding.message}`}
to="/flows/$flowName"
params={{ flowName: binding.flow }}
to="/flows/$flowId"
params={{ flowId: binding.flow_id! }}
search={{ node: binding.node }}
className="min-w-0 truncate font-mono hover:underline"
>
@@ -839,8 +840,8 @@ export function UseInFlow({
const { data } = useQuery(flowsQueryOptions())
const flows = data?.data ?? []
const place = useMutation({
mutationFn: async (flowName: string) => {
const { definition } = await FlowsService.readFlow({ flowId: flowName })
mutationFn: async (flowId: string) => {
const { definition } = await FlowsService.readFlow({ flowId })
const nodes = definition.nodes ?? []
const existing = deviceNodeOf(nodes, device.id)
const node = existing ?? {
@@ -854,7 +855,7 @@ export function UseInFlow({
const placed = port ? withPort(node, port) : node
if (placed !== existing) {
await FlowsService.saveFlow({
flowId: flowName,
flowId,
requestBody: {
...definition,
nodes: existing
@@ -863,12 +864,12 @@ export function UseInFlow({
},
})
}
return { flowName, node: placed.id }
return { flowId, node: placed.id }
},
onSuccess: ({ flowName, node }) =>
onSuccess: ({ flowId, node }) =>
navigate({
to: "/flows/$flowName",
params: { flowName },
to: "/flows/$flowId",
params: { flowId },
search: { node },
}),
onError: (error) => handleError.call(showErrorToast, error as ApiError),
@@ -876,7 +877,7 @@ export function UseInFlow({
if (flows.length === 0) return null
return (
<Select value="" onValueChange={(flowName) => place.mutate(flowName)}>
<Select value="" onValueChange={(flowId) => place.mutate(flowId)}>
<SelectTrigger
size={size}
className="shrink-0 justify-self-start"
@@ -892,7 +893,7 @@ export function UseInFlow({
</SelectTrigger>
<SelectContent>
{flows.map((flow) => (
<SelectItem key={flow.name} value={flow.name}>
<SelectItem key={flow.id} value={flow.id!}>
{flow.title || flow.name}
</SelectItem>
))}