Console: one toolbar pattern on Logs, Errors, Availability and Analytics
The four filter forms take the shared .toolbar row with small buttons. The Logs level label says Level (NAV-C50) and no longer repeats All levels, which stays as the first option. Toolbar labels match the controls' size and colour, and selects and text inputs shrink to the row so a long instance name cannot push it off a narrow screen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+73
−20
internal/console/appnav_test.go+54 −0internal/console/approved_nav_copy_test.go+1 −0internal/console/server.go+2 −2internal/console/templates/app_analytics.html+2 −2internal/console/templates/app_availability.html+3 −3internal/console/templates/app_errors.html+3 −3internal/console/templates/app_logs.html+5 −5internal/console/templates/layout.html+3 −5
CI failed — run details
diff --git a/internal/console/appnav_test.go b/internal/console/appnav_test.go| index c84779ca2..9d4190179 100644 |
| --- a/internal/console/appnav_test.go |
| +++ b/internal/console/appnav_test.go |
| @@ -202,3 +202,57 @@ func TestRunningLeftoversNameTheTab(t *testing.T) { |
| t.Errorf("the instance page's back link does not say Running:\n%s", one) |
| } |
| } |
| + |
| +func TestLogsToolbar(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInPaul(t, fx) |
| + for _, tab := range []string{"logs", "errors", "availability", "analytics"} { |
| + status, _, body := get(t, c, fx.u("/apps/kass/"+tab)) |
| + if status != 200 { |
| + t.Fatalf("GET /apps/kass/%s = %d", tab, status) |
| + } |
| + if strings.Contains(body, `<form method="get" class="small"`) { |
| + t.Errorf("%s: the filter form still has class small", tab) |
| + } |
| + at := strings.Index(body, `<form method="get" class="toolbar"`) |
| + if at < 0 { |
| + t.Fatalf("%s: no toolbar form", tab) |
| + } |
| + form, _, _ := strings.Cut(body[at:], "</form>") |
| + buttons := 0 |
| + for _, part := range strings.Split(form, "<button")[1:] { |
| + buttons++ |
| + tag, _, _ := strings.Cut(part, ">") |
| + if !strings.Contains(tag, `class="btn-sm"`) { |
| + t.Errorf("%s: button <button%s> lacks class btn-sm", tab, tag) |
| + } |
| + } |
| + if buttons == 0 { |
| + t.Errorf("%s: the toolbar has no buttons", tab) |
| + } |
| + if tab != "logs" { |
| + continue |
| + } |
| + for _, need := range []string{`id="logs-filter"`, `data-url=`, `data-cursor=`, `id="log-follow"`, `id="log-pause"`, `name="host"`, `name="stream"`, `name="since"`, `name="level"`, `name="text"`} { |
| + if !strings.Contains(body[at:at+len(form)], need) { |
| + t.Errorf("logs: the form lost %q", need) |
| + } |
| + } |
| + if !strings.Contains(form, `id="logs-filter"`) { |
| + t.Errorf("logs: the toolbar form is not the #logs-filter form") |
| + } |
| + before, _, _ := strings.Cut(form, `<select name="level">`) |
| + label := before[strings.LastIndex(before, "<label>")+len("<label>"):] |
| + if got := strings.TrimSpace(label); got != "Level" { |
| + t.Errorf("logs: level label = %q, want the approved NAV-C50 %q", got, "Level") |
| + } |
| + if n := strings.Count(form, "All levels"); n != 1 { |
| + t.Errorf("logs: %q appears %d times in the form, want once (the first option)", "All levels", n) |
| + } |
| + level, _, _ := strings.Cut(form[strings.Index(form, `<select name="level">`):], "</select>") |
| + if first := strings.Index(level, "<option"); !strings.Contains(level[first:], ">All levels</option>") || |
| + strings.Index(level[first:], "All levels") > strings.Index(level[first:], `value="debug"`) { |
| + t.Errorf("logs: All levels is not the first level option:\n%s", level) |
| + } |
| + } |
| +} |
diff --git a/internal/console/approved_nav_copy_test.go b/internal/console/approved_nav_copy_test.go| index 98f9a17bc..54fec1cf3 100644 |
| --- a/internal/console/approved_nav_copy_test.go |
| +++ b/internal/console/approved_nav_copy_test.go |
| @@ -32,6 +32,7 @@ var navCopyBuilt = map[string]bool{ |
| "NAV-C45": true, |
| "NAV-C10": true, "NAV-C11": true, "NAV-C12": true, "NAV-C13": true, |
| "NAV-C14": true, "NAV-C15": true, "NAV-C16": true, |
| + "NAV-C50": true, |
| } |
| type navCopyRow struct{ ID, Where, Old, New, CheckedBy, Status string } |
diff --git a/internal/console/server.go b/internal/console/server.go| index f2d2c6540..872f3d361 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -2285,7 +2285,7 @@ type SettingsSectionLink struct { |
| } |
| type appLogsCopy struct { |
| - Instance, AllInstances, Search, AllLevels, Follow, Pause, Widen, FollowError, Refreshed string |
| + Instance, AllInstances, Search, Level, AllLevels, Follow, Pause, Widen, FollowError, Refreshed string |
| } |
| // IsOwner is the template's one permission question. |
| @@ -3938,7 +3938,7 @@ func (s *Server) handleAppLogs(w http.ResponseWriter, r *http.Request) { |
| } |
| q := r.URL.Query() |
| p.LogCopy = appLogsCopy{ |
| - Instance: "Instances", AllInstances: "All instances", Search: "Search logs", |
| + Instance: "Instances", AllInstances: "All instances", Search: "Search logs", Level: "Level", |
| AllLevels: "All levels", Follow: "Follow live", Pause: "Pause", |
| Widen: "Show the last 24 hours", |
| FollowError: "Live updates failed. Follow live again to retry.", Refreshed: "Updated", |
diff --git a/internal/console/templates/app_analytics.html b/internal/console/templates/app_analytics.html| index 87772e714..2a0a42dc8 100644 |
| --- a/internal/console/templates/app_analytics.html |
| +++ b/internal/console/templates/app_analytics.html |
| @@ -11,7 +11,7 @@ When on, the edge counts HTML page views and daily visitors as it serves them: n |
| no stored IP. A visitor is a salted hash that changes every day. Turn it on for this app or for the whole |
| account on the <a href="{{.Base}}/apps/{{.AppName}}/settings">Settings</a> tab.</p> |
| {{end}} |
| -<form method="get" class="small"> |
| +<form method="get" class="toolbar"> |
| <label>range |
| <select name="range"> |
| <option value="today"{{if eq .AnalyticsRange "today"}} selected{{end}}>today</option> |
| @@ -19,7 +19,7 @@ account on the <a href="{{.Base}}/apps/{{.AppName}}/settings">Settings</a> tab.< |
| <option value="30d"{{if eq .AnalyticsRange "30d"}} selected{{end}}>30 days</option> |
| </select> |
| </label> |
| - <button type="submit">Update</button> |
| + <button type="submit" class="btn-sm">Update</button> |
| </form> |
| {{with .AnalyticsWin}} |
| <div class="tablewrap"><table> |
diff --git a/internal/console/templates/app_availability.html b/internal/console/templates/app_availability.html| index 2af05a0be..b980666e2 100644 |
| --- a/internal/console/templates/app_availability.html |
| +++ b/internal/console/templates/app_availability.html |
| @@ -5,7 +5,7 @@ |
| <h2 class="visually-hidden">Availability</h2> |
| {{if .ErrsErr}}<p class="banner error">{{.ErrsErr}}</p>{{end}} |
| -<form method="get" class="small"> |
| +<form method="get" class="toolbar"> |
| <label>from the last |
| <select name="since"> |
| <option value="1h"{{if eq .ErrSince "1h"}} selected{{end}}>hour</option> |
| @@ -13,8 +13,8 @@ |
| <option value="168h"{{if eq .ErrSince "168h"}} selected{{end}}>week</option> |
| </select> |
| </label> |
| - <label>host <input name="host" value="{{.ErrHost}}" size="24"></label> |
| - <button type="submit">Update</button> |
| + <label>host <input type="text" name="host" value="{{.ErrHost}}" size="24"></label> |
| + <button type="submit" class="btn-sm">Update</button> |
| </form> |
| <p class="small">Requests an instance could not answer — a 502, 503 or 504 — grouped by cause rather than by page, and the platform's own events about the instance: failed wakes and exits. |
| A 500 is the app answering, and stays on Errors. A visitor who left within five seconds is not counted; one who gave up after waiting longer is. Counts are to the nearest flush.</p> |
diff --git a/internal/console/templates/app_errors.html b/internal/console/templates/app_errors.html| index 97552ece3..57fe56357 100644 |
| --- a/internal/console/templates/app_errors.html |
| +++ b/internal/console/templates/app_errors.html |
| @@ -5,7 +5,7 @@ |
| <h2 class="visually-hidden">Errors</h2> |
| {{if .ErrsErr}}<p class="banner error">{{.ErrsErr}}</p>{{end}} |
| -<form method="get" class="small"> |
| +<form method="get" class="toolbar"> |
| <label>from the last |
| <select name="since"> |
| <option value="1h"{{if eq .ErrSince "1h"}} selected{{end}}>hour</option> |
| @@ -29,8 +29,8 @@ |
| <option value="warn"{{if eq .ErrLevel "warn"}} selected{{end}}>warn and above</option> |
| </select> |
| </label> |
| - <label>host <input name="host" value="{{.ErrHost}}" size="24"></label> |
| - <button type="submit">Update</button> |
| + <label>host <input type="text" name="host" value="{{.ErrHost}}" size="24"></label> |
| + <button type="submit" class="btn-sm">Update</button> |
| </form> |
| <p class="small">Sources live: {{if .ErrWin.Sources}}{{range $i, $s := .ErrWin.Sources}}{{if $i}}, {{end}}{{$s}}{{end}}{{else}}none yet{{end}}. |
| Counts are to the nearest flush. Messages are redacted for addresses and credentials before they are stored; treat that as a floor, not a guarantee.</p> |
diff --git a/internal/console/templates/app_logs.html b/internal/console/templates/app_logs.html| index 6196d18b8..1c4b09903 100644 |
| --- a/internal/console/templates/app_logs.html |
| +++ b/internal/console/templates/app_logs.html |
| @@ -5,7 +5,7 @@ |
| <h2 class="visually-hidden">Logs</h2> |
| {{if .LogsErr}}<p class="banner error">{{.LogsErr}}</p>{{end}} |
| -<form method="get" class="small" id="logs-filter" data-url="{{.Base}}/apps/{{.AppName}}/logs/data" data-cursor="{{.LogCursor}}" data-follow-error="{{.LogCopy.FollowError}}" data-refreshed="{{.LogCopy.Refreshed}}"> |
| +<form method="get" class="toolbar" id="logs-filter" data-url="{{.Base}}/apps/{{.AppName}}/logs/data" data-cursor="{{.LogCursor}}" data-follow-error="{{.LogCopy.FollowError}}" data-refreshed="{{.LogCopy.Refreshed}}"> |
| <label>{{.LogCopy.Instance}} |
| <select name="host"> |
| <option value="">{{.LogCopy.AllInstances}}</option> |
| @@ -29,7 +29,7 @@ |
| <option value="168h"{{if eq .LogSince "168h"}} selected{{end}}>week</option> |
| </select> |
| </label> |
| - <label>{{.LogCopy.AllLevels}} |
| + <label>{{.LogCopy.Level}} |
| <select name="level"> |
| <option value=""{{if eq .LogLevel ""}} selected{{end}}>{{.LogCopy.AllLevels}}</option> |
| <option value="debug"{{if eq .LogLevel "debug"}} selected{{end}}>debug</option> |
| @@ -42,9 +42,9 @@ |
| <input type="search" name="text" value="{{.LogGrep}}"> |
| </label> |
| {{if .LogLegacyGrep}}<input type="hidden" name="grep" value="{{.LogLegacyGrep}}">{{end}} |
| - <button type="submit">Update</button> |
| - <button type="button" id="log-follow">{{.LogCopy.Follow}}</button> |
| - <button type="button" id="log-pause" hidden>{{.LogCopy.Pause}}</button> |
| + <button type="submit" class="btn-sm">Update</button> |
| + <button type="button" class="btn-sm" id="log-follow">{{.LogCopy.Follow}}</button> |
| + <button type="button" class="btn-sm" id="log-pause" hidden>{{.LogCopy.Pause}}</button> |
| </form> |
| {{if .LogTruncated}}<p class="small">Showing the newest {{len .LogRows}} lines of this window — narrow the window, or use <code>carlos logs</code> for more.</p>{{end}} |
diff --git a/internal/console/templates/layout.html b/internal/console/templates/layout.html| index f59b4c695..f0f116cce 100644 |
| --- a/internal/console/templates/layout.html |
| +++ b/internal/console/templates/layout.html |
| @@ -59,7 +59,9 @@ |
| .toolbar input, .toolbar select, .toolbar button { height: 2rem; margin: 0; } |
| /* economics_accounts.html (a frozen operator page) still says listctl. */ |
| .listctl { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.6rem; } |
| - .toolbar label { display: inline-flex; align-items: center; gap: 0.35rem; } |
| + .toolbar label { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; font-size: 0.9rem; color: var(--muted); } |
| + .toolbar select, .toolbar input[type=search], .toolbar input[type=text] { max-width: 100%; min-width: 0; } |
| + #logs-filter select[name="host"] { max-width: 12rem; } |
| /* A section heading with its one action at the right end of the row. */ |
| .sectionhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 2rem 0 0.75rem; } |
| .sectionhead h2 { margin: 0; } |
| @@ -202,10 +204,6 @@ |
| the console's own output. The pane is a scrolled region in BOTH axes — |
| sideways because lines do not wrap, and down because 200 lines must not |
| turn the page itself into the scrollbar. */ |
| - #logs-filter { display: flex; flex-wrap: wrap; align-items: end; gap: 0.65rem; margin-bottom: 1rem; } |
| - #logs-filter label { display: flex; flex-direction: column; gap: 0.25rem; max-width: 100%; } |
| - #logs-filter select, #logs-filter input { max-width: 100%; margin: 0; } |
| - #logs-filter select[name="host"] { max-width: 28rem; } |
| .term { |
| background: var(--accent-soft); border-radius: 0.5rem; |
| padding: 0.8rem 0 0.8rem 1rem; margin: 0 0 1rem; |