console: the operator shell on Rastrillo's console layout; the phone index; Storage requests moved in
op_top and op_bottom port Rastrillo v0.29.0's console layout by hand in its DOM order: the bar with the CARLOS operator brand and the account menu (Customer console, Sign out through the existing sign-out form), the back strip, the rail of eight operator pages (Storage requests only for a store operator), and the rst-page main, loading only the console's /static/ files. The partials op_page_header, op_status, op_stat, op_empty, op_meter, op_seg_tabs, op_dropdown, op_list_bar and op_pagination port their Rastrillo markup with the approved copy. GET /fleet/index is the phone's list of pages and reads nothing remote. /fleet/store renders in the shell with its sentences unchanged, in cards, with Rastrillo's buttons and input; its gates are unchanged. ops.css gains card padding, the action row, list column templates, co-note and the table wrapper. The customer layout is untouched. Copy OPS-1 to OPS-19 and OPS-138 are built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 files changed,
+879
−13
approved_operator_pages_copy_test.go+7 −2internal/console/claim_invariant_fixtures_test.go+1 −0internal/console/claim_invariant_probes_read_test.go+2 −1internal/console/opparts.go+149 −0internal/console/opshell.go+95 −0internal/console/opshell_test.go+409 −0internal/console/server.go+13 −0internal/console/static/ops.css+35 −0internal/console/storepage.go+3 −1internal/console/templates/opparts.html+81 −0internal/console/templates/ops_index.html+6 −0internal/console/templates/opshell.html+65 −0internal/console/templates/store_approvals.html+12 −9internal/console/testdata/claim-routes.txt+1 −0
CI failed — run details
diff --git a/approved_operator_pages_copy_test.go b/approved_operator_pages_copy_test.go| index a986f6a0d..516699bc6 100644 |
| --- a/approved_operator_pages_copy_test.go |
| +++ b/approved_operator_pages_copy_test.go |
| @@ -42,8 +42,13 @@ var operatorPagesCopyIDs = func() []string { |
| // operatorPagesCopyBuilt is every row whose text the code or templates carry. |
| // The task that writes a row's text adds its entry here in the same commit. |
| // An entry is "OPS-n", checked in the row's file, or "OPS-n@<path>", checked |
| -// in that file (a path under internal/console/). Nothing is built yet. |
| -var operatorPagesCopyBuilt = []string{} |
| +// in that file (a path under internal/console/). |
| +var operatorPagesCopyBuilt = []string{ |
| + // Task 3: the shell, its partials, the index, Storage requests. |
| + "OPS-1", "OPS-2", "OPS-3", "OPS-4", "OPS-5", "OPS-6", "OPS-7", |
| + "OPS-8", "OPS-9", "OPS-10", "OPS-11", "OPS-12", "OPS-13", "OPS-14", "OPS-15", |
| + "OPS-16", "OPS-17", "OPS-18", "OPS-19", "OPS-138", |
| +} |
| // operatorPagesBuiltRows is entryBuiltRows for operatorPagesCopyBuilt. |
| func operatorPagesBuiltRows(rows []copyRow, entries []string) ([]copyRow, []string) { |
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go| index fbd2d57a1..3925fee44 100644 |
| --- a/internal/console/claim_invariant_fixtures_test.go |
| +++ b/internal/console/claim_invariant_fixtures_test.go |
| @@ -891,6 +891,7 @@ var claimFixtures = map[string]claimFixture{ |
| "route GET /fleet": claimRead("operator fleet view"), |
| "route GET /fleet/economics": claimRead("operator economics view"), |
| "route GET /fleet/economics/accounts": claimRead("operator per-account economics table"), |
| + "route GET /fleet/index": claimRead("operator section index; reads nothing remote"), |
| "route GET /fleet/metrics": claimRead("operator box metrics"), |
| "route GET /fleet/store": claimRead("operator entitlement queue page"), |
| "route GET /healthz": claimRead("answers ok and the build"), |
diff --git a/internal/console/claim_invariant_probes_read_test.go b/internal/console/claim_invariant_probes_read_test.go| index 8b1271423..64f463f93 100644 |
| --- a/internal/console/claim_invariant_probes_read_test.go |
| +++ b/internal/console/claim_invariant_probes_read_test.go |
| @@ -171,8 +171,9 @@ var claimReadProbes = map[string]claimProbe{ |
| "route GET /fleet": claimPageRead(nil, "/fleet", "<h1>Fleet status</h1>"), |
| "route GET /fleet/economics": claimPageRead(nil, "/fleet/economics", "<h1>Fleet economics</h1>"), |
| "route GET /fleet/economics/accounts": claimPageRead(nil, "/fleet/economics/accounts", "<h1>Fleet economics: accounts</h1>"), |
| + "route GET /fleet/index": claimPageRead(nil, "/fleet/index", "rst-shell-console=\"index\""), |
| "route GET /fleet/metrics": claimPageRead(nil, "/fleet/metrics", "<h1>Fleet metrics</h1>"), |
| - "route GET /fleet/store": claimPageRead(claimWorldApply, "/fleet/store", "<h1>Object storage applications</h1>"), |
| + "route GET /fleet/store": claimPageRead(claimWorldApply, "/fleet/store", "<h1>Storage requests</h1>"), |
| "route GET /healthz": claimPageRead(nil, "/healthz", "ok"), |
| "route GET /static/{hash}/{file...}": claimPageRead(nil, assetURL("rastrillo/tokens.css"), "--rst-"), |
diff --git a/internal/console/opparts.go b/internal/console/opparts.go| new file mode 100644 |
| index 000000000..d0161dc6a |
| --- /dev/null |
| +++ b/internal/console/opparts.go |
| @@ -0,0 +1,149 @@ |
| +package console |
| + |
| +import ( |
| + "net/url" |
| + "strconv" |
| +) |
| + |
| +// The data of the operator pages' partials (templates/opparts.html), each a |
| +// port of one Rastrillo v0.29.0 ui/partials/<name>.html. Rastrillo's partials |
| +// take a dict and format numbers through its localizer; the console's take |
| +// these structs and preformatted strings (opNumber). |
| + |
| +// opHeader is op_page_header's data: the page's <h1> and one quiet line. |
| +type opHeader struct{ Title, Sub string } |
| + |
| +// opPill is op_status's data. Tone is "neutral" (the default), "positive", |
| +// "warning" or "negative"; the label is always the visible word. |
| +type opPill struct{ Label, Tone string } |
| + |
| +// opStat is op_stat's data: one reading in an rst-stats band. Value is |
| +// preformatted; Delta carries its own sign; Tone colours the delta and is |
| +// the caller's call, never derived from the sign. |
| +type opStat struct { |
| + Label, Value, Delta, Tone, Note string |
| + Lead bool |
| +} |
| + |
| +// opEmpty is op_empty's data: an optional <h2> and one sentence. The |
| +// operator pages' empty states have no call to action. |
| +type opEmpty struct{ Title, Body string } |
| + |
| +// opMeter is op_meter's data: a fill clamped to 0..100 beside its text. |
| +type opMeter struct { |
| + Percent int |
| + Text string |
| +} |
| + |
| +// opTab is one link of a tab strip or a dropdown. |
| +type opTab struct { |
| + Label, Href string |
| + Current bool |
| +} |
| + |
| +// opTabs is op_seg_tabs's data: the nav's accessible name and its links. |
| +type opTabs struct { |
| + Label string |
| + Items []opTab |
| +} |
| + |
| +// opDropdown is op_dropdown's data: the summary's text, an accessible name |
| +// when that text alone is not one, and the links. |
| +type opDropdown struct { |
| + Label, Aria string |
| + Items []opTab |
| +} |
| + |
| +// opListBar is op_list_bar's data: a GET search form (Action, the current |
| +// Query, the field's Placeholder, the Hidden pairs carried across) and an |
| +// optional filter dropdown. ClearHref, when set, is where the search's clear |
| +// link goes; otherwise Clear computes it. |
| +type opListBar struct { |
| + Action, Query, Placeholder, ClearHref string |
| + Hidden [][2]string |
| + Filter *opDropdown |
| +} |
| + |
| +// Clear is where the search's clear link goes: ClearHref, or Action with |
| +// every Hidden pair but q, as Rastrillo's searchClear computes it. |
| +func (b opListBar) Clear() string { |
| + if b.ClearHref != "" { |
| + return b.ClearHref |
| + } |
| + q := url.Values{} |
| + for _, h := range b.Hidden { |
| + if h[0] != "q" { |
| + q.Add(h[0], h[1]) |
| + } |
| + } |
| + if enc := q.Encode(); enc != "" { |
| + return b.Action + "?" + enc |
| + } |
| + return b.Action |
| +} |
| + |
| +// opPageItem is one control of a pager: a page link, the current page, a |
| +// disabled step, or the gap between runs of pages. |
| +type opPageItem struct { |
| + Label, Href string |
| + Current, Disabled, Gap bool |
| +} |
| + |
| +// opPager is op_pagination's data. |
| +type opPager struct { |
| + Label string |
| + Items []opPageItem |
| +} |
| + |
| +// opPages is a pager's items for page of pages: the first and last pages, |
| +// the current page and two either side, and a gap between runs. Each link |
| +// is path with q and page=<n>; page 1 carries no page parameter. |
| +func opPages(path string, q url.Values, page, pages int) []opPageItem { |
| + if pages < 1 { |
| + return nil |
| + } |
| + page = min(max(page, 1), pages) |
| + var out []opPageItem |
| + last := 0 |
| + for n := 1; n <= pages; n++ { |
| + if n != 1 && n != pages && (n < page-2 || n > page+2) { |
| + continue |
| + } |
| + if last != 0 && n > last+1 { |
| + out = append(out, opPageItem{Gap: true}) |
| + } |
| + out = append(out, opPageItem{Label: opNumber(n), Href: opPageHref(path, q, n), Current: n == page}) |
| + last = n |
| + } |
| + return out |
| +} |
| + |
| +func opPageHref(path string, q url.Values, n int) string { |
| + v := url.Values{} |
| + for k, vs := range q { |
| + if k != "page" { |
| + v[k] = append([]string(nil), vs...) |
| + } |
| + } |
| + if n > 1 { |
| + v.Set("page", strconv.Itoa(n)) |
| + } |
| + if enc := v.Encode(); enc != "" { |
| + return path + "?" + enc |
| + } |
| + return path |
| +} |
| + |
| +// opNumber is n with commas between thousands: 1,214. It is the template |
| +// func opnum, standing in for Rastrillo's locale-aware number. |
| +func opNumber(n int) string { |
| + s := strconv.Itoa(n) |
| + sign := "" |
| + if n < 0 { |
| + sign, s = "-", s[1:] |
| + } |
| + for i := len(s) - 3; i > 0; i -= 3 { |
| + s = s[:i] + "," + s[i:] |
| + } |
| + return sign + s |
| +} |
diff --git a/internal/console/opshell.go b/internal/console/opshell.go| new file mode 100644 |
| index 000000000..5e27fe3aa |
| --- /dev/null |
| +++ b/internal/console/opshell.go |
| @@ -0,0 +1,95 @@ |
| +package console |
| + |
| +import "net/http" |
| + |
| +// The operator pages' shell (spec 2026-10-25, Part 3): Rastrillo's console |
| +// layout, a bar across the top and a rail down the side, ported by hand into |
| +// templates/opshell.html as op_top and op_bottom. The customer console keeps |
| +// its own layout (layout.html); nothing here reaches it. |
| +// |
| +// Rastrillo's layout takes a page's view, rail item and way back as blocks a |
| +// page redefines. One shared template set cannot redefine a block per page, |
| +// so they are opShell's fields instead. |
| + |
| +// opShell is what the shell needs to know about the page it frames. Rail is |
| +// the current rail item's key ("" on the index); View is "page" or "index"; |
| +// Up is the back control's target on a phone. |
| +type opShell struct { |
| + Rail, View, Up string |
| + StoreOperator bool |
| +} |
| + |
| +// opRailItem is one link in the rail. StoreOnly items show only to a store |
| +// operator (Config.StoreOperators), since their page refuses everyone else. |
| +type opRailItem struct { |
| + Key, Href, Label string |
| + StoreOnly bool |
| +} |
| + |
| +// opRail is the rail, top to bottom. Each label is also its page's <h1>. |
| +var opRail = []opRailItem{ |
| + {Key: "dashboard", Href: "/fleet", Label: "Dashboard"}, |
| + {Key: "people", Href: "/fleet/people", Label: "People and accounts"}, |
| + {Key: "activity", Href: "/fleet/activity", Label: "Activity"}, |
| + {Key: "boxes", Href: "/fleet/boxes", Label: "Boxes"}, |
| + {Key: "metrics", Href: "/fleet/metrics", Label: "Metrics"}, |
| + {Key: "store", Href: "/fleet/store", Label: "Storage requests", StoreOnly: true}, |
| + {Key: "economics", Href: "/fleet/economics", Label: "Economics"}, |
| + {Key: "architecture", Href: "/fleet/architecture", Label: "Architecture"}, |
| +} |
| + |
| +// opIndexTitle is the index's title, and the rail's accessible name. |
| +const opIndexTitle = "Operator pages" |
| + |
| +// opRailFor is the rail op's viewer sees: StoreOnly items only for a store |
| +// operator. It is the template func opRail. |
| +func opRailFor(op *opShell) []opRailItem { |
| + out := make([]opRailItem, 0, len(opRail)) |
| + for _, it := range opRail { |
| + if it.StoreOnly && (op == nil || !op.StoreOperator) { |
| + continue |
| + } |
| + out = append(out, it) |
| + } |
| + return out |
| +} |
| + |
| +// opRailLabel is the rail label of key, or opIndexTitle for "" (the index). |
| +func opRailLabel(key string) string { |
| + for _, it := range opRail { |
| + if it.Key == key { |
| + return it.Label |
| + } |
| + } |
| + return opIndexTitle |
| +} |
| + |
| +// opPage is the page an operator page renders with: titled by its rail |
| +// item, framed by the shell. The caller has already passed operatorOnly. |
| +func (s *Server) opPage(addr, raw, rail string) page { |
| + return page{ |
| + Title: opRailLabel(rail), |
| + Address: addr, |
| + CSRF: raw, |
| + Op: &opShell{ |
| + Rail: rail, |
| + View: "page", |
| + Up: "/fleet/index#nav-" + rail, |
| + StoreOperator: s.storeOperator(addr), |
| + }, |
| + } |
| +} |
| + |
| +// handleOpIndex is the phone's list of operator pages. On a phone the rail |
| +// is the whole page; at width the rail sits beside a line asking for a |
| +// choice. It reads only the session and the operator bit. |
| +func (s *Server) handleOpIndex(w http.ResponseWriter, r *http.Request) { |
| + addr, raw, ok := s.operatorOnly(w, r) |
| + if !ok { |
| + return |
| + } |
| + p := s.opPage(addr, raw, "") |
| + p.Op.View = "index" |
| + p.Op.Up = "/fleet" |
| + s.render(w, http.StatusOK, "ops_index", p) |
| +} |
diff --git a/internal/console/opshell_test.go b/internal/console/opshell_test.go| new file mode 100644 |
| index 000000000..a5cd17dad |
| --- /dev/null |
| +++ b/internal/console/opshell_test.go |
| @@ -0,0 +1,409 @@ |
| +package console |
| + |
| +import ( |
| + "net/http" |
| + "net/url" |
| + "regexp" |
| + "slices" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/objstore" |
| +) |
| + |
| +// signInOperator signs Paul in and makes him a deployment operator and a |
| +// store operator, as storepage_test.go does. |
| +func signInOperator(t *testing.T, fx *consoleFixture) *http.Client { |
| + t.Helper() |
| + c := signInPaul(t, fx) |
| + if err := fx.st.SetOperator("paul@keymail.dev", true); err != nil { |
| + t.Fatal(err) |
| + } |
| + fx.srv.cfg.StoreOperators = []string{"paul@keymail.dev"} |
| + return c |
| +} |
| + |
| +// operatorScreens is every operator screen the walk can request: each |
| +// registered GET under /fleet with no path parameter, minus the screens |
| +// perf-budgets.txt records as skip (the POST-only doors). |
| +func operatorScreens(fx *consoleFixture) []string { |
| + recs := perfReadBudgets() |
| + var out []string |
| + for _, screen := range perfInventory(fx.srv.claimEntries.snapshot()) { |
| + path, params := perfScreenPath(screen) |
| + if params || !(path == "/fleet" || strings.HasPrefix(path, "/fleet/")) { |
| + continue |
| + } |
| + if rec, ok := recs[screen]; ok && rec.Kind == "skip" { |
| + continue |
| + } |
| + out = append(out, path) |
| + } |
| + return out |
| +} |
| + |
| +// opShellPending is the operator screens not yet moved into the shell. |
| +// Later tasks delete entries; none adds one. |
| +var opShellPending = map[string]bool{ |
| + "/fleet": true, |
| + "/fleet/metrics": true, |
| + "/fleet/economics": true, |
| + "/fleet/economics/accounts": true, |
| + "/fleet/architecture": true, |
| +} |
| + |
| +// opRailKeyFor is the rail item a page sits under: the longest rail href |
| +// that prefixes path. The index sits under none. |
| +func opRailKeyFor(path string) string { |
| + if path == "/fleet/index" { |
| + return "" |
| + } |
| + key, best := "", -1 |
| + for _, it := range opRail { |
| + if (path == it.Href || strings.HasPrefix(path, it.Href+"/")) && len(it.Href) > best { |
| + key, best = it.Key, len(it.Href) |
| + } |
| + } |
| + return key |
| +} |
| + |
| +var ( |
| + opInlineStyle = regexp.MustCompile(`(?i)\sstyle\s*=`) |
| + opNavBlock = regexp.MustCompile(`(?s)<nav rst-shell-nav[^>]*>(.*?)</nav>`) |
| + opNavLink = regexp.MustCompile(`<a id="nav-([a-z]+)" href="([^"]+)"( aria-current="page")?>`) |
| + opLinkTag = regexp.MustCompile(`<link[^>]*>`) |
| + opScriptTag = regexp.MustCompile(`<script[^>]*>`) |
| + opURLAttr = regexp.MustCompile(`(?:href|src)="([^"]*)"`) |
| +) |
| + |
| +// opNavLinks is the rail's links on a page: key, href and whether the link |
| +// is the current one. |
| +type opNavLinkSeen struct { |
| + Key, Href string |
| + Current bool |
| +} |
| + |
| +func opNavLinks(t *testing.T, body string) []opNavLinkSeen { |
| + t.Helper() |
| + m := opNavBlock.FindStringSubmatch(body) |
| + if m == nil { |
| + t.Fatalf("no <nav rst-shell-nav> in:\n%s", body) |
| + } |
| + var out []opNavLinkSeen |
| + for _, l := range opNavLink.FindAllStringSubmatch(m[1], -1) { |
| + out = append(out, opNavLinkSeen{Key: l[1], Href: l[2], Current: l[3] != ""}) |
| + } |
| + if n := strings.Count(m[1], "<a "); n != len(out) { |
| + t.Fatalf("the rail has %d links, %d of the expected shape:\n%s", n, len(out), m[1]) |
| + } |
| + return out |
| +} |
| + |
| +// assertOpShell holds for every operator page in the shell, seen by a store |
| +// operator. |
| +func assertOpShell(t *testing.T, path, body string) { |
| + t.Helper() |
| + view := "page" |
| + if path == "/fleet/index" { |
| + view = "index" |
| + } |
| + if !strings.Contains(body, `<div rst-shell-console="`+view+`">`) { |
| + t.Errorf("%s: no <div rst-shell-console=%q>", path, view) |
| + } |
| + if n := strings.Count(body, "rst-shell-console"); n != 1 { |
| + t.Errorf("%s: rst-shell-console appears %d times, want 1", path, n) |
| + } |
| + if n := strings.Count(body, "<h1"); n != 1 { |
| + t.Errorf("%s: %d <h1 elements, want 1", path, n) |
| + } |
| + links := opNavLinks(t, body) |
| + var hrefs, want []string |
| + current := 0 |
| + for _, l := range links { |
| + hrefs = append(hrefs, l.Href) |
| + if l.Current { |
| + current++ |
| + if l.Key != opRailKeyFor(path) { |
| + t.Errorf("%s: the current rail link is %q, want %q", path, l.Key, opRailKeyFor(path)) |
| + } |
| + } |
| + } |
| + for _, it := range opRail { |
| + want = append(want, it.Href) |
| + } |
| + if !slices.Equal(hrefs, want) { |
| + t.Errorf("%s: rail hrefs %q, want %q", path, hrefs, want) |
| + } |
| + if wantCurrent := map[bool]int{true: 0, false: 1}[path == "/fleet/index"]; current != wantCurrent { |
| + t.Errorf("%s: %d rail links are current, want %d", path, current, wantCurrent) |
| + } |
| + if opInlineStyle.MatchString(body) || strings.Contains(body, "<style") { |
| + t.Errorf("%s: carries an inline style", path) |
| + } |
| + if strings.Contains(body, "data-poll") { |
| + t.Errorf("%s: carries data-poll", path) |
| + } |
| + for _, tag := range append(opLinkTag.FindAllString(body, -1), opScriptTag.FindAllString(body, -1)...) { |
| + u := opURLAttr.FindStringSubmatch(tag) |
| + if u == nil || !strings.HasPrefix(u[1], "/static/") { |
| + t.Errorf("%s: %s does not load from /static/", path, tag) |
| + } |
| + } |
| + for _, sheet := range []string{"rastrillo/tokens.css", "rastrillo/day.css", "rastrillo/shell.css"} { |
| + if !strings.Contains(body, `<link rel="stylesheet" href="`+assetURL(sheet)+`">`) { |
| + t.Errorf("%s: does not link %s", path, sheet) |
| + } |
| + } |
| +} |
| + |
| +func TestEveryOperatorPageRendersInTheShell(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + putEntitlement(t, fx, fx.sqid, &objstore.Entitlement{Applied: &objstore.Applied{By: "paul@keymail.dev", At: time.Now(), Note: "a note"}}) |
| + seen := 0 |
| + for _, path := range operatorScreens(fx) { |
| + if opShellPending[path] { |
| + continue |
| + } |
| + seen++ |
| + status, _, body := get(t, c, fx.ts.URL+path) |
| + if status != http.StatusOK { |
| + t.Errorf("%s = %d, want 200", path, status) |
| + continue |
| + } |
| + assertOpShell(t, path, body) |
| + } |
| + if seen < 2 { |
| + t.Fatalf("checked %d operator pages; /fleet/index and /fleet/store at least", seen) |
| + } |
| +} |
| + |
| +func TestOperatorShellPendingShrinks(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + screens := operatorScreens(fx) |
| + for path := range opShellPending { |
| + if !slices.Contains(screens, path) { |
| + t.Errorf("opShellPending names %s, which is not an operator screen: delete it", path) |
| + } |
| + } |
| +} |
| + |
| +func TestRailHidesStorageFromOtherOperators(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + fx.srv.cfg.StoreOperators = nil |
| + status, _, body := get(t, c, fx.ts.URL+"/fleet/index") |
| + if status != http.StatusOK { |
| + t.Fatalf("/fleet/index = %d", status) |
| + } |
| + links := opNavLinks(t, body) |
| + if len(links) != 7 { |
| + t.Fatalf("the rail has %d links, want 7: %+v", len(links), links) |
| + } |
| + if strings.Contains(body, `href="/fleet/store"`) { |
| + t.Fatal("an operator not on StoreOperators is shown /fleet/store") |
| + } |
| +} |
| + |
| +func TestOperatorGateUnchangedOnEveryOperatorPage(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + out := newBrowser(t) |
| + ghostStatus, _, ghost := get(t, out, fx.ts.URL+"/this-route-does-not-exist") |
| + if ghostStatus != http.StatusNotFound { |
| + t.Fatalf("sanity: missing route = %d", ghostStatus) |
| + } |
| + notOperator := signInPaul(t, fx) |
| + for _, path := range operatorScreens(fx) { |
| + for _, q := range []string{"", "?q=x&page=2"} { |
| + for who, c := range map[string]*http.Client{"signed out": out, "not an operator": notOperator} { |
| + if st, _, body := get(t, c, fx.ts.URL+path+q); st != ghostStatus || body != ghost { |
| + t.Errorf("%s%s %s = %d %q, want the missing-route 404", path, q, who, st, body) |
| + } |
| + } |
| + } |
| + } |
| +} |
| + |
| +func TestOperatorShellAccountMenu(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + _, _, body := get(t, c, fx.ts.URL+"/fleet/index") |
| + csrf := sessionToken(t, fx, c) |
| + for _, want := range []string{ |
| + `<a href="/">Customer console</a>`, |
| + `<form method="post" action="/auth/signout">`, |
| + `<input type="hidden" name="csrf" value="` + csrf + `">`, |
| + `<button type="submit">Sign out</button>`, |
| + } { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("/fleet/index lacks %s", want) |
| + } |
| + } |
| + form := body[strings.Index(body, `action="/auth/signout"`):] |
| + form = form[:strings.Index(form, "</form>")] |
| + if !strings.Contains(form, csrf) || !strings.Contains(form, "Sign out") { |
| + t.Errorf("the sign-out form does not carry the session's CSRF and its button:\n%s", form) |
| + } |
| + _, _, body = get(t, c, fx.ts.URL+"/fleet/store") |
| + if !strings.Contains(body, `<a href="/fleet/index#nav-store" rel="up">Back</a>`) { |
| + t.Error("/fleet/store's back strip does not link /fleet/index#nav-store") |
| + } |
| + if !strings.Contains(body, `<a id="nav-store" href="/fleet/store" aria-current="page">Storage requests</a>`) { |
| + t.Error("/fleet/store's rail link is not nav-store, current") |
| + } |
| +} |
| + |
| +func TestCustomerPagesKeepTheirLayout(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + for _, p := range []string{fx.path("/"), fx.path("/apps/kass")} { |
| + status, _, body := get(t, c, fx.ts.URL+p) |
| + if status != http.StatusOK { |
| + t.Fatalf("%s = %d", p, status) |
| + } |
| + for _, want := range []string{"<header>", ":root {"} { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("%s lacks %q", p, want) |
| + } |
| + } |
| + for _, not := range []string{"rst-shell-console", "/static/"} { |
| + if strings.Contains(body, not) { |
| + t.Errorf("%s carries %q", p, not) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// Storage requests in the shell: the approved heading and subhead, the |
| +// queue's own sentences, Rastrillo's buttons and input, and no "Fleet |
| +// status" link (the rail replaces it). |
| +func TestStoreRequestsPageInTheShell(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + _, _, body := get(t, c, fx.ts.URL+"/fleet/store") |
| + for _, want := range []string{ |
| + "<title>Storage requests · CARLOS operator</title>", |
| + "<h1>Storage requests</h1>", |
| + "<p rst-page-header-sub>Object storage requests waiting for a decision.</p>", |
| + "<div rst-empty>", |
| + "No pending storage applications.", |
| + } { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("empty queue lacks %q", want) |
| + } |
| + } |
| + if strings.Contains(body, "Fleet status") { |
| + t.Error("the page still links Fleet status") |
| + } |
| + putEntitlement(t, fx, fx.sqid, &objstore.Entitlement{Applied: &objstore.Applied{By: "paul@keymail.dev", At: time.Now(), Note: "a note"}}) |
| + _, _, body = get(t, c, fx.ts.URL+"/fleet/store") |
| + for _, want := range []string{ |
| + "1 pending applications. Oldest first.", |
| + "<h2>Account " + fx.sqid + "</h2>", |
| + `<button rst-btn="primary" type="submit">Approve</button>`, |
| + `<button rst-btn="danger" type="submit">Decline</button>`, |
| + `<input rst-input type="text" name="reason" required>`, |
| + } { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("queue lacks %q", want) |
| + } |
| + } |
| + if strings.Contains(body, "rst-empty") { |
| + t.Error("a queue with an application shows the empty state") |
| + } |
| +} |
| + |
| +// opPages's window and opNumber's commas (not acceptance: pure functions). |
| +func TestOpPagesWindow(t *testing.T) { |
| + items := opPages("/fleet/people", url.Values{"q": {"a"}}, 6, 12) |
| + var labels []string |
| + for _, it := range items { |
| + switch { |
| + case it.Gap: |
| + labels = append(labels, "gap") |
| + default: |
| + labels = append(labels, it.Label) |
| + } |
| + if it.Current != (it.Label == "6") { |
| + t.Errorf("item %q current=%v", it.Label, it.Current) |
| + } |
| + } |
| + if want := []string{"1", "gap", "4", "5", "6", "7", "8", "gap", "12"}; !slices.Equal(labels, want) { |
| + t.Fatalf("labels %q, want %q", labels, want) |
| + } |
| + if items[2].Href != "/fleet/people?page=4&q=a" { |
| + t.Errorf("page 4 href %q", items[2].Href) |
| + } |
| + if items[0].Href != "/fleet/people?q=a" { |
| + t.Errorf("page 1 href %q, want no page", items[0].Href) |
| + } |
| + if got := opPages("/fleet/people", nil, 1, 3); len(got) != 3 || got[0].Href != "/fleet/people" || !got[0].Current { |
| + t.Errorf("three pages from the first: %+v", got) |
| + } |
| + if got := opNumber(1214); got != "1,214" { |
| + t.Errorf("opNumber(1214) = %q", got) |
| + } |
| + if got := opNumber(7); got != "7" { |
| + t.Errorf("opNumber(7) = %q", got) |
| + } |
| + if got := opNumber(1234567); got != "1,234,567" { |
| + t.Errorf("opNumber(1234567) = %q", got) |
| + } |
| + if got := opNumber(-1214); got != "-1,214" { |
| + t.Errorf("opNumber(-1214) = %q", got) |
| + } |
| +} |
| + |
| +// The partials no page uses yet render their Rastrillo markup from their |
| +// data (not acceptance: each partial executed alone). |
| +func TestOpPartialsRender(t *testing.T) { |
| + render := func(name string, data any) string { |
| + t.Helper() |
| + var b strings.Builder |
| + if err := templates.ExecuteTemplate(&b, name, data); err != nil { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + return b.String() |
| + } |
| + cases := []struct { |
| + name string |
| + data any |
| + want []string |
| + }{ |
| + {"op_page_header", opHeader{Title: "T", Sub: "S"}, []string{"<header rst-page-header>", "<h1>T</h1>", "<p rst-page-header-sub>S</p>"}}, |
| + {"op_status", opPill{Label: "up"}, []string{`<span rst-status rst-tone="neutral">up</span>`}}, |
| + {"op_status", opPill{Label: "down", Tone: "negative"}, []string{`rst-tone="negative">down<`}}, |
| + {"op_stat", opStat{Label: "L", Value: "1,214", Delta: "+5", Tone: "positive", Note: "n", Lead: true}, |
| + []string{`<div rst-stat="lead">`, "<span rst-stat-num>1,214</span>", `<span rst-stat-delta rst-tone="positive">+5</span>`, "<span rst-stat-note>n</span>"}}, |
| + {"op_empty", opEmpty{Title: "H", Body: "B"}, []string{"<h2 rst-empty-title>H</h2>", "<p rst-empty-body>B</p>"}}, |
| + {"op_meter", opMeter{Percent: 140, Text: "7 / 5"}, []string{`value="100"`, "<span rst-meter-num>7 / 5</span>"}}, |
| + {"op_meter", opMeter{Percent: -3, Text: "x"}, []string{`value="0"`}}, |
| + {"op_seg_tabs", opTabs{Label: "Views", Items: []opTab{{Label: "A", Href: "/a", Current: true}, {Label: "B", Href: "/b"}}}, |
| + []string{`<nav rst-seg-tabs aria-label="Views">`, `<a href="/a" aria-current="page">A</a>`, `<a href="/b">B</a>`}}, |
| + {"op_dropdown", opDropdown{Label: "All", Aria: "Filter: All", Items: []opTab{{Label: "All", Href: "/x", Current: true}}}, |
| + []string{`<details rst-dropdown name="rst-menus">`, `aria-label="Filter: All"`, `<a href="/x" aria-current="true">All`}}, |
| + {"op_list_bar", opListBar{Action: "/fleet/people", Query: "a&b", Placeholder: "Find", Hidden: [][2]string{{"view", "accounts"}, {"q", "old"}}, |
| + Filter: &opDropdown{Label: "All", Items: []opTab{{Label: "All", Href: "/fleet/people"}}}}, |
| + []string{"<div rst-lbar>", `<search><form rst-search method="get" action="/fleet/people">`, `value="a&b"`, `aria-label="Find"`, |
| + `<a rst-search-clear href="/fleet/people?view=accounts" aria-label="Clear the search">`, |
| + `<input type="hidden" name="view" value="accounts">`, `<button class="rst-sr-only" type="submit">Search</button>`, "<details rst-dropdown"}}, |
| + {"op_pagination", opPager{Items: opPages("/fleet/people", nil, 6, 12)}, |
| + []string{`<nav rst-pagination aria-label="Pages">`, `<a href="/fleet/people">1</a>`, `<span rst-pagination-gap aria-hidden="true">…</span>`, |
| + `<span aria-current="page">6</span>`, `<a href="/fleet/people?page=12">12</a>`}}, |
| + } |
| + for _, c := range cases { |
| + got := render(c.name, c.data) |
| + for _, w := range c.want { |
| + if !strings.Contains(got, w) { |
| + t.Errorf("%s lacks %s in:\n%s", c.name, w, got) |
| + } |
| + } |
| + if opInlineStyle.MatchString(got) { |
| + t.Errorf("%s carries an inline style", c.name) |
| + } |
| + } |
| + if got := render("op_list_bar", opListBar{Action: "/p"}); strings.Contains(got, "rst-search-clear") || !strings.Contains(got, `aria-label="Search"`) { |
| + t.Errorf("a list bar with no query: %s", got) |
| + } |
| +} |
diff --git a/internal/console/server.go b/internal/console/server.go| index a8c8c5d10..b6c64dc9c 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -205,6 +205,14 @@ var templates = template.Must(template.New("").Funcs(template.FuncMap{ |
| "icon": icon, |
| // asset is the hashed URL of an embedded static file (assets.go). |
| "asset": assetURL, |
| + // The operator shell and its partials (opshell.go, opparts.go): opRail |
| + // is the rail a page's viewer sees, opnum a number with thousands |
| + // commas, and opHeader and opEmpty build the partials' data in a |
| + // template. |
| + "opRail": opRailFor, |
| + "opnum": opNumber, |
| + "opHeader": func(title, sub string) opHeader { return opHeader{Title: title, Sub: sub} }, |
| + "opEmpty": func(title, body string) opEmpty { return opEmpty{Title: title, Body: body} }, |
| // join renders fleetPageBox.Tags back into the tag form's editable |
| // text input, comma-separated — the exact grammar SetFleetBoxTags |
| // expects back, so an owner opening the form sees the same string they'd |
| @@ -1612,6 +1620,7 @@ func NewServer(cfg Config, st *Store) (*Server, error) { |
| s.registerRoute("GET /auth/confirm", s.handleConfirm) |
| s.registerRoute("POST /auth/signout", s.handleSignout) |
| s.registerRoute("GET /fleet", s.handleFleet) |
| + s.registerRoute("GET /fleet/index", s.handleOpIndex) |
| s.registerRoute("GET /fleet/store", s.handleStoreApprovalsPage) |
| s.registerRoute("POST /fleet/store/{account}/{decision}", s.handleStoreDecisionPage) |
| s.registerRoute("POST /a/{sqid}/store/apply", s.handleStoreApplyPage) |
| @@ -2044,6 +2053,10 @@ type page struct { |
| InstanceListURL string |
| DeploymentTargets []deploymentTarget |
| + // Op frames an operator page in the operator shell (opshell.go); nil |
| + // on every customer page. |
| + Op *opShell |
| + |
| Title string |
| Address string // signed-in address, "" when signed out |
| CSRF string // the session token, double-submitted on the signout POST |
diff --git a/internal/console/static/ops.css b/internal/console/static/ops.css| index 8c1899124..d40785ccd 100644 |
| --- a/internal/console/static/ops.css |
| +++ b/internal/console/static/ops.css |
| @@ -3,3 +3,38 @@ |
| * prefix. Nothing else lives in this file: the design system is the |
| * Rastrillo files in rastrillo/, which are never edited here. |
| */ |
| + |
| +/* A card that holds prose or a form rather than list rows: Rastrillo's |
| + card has no padding of its own, since its rows bring theirs. Stacked |
| + cards, and an empty state under one, keep a gap between them. */ |
| +[co-pad] { margin-block-start: var(--rst-sp-4); padding: var(--rst-sp-4) var(--rst-sp-5); } |
| +[co-pad] > * { margin-block: 0; } |
| +[co-pad] > * + * { margin-block-start: var(--rst-sp-3); } |
| +[co-pad] > h2 { font-size: var(--rst-fs-lg); } |
| +[co-pad] + * { margin-block-start: var(--rst-sp-4); } |
| + |
| +/* A row of forms that act on one thing: Approve beside Decline and its |
| + reason. Each form keeps its own fields together. */ |
| +[co-actions] { align-items: flex-end; display: flex; flex-wrap: wrap; gap: var(--rst-sp-3) var(--rst-sp-5); } |
| +[co-actions] > form { align-items: flex-end; display: flex; flex-wrap: wrap; gap: var(--rst-sp-2); } |
| +[co-actions] label { color: var(--rst-text-muted); display: flex; flex-direction: column; font-size: var(--rst-fs-sm); gap: 0.2rem; } |
| +[co-actions] [rst-input] { inline-size: 16rem; max-inline-size: 100%; } |
| + |
| +/* List grids: Rastrillo's [rst-lrow] lays each row out from --rst-cols, |
| + which a list card names once. One template per operator list. */ |
| +[co-cols="people"] { --rst-cols: minmax(12rem, 2fr) minmax(8rem, 1fr) 7rem 7rem; } |
| +[co-cols="activity"] { --rst-cols: 6rem minmax(10rem, 1.2fr) minmax(12rem, 2fr) minmax(7rem, 1fr); } |
| +[co-cols="boxes"] { --rst-cols: minmax(8rem, 1fr) 7rem 6rem minmax(9rem, 1.4fr) 8rem; } |
| +[co-cols="jobs"] { --rst-cols: minmax(10rem, 1.5fr) 9rem 8rem minmax(10rem, 2fr); } |
| + |
| +/* A quiet note under a table or a band: what today's pages wrote as a |
| + <p class="small">. */ |
| +[co-note] { color: var(--rst-text-faint); font-size: var(--rst-fs-sm); margin: var(--rst-sp-2) 0 0; } |
| + |
| +/* A data table inside a card. The wrapper scrolls sideways on a narrow |
| + screen, so a wide table never widens the page. */ |
| +.co-table-wrap { overflow-x: auto; } |
| +[co-table] { border-collapse: collapse; font-variant-numeric: tabular-nums; inline-size: 100%; } |
| +[co-table] th, [co-table] td { border-block-end: 1px solid var(--rst-line); padding: 0.55rem 1rem; text-align: start; vertical-align: top; white-space: nowrap; } |
| +[co-table] th { color: var(--rst-text-faint); font-size: var(--rst-fs-xs); font-weight: 550; letter-spacing: 0.05em; text-transform: uppercase; } |
| +[co-table] tr:last-child > td { border-block-end: 0; } |
diff --git a/internal/console/storepage.go b/internal/console/storepage.go| index c4152fb40..927c7c011 100644 |
| --- a/internal/console/storepage.go |
| +++ b/internal/console/storepage.go |
| @@ -149,7 +149,9 @@ func (s *Server) handleStoreApprovalsPage(w http.ResponseWriter, r *http.Request |
| if err != nil { |
| log.Printf("console: storage bucket count: %v", err) |
| } |
| - s.render(w, http.StatusOK, "store_approvals", page{Title: "Object storage applications", Address: addr, CSRF: raw, StoreQueue: v}) |
| + p := s.opPage(addr, raw, "store") |
| + p.StoreQueue = v |
| + s.render(w, http.StatusOK, "store_approvals", p) |
| } |
| func (s *Server) handleStoreDecisionPage(w http.ResponseWriter, r *http.Request) { |
diff --git a/internal/console/templates/opparts.html b/internal/console/templates/opparts.html| new file mode 100644 |
| index 000000000..ca95cb844 |
| --- /dev/null |
| +++ b/internal/console/templates/opparts.html |
| @@ -0,0 +1,81 @@ |
| +{{/* The operator pages' partials. Each is one Rastrillo v0.29.0 |
| + ui/partials/<name>.html, its markup kept, with the catalog lookups (T) |
| + replaced by the approved copy, numbers preformatted by the caller |
| + (opnum), and the console's own icon func. Their data are the op* |
| + structs in opparts.go. */}} |
| + |
| +{{/* page-header: the page's <h1> and an optional subhead. No action. */}} |
| +{{define "op_page_header"}}<header rst-page-header> |
| + <div rst-page-header-titles> |
| + <h1>{{.Title}}</h1> |
| + {{- if .Sub}} |
| + <p rst-page-header-sub>{{.Sub}}</p> |
| + {{- end}} |
| + </div> |
| +</header>{{end}} |
| + |
| +{{/* status-pill: a status word as a tinted pill. The word is always the |
| + text; the tone is a second signal, never the only one. */}} |
| +{{define "op_status"}}<span rst-status rst-tone="{{if .Tone}}{{.Tone}}{{else}}neutral{{end}}">{{.Label}}</span>{{end}} |
| + |
| +{{/* stat: one reading in an rst-stats band. Delta carries its own sign. */}} |
| +{{define "op_stat"}}<div rst-stat{{if .Lead}}="lead"{{end}}><span rst-stat-label>{{.Label}}</span><span rst-stat-num>{{.Value}}</span>{{with .Delta}}<span rst-stat-delta rst-tone="{{if $.Tone}}{{$.Tone}}{{else}}neutral{{end}}">{{.}}</span>{{end}}{{with .Note}}<span rst-stat-note>{{.}}</span>{{end}}</div>{{end}} |
| + |
| +{{/* empty-state: an optional <h2> and one sentence, with no call to |
| + action on the operator pages. */}} |
| +{{define "op_empty"}}<div rst-empty> |
| + {{- if .Title}} |
| + <h2 rst-empty-title>{{.Title}}</h2> |
| + {{- end}} |
| + <p rst-empty-body>{{.Body}}</p> |
| +</div>{{end}} |
| + |
| +{{/* meter: a capacity bar beside its text. The text is what a reader gets; |
| + the bar is decoration over it, hence aria-hidden. */}} |
| +{{define "op_meter"}}{{$p := .Percent}}{{if lt $p 0}}{{$p = 0}}{{end}}{{if gt $p 100}}{{$p = 100}}{{end}}<span rst-meter><meter rst-meter-bar value="{{$p}}" min="0" max="100" aria-hidden="true"></meter><span rst-meter-num>{{.Text}}</span></span>{{end}} |
| + |
| +{{/* seg-tabs: a segmented control of server-rendered links. */}} |
| +{{define "op_seg_tabs"}}<nav rst-seg-tabs aria-label="{{.Label}}">{{range .Items}}<a href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{.Label}}</a>{{end}}</nav>{{end}} |
| + |
| +{{/* dropdown: a zero-JS disclosure of plain links, in the one menu group |
| + every dropdown shares. */}} |
| +{{define "op_dropdown"}}<details rst-dropdown name="rst-menus"> |
| + <summary rst-btn{{if .Aria}} aria-label="{{.Aria}}"{{end}}>{{.Label}} {{icon "chevron-down"}}</summary> |
| + <div rst-dropdown-menu> |
| + {{- range .Items}} |
| + <a href="{{.Href}}"{{if .Current}} aria-current="true"{{end}}>{{.Label}}{{if .Current}} {{icon "check"}}{{end}}</a> |
| + {{- end}} |
| + </div> |
| +</details>{{end}} |
| + |
| +{{/* list-bar with list-bar-search inlined: a GET search form inside a |
| + <search> landmark, its clear link when there is a query, its hidden |
| + pairs, a visually hidden submit, and an optional filter dropdown. */}} |
| +{{define "op_list_bar"}}<div rst-lbar> |
| + <search><form rst-search method="get"{{if .Action}} action="{{.Action}}"{{end}}> |
| + {{icon "search"}} |
| + <input type="search" name="q"{{if .Query}} value="{{.Query}}"{{end}}{{if .Placeholder}} placeholder="{{.Placeholder}}"{{end}} aria-label="{{if .Placeholder}}{{.Placeholder}}{{else}}Search{{end}}"> |
| + {{- if .Query}} |
| + <a rst-search-clear href="{{.Clear}}" aria-label="Clear the search">{{icon "x"}}</a> |
| + {{- end}} |
| + {{- range .Hidden}} |
| + <input type="hidden" name="{{index . 0}}" value="{{index . 1}}"> |
| + {{- end}} |
| + <button class="rst-sr-only" type="submit">Search</button> |
| +</form></search> |
| + {{- with .Filter}} |
| + {{template "op_dropdown" .}} |
| + {{- end}} |
| +</div>{{end}} |
| + |
| +{{/* pagination: a strip of ordinary page links. The current page is |
| + aria-current and filled; a disabled item is a plain span. */}} |
| +{{define "op_pagination"}}<nav rst-pagination aria-label="{{if .Label}}{{.Label}}{{else}}Pages{{end}}"> |
| + {{- range .Items}} |
| + {{- if .Gap}}<span rst-pagination-gap aria-hidden="true">…</span> |
| + {{- else if .Current}}<span aria-current="page">{{.Label}}</span> |
| + {{- else if .Disabled}}<span rst-pagination-disabled>{{.Label}}</span> |
| + {{- else}}<a href="{{.Href}}">{{.Label}}</a> |
| + {{- end}} |
| + {{- end}} |
| +</nav>{{end}} |
diff --git a/internal/console/templates/ops_index.html b/internal/console/templates/ops_index.html| new file mode 100644 |
| index 000000000..7c7d6c8d1 |
| --- /dev/null |
| +++ b/internal/console/templates/ops_index.html |
| @@ -0,0 +1,6 @@ |
| +{{/* The operator pages' index. On a phone the rail is the whole page and |
| + this content is hidden; at width the rail sits beside it. Each rail |
| + link has the id a page's back strip returns to (/fleet/index#nav-<key>). */}} |
| +{{define "ops_index"}}{{template "op_top" .}} |
| +{{template "op_empty" (opEmpty "" "Choose a page.")}} |
| +{{template "op_bottom" .}}{{end}} |
diff --git a/internal/console/templates/opshell.html b/internal/console/templates/opshell.html| new file mode 100644 |
| index 000000000..a490b0a05 |
| --- /dev/null |
| +++ b/internal/console/templates/opshell.html |
| @@ -0,0 +1,65 @@ |
| +{{/* The operator pages' shell: Rastrillo v0.29.0's ui/layouts/console.html, |
| + ported by hand in the same DOM order (bar, back strip, rail, main), so |
| + the reading and focus order is the same at every width. Its per-page |
| + blocks (view, up, nav) are .Op's fields (opshell.go). It loads only the |
| + console's own /static/ files, minus busy.js and light.js, and carries |
| + nothing from layout.html: the customer console's look is its own. |
| + |
| + On a phone the index (/fleet/index) is the rail alone, headed by the |
| + bar's <h1>; every other page shows its content under a back strip that |
| + returns to its row on the index. Each page's <h1> is its page header's, |
| + so the bar's <h1> is written only on the index. */}} |
| +{{define "op_top"}}<!doctype html> |
| +<html lang="en" dir="ltr"> |
| +<head> |
| +<meta charset="utf-8"> |
| +<meta name="viewport" content="width=device-width"> |
| +<title>{{.Title}} · CARLOS operator</title> |
| +<link rel="stylesheet" href="{{asset "rastrillo/tokens.css"}}"> |
| +<link rel="stylesheet" href="{{asset "rastrillo/day.css"}}"> |
| +<link rel="stylesheet" href="{{asset "rastrillo/shell.css"}}"> |
| +<link rel="stylesheet" href="{{asset "ops.css"}}"> |
| +<script defer src="{{asset "rastrillo/rastrillo.js"}}"></script> |
| +<script defer src="{{asset "rastrillo/anchor.js"}}"></script> |
| +<script defer blocking="render" src="{{asset "rastrillo/shell.js"}}"></script> |
| +</head> |
| +<body> |
| +<div rst-shell-console="{{.Op.View}}"> |
| +<a rst-skip href="#main">Skip to content</a> |
| +<header rst-shell-bar> |
| +{{if eq .Op.View "index"}}<h1 rst-shell-title><span>CARLOS operator</span><span>{{.Title}}</span></h1> |
| +{{end}}<a rst-shell-brand href="/fleet">CARLOS operator</a> |
| +<details rst-shell-menu name="rst-shell-menu"><summary><span rst-shell-menu-label>{{icon "menu"}}Menu</span><span rst-shell-avatar>{{template "op_profile" .}}</span></summary></details> |
| +<div rst-shell-tail> |
| +<div rst-shell-who>{{template "op_profile" .}}</div> |
| +<details rst-dropdown rst-shell-account name="rst-menus"> |
| +<summary>{{.Address}}<span rst-caret aria-hidden="true">{{icon "chevron-down"}}</span></summary> |
| +<div rst-dropdown-menu><a href="/">Customer console</a><form method="post" action="/auth/signout"> |
| +<input type="hidden" name="csrf" value="{{.CSRF}}"> |
| +<button type="submit">Sign out</button> |
| +</form></div> |
| +</details> |
| +</div> |
| +</header> |
| +<div rst-shell-back><a href="{{.Op.Up}}" rel="up">Back</a></div> |
| +<aside rst-shell-rail> |
| +<nav rst-shell-nav aria-label="Operator pages">{{range opRail .Op}} |
| +<a id="nav-{{.Key}}" href="{{.Href}}"{{if eq .Key $.Op.Rail}} aria-current="page"{{end}}>{{.Label}}</a>{{end}} |
| +</nav> |
| +</aside> |
| +<main rst-shell-main id="main"> |
| +<div rst-page> |
| +{{end}} |
| + |
| +{{/* op_profile is the signed-in person as the bar shows them: Rastrillo's |
| + empty avatar and the address. */}} |
| +{{define "op_profile"}}<span rst-person-av="empty placeholder" aria-hidden="true"></span><span rst-person-name>{{.Address}}</span>{{end}} |
| + |
| +{{define "op_bottom"}} |
| +</div> |
| +</main> |
| +<footer rst-shell-foot>🤖 Console text written by an LLM, per <a href="https://11factor.org/#x">factor X</a>.</footer> |
| +</div> |
| +</body> |
| +</html> |
| +{{end}} |
diff --git a/internal/console/templates/store_approvals.html b/internal/console/templates/store_approvals.html| index cf9df12d8..316d92c4f 100644 |
| --- a/internal/console/templates/store_approvals.html |
| +++ b/internal/console/templates/store_approvals.html |
| @@ -1,27 +1,30 @@ |
| -{{define "store_approvals"}}{{template "top" .}} |
| -<h1>Object storage applications</h1> |
| -<p><a href="/fleet">Fleet status</a></p> |
| +{{define "store_approvals"}}{{template "op_top" .}} |
| +{{template "op_page_header" (opHeader .Title "Object storage requests waiting for a decision.")}} |
| {{with .StoreQueue}} |
| +<div rst-card co-pad> |
| {{if .CountKnown}}<p>Provisioned stores: {{.Buckets}} (daily sweep: {{.SweepDate}}).</p> |
| {{else}}<p>Bucket count unavailable. A complete storage sweep is needed.</p>{{end}} |
| <p>Each provisioned store names a bucket. This daily count includes adopted or shared buckets, excludes incomplete provisions, and can lag changes. AWS bucket quotas still apply; CARLOS does not cap stores per account.</p> |
| <p>AWS now defaults to 10,000 general-purpose buckets per cloud account; the earlier default was 100. This deployment's quota may differ.</p> |
| <p>{{len .Applications}} pending applications. Oldest first.</p> |
| +</div> |
| {{range .Applications}} |
| -<section> |
| +<section rst-card co-pad> |
| <h2>Account {{.Account}}</h2> |
| <p>Applied by {{.Applied.By}} on {{fmtTime .Applied.At}}</p> |
| {{if .Applied.Note}}<p>{{.Applied.Note}}</p>{{end}} |
| +<div co-actions> |
| <form method="post" action="/fleet/store/{{.Account}}/approve"> |
| <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| -<button type="submit">Approve</button> |
| +<button rst-btn="primary" type="submit">Approve</button> |
| </form> |
| <form method="post" action="/fleet/store/{{.Account}}/decline"> |
| <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| -<label>Reason <input type="text" name="reason" required></label> |
| -<button type="submit">Decline</button> |
| +<label>Reason <input rst-input type="text" name="reason" required></label> |
| +<button rst-btn="danger" type="submit">Decline</button> |
| </form> |
| +</div> |
| </section> |
| -{{else}}<p>No pending storage applications.</p>{{end}} |
| +{{else}}{{template "op_empty" (opEmpty "" "No pending storage applications.")}}{{end}} |
| {{end}} |
| -{{template "bottom" .}}{{end}} |
| +{{template "op_bottom" .}}{{end}} |
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt| index 53ba079ad..b6881cc5e 100644 |
| --- a/internal/console/testdata/claim-routes.txt |
| +++ b/internal/console/testdata/claim-routes.txt |
| @@ -114,6 +114,7 @@ route GET /auth/stepup/callback |
| route GET /fleet |
| route GET /fleet/economics |
| route GET /fleet/economics/accounts |
| +route GET /fleet/index |
| route GET /fleet/metrics |
| route GET /fleet/store |
| route GET /healthz |