Public: anyone can read this; the crew can change it.
Empty words: move the admin and system pages onto the shared table #15909
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/15899-empty-words-move-the-admin-and-system-pa → main 13 commits fork 2 threads · 2 unresolved
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 | ||
| 12 | 12 | 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`. |
| 13 | 13 | `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. |
| 14 | 14 | |
| 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. | |
| 15 | 16 | The studio and file renderers draw theirs from the same table: `domains`, `dumps`, `jobs`, `holds`, |
| 16 | 17 | `appList`, and the `preview`, `results`, `components` and `dependencies` of a rendered file. A |
| 17 | 18 | `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 = { | ||
| 61 | 61 | labels: { sentence: "No labels yet." }, |
| 62 | 62 | events: { sentence: "No events yet." }, |
| 63 | 63 | 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." }, | |
| 64 | 78 | } as const satisfies Readonly<Record<string, EmptyWords>>; |
| 65 | 79 | |
| 66 | 80 | export type EmptyKind = keyof typeof TABLE; |
src/web/empty_words.ts +19 −2
| @@ -19,6 +19,20 @@ const ICONS = { | ||
| 19 | 19 | apps: "rocket", |
| 20 | 20 | people: "users", |
| 21 | 21 | 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", | |
| 22 | 36 | domains: "globe", |
| 23 | 37 | dumps: "repo", |
| 24 | 38 | jobs: "clock", |
| @@ -76,10 +90,13 @@ export function emptyList(kind: keyof typeof ICONS, o: EmptyOptions = {}): Html | ||
| 76 | 90 | } |
| 77 | 91 | |
| 78 | 92 | /** 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 { | |
| 81 | 97 | const w: EmptyWords = EMPTY_WORDS[kind]; |
| 82 | 98 | 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>`; | |
| 83 | 100 | return html`<p class="muted small">${reason === undefined ? w.sentence : `${w.sentence} ${reason}`}</p>`; |
| 84 | 101 | } |
| 85 | 102 |
src/web/pages/admin-limits.ts +2 −1
| @@ -26,6 +26,7 @@ import { field, readForm } from "../form.ts"; | ||
| 26 | 26 | import { html, when, type Html } from "../html.ts"; |
| 27 | 27 | import { flashTo, page } from "../layout.ts"; |
| 28 | 28 | import { btn, confirmAction, icon, row, time } from "../ui.ts"; |
| 29 | import { emptyList } from "../empty_words.ts"; | |
| 29 | 30 | import { plansRow } from "../settings/plans.ts"; |
| 30 | 31 | import { accountSections } from "./origins.ts"; |
| 31 | 32 | |
| @@ -234,7 +235,7 @@ export function limitsPage(ctx: Ctx): Response { | ||
| 234 | 235 | ${historyBlock("Quota changes", quotaHistory)} |
| 235 | 236 | <section class="settings-block mt"> |
| 236 | 237 | <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>`} | |
| 238 | 239 | </section>`; |
| 239 | 240 | const response = page({ |
| 240 | 241 | ctx, |
src/web/pages/audit.ts +2 −7
| @@ -46,12 +46,12 @@ import { flashTo, page } from "../layout.ts"; | ||
| 46 | 46 | import { |
| 47 | 47 | badge, |
| 48 | 48 | btn, |
| 49 | empty, | |
| 50 | 49 | icon, |
| 51 | 50 | row, |
| 52 | 51 | sha, |
| 53 | 52 | time, |
| 54 | 53 | } from "../ui.ts"; |
| 54 | import { emptyList } from "../empty_words.ts"; | |
| 55 | 55 | |
| 56 | 56 | const AUDIT_LIMIT = 200; |
| 57 | 57 | |
| @@ -132,12 +132,7 @@ export async function auditPage(ctx: Ctx): Promise<Response> { | ||
| 132 | 132 | </p> |
| 133 | 133 | </div> |
| 134 | 134 | ${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") | |
| 141 | 136 | : html`<p class="mb"> |
| 142 | 137 | ${summary(sound.length, open, unsound.length, unread.length)} |
| 143 | 138 | ${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"; | ||
| 28 | 28 | import { html, type Html } from "../html.ts"; |
| 29 | 29 | import { flashTo, page } from "../layout.ts"; |
| 30 | 30 | import { btn, copyField, field as formField, selectField } from "../ui.ts"; |
| 31 | import { emptyList } from "../empty_words.ts"; | |
| 31 | 32 | import type { FieldOptions } from "../ui.ts"; |
| 32 | 33 | import { accountSections } from "./origins.ts"; |
| 33 | 34 | |
| @@ -84,7 +85,7 @@ function codesSection(ctx: Ctx, shown: Shown | undefined, r: Refused | undefined | ||
| 84 | 85 | ${formField(kept(r, { label: "Expires", name: "expires", type: "date", value: "" }))} |
| 85 | 86 | ${btn("Make a code", { variant: "primary" })} |
| 86 | 87 | </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>`} | |
| 88 | 89 | </section>`; |
| 89 | 90 | } |
| 90 | 91 |
src/web/pages/capacity.ts +3 −4
| @@ -19,6 +19,7 @@ import { field, readForm } from "../form.ts"; | ||
| 19 | 19 | import { html, when, type Html } from "../html.ts"; |
| 20 | 20 | import { flashTo } from "../layout.ts"; |
| 21 | 21 | import { badge, btn, row, time } from "../ui.ts"; |
| 22 | import { emptyLine } from "../empty_words.ts"; | |
| 22 | 23 | import { usageShell } from "./usage-tabs.ts"; |
| 23 | 24 | import { REACH_SETTINGS } from "../../actions/child_reach.ts"; |
| 24 | 25 | |
| @@ -173,9 +174,7 @@ export function capacityPage(ctx: Ctx): Response { | ||
| 173 | 174 | "Egress connections", |
| 174 | 175 | open.length === 0 |
| 175 | 176 | ? 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" })}` | |
| 179 | 178 | : html`<ul class="list setting-list" id="egress-open"> |
| 180 | 179 | ${row({ id: "egress-npm", title: npm })} |
| 181 | 180 | ${open.map((r) => |
| @@ -212,7 +211,7 @@ export function capacityPage(ctx: Ctx): Response { | ||
| 212 | 211 | )} |
| 213 | 212 | <p class="small" id="load">${loadLine(ctx.app)}</p> |
| 214 | 213 | ${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. |
||
| 216 | 215 | ${happened}${connections}${swap}`; |
| 217 | 216 | const response = usageShell(ctx, "capacity", body); |
| 218 | 217 | notePhase(ctx.request, "render", performance.now() - rendering); |
src/web/pages/runners.ts +2 −1
| @@ -18,6 +18,7 @@ import { readForm } from "../form.ts"; | ||
| 18 | 18 | import { html } from "../html.ts"; |
| 19 | 19 | import { flashTo, page } from "../layout.ts"; |
| 20 | 20 | import { badge, btn, icon, row, time } from "../ui.ts"; |
| 21 | import { emptyList } from "../empty_words.ts"; | |
| 21 | 22 | import { accountSections } from "./origins.ts"; |
| 22 | 23 | |
| 23 | 24 | const HERE = "/settings/runners"; |
| @@ -62,7 +63,7 @@ export function runnersPage(ctx: Ctx): Response { | ||
| 62 | 63 | const body = html`<section class="settings-block"> |
| 63 | 64 | <p class="muted small">Enrol one with <code>POST /api/v1/admin/runners</code>.</p> |
| 64 | 65 | ${seen.value.length === 0 |
| 65 | ? html`<p class="muted small">No runner is enrolled.</p>` | |
| 66 | ? emptyList("runners") | |
| 66 | 67 | : html`<ul class="list setting-list" id="runner-list"> |
| 67 | 68 | ${seen.value.map((r) => runnerRow(r, held.get(r.id) ?? 0, work.get(r.id) ?? { jobs: 1, ran: 0 }, now))} |
| 68 | 69 | </ul>`} |
src/web/pages/settings.ts +2 −1
| @@ -122,6 +122,7 @@ import { | ||
| 122 | 122 | time, |
| 123 | 123 | tlEvent, |
| 124 | 124 | } from "../ui.ts"; |
| 125 | import { emptyLine } from "../empty_words.ts"; | |
| 125 | 126 | import { cutWaveFor } from "../../actions/cut_wave.ts"; |
| 126 | 127 | import { liveClientJs } from "../live.ts"; |
| 127 | 128 | import { outsideAgentsJs } from "./outside-agents-live.ts"; |
| @@ -909,7 +910,7 @@ export function appVisitorsView(v: AppVitals): Html { | ||
| 909 | 910 | <div><dt>p75 CLS</dt><dd>${shiftText(v.clsP75)}</dd></div> |
| 910 | 911 | ${v.wait === undefined ? "" : html`<div><dt>Slowest wait, 10 min</dt><dd>${relayWaitWords(v.wait)}</dd></div>`} |
| 911 | 912 | </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")} | |
| 913 | 914 | </section>`; |
| 914 | 915 | } |
| 915 | 916 |
src/web/pages/system.ts +4 −3
| @@ -68,6 +68,7 @@ import { lastDrill, lastPass } from "../../snapshot/drills.ts"; | ||
| 68 | 68 | import { stalePullsSection } from "./maintenance.ts"; |
| 69 | 69 | import { shapeWords } from "../../engine/mode.ts"; |
| 70 | 70 | import { badge, btn, chartBox, disclosure, meter, pill, row, time } from "../ui.ts"; |
| 71 | import { EMPTY_WORDS, emptyLine, emptyList } from "../empty_words.ts"; | |
| 71 | 72 | import { LARGEST_DIRS, largestDirs, type LargestDirs } from "../../system/largest_dirs.ts"; |
| 72 | 73 | import { DB_FILE_CAP, DB_GROWTH_MAX, TOP, dbSize, dbSizeNeed, type DbSize } from "../../system/db_size.ts"; |
| 73 | 74 | import { resultWords, weekRows, weekWords, type WeekRow } from "../../maintain/week_line.ts"; |
| @@ -113,7 +114,7 @@ export function largestDirsSection(found: LargestDirs | null): Html { | ||
| 113 | 114 | ${found === null |
| 114 | 115 | ? html`<p class="muted small">Being measured; reload in a moment.</p>` |
| 115 | 116 | : found.dirs.length === 0 |
| 116 | ? html`<p class="muted small">No directories under the forge's data.</p>` | |
| 117 | ? emptyList("dirs") | |
| 117 | 118 | : 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> |
| 118 | 119 | <p class="muted small">Measured ${time(found.at)}</p>`}</section>`; |
| 119 | 120 | } |
| @@ -327,7 +328,7 @@ export function heapCensusSection(heads: readonly Omit<Census, "byType">[], grew | ||
| 327 | 328 | const last = heads[heads.length - 1]; |
| 328 | 329 | const said = |
| 329 | 330 | first === undefined || last === undefined |
| 330 | ? "No heap census yet." | |
| 331 | ? EMPTY_WORDS.heap.sentence | |
| 331 | 332 | : heads.length === 1 |
| 332 | 333 | ? `One heap census, at ${String(first.uptimeMin)} min up: ${first.objectCount.toLocaleString("en-US")} objects. The next shows what grew since.` |
| 333 | 334 | : `${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> { | ||
| 696 | 697 | temps: html`${v.temps.map((t) => `${t.chip} ${t.label} ${t.celsius.toFixed(0)}°C`).join(" · ")}`, |
| 697 | 698 | "sys-disks": |
| 698 | 699 | 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>` | |
| 700 | 701 | : html`${v.disks.map((d) => meterRow(d.mount, d.usedBytes, d.totalBytes, `${bytes(d.usedBytes)} / ${bytes(d.totalBytes)} ${d.fs}`))} |
| 701 | 702 | ${v.io.map((d) => figureRow(d.name, `R ${rateOf(d.readBytesPerSecond)} W ${rateOf(d.writeBytesPerSecond)}`, { io: d.name }))} |
| 702 | 703 | ${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"; | ||
| 18 | 18 | import { html, raw, type Html } from "../html.ts"; |
| 19 | 19 | import { flashTo, page } from "../layout.ts"; |
| 20 | 20 | import { btn, icon, row, time } from "../ui.ts"; |
| 21 | import { emptyLine, emptyList } from "../empty_words.ts"; | |
| 21 | 22 | import { accountSections } from "./origins.ts"; |
| 22 | 23 | |
| 23 | 24 | const isAdminPerson = (ctx: Ctx): boolean => |
| @@ -50,7 +51,7 @@ function regions(ctx: Ctx, timed = false): Record<string, string> | undefined { | ||
| 50 | 51 | }); |
| 51 | 52 | const out: Record<string, Html> = { |
| 52 | 53 | "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>`, | |
| 54 | 55 | "teams-changes": |
| 55 | 56 | changes.length === 0 |
| 56 | 57 | ? html`` |
| @@ -89,7 +90,7 @@ function teamBody(t: Team, agents: readonly Agent[], waiting: readonly QueuedPul | ||
| 89 | 90 | <fieldset class="field"> |
| 90 | 91 | <legend>Members</legend> |
| 91 | 92 | ${agents.length === 0 |
| 92 | ? html`<span class="muted small">No agents yet.</span>` | |
| 93 | ? emptyLine("teamAgents") | |
| 93 | 94 | : agents.map( |
| 94 | 95 | (a) => html`<label class="small"> |
| 95 | 96 | <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"; | ||
| 19 | 19 | import { html } from "../html.ts"; |
| 20 | 20 | import { flashTo, page } from "../layout.ts"; |
| 21 | 21 | import { badge, btn, icon, row, time } from "../ui.ts"; |
| 22 | import { emptyList } from "../empty_words.ts"; | |
| 22 | 23 | import { accountSections } from "./origins.ts"; |
| 23 | 24 | |
| 24 | 25 | function owner(ctx: Ctx): Response | undefined { |
| @@ -64,7 +65,7 @@ export function trustedPage(ctx: Ctx): Response { | ||
| 64 | 65 | <section class="settings-block"> |
| 65 | 66 | <h2>Trusted sources</h2> |
| 66 | 67 | ${entries.length === 0 |
| 67 | ? html`<p class="muted small">No one is trusted, so every pull waits for review.</p>` | |
| 68 | ? emptyList("trusted") | |
| 68 | 69 | : html`<ul class="list setting-list" id="trusted-list"> |
| 69 | 70 | ${entries.map((s) => { |
| 70 | 71 | const lapsed = s.until <= now.toISOString(); |
src/web/pages/visitors.ts +3 −2
| @@ -16,6 +16,7 @@ import { html, type Html } from "../html.ts"; | ||
| 16 | 16 | import { flashTo } from "../layout.ts"; |
| 17 | 17 | import { TRAFFIC_TONES } from "../studio/kpi_row.ts"; |
| 18 | 18 | import { btn, row } from "../ui.ts"; |
| 19 | import { emptyList } from "../empty_words.ts"; | |
| 19 | 20 | |
| 20 | 21 | const W = 600; |
| 21 | 22 | const H = 72; |
| @@ -80,7 +81,7 @@ export function ledBlock(ctx: Ctx): Html { | ||
| 80 | 81 | return html`<section class="settings-block"> |
| 81 | 82 | <h2>What led to a forge</h2> |
| 82 | 83 | ${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") | |
| 84 | 85 | : html`<ul class="list setting-list">${forges.map(led)}</ul>`} |
| 85 | 86 | </section>`; |
| 86 | 87 | } |
| @@ -101,7 +102,7 @@ export function visitorsBlock(ctx: Ctx, now: number): Html { | ||
| 101 | 102 | : 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> |
| 102 | 103 | <div class="muted">${bars(r.perDay)}</div> |
| 103 | 104 | ${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>` | |
| 105 | 106 | : html`<ul class="list setting-list">${r.returning.map(returningRow)}</ul>`} |
| 106 | 107 | <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>`} |
| 107 | 108 | </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 | ||
| 85 | 85 | expect(m).toContain('action="/settings/keys"'); |
| 86 | 86 | }); |
| 87 | 87 | |
| 88 | test("empty lists are one muted sentence, not a panel", async () => { | |
| 88 | test("empty lists draw from the shared empty table", async () => { | |
| 89 | 89 | const other = await fetch(`${base}/signup`, { |
| 90 | 90 | method: "POST", |
| 91 | 91 | 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 () => { | ||
| 94 | 94 | const c = (other.headers.get("set-cookie") ?? "").split(";")[0]!; |
| 95 | 95 | const get = async (path: string) => (await (await fetch(`${base}${path}`, { headers: { cookie: c } })).text()); |
| 96 | 96 | const tokens = await get("/settings/tokens"); |
| 97 | expect(tokens).toContain("No access codes yet."); | |
| 97 | 98 | expect(tokens).toContain('<p class="muted">No access codes yet.'); |
| 98 | expect(tokens).not.toContain("empty-title"); | |
| 99 | 99 | const keys = await get("/settings/keys"); |
| 100 | 100 | expect(keys).toContain('<p class="muted">No computer keys yet.'); |
| 101 | expect(keys).not.toContain("empty-title"); | |
| 102 | 101 | const card = String(sessionsCard([], "/settings")); |
| 103 | 102 | expect(card).toContain('<p class="muted">Not signed in on any browser.</p>'); |
| 104 | 103 | 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 | ||
| 115 | 115 | const once = kind === "apps" || kind === "board"; |
| 116 | 116 | // waves: the one step is a tell button (a form), not a link. |
| 117 | 117 | if (kind === "waves") { |
| 118 | expect(mine[0]).toContain(w.label); | |
| 118 | expect(mine[0]).toContain(w.label!); | |
| 119 | 119 | expect(mine[0]).toContain('action="/root/fresh/tell"'); |
| 120 | 120 | continue; |
| 121 | 121 | } |
| @@ -195,3 +195,11 @@ test("every empty list page has one link in its empty state, or is allowed with | ||
| 195 | 195 | test("every allowed page names its reason", () => { |
| 196 | 196 | for (const [path, why] of Object.entries(ALLOWED)) expect(`${path}: ${why.length > 10}`).toBe(`${path}: true`); |
| 197 | 197 | }); |
| 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 | ||
| 25 | 25 | // (repository pages), #15902 (apps, forges) and #15903 (studio, renderers); #15851 waits for them. |
| 26 | 26 | const OWN_WORDS: Readonly<Record<string, number>> = { |
| 27 | 27 | "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, | |
| 31 | 28 | "src/web/pages/boards.ts": 1, |
| 32 | 29 | "src/web/pages/browse.ts": 1, |
| 33 | 30 | "src/web/pages/build_shots.ts": 1, |
| 34 | "src/web/pages/capacity.ts": 1, | |
| 35 | 31 | "src/web/pages/commits.ts": 1, |
| 36 | 32 | "src/web/pages/contribute.ts": 1, |
| 37 | 33 | "src/web/pages/display.ts": 1, |
| @@ -45,13 +41,7 @@ const OWN_WORDS: Readonly<Record<string, number>> = { | ||
| 45 | 41 | "src/web/pages/packs.ts": 2, |
| 46 | 42 | "src/web/pages/pull.ts": 1, |
| 47 | 43 | "src/web/pages/reports.ts": 1, |
| 48 | "src/web/pages/runners.ts": 1, | |
| 49 | "src/web/pages/settings.ts": 1, | |
| 50 | 44 | "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, | |
| 55 | 45 | "src/web/studio/explore.ts": 1, |
| 56 | 46 | "src/web/studio/hold.ts": 1, |
| 57 | 47 | }; |
new above
offline
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.