Console: page heads, one danger style, settings rows on account settings
Apps, Trash and New account get the .pagehead. Trash's permanent delete moves into each row as a small red button, owners only, same POST target, CSRF and confirmation. Account settings forms use the settings-row pattern and Delete account gets the danger style. The New account help text says Team (NAV-C60 to C66).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+186
−35
internal/console/appnav_test.go+97 −0internal/console/approved_nav_copy_test.go+2 −0internal/console/deletion_test.go+43 −0internal/console/templates/account_settings.html+8 −8internal/console/templates/apps.html+6 −2internal/console/templates/newaccount.html+10 −7internal/console/templates/trash.html+20 −18
CI failed — run details
diff --git a/internal/console/appnav_test.go b/internal/console/appnav_test.go| index 9d4190179..17b73eee8 100644 |
| --- a/internal/console/appnav_test.go |
| +++ b/internal/console/appnav_test.go |
| @@ -2,10 +2,12 @@ package console |
| import ( |
| "fmt" |
| + "os" |
| "reflect" |
| "regexp" |
| "strings" |
| "testing" |
| + "time" |
| "github.com/carlosframework/platform/internal/registry" |
| ) |
| @@ -256,3 +258,98 @@ func TestLogsToolbar(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// pageHeadBefore reports whether the pagehead div opens before the first |
| +// <h1> in body, so the heading sits inside it. |
| +func pageHeadBefore(body, h1 string) bool { |
| + head := strings.Index(body, `<div class="pagehead">`) |
| + at := strings.Index(body, h1) |
| + return head >= 0 && at > head |
| +} |
| + |
| +func TestPageHeadsOnAccountPages(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInPaul(t, fx) |
| + acct, err := fx.st.AccountBySqid(fx.sqid) |
| + if err != nil || acct == nil { |
| + t.Fatalf("AccountBySqid = %v %v", acct, err) |
| + } |
| + eyebrow := `<p class="eyebrow">Account · ` + acct.Name + `</p>` |
| + |
| + status, _, body := get(t, c, fx.u("/")) |
| + if status != 200 { |
| + t.Fatalf("GET / = %d", status) |
| + } |
| + if !pageHeadBefore(body, "<h1>Apps</h1>") || !strings.Contains(body, eyebrow) { |
| + t.Errorf("Apps page lacks the page head, the Apps h1 or the eyebrow %q:\n%s", eyebrow, body) |
| + } |
| + |
| + fx2, c2, _ := trashPageFixture(t) |
| + status, _, body = get(t, c2, fx2.u("/trash")) |
| + if status != 200 { |
| + t.Fatalf("GET /trash = %d", status) |
| + } |
| + if !pageHeadBefore(body, "<h1>Trash</h1>") || !strings.Contains(body, eyebrow) { |
| + t.Errorf("Trash page lacks the page head or the eyebrow %q:\n%s", eyebrow, body) |
| + } |
| + |
| + status, _, body = get(t, c, fx.ts.URL+"/accounts/new") |
| + if status != 200 { |
| + t.Fatalf("GET /accounts/new = %d", status) |
| + } |
| + if !pageHeadBefore(body, "<h1>New account</h1>") || !strings.Contains(body, `<p class="eyebrow">Accounts</p>`) { |
| + t.Errorf("New account page lacks the page head or the Accounts eyebrow:\n%s", body) |
| + } |
| + if !strings.Contains(navSpace(body), "you can invite teammates from the account's Team page.") { |
| + t.Errorf("the New account help text does not say Team:\n%s", body) |
| + } |
| +} |
| + |
| +func TestAccountSettingsFormsUseSettingsRow(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + if err := fx.st.CreateAccount(42, "cdef", "shop", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + c := signInPaul(t, fx) |
| + status, _, body := get(t, c, fx.ts.URL+"/a/cdef/settings") |
| + if status != 200 { |
| + t.Fatalf("GET /a/cdef/settings = %d:\n%s", status, body) |
| + } |
| + _, main, _ := strings.Cut(body, "<main>") |
| + if strings.Contains(main, `class="signin"`) { |
| + t.Errorf("account settings still has a signin-style form:\n%s", main) |
| + } |
| + for _, want := range []string{ |
| + `<form class="settings-row" method="post" action="/a/cdef/delete">`, |
| + `class="btn-sm btn-danger">Delete account</button>`, |
| + `<form class="settings-row" method="post" action="/a/cdef/services/new">`, |
| + `class="btn-sm">Mint credential</button>`, |
| + } { |
| + if !strings.Contains(main, want) { |
| + t.Errorf("account settings lacks %q:\n%s", want, main) |
| + } |
| + } |
| + |
| + // The two telemetry forms render only where the bucket can read the |
| + // account's settings file, and the test store's dirstore refuses that key, |
| + // so read them from the template source. |
| + raw, err := os.ReadFile("templates/account_settings.html") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + src := string(raw) |
| + if strings.Contains(src, `class="signin"`) { |
| + t.Error("account_settings.html still has a signin-style form") |
| + } |
| + for _, want := range []string{ |
| + `<form class="settings-row" method="post" action="{{.Base}}/errors/level">`, |
| + `<form class="settings-row" method="post" action="{{.Base}}/analytics/setting">`, |
| + } { |
| + if !strings.Contains(src, want) { |
| + t.Errorf("account_settings.html lacks %q", want) |
| + } |
| + } |
| + if n := strings.Count(src, `class="btn-sm">Save</button>`); n != 2 { |
| + t.Errorf("%d small Save buttons, want 2", n) |
| + } |
| +} |
diff --git a/internal/console/approved_nav_copy_test.go b/internal/console/approved_nav_copy_test.go| index 672af0592..34e054632 100644 |
| --- a/internal/console/approved_nav_copy_test.go |
| +++ b/internal/console/approved_nav_copy_test.go |
| @@ -34,6 +34,8 @@ var navCopyBuilt = map[string]bool{ |
| "NAV-C10": true, "NAV-C11": true, "NAV-C12": true, "NAV-C13": true, |
| "NAV-C14": true, "NAV-C15": true, "NAV-C16": true, |
| "NAV-C50": true, |
| + "NAV-C60": true, "NAV-C61": true, "NAV-C62": true, "NAV-C63": true, |
| + "NAV-C64": true, "NAV-C65": true, "NAV-C66": true, |
| } |
| type navCopyRow struct{ ID, Where, Old, New, CheckedBy, Status string } |
diff --git a/internal/console/deletion_test.go b/internal/console/deletion_test.go| index ea0d33e33..f96d3d1e8 100644 |
| --- a/internal/console/deletion_test.go |
| +++ b/internal/console/deletion_test.go |
| @@ -929,3 +929,46 @@ func TestDeleteConfirmationNamesEachAppsWindow(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// Delete permanently sits in the trashed app's own row, small and red, for an |
| +// owner only; the section heading it used to sit under is gone. |
| +func TestTrashDeleteSitsInItsRow(t *testing.T) { |
| + fx, c, _ := trashPageFixture(t) |
| + status, _, body := get(t, c, fx.u("/trash")) |
| + if status != http.StatusOK { |
| + t.Fatalf("trash page = %d:\n%s", status, body) |
| + } |
| + _, afterCell, ok := strings.Cut(body, "<td>kass</td>") |
| + if !ok { |
| + t.Fatalf("no row for kass:\n%s", body) |
| + } |
| + row, _, _ := strings.Cut(afterCell, "</tr>") |
| + for _, want := range []string{ |
| + `/trash/restore"`, `/trash/delete"`, |
| + `class="btn-sm btn-danger">Delete permanently</button>`, |
| + } { |
| + if !strings.Contains(row, want) { |
| + t.Errorf("kass's row lacks %q:\n%s", want, row) |
| + } |
| + } |
| + if strings.Contains(body, "<h2>Delete now</h2>") { |
| + t.Errorf("the Delete now heading is still on the page:\n%s", body) |
| + } |
| + |
| + if err := fx.st.AddMember(OpsAccountID, "sam@keymail.dev", RoleMember, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + fx.setUser("sam@keymail.dev") |
| + mc := newBrowser(t) |
| + signUp(t, fx, mc, "code-sam-row") |
| + status, _, member := get(t, mc, fx.u("/trash")) |
| + if status != http.StatusOK { |
| + t.Fatalf("member trash page = %d:\n%s", status, member) |
| + } |
| + if strings.Contains(member, `/trash/delete"`) { |
| + t.Errorf("a plain member's trash page offers permanent deletion:\n%s", member) |
| + } |
| + if !strings.Contains(member, `/trash/restore"`) { |
| + t.Errorf("a plain member's trash page lacks Restore:\n%s", member) |
| + } |
| +} |
diff --git a/internal/console/templates/account_settings.html b/internal/console/templates/account_settings.html| index 03bbfb703..43513848b 100644 |
| --- a/internal/console/templates/account_settings.html |
| +++ b/internal/console/templates/account_settings.html |
| @@ -143,7 +143,7 @@ |
| <p class="small">No service credentials in this account.</p> |
| {{end}} |
| <h3>Mint a credential</h3> |
| -<form class="signin" method="post" action="{{.Base}}/services/new"> |
| +<form class="settings-row" method="post" action="{{.Base}}/services/new"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| <input type="text" name="name" placeholder="name, e.g. ci-runner"> |
| <select name="role"> |
| @@ -157,7 +157,7 @@ |
| {{range .ServiceRungs}}<label class="small"><input type="checkbox" name="rungs" value="{{.}}"> {{.}}</label>{{end}} |
| <label class="small">Commands, for a run credential: |
| <input type="text" name="commands" placeholder="import classic, import sync"></label> |
| - <button type="submit">Mint credential</button> |
| + <button type="submit" class="btn-sm">Mint credential</button> |
| </form> |
| <p class="small">The secret is shown once, on the next screen, and is never recoverable from here. |
| Minting and rotating both ask for your passkey; revoking does not, so it stays one step in an |
| @@ -167,7 +167,7 @@ |
| <p class="small">This account’s Errors log level could not be read just now, so it is not |
| shown and cannot be changed from here. Reload before concluding anything.</p> |
| {{else}} |
| -<form class="signin" method="post" action="{{.Base}}/errors/level"> |
| +<form class="settings-row" method="post" action="{{.Base}}/errors/level"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| <label>Log lines counted as errors: |
| <select name="level"> |
| @@ -175,7 +175,7 @@ shown and cannot be changed from here. Reload before concluding anything.</p> |
| <option value="warn"{{if eq .ErrLevelSetting.LogLevel "warn"}} selected{{end}}>warn and above</option> |
| </select> |
| </label> |
| - <button type="submit">Save</button> |
| + <button type="submit" class="btn-sm">Save</button> |
| </form> |
| <p class="small">Currently {{.ErrLevelSetting.LogLevel}}, from the {{.ErrLevelSetting.LogLevelFrom}} |
| — the level for every app without its own setting, which an app’s own Settings tab |
| @@ -188,7 +188,7 @@ nothing here.</p> |
| <p class="small">This account’s analytics setting could not be read just now. Reload before |
| concluding anything.</p> |
| {{else}} |
| -<form class="signin" method="post" action="{{.Base}}/analytics/setting"> |
| +<form class="settings-row" method="post" action="{{.Base}}/analytics/setting"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| <label>Count page views at the edge: |
| <select name="count"> |
| @@ -196,7 +196,7 @@ concluding anything.</p> |
| <option value="edge"{{if eq .AnalyticsSetting.Count "edge"}} selected{{end}}>on (edge)</option> |
| </select> |
| </label> |
| - <button type="submit">Save</button> |
| + <button type="submit" class="btn-sm">Save</button> |
| </form> |
| <p class="small">Currently {{.AnalyticsSetting.Count}}, from the {{.AnalyticsSetting.CountFrom}} |
| — for every app without its own setting, which an app’s own Settings tab overrides.</p> |
| @@ -214,10 +214,10 @@ is off until you turn it on.</p> |
| <p class="small">An account with no apps can be retired. Type <strong>{{.Account.Name}}</strong> to |
| confirm, then confirm with your passkey. Members and pending invitations go with it; nothing |
| outside this account is touched.</p> |
| -<form class="signin" method="post" action="{{.Base}}/delete"> |
| +<form class="settings-row" method="post" action="{{.Base}}/delete"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| <input type="text" name="confirm" placeholder="{{.Account.Name}}"> |
| - <button type="submit">Delete account</button> |
| + <button type="submit" class="btn-sm btn-danger">Delete account</button> |
| </form> |
| {{end}} |
| {{end}} |
diff --git a/internal/console/templates/apps.html b/internal/console/templates/apps.html| index adc59fe07..9bf1ecfd6 100644 |
| --- a/internal/console/templates/apps.html |
| +++ b/internal/console/templates/apps.html |
| @@ -2,8 +2,11 @@ |
| {{if .Welcome}}<p class="banner">Account created — welcome! You signed up as <strong>{{.Address}}</strong>.</p>{{end}} |
| {{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}} |
| {{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| +<div class="pagehead"> |
| + <p class="eyebrow">Account · {{.Account.Name}}</p> |
| {{if .Apps}} |
| -<h1>{{.Account.Name}}</h1> |
| + <h1>Apps</h1> |
| +</div> |
| <div class="tablewrap"> |
| <table> |
| <tr><th scope="col">App</th><th scope="col">Running at</th><th scope="col">Health</th><th scope="col">{{$.StatusCopy.ObservedLabel}}</th></tr> |
| @@ -18,7 +21,8 @@ |
| </table> |
| </div> |
| {{else}} |
| -<h1>Welcome to {{.ConsoleName}}</h1> |
| + <h1>Welcome to {{.ConsoleName}}</h1> |
| +</div> |
| <p>The account <strong>{{.Account.Name}}</strong> is ready. No apps live here yet — claim a name below and it's yours.</p> |
| {{end}} |
| {{if .TrashN}}<p class="small"><a href="{{.Nav}}/trash">Trash ({{.TrashN}})</a>: deleted apps you can still |
diff --git a/internal/console/templates/newaccount.html b/internal/console/templates/newaccount.html| index ef42103ca..fcdf03e8a 100644 |
| --- a/internal/console/templates/newaccount.html |
| +++ b/internal/console/templates/newaccount.html |
| @@ -1,9 +1,12 @@ |
| {{define "newaccount"}}{{template "top" .}} |
| -<h1>New account</h1> |
| -<p class="lede">An account is a project or a team: it owns apps, has members, |
| -and deploys independently of your other accounts.</p> |
| {{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| {{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}} |
| +<div class="pagehead"> |
| + <p class="eyebrow">Accounts</p> |
| + <h1>New account</h1> |
| + <p class="lede">An account is a project or a team: it owns apps, has members, |
| +and deploys independently of your other accounts.</p> |
| +</div> |
| <form class="signin" method="post" action="/accounts/new"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| <label class="visually-hidden" for="account-name">Account name</label> |
| @@ -12,9 +15,9 @@ and deploys independently of your other accounts.</p> |
| <p class="small">a-z, 0-9 and hyphens — it appears in your URLs</p> |
| <button type="submit">Create account</button> |
| </form> |
| -<p class="small">Names are deliberately not unique — two accounts may both be |
| -called “blog”. Identity is the short id in the URL, so there is nothing to |
| -squat. You will be its first owner, and you can invite teammates from the |
| -account's page.</p> |
| +<p class="small">Names are deliberately not unique. Two accounts may both be |
| +called “blog”. Identity is the short id in the URL, so nobody can reserve a |
| +name. You will be its first owner, and you can invite teammates from the |
| +account's Team page.</p> |
| {{if .Account}}<p class="small"><a href="{{.Nav}}/">Back to {{.Account.Name}}</a></p>{{end}} |
| {{template "bottom" .}}{{end}} |
diff --git a/internal/console/templates/trash.html b/internal/console/templates/trash.html| index cc6c71673..1e93e1ff7 100644 |
| --- a/internal/console/templates/trash.html |
| +++ b/internal/console/templates/trash.html |
| @@ -1,7 +1,10 @@ |
| {{define "trash"}}{{template "top" .}} |
| {{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}} |
| {{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| -<h1>Trash</h1> |
| +<div class="pagehead"> |
| + <p class="eyebrow">Account · {{.Account.Name}}</p> |
| + <h1>Trash</h1> |
| +</div> |
| {{if .Trashed}} |
| <p>A deleted app serves nothing and is hidden from the app list, but everything it had — |
| its releases, its channels, its history — is still here. Restoring one brings all of that |
| @@ -12,6 +15,13 @@ |
| <p class="small">Left alone, the platform destroys a trashed app on its own on the date in the last column: |
| 30 days after it was deleted, or 3 days for a temporary app. That is permanent. The objects go, and the |
| name is free for anyone in this account to claim again.</p> |
| +{{if .IsOwner}} |
| +<p class="small">Deleting now does what the wait would do on its own, immediately and |
| + permanently: every object the app owns is destroyed and its name is freed. There is no undo |
| + and no copy anywhere. Type the app's name to confirm, then confirm with your passkey. A |
| + signed-in browser on its own is not enough. An app still marked as production cannot be |
| + permanently deleted, whatever you type. Turn its safety delay off first.</p> |
| +{{end}} |
| <div class="tablewrap"> |
| <table> |
| <tr><th>App</th><th>Deleted by</th><th>Deleted</th><th>Destroyed on</th><th></th></tr> |
| @@ -27,28 +37,20 @@ |
| <input type="hidden" name="app" value="{{.App}}"> |
| <button class="linkish" type="submit">Restore</button> |
| </form> |
| + {{if $.IsOwner}} |
| + <form class="settings-row" method="post" action="{{$.Base}}/trash/delete"> |
| + <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| + <input type="hidden" name="app" value="{{.App}}"> |
| + <label class="visually-hidden" for="confirm-{{.App}}">Type {{.App}} to delete it permanently</label> |
| + <input id="confirm-{{.App}}" type="text" name="confirm" placeholder="{{.App}}"> |
| + <button type="submit" class="btn-sm btn-danger">Delete permanently</button> |
| + </form> |
| + {{end}} |
| </td> |
| </tr> |
| {{end}} |
| </table> |
| </div> |
| -{{if .IsOwner}} |
| -<h2>Delete now</h2> |
| -<p class="small">Deleting now does what the wait would do on its own, immediately and |
| - permanently: every object the app owns is destroyed and its name is freed. There is no undo |
| - and no copy anywhere. Type the app's name to confirm, then confirm with your passkey. A |
| - signed-in browser on its own is not enough. An app still marked as production cannot be |
| - permanently deleted, whatever you type. Turn its safety delay off first.</p> |
| -{{range .Trashed}} |
| -<form class="signin" method="post" action="{{$.Base}}/trash/delete"> |
| - <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| - <input type="hidden" name="app" value="{{.App}}"> |
| - <label class="visually-hidden" for="confirm-{{.App}}">Type {{.App}} to delete it permanently</label> |
| - <input id="confirm-{{.App}}" type="text" name="confirm" placeholder="{{.App}}"> |
| - <button type="submit">Delete “{{.App}}” permanently</button> |
| -</form> |
| -{{end}} |
| -{{end}} |
| {{else}} |
| <p>Nothing here. An app deleted with <code>carlos apps delete</code> waits in this Trash, |
| restorable the whole time, until the platform destroys it: 30 days for most apps, 3 days for a |