Files
sam 32fbf8b69c refactor(gateway,ui): the page catalogue is generated from the router (#2050)
The assistant's catalogue was a 33-entry literal in Go, hand-maintained beside
the dashboard's routes: eight real pages were missing from it, so page_index
could not name them, and descriptions had drifted where both copies existed.

The routes move to ui/src/router/routes.ts, free of component imports, and
ui/scripts/pages.ts writes the catalogue from them. The nav and page_index now
read the same generated file, and task pages:check fails when it is stale, the
way the proto, sqlc and OpenAPI outputs do.
2026-11-21 03:53:10 +11:00

38 lines
1.1 KiB
Go

// Package pages is the dashboard's page catalogue: every route the operator can
// reach, with the label its navigation shows and the one-line description the
// assistant reads when it points someone at a page.
//
// pages.json is generated from the dashboard's own route table by
// `task pages:generate`, and `task check` rejects it when stale, so the
// catalogue cannot list a page the dashboard lost or miss one it gained.
package pages
import (
_ "embed"
"encoding/json"
"fmt"
)
//go:embed pages.json
var file []byte
// Page is one destination in the dashboard.
type Page struct {
// Path is the route, and what the browser's history entry becomes.
Path string `json:"path"`
// Label is the name the navigation shows.
Label string `json:"label"`
// Description says what the page is for, so the assistant can answer
// "where do I go for that?" without guessing.
Description string `json:"description"`
}
// All returns the catalogue in the dashboard's own order.
func All() ([]Page, error) {
var out []Page
if err := json.Unmarshal(file, &out); err != nil {
return nil, fmt.Errorf("dashboard pages: %w", err)
}
return out, nil
}