Public: anyone can read this; the crew can change it.

Empty words: move the admin and system pages onto the shared table #15909

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/15899-empty-words-move-the-admin-and-system-pa → main 13 commits fork 2 threads · 2 unresolved

  • Merged. mason/15899-empty-words-move-the-admin-and-system-pa was merged into main as 0882841.

Review

Sign in to review this change.
16 files changed +70 −39
docs/features/empty-words.md +1
@@ -12,6 +12,7 @@ A filtered view (closed issues, one kind of event) passes its own title to `empt
1212 Pages that still word their own "No …" line, as `empty({ title })` or a `<p class="… muted …">No …`, are counted in the ratchet at the top of `test/empty-words-all.test.ts`: the count may only fall. Try `/my-repos` on a fresh account, `/releases`, or `/root/fresh/forks`.
1313 `test/empty-states.test.ts` and `test/empty-words-all.test.ts` hold every kind to its sentence, any reason to being more than the sentence, and any link to a place that exists.
1414
15 The admin, system and account pages draw their small empty lists (codes, keys, changes, runners, teams, devices, and the system page's measurements) from the same table. A row there may have no link, and may carry a `reason` where the page around it does not already say what fills the list.
1516 The studio and file renderers draw theirs from the same table: `domains`, `dumps`, `jobs`, `holds`,
1617 `appList`, and the `preview`, `results`, `components` and `dependencies` of a rendered file. A
1718 `reason` is set only where the page does not already say what the list is; a `label` with no `href`
src/core/empty_words.ts +14
@@ -61,6 +61,20 @@ const TABLE = {
6161 labels: { sentence: "No labels yet." },
6262 events: { sentence: "No events yet." },
6363 displays: { sentence: "No displays yet.", reason: "Add a display.json to a repository's default branch to make one." },
64 changes: { sentence: "No change yet." },
65 auditApps: { sentence: "No apps to audit.", reason: "An app's policy shows here once it has a contract.", label: "New app", href: "/apps/new" },
66 dirs: { sentence: "No directories under the forge's data." },
67 heap: { sentence: "No heap census yet." },
68 disks: { sentence: "No disks or network were read." },
69 egress: { sentence: "No app holds an egress connection open." },
70 runners: { sentence: "No runner is enrolled." },
71 billingCodes: { sentence: "No code yet." },
72 trusted: { sentence: "No one is trusted, so every pull waits for review." },
73 linkedVisitors: { sentence: "No forge has been linked to a visitor yet.", reason: "Forges started from a plan or a code are; a Stripe checkout is not yet." },
74 returnVisitors: { sentence: "No visitor has come back in the window." },
75 teams: { sentence: "No teams yet." },
76 teamAgents: { sentence: "No agents yet." },
77 loads: { sentence: "No load reports in the last 30 days." },
6478 } as const satisfies Readonly<Record<string, EmptyWords>>;
6579
6680 export type EmptyKind = keyof typeof TABLE;
src/web/empty_words.ts +19 −2
@@ -19,6 +19,20 @@ const ICONS = {
1919 apps: "rocket",
2020 people: "users",
2121 waves: "activity",
22 changes: "activity",
23 auditApps: "shield",
24 dirs: "repo",
25 heap: "activity",
26 disks: "activity",
27 egress: "check",
28 runners: "bot",
29 billingCodes: "key",
30 trusted: "users",
31 linkedVisitors: "users",
32 returnVisitors: "users",
33 teams: "users",
34 teamAgents: "bot",
35 loads: "activity",
2236 domains: "globe",
2337 dumps: "repo",
2438 jobs: "clock",
@@ -76,10 +90,13 @@ export function emptyList(kind: keyof typeof ICONS, o: EmptyOptions = {}): Html
7690 }
7791
7892 /** A list of none inside a block that already has its next step (a form just below): one muted
79 * line, the sentence and its reason, no picture and no link, so the form stays in view. */
80 export function emptyLine(kind: Exclude<EmptyKind, keyof typeof ICONS>, o: { reason?: string } = {}): Html {
93 * line, the sentence and its reason, no picture and no link, so the form stays in view. It is also
94 * the compact form for small inline lists (a fieldset, a list item, a narrow phone), where the
95 * picture block would cost layout and bytes; any kind may be drawn this way. */
96 export function emptyLine(kind: EmptyKind, o: { reason?: string; id?: string } = {}): Html {
8197 const w: EmptyWords = EMPTY_WORDS[kind];
8298 const reason = o.reason ?? w.reason;
99 if (o.id !== undefined) return html`<p class="muted small" id="${o.id}">${reason === undefined ? w.sentence : `${w.sentence} ${reason}`}</p>`;
83100 return html`<p class="muted small">${reason === undefined ? w.sentence : `${w.sentence} ${reason}`}</p>`;
84101 }
85102
src/web/pages/admin-limits.ts +2 −1
@@ -26,6 +26,7 @@ import { field, readForm } from "../form.ts";
2626 import { html, when, type Html } from "../html.ts";
2727 import { flashTo, page } from "../layout.ts";
2828 import { btn, confirmAction, icon, row, time } from "../ui.ts";
29 import { emptyList } from "../empty_words.ts";
2930 import { plansRow } from "../settings/plans.ts";
3031 import { accountSections } from "./origins.ts";
3132
@@ -234,7 +235,7 @@ export function limitsPage(ctx: Ctx): Response {
234235 ${historyBlock("Quota changes", quotaHistory)}
235236 <section class="settings-block mt">
236237 <h2>Changes</h2>
237 ${history.length === 0 ? html`<p class="muted small">No change yet.</p>` : html`<ul class="list">${history}</ul>`}
238 ${history.length === 0 ? emptyList("changes") : html`<ul class="list">${history}</ul>`}
238239 </section>`;
239240 const response = page({
240241 ctx,
src/web/pages/audit.ts +2 −7
@@ -46,12 +46,12 @@ import { flashTo, page } from "../layout.ts";
4646 import {
4747 badge,
4848 btn,
49 empty,
5049 icon,
5150 row,
5251 sha,
5352 time,
5453 } from "../ui.ts";
54 import { emptyList } from "../empty_words.ts";
5555
5656 const AUDIT_LIMIT = 200;
5757
@@ -132,12 +132,7 @@ export async function auditPage(ctx: Ctx): Promise<Response> {
132132 </p>
133133 </div>
134134 ${audited.length === 0
135 ? empty({
136 icon: "shield",
137 title: "No apps to audit",
138 note: "An app's policy shows here once it has a contract.",
139 action: btn("New app", { href: "/apps/new", variant: "link" }),
140 })
135 ? emptyList("auditApps")
141136 : html`<p class="mb">
142137 ${summary(sound.length, open, unsound.length, unread.length)}
143138 ${when(disobeying.length > 0, () =>
src/web/pages/billing.ts +2 −1
@@ -28,6 +28,7 @@ import { field, kept, readForm, refused, type Refused } from "../form.ts";
2828 import { html, type Html } from "../html.ts";
2929 import { flashTo, page } from "../layout.ts";
3030 import { btn, copyField, field as formField, selectField } from "../ui.ts";
31 import { emptyList } from "../empty_words.ts";
3132 import type { FieldOptions } from "../ui.ts";
3233 import { accountSections } from "./origins.ts";
3334
@@ -84,7 +85,7 @@ function codesSection(ctx: Ctx, shown: Shown | undefined, r: Refused | undefined
8485 ${formField(kept(r, { label: "Expires", name: "expires", type: "date", value: "" }))}
8586 ${btn("Make a code", { variant: "primary" })}
8687 </form>
87 ${lines.length === 0 ? html`<p class="muted small">No code yet.</p>` : html`<ul class="list setting-list">${lines}</ul>`}
88 ${lines.length === 0 ? emptyList("billingCodes") : html`<ul class="list setting-list">${lines}</ul>`}
8889 </section>`;
8990 }
9091
src/web/pages/capacity.ts +3 −4
@@ -19,6 +19,7 @@ import { field, readForm } from "../form.ts";
1919 import { html, when, type Html } from "../html.ts";
2020 import { flashTo } from "../layout.ts";
2121 import { badge, btn, row, time } from "../ui.ts";
22 import { emptyLine } from "../empty_words.ts";
2223 import { usageShell } from "./usage-tabs.ts";
2324 import { REACH_SETTINGS } from "../../actions/child_reach.ts";
2425
@@ -173,9 +174,7 @@ export function capacityPage(ctx: Ctx): Response {
173174 "Egress connections",
174175 open.length === 0
175176 ? html`<p class="muted small" id="egress-npm">${npm}</p>
176 <p class="muted small" id="egress-open">
177 No app holds an egress connection open.
178 </p>`
177 ${emptyLine("egress", { id: "egress-open" })}`
outdated

Principle 7 and issue box 1: this is the table sentence in a hand-made <p>, not emptyList("egress"). Give emptyList a compact form and use it here, or raise the size budget with a reason.

179178 : html`<ul class="list setting-list" id="egress-open">
180179 ${row({ id: "egress-npm", title: npm })}
181180 ${open.map((r) =>
@@ -212,7 +211,7 @@ export function capacityPage(ctx: Ctx): Response {
212211 )}
213212 <p class="small" id="load">${loadLine(ctx.app)}</p>
214213 ${table}
215 ${block("Changes", history.length === 0 ? html`<p class="muted small">No change yet.</p>` : html`<ul class="list">${history}</ul>`, "changes")}
214 ${block("Changes", history.length === 0 ? emptyLine("changes") : html`<ul class="list">${history}</ul>`, "changes")}
outdated

Same: Changes draws its own <p class="muted small"> from EMPTY_WORDS.changes.sentence. The other pages draw emptyList("changes"); this one should too, so the same state looks the same everywhere.

216215 ${happened}${connections}${swap}`;
217216 const response = usageShell(ctx, "capacity", body);
218217 notePhase(ctx.request, "render", performance.now() - rendering);
src/web/pages/runners.ts +2 −1
@@ -18,6 +18,7 @@ import { readForm } from "../form.ts";
1818 import { html } from "../html.ts";
1919 import { flashTo, page } from "../layout.ts";
2020 import { badge, btn, icon, row, time } from "../ui.ts";
21 import { emptyList } from "../empty_words.ts";
2122 import { accountSections } from "./origins.ts";
2223
2324 const HERE = "/settings/runners";
@@ -62,7 +63,7 @@ export function runnersPage(ctx: Ctx): Response {
6263 const body = html`<section class="settings-block">
6364 <p class="muted small">Enrol one with <code>POST /api/v1/admin/runners</code>.</p>
6465 ${seen.value.length === 0
65 ? html`<p class="muted small">No runner is enrolled.</p>`
66 ? emptyList("runners")
6667 : html`<ul class="list setting-list" id="runner-list">
6768 ${seen.value.map((r) => runnerRow(r, held.get(r.id) ?? 0, work.get(r.id) ?? { jobs: 1, ran: 0 }, now))}
6869 </ul>`}
src/web/pages/settings.ts +2 −1
@@ -122,6 +122,7 @@ import {
122122 time,
123123 tlEvent,
124124 } from "../ui.ts";
125 import { emptyLine } from "../empty_words.ts";
125126 import { cutWaveFor } from "../../actions/cut_wave.ts";
126127 import { liveClientJs } from "../live.ts";
127128 import { outsideAgentsJs } from "./outside-agents-live.ts";
@@ -909,7 +910,7 @@ export function appVisitorsView(v: AppVitals): Html {
909910 <div><dt>p75 CLS</dt><dd>${shiftText(v.clsP75)}</dd></div>
910911 ${v.wait === undefined ? "" : html`<div><dt>Slowest wait, 10 min</dt><dd>${relayWaitWords(v.wait)}</dd></div>`}
911912 </dl>
912 ${spark ? html`<div class="bar muted">${spark}</div>` : html`<p class="muted small mt">No load reports in the last 30 days</p>`}
913 ${spark ? html`<div class="bar muted">${spark}</div>` : emptyLine("loads")}
913914 </section>`;
914915 }
915916
src/web/pages/system.ts +4 −3
@@ -68,6 +68,7 @@ import { lastDrill, lastPass } from "../../snapshot/drills.ts";
6868 import { stalePullsSection } from "./maintenance.ts";
6969 import { shapeWords } from "../../engine/mode.ts";
7070 import { badge, btn, chartBox, disclosure, meter, pill, row, time } from "../ui.ts";
71 import { EMPTY_WORDS, emptyLine, emptyList } from "../empty_words.ts";
7172 import { LARGEST_DIRS, largestDirs, type LargestDirs } from "../../system/largest_dirs.ts";
7273 import { DB_FILE_CAP, DB_GROWTH_MAX, TOP, dbSize, dbSizeNeed, type DbSize } from "../../system/db_size.ts";
7374 import { resultWords, weekRows, weekWords, type WeekRow } from "../../maintain/week_line.ts";
@@ -113,7 +114,7 @@ export function largestDirsSection(found: LargestDirs | null): Html {
113114 ${found === null
114115 ? html`<p class="muted small">Being measured; reload in a moment.</p>`
115116 : found.dirs.length === 0
116 ? html`<p class="muted small">No directories under the forge's data.</p>`
117 ? emptyList("dirs")
117118 : html`<ul class="list" aria-label="The ${String(LARGEST_DIRS)} largest directories under the forge's data">${found.dirs.map((d) => figureRow(d.name, bytes(d.bytes), { dir: d.name, bytes: String(d.bytes) }))}</ul>
118119 <p class="muted small">Measured ${time(found.at)}</p>`}</section>`;
119120 }
@@ -327,7 +328,7 @@ export function heapCensusSection(heads: readonly Omit<Census, "byType">[], grew
327328 const last = heads[heads.length - 1];
328329 const said =
329330 first === undefined || last === undefined
330 ? "No heap census yet."
331 ? EMPTY_WORDS.heap.sentence
331332 : heads.length === 1
332333 ? `One heap census, at ${String(first.uptimeMin)} min up: ${first.objectCount.toLocaleString("en-US")} objects. The next shows what grew since.`
333334 : `${String(heads.length)} heap censuses: ${first.objectCount.toLocaleString("en-US")} objects at the first (${String(first.uptimeMin)} min up), ${last.objectCount.toLocaleString("en-US")} at the last (${String(last.uptimeMin)} min up).`;
@@ -696,7 +697,7 @@ export function regions(v: SystemView): Record<string, string> {
696697 temps: html`${v.temps.map((t) => `${t.chip} ${t.label} ${t.celsius.toFixed(0)}°C`).join(" · ")}`,
697698 "sys-disks":
698699 v.disks.length + v.io.length + v.net.length === 0
699 ? html`<li class="muted">No disks or network were read.</li>`
700 ? html`<li>${emptyLine("disks")}</li>`
700701 : html`${v.disks.map((d) => meterRow(d.mount, d.usedBytes, d.totalBytes, `${bytes(d.usedBytes)} / ${bytes(d.totalBytes)} ${d.fs}`))}
701702 ${v.io.map((d) => figureRow(d.name, `R ${rateOf(d.readBytesPerSecond)} W ${rateOf(d.writeBytesPerSecond)}`, { io: d.name }))}
702703 ${v.net.map((n) => figureRow(n.name, `↓ ${rateOf(n.rxBytesPerSecond)} ↑ ${rateOf(n.txBytesPerSecond)}`, { net: n.name }))}`,
src/web/pages/teams.ts +3 −2
@@ -18,6 +18,7 @@ import { eventStream } from "../../http/sse.ts";
1818 import { html, raw, type Html } from "../html.ts";
1919 import { flashTo, page } from "../layout.ts";
2020 import { btn, icon, row, time } from "../ui.ts";
21 import { emptyLine, emptyList } from "../empty_words.ts";
2122 import { accountSections } from "./origins.ts";
2223
2324 const isAdminPerson = (ctx: Ctx): boolean =>
@@ -50,7 +51,7 @@ function regions(ctx: Ctx, timed = false): Record<string, string> | undefined {
5051 });
5152 const out: Record<string, Html> = {
5253 "teams-total": html`${String(total)}%`,
53 "teams-cards": cards.length === 0 ? html`<p class="muted small">No teams yet.</p>` : html`<ul class="list">${cards}</ul>`,
54 "teams-cards": cards.length === 0 ? emptyList("teams") : html`<ul class="list">${cards}</ul>`,
5455 "teams-changes":
5556 changes.length === 0
5657 ? html``
@@ -89,7 +90,7 @@ function teamBody(t: Team, agents: readonly Agent[], waiting: readonly QueuedPul
8990 <fieldset class="field">
9091 <legend>Members</legend>
9192 ${agents.length === 0
92 ? html`<span class="muted small">No agents yet.</span>`
93 ? emptyLine("teamAgents")
9394 : agents.map(
9495 (a) => html`<label class="small">
9596 <input type="checkbox" name="member" value="${a.user.id}" ${t.members.includes(a.user.id) ? "checked" : ""} />
src/web/pages/trusted.ts +2 −1
@@ -19,6 +19,7 @@ import { field, readForm } from "../form.ts";
1919 import { html } from "../html.ts";
2020 import { flashTo, page } from "../layout.ts";
2121 import { badge, btn, icon, row, time } from "../ui.ts";
22 import { emptyList } from "../empty_words.ts";
2223 import { accountSections } from "./origins.ts";
2324
2425 function owner(ctx: Ctx): Response | undefined {
@@ -64,7 +65,7 @@ export function trustedPage(ctx: Ctx): Response {
6465 <section class="settings-block">
6566 <h2>Trusted sources</h2>
6667 ${entries.length === 0
67 ? html`<p class="muted small">No one is trusted, so every pull waits for review.</p>`
68 ? emptyList("trusted")
6869 : html`<ul class="list setting-list" id="trusted-list">
6970 ${entries.map((s) => {
7071 const lapsed = s.until <= now.toISOString();
src/web/pages/visitors.ts +3 −2
@@ -16,6 +16,7 @@ import { html, type Html } from "../html.ts";
1616 import { flashTo } from "../layout.ts";
1717 import { TRAFFIC_TONES } from "../studio/kpi_row.ts";
1818 import { btn, row } from "../ui.ts";
19 import { emptyList } from "../empty_words.ts";
1920
2021 const W = 600;
2122 const H = 72;
@@ -80,7 +81,7 @@ export function ledBlock(ctx: Ctx): Html {
8081 return html`<section class="settings-block">
8182 <h2>What led to a forge</h2>
8283 ${forges.length === 0
83 ? html`<p class="muted small">No forge has been linked to a visitor yet. Forges started from a plan or a code are; a Stripe checkout is not yet.</p>`
84 ? emptyList("linkedVisitors")
8485 : html`<ul class="list setting-list">${forges.map(led)}</ul>`}
8586 </section>`;
8687 }
@@ -101,7 +102,7 @@ export function visitorsBlock(ctx: Ctx, now: number): Html {
101102 : html`<p class="small muted">${r.newVisitors} new and ${r.returningVisitors} returning visitors in the last ${r.days} days; the darker bars are the ones who came back.</p>
102103 <div class="muted">${bars(r.perDay)}</div>
103104 ${r.returning.length === 0
104 ? html`<p class="muted small" data-empty>No visitor has come back in the window.</p>`
105 ? html`<div data-empty>${emptyList("returnVisitors")}</div>`
105106 : html`<ul class="list setting-list">${r.returning.map(returningRow)}</ul>`}
106107 <p class="small muted">A visitor with no cookie is guessed from the browser, system, language and network, and marked guessed. <a href="/privacy">What is kept</a>.</p>`}
107108 </section>`;
test/account-rows.test.ts +2 −3
@@ -85,7 +85,7 @@ test("keys are rows under a Computer keys heading, each with its Remove link", a
8585 expect(m).toContain('action="/settings/keys"');
8686 });
8787
88 test("empty lists are one muted sentence, not a panel", async () => {
88 test("empty lists draw from the shared empty table", async () => {
8989 const other = await fetch(`${base}/signup`, {
9090 method: "POST",
9191 body: new URLSearchParams({ username: "bob", email: "[email protected]", password: "account-password" }),
@@ -94,11 +94,10 @@ test("empty lists are one muted sentence, not a panel", async () => {
9494 const c = (other.headers.get("set-cookie") ?? "").split(";")[0]!;
9595 const get = async (path: string) => (await (await fetch(`${base}${path}`, { headers: { cookie: c } })).text());
9696 const tokens = await get("/settings/tokens");
97 expect(tokens).toContain("No access codes yet.");
9798 expect(tokens).toContain('<p class="muted">No access codes yet.');
98 expect(tokens).not.toContain("empty-title");
9999 const keys = await get("/settings/keys");
100100 expect(keys).toContain('<p class="muted">No computer keys yet.');
101 expect(keys).not.toContain("empty-title");
102101 const card = String(sessionsCard([], "/settings"));
103102 expect(card).toContain('<p class="muted">Not signed in on any browser.</p>');
104103 expect(card).not.toContain("<ul");
test/empty-states.test.ts +9 −1
@@ -115,7 +115,7 @@ test("the six lists take their empty sentence from one table, each with a single
115115 const once = kind === "apps" || kind === "board";
116116 // waves: the one step is a tell button (a form), not a link.
117117 if (kind === "waves") {
118 expect(mine[0]).toContain(w.label);
118 expect(mine[0]).toContain(w.label!);
119119 expect(mine[0]).toContain('action="/root/fresh/tell"');
120120 continue;
121121 }
@@ -195,3 +195,11 @@ test("every empty list page has one link in its empty state, or is allowed with
195195 test("every allowed page names its reason", () => {
196196 for (const [path, why] of Object.entries(ALLOWED)) expect(`${path}: ${why.length > 10}`).toBe(`${path}: true`);
197197 });
198
199 test("every kind in the table is one sentence, and a link needs both its label and its place, or is handed its place", () => {
200 for (const [kind, w] of Object.entries(EMPTY_WORDS)) {
201 expect(w.sentence.endsWith("."), kind).toBe(true);
202 if (w.href !== undefined) expect(w.label !== undefined, kind).toBe(true);
203 expect((String(emptyList(kind as Parameters<typeof emptyList>[0])).match(/<a\s/g) ?? []).length, kind).toBe(w.label && w.href ? 1 : 0);
204 }
205 });
test/empty-words-all.test.ts −10
@@ -25,13 +25,9 @@ const OWN_FORM = /empty\(\{\s*(?:icon: [^,]+,\s*)?title: [`"]No |empty\("No |<p
2525 // (repository pages), #15902 (apps, forges) and #15903 (studio, renderers); #15851 waits for them.
2626 const OWN_WORDS: Readonly<Record<string, number>> = {
2727 "src/web/diff-view.ts": 1,
28 "src/web/pages/admin-limits.ts": 1,
29 "src/web/pages/audit.ts": 1,
30 "src/web/pages/billing.ts": 1,
3128 "src/web/pages/boards.ts": 1,
3229 "src/web/pages/browse.ts": 1,
3330 "src/web/pages/build_shots.ts": 1,
34 "src/web/pages/capacity.ts": 1,
3531 "src/web/pages/commits.ts": 1,
3632 "src/web/pages/contribute.ts": 1,
3733 "src/web/pages/display.ts": 1,
@@ -45,13 +41,7 @@ const OWN_WORDS: Readonly<Record<string, number>> = {
4541 "src/web/pages/packs.ts": 2,
4642 "src/web/pages/pull.ts": 1,
4743 "src/web/pages/reports.ts": 1,
48 "src/web/pages/runners.ts": 1,
49 "src/web/pages/settings.ts": 1,
5044 "src/web/pages/sources.ts": 1,
51 "src/web/pages/system.ts": 1,
52 "src/web/pages/teams.ts": 1,
53 "src/web/pages/trusted.ts": 1,
54 "src/web/pages/visitors.ts": 1,
5545 "src/web/studio/explore.ts": 1,
5646 "src/web/studio/hold.ts": 1,
5747 };

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs