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
@@ -0,0 +1,43 @@
import { useQuery } from "@tanstack/react-query"
import { createFileRoute } from "@tanstack/react-router"
import { DashboardEditor } from "@/components/Dashboard/DashboardEditor"
import type { Dashboard } from "@/components/Dashboard/DashboardView"
import { dashboardQueryOptions } from "@/components/Dashboard/queries"
import { useFlowSocket } from "@/components/Flow/useFlowSocket"
type Search = { edit?: boolean }
export const Route = createFileRoute("/_canvas/dashboards/$id")({
component: DashboardRoute,
// Edit mode is a search param so viewing stays the default a panel opens
// into, and an editing session is a link someone can send.
validateSearch: (search: Record<string, unknown>): Search => ({
edit: search.edit === true || search.edit === "true" || undefined,
}),
})
function DashboardRoute() {
const { id } = Route.useParams()
const { edit } = Route.useSearch()
// Widgets read live values; the canvas shell has no socket of its own.
useFlowSocket()
// The working copy: an edit is the editor's until it is published, so what
// a wall panel is showing right now stays untouched by this session.
const { data: dashboard } = useQuery(dashboardQueryOptions(id, true))
if (!dashboard) return null
return (
<>
{/* From the document, since the id in the address can be opaque. */}
<title>{`${dashboard.title || dashboard.name} - Fluksio`}</title>
<DashboardEditor
// Leaving edit mode drops the draft, so the session starts clean.
key={`${id}:${edit ? "edit" : "view"}`}
dashboard={dashboard as Dashboard}
edit={Boolean(edit)}
/>
</>
)
}