Public: anyone can read this; the crew can change it.
Every list page that says "nothing here" says why and offers one next step, from one table of empty words #15873
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15851-every-list-page-that-says-nothing-here-s → main 0 commits fork 8 threads · 8 unresolved
docs/features/empty-words.md +10 −18
| @@ -1,21 +1,13 @@ | ||
| 1 | 1 | --- |
| 2 | topic: What a forge is | |
| 3 | row: Empty lists | |
| 2 | topic: When something is wrong | |
| 3 | row: Empty lists say why | |
| 4 | 4 | --- |
| 5 | # Empty lists | |
| 5 | # Empty lists say why | |
| 6 | 6 | |
| 7 | The board, inbox, runs, apps and people lists word their empty state from one table, | |
| 8 | `EMPTY_WORDS` in `src/core/empty_words.ts`: one plain sentence and one link each. | |
| 9 | ||
| 10 | - **Web:** a page draws it with `emptyList(kind)` (`src/web/empty_words.ts`). The link is a plain | |
| 11 | link, never a primary button, so an empty state adds no second accent. A page may name where the | |
| 12 | link goes (a repository's own issues), or pass `noAction` when the viewer cannot take it or the | |
| 13 | page already offers it (apps: the header has "New app"; boards: "Make a board" sits just below). | |
| 14 | - **Terminal:** the boards, runs, apps and inbox screens take their empty title from the same | |
| 15 | `sentence`; they keep their own key hints as the body, because a terminal has keys, not links. | |
| 16 | The people screen is never empty (the signed-in admin is always one). | |
| 17 | - "Invite someone" goes to `/admin/limits`, where invite links are minted; the people page is | |
| 18 | admin-only, so only an admin ever sees it. | |
| 19 | ||
| 20 | A new list that can be empty gets a row in the table, not its own words. | |
| 21 | `test/empty-states.test.ts` walks the lists and holds each to its sentence and its link. | |
| 7 | Every list page that has nothing to show draws one sentence and at most one next step, all from one table: `EMPTY_WORDS` in `src/core/empty_words.ts`. The web reads it through `emptyList(kind)` (`src/web/empty_words.ts`); the terminal reads the same table for the sentence (`src/tui/screens/*`, `emptyState`), so a screen never words its own. | |
| 8 | A reason line is opt-in per kind: only where the page does not already say what the list is (releases, forks, commits, displays), since nothing explains itself twice. A link is opt-in too: a kind names an href only where that place exists unscoped (`/new`, `/tell`); a repository's list hands in its own (`emptyList("builds", { href })`), and with none the state draws no link. An origin's list read live passes its own `note`. | |
| 9 | Kinds: board, inbox, runs, apps, people, waves, builds, releases, forks, repos, commits, displays, issues, pulls, branches, labels, events. The terminal's repositories, forks, releases and displays screens read the same words; `NO_RELEASES_YET` and `DISPLAYS_NOTE` are the table's reasons, not copies. | |
| 10 | One state is worded by its page on purpose: the commits page, when you have paged past the end of a history that has commits, says so itself ("No commits on this page"); that is a place in a list, not an empty list. | |
| 11 | A filtered view (closed issues, one kind of event) passes its own title to `emptyList` and keeps the table's reason, if the kind has one. | |
| 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 | `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. |
src/core/empty_words.ts +35 −4
| @@ -5,14 +5,34 @@ | ||
| 5 | 5 | * every kind and holds each to its sentence and its single link. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | export type EmptyKind = "board" | "inbox" | "runs" | "apps" | "people" | "waves"; | |
| 8 | export type EmptyKind = "board" | "inbox" | "runs" | "apps" | "people" | "waves" | |
| 9 | | "builds" | |
| 10 | | "releases" | |
| 11 | | "forks" | |
| 12 | | "repos" | |
| 13 | | "commits" | |
| 14 | | "displays" | |
| 15 | | "issues" | |
| 16 | | "pulls" | |
| 17 | | "branches" | |
| 18 | | "labels" | |
| 19 | | "events"; | |
| 9 | 20 | |
| 10 | 21 | export interface EmptyWords { |
| 11 | 22 | /** One sentence, plain words, ending in a full stop. */ |
| 12 | 23 | readonly sentence: string; |
| 13 | /** The one action, and where it goes when the page does not say otherwise. */ | |
| 14 | readonly label: string; | |
| 15 | readonly href: string; | |
| 24 | /** | |
| 25 | * Why it is empty, in one calm sentence, only where the page does not already say it: a list that | |
| 26 | * names what it is carries none (nothing explains itself twice). | |
| 27 | */ | |
| 28 | readonly reason?: string; | |
| 29 | /** The one action's words, only where one exists. */ | |
| 30 | readonly label?: string; | |
| 31 | /** | |
| 32 | * Where the action goes, only where that place exists unscoped; a repository's list hands in its | |
| 33 | * own (`emptyList(kind, { href })`), and a label with no href and none handed in draws no link. | |
| 34 | */ | |
outdated
Principle 1: the forks reason is two clauses long and explains the concept twice. Cut it to one sentence, e.g. 'A fork is a copy that can send changes back here.' |
||
| 35 | readonly href?: string; | |
outdated
Principle 1/8: 'Repositories you can write to are listed here.' restates the sentence and does not say why it is empty or what puts something here. Try: 'A repository appears here once you create one or are given write access.' |
||
| 16 | 36 | } |
| 17 | 37 | |
| 18 | 38 | export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = { |
| @@ -22,4 +42,15 @@ export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = { | ||
| 22 | 42 | apps: { sentence: "Nothing runs here yet.", label: "New app", href: "/apps/new" }, |
| 23 | 43 | waves: { sentence: "No waves yet.", label: "Tell the crew", href: "/tell" }, |
| 24 | 44 | people: { sentence: "Nobody has joined yet.", label: "Invite someone", href: "/admin/limits" }, |
| 45 | builds: { sentence: "No builds yet.", label: "Pin one from a branch" }, | |
| 46 | releases: { sentence: "No releases yet.", reason: "A pull landed on the forge's own repository is recorded here." }, | |
| 47 | forks: { sentence: "No forks yet.", reason: "A fork is a copy under another name that can propose changes back here, and follows this one until it has work of its own." }, | |
| 48 | repos: { sentence: "No repositories yet.", label: "New repository", href: "/new" }, | |
| 49 | commits: { sentence: "No commits yet.", reason: "Push a branch and its history shows up here." }, | |
| 50 | issues: { sentence: "No issues yet." }, | |
| 51 | pulls: { sentence: "No pulls yet." }, | |
| 52 | branches: { sentence: "No branches yet." }, | |
| 53 | labels: { sentence: "No labels yet." }, | |
| 54 | events: { sentence: "No events yet." }, | |
| 55 | displays: { sentence: "No displays yet.", reason: "Add a display.json to a repository's default branch to make one." }, | |
| 25 | 56 | }; |
src/display/known.ts +2 −1
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | |
| 17 | 17 | import type { App } from "../app.ts"; |
| 18 | 18 | import { listAdminOwnedRepos, listEveryRepo, readableRepoIds, repoDatesFor, type Repo } from "../core/repos.ts"; |
| 19 | import { EMPTY_WORDS } from "../core/empty_words.ts"; | |
| 19 | 20 | import type { User } from "../core/users.ts"; |
| 20 | 21 | import { listBuildPins } from "../git/builds.ts"; |
| 21 | 22 | import { repoDir } from "../git/repos.ts"; |
| @@ -315,7 +316,7 @@ export async function withoutDisplay(app: App, repos: readonly Repo[]): Promise< | ||
| 315 | 316 | /** What a display is; the page and the terminal screen say it once, above the list. */ |
| 316 | 317 | export const DISPLAYS_SENTENCE = "A display is a showcase screen for a repository: its pinned demos, laid out as a shelf, grid or graph, to open full screen."; |
| 317 | 318 | /** How to make one; the empty state of the page and of the terminal screen. */ |
| 318 | export const DISPLAYS_NOTE = "Add a display.json to a repository's default branch to make one."; | |
| 319 | export const DISPLAYS_NOTE = EMPTY_WORDS.displays.reason ?? ""; | |
| 319 | 320 | /** The link text for a display whose file does not parse. */ |
| 320 | 321 | export const INVALID_TITLE = "display.json is invalid"; |
| 321 | 322 | /** Said while a cold list is still reading; an empty cold answer says only this, never "No displays". */ |
src/release/words.ts +3 −1
| @@ -5,6 +5,8 @@ | ||
| 5 | 5 | * the sha; the terminal with `plain`, joining the parts as they are. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { EMPTY_WORDS } from "../core/empty_words.ts"; | |
| 9 | ||
| 8 | 10 | /** A template tag: the page's `html`, or `plain` for the terminal. */ |
| 9 | 11 | export type Tag<T, V> = (strings: TemplateStringsArray, ...values: V[]) => T; |
| 10 | 12 | |
| @@ -19,7 +21,7 @@ export function liveSince<T, V>(tag: Tag<T, V>, sha: V, since: V): T { | ||
| 19 | 21 | } |
| 20 | 22 | |
| 21 | 23 | /** What the empty releases view says will fill it. */ |
| 22 | export const NO_RELEASES_YET = "A pull landed on the forge's own repository is recorded here."; | |
| 24 | export const NO_RELEASES_YET = EMPTY_WORDS.releases.reason ?? ""; | |
| 23 | 25 | |
| 24 | 26 | /** Why a kept release offers no rollback: it is the one serving. */ |
| 25 | 27 | export const ALREADY_LIVE = "This release is the one serving; there is nothing to roll back to."; |
src/tui/screens/builds.ts +2 −1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | * which check again. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 11 | 12 | import { setCart } from "../../actions/build_cart.ts"; |
| 12 | 13 | import { deletePin, notePin, pinBuild } from "../../actions/builds.ts"; |
| 13 | 14 | import { canRead, canWrite, type Repo } from "../../core/repos.ts"; |
| @@ -25,7 +26,7 @@ import { shotsScreen } from "./shots.ts"; | ||
| 25 | 26 | import { ListState, ago, confirmScreen, metaOf, promptScreen } from "./common.ts"; |
| 26 | 27 | |
| 27 | 28 | export const NOT_FOUND_LINE = "No such repository"; |
| 28 | export const NO_BUILDS_LINE = "No builds pinned yet."; | |
| 29 | export const NO_BUILDS_LINE = EMPTY_WORDS.builds.sentence; | |
| 29 | 30 | export const DELETED_LINE = "Deleted that pin; its commit and notes stay."; |
| 30 | 31 | |
| 31 | 32 | /** What a refused or failed action reads as. */ |
src/tui/screens/commits.ts +2 −1
| @@ -20,6 +20,7 @@ import { fill, len, split } from "../ui/layout.ts"; | ||
| 20 | 20 | import type { Tokens } from "../ui/theme.ts"; |
| 21 | 21 | import { numberWidth, renderFileDiff } from "../ui/diff.ts"; |
| 22 | 22 | import type { KeyEvent } from "../term/input.ts"; |
| 23 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 23 | 24 | import { card, emptyState } from "../ui/widgets.ts"; |
| 24 | 25 | import type { Session } from "../session.ts"; |
| 25 | 26 | import { |
| @@ -135,7 +136,7 @@ export function commitsScreen( | ||
| 135 | 136 | ); |
| 136 | 137 | if (commits.length === 0) { |
| 137 | 138 | emptyState(s, body!, c, { |
| 138 | title: loaded ? "No commits" : "Reading…", | |
| 139 | title: loaded ? EMPTY_WORDS.commits.sentence : "Reading…", | |
| 139 | 140 | body: loaded |
| 140 | 141 | ? `Nothing has landed on ${ref} yet.` |
| 141 | 142 | : `Reading the log of ${ref}`, |
src/tui/screens/dashboard.ts +2 −1
| @@ -101,6 +101,7 @@ import type { Tokens } from "../ui/theme.ts"; | ||
| 101 | 101 | import { truncate } from "../term/width.ts"; |
| 102 | 102 | import { beside, fill, len, split } from "../ui/layout.ts"; |
| 103 | 103 | import { icon, type IconSet } from "../ui/icons.ts"; |
| 104 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 104 | 105 | import { card, emptyState } from "../ui/widgets.ts"; |
| 105 | 106 | import type { Session } from "../session.ts"; |
| 106 | 107 | import { |
| @@ -1787,7 +1788,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen { | ||
| 1787 | 1788 | const on = focus === "repos"; |
| 1788 | 1789 | if (rows.length === 0) { |
| 1789 | 1790 | emptyState(s, r, c, { |
| 1790 | title: f.signedIn ? "No repositories yet" : "Nothing public yet", | |
| 1791 | title: f.signedIn ? EMPTY_WORDS.repos.sentence : "Nothing public yet", | |
| 1791 | 1792 | body: f.signedIn |
| 1792 | 1793 | ? "Press n for a new repository, or / to find one." |
| 1793 | 1794 | : "Press s to sign in, or / to find one.", |
src/tui/screens/forks.ts +3 −2
| @@ -40,6 +40,7 @@ import { binding } from "../app/keys.ts"; | ||
| 40 | 40 | import { style } from "../term/style.ts"; |
| 41 | 41 | import { truncate, wrap } from "../term/width.ts"; |
| 42 | 42 | import { fill, len, split } from "../ui/layout.ts"; |
| 43 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 43 | 44 | import { emptyState } from "../ui/widgets.ts"; |
| 44 | 45 | import type { Session } from "../session.ts"; |
| 45 | 46 | import { issueScreen } from "./issue.ts"; |
| @@ -398,8 +399,8 @@ export function forksScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 398 | 399 | } |
| 399 | 400 | if (list.length === 0) { |
| 400 | 401 | emptyState(s, body!, c, { |
| 401 | title: ranked === undefined ? "Reading…" : "No forks yet", | |
| 402 | body: "", | |
| 402 | title: ranked === undefined ? "Reading…" : EMPTY_WORDS.forks.sentence, | |
| 403 | body: ranked === undefined ? "" : EMPTY_WORDS.forks.reason ?? "", | |
| 403 | 404 | }); |
| 404 | 405 | return; |
| 405 | 406 | } |
src/tui/screens/releases.ts +2 −1
| @@ -19,6 +19,7 @@ import type { Session } from "../session.ts"; | ||
| 19 | 19 | import { style } from "../term/style.ts"; |
| 20 | 20 | import { truncate } from "../term/width.ts"; |
| 21 | 21 | import { fill, len, split } from "../ui/layout.ts"; |
| 22 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 22 | 23 | import { emptyState } from "../ui/widgets.ts"; |
| 23 | 24 | import { ListState, confirmScreen, drawList, hitList, ago, metaOf, runAsync, type ListRow } from "./common.ts"; |
| 24 | 25 | |
| @@ -112,7 +113,7 @@ export function releasesScreen(f: Session, ctx: Ctx): Screen { | ||
| 112 | 113 | s.text(head!.x, head!.y, truncate([liveText(f), journeyText(f)].filter((x) => x !== undefined).join(" · "), head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 113 | 114 | if (lines.length === 0) { |
| 114 | 115 | emptyState(s, body!, c, { |
| 115 | title: loaded ? "No releases yet" : "Reading…", | |
| 116 | title: loaded ? EMPTY_WORDS.releases.sentence : "Reading…", | |
| 116 | 117 | body: NO_RELEASES_YET, |
| 117 | 118 | }); |
| 118 | 119 | return; |
src/tui/screens/repolist.ts +2 −1
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | * write, from `listReposWritableTo`. Enter opens one as the dashboard does. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 6 | 7 | import { listReposWritableTo, type Repo } from "../../core/repos.ts"; |
| 7 | 8 | import type { Ctx, Screen } from "../app/app.ts"; |
| 8 | 9 | import { binding } from "../app/keys.ts"; |
| @@ -25,7 +26,7 @@ export function repoListScreen(f: Session, ctx: Ctx): Screen { | ||
| 25 | 26 | const c = ctx.theme.c; |
| 26 | 27 | const repos = read(); |
| 27 | 28 | const [head, list] = split(area, "v", [len(1), fill(1)]); |
| 28 | const text = repos.length === 0 ? "No repositories yet." : `${repos.length} repositories you may write`; | |
| 29 | const text = repos.length === 0 ? EMPTY_WORDS.repos.sentence : `${repos.length} repositories you may write`; | |
| 29 | 30 | s.text(head!.x, head!.y, truncate(text, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 30 | 31 | const rows: ListRow[] = repos.map((r) => ({ title: `${r.ownerName}/${r.name}` })); |
| 31 | 32 | drawList(s, list!, c, state, rows); |
src/web/empty_words.ts +23 −2
| @@ -18,6 +18,17 @@ const ICONS: Readonly<Record<EmptyKind, IconName>> = { | ||
| 18 | 18 | apps: "repo", |
| 19 | 19 | people: "users", |
| 20 | 20 | waves: "activity", |
| 21 | builds: "pin", | |
| 22 | releases: "activity", | |
| 23 | forks: "fork", | |
| 24 | repos: "repo", | |
| 25 | commits: "commit", | |
| 26 | displays: "pin", | |
| 27 | issues: "issue", | |
| 28 | pulls: "pull", | |
| 29 | branches: "branch", | |
| 30 | labels: "tag", | |
| 31 | events: "activity", | |
| 21 | 32 | }; |
| 22 | 33 | |
| 23 | 34 | export interface EmptyOptions { |
| @@ -25,15 +36,25 @@ export interface EmptyOptions { | ||
| 25 | 36 | href?: string; |
| 26 | 37 | /** Leave the link out: the viewer cannot take the action, or the page already offers it. */ |
| 27 | 38 | noAction?: boolean; |
| 39 | /** A filtered view names its filter ("No closed issues"); the reason stays the table's. */ | |
| 40 | title?: string; | |
| 41 | /** A list whose reason is its own (an origin's list, read live) hands it in. */ | |
| 42 | note?: string; | |
| 43 | /** A page that has its own action (a link back to the unfiltered list) hands it in. */ | |
| 44 | action?: Html; | |
| 28 | 45 | bind?: string | undefined; |
| 29 | 46 | } |
| 30 | 47 | |
| 31 | 48 | export function emptyList(kind: EmptyKind, o: EmptyOptions = {}): Html { |
| 32 | 49 | const w = EMPTY_WORDS[kind]; |
| 50 | const note = o.note ?? w.reason; | |
| 51 | const href = o.href ?? w.href; | |
| 52 | const action = o.action ?? (o.noAction || w.label === undefined || href === undefined ? undefined : btn(w.label, { href, variant: "link" })); | |
outdated
Principle 1: a reason line under every sentence is a second explanation on lists that already say what they are. Make it opt-in per kind, not universal. |
||
| 33 | 53 | return empty({ |
| 34 | 54 | icon: ICONS[kind], |
| 35 | title: w.sentence, | |
| 36 | ...(o.noAction ? {} : { action: btn(w.label, { href: o.href ?? w.href, variant: "link" }) }), | |
| 55 | title: o.title ?? w.sentence, | |
| 56 | ...(note === undefined ? {} : { note }), | |
| 57 | ...(action === undefined ? {} : { action }), | |
| 37 | 58 | bind: o.bind, |
| 38 | 59 | }); |
| 39 | 60 | } |
src/web/pages/branches.ts +2 −6
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | * are readable and nothing more, which is the whole rule of a live browse. |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | import { emptyList } from "../empty_words.ts"; | |
| 18 | 19 | import { createBranch, deleteBranch } from "../../actions/branches.ts"; |
| 19 | 20 | import type { Repo } from "../../core/repos.ts"; |
| 20 | 21 | import { notePhase, takeSessionTime, timePhaseAsync } from "../../core/route_timing.ts"; |
| @@ -33,7 +34,6 @@ import { localScope } from "../scope.ts"; | ||
| 33 | 34 | import { |
| 34 | 35 | badge, |
| 35 | 36 | btn, |
| 36 | empty, | |
| 37 | 37 | field, |
| 38 | 38 | icon, |
| 39 | 39 | selectField, |
| @@ -291,11 +291,7 @@ export async function renderBranches( | ||
| 291 | 291 | ? html`<p class="small"><a href="${scope.base}/builds">Builds</a></p>` |
| 292 | 292 | : null} |
| 293 | 293 | ${rows.length === 0 |
| 294 | ? empty({ | |
| 295 | icon: "branch", | |
| 296 | title: "No branches yet", | |
| 297 | note: "Push one, or create the first from the form above.", | |
| 298 | }) | |
| 294 | ? emptyList("branches", { noAction: true }) | |
| 299 | 295 | : html`<h2 class="mt"> |
| 300 | 296 | ${rows.length} branch${rows.length === 1 ? "" : "es"} |
| 301 | 297 | ${when( |
src/web/pages/browse.ts +3 −2
| @@ -25,6 +25,7 @@ | ||
| 25 | 25 | * labels and authors instead. |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | import { emptyList } from "../empty_words.ts"; | |
| 28 | 29 | import { binaryRefusal } from "../render/opens_with.ts"; |
| 29 | 30 | import { mirrorJobFor, startMirrorJob } from "../../actions/origins.ts"; |
| 30 | 31 | import { forkOrigin } from "../../actions/contribute.ts"; |
| @@ -648,8 +649,8 @@ async function browseThreadList( | ||
| 648 | 649 | |
| 649 | 650 | const list = |
| 650 | 651 | items.length === 0 |
| 651 | ? empty({ | |
| 652 | icon: kind === "issue" ? "issue" : "pull", | |
| 652 | ? emptyList(kind === "issue" ? "issues" : "pulls", { | |
| 653 | noAction: true, | |
| 653 | 654 | title: |
| 654 | 655 | query.state === "closed" |
| 655 | 656 | ? `No closed ${segment}` |
src/web/pages/builds.ts +2 −1
| @@ -27,6 +27,7 @@ import { backTo, field as formValue, readForm } from "../form.ts"; | ||
| 27 | 27 | import { isLocalPath } from "../flash.ts"; |
| 28 | 28 | import { html, when, type Html } from "../html.ts"; |
| 29 | 29 | import { flashTo, page } from "../layout.ts"; |
| 30 | import { emptyList } from "../empty_words.ts"; | |
| 30 | 31 | import { btn, field, row, selectField, time } from "../ui.ts"; |
| 31 | 32 | |
| 32 | 33 | /** |
| @@ -99,7 +100,7 @@ export function buildsList( | ||
| 99 | 100 | ${when(nodes.length > 0, () => html`<a href="${base}/iterations?layout=tree">Iterations</a>`)} |
| 100 | 101 | </p> |
| 101 | 102 | ${nodes.length === 0 |
| 102 | ? html`<p class="muted">No builds yet.${canPin ? html` Pin one from <a href="${base}/branches">a branch</a> to make it.` : null}</p>` | |
| 103 | ? emptyList("builds", canPin ? { href: `${base}/branches` } : { noAction: true }) | |
| 103 | 104 | : html`<ul class="list builds">${nodes.map((n) => buildRow(base, n, canPreview, canDelete))}</ul>`}`; |
| 104 | 105 | } |
| 105 | 106 |
src/web/pages/commits.ts +4 −7
| @@ -40,6 +40,7 @@ import { | ||
| 40 | 40 | sha, |
| 41 | 41 | time, |
| 42 | 42 | } from "../ui.ts"; |
| 43 | import { emptyList } from "../empty_words.ts"; | |
| 43 | 44 | import { |
| 44 | 45 | pathCrumbs, |
| 45 | 46 | refMenu, |
| @@ -204,13 +205,9 @@ export function historyBar( | ||
| 204 | 205 | } |
| 205 | 206 | |
| 206 | 207 | export const noCommits = (later: boolean): Html => |
| 207 | empty({ | |
| 208 | icon: "commit", | |
| 209 | title: later ? "No commits on this page" : "No commits yet", | |
| 210 | note: later | |
| 211 | ? "You have paged past the end of this history." | |
| 212 | : "Push a branch and its history shows up here.", | |
| 213 | }); | |
| 208 | later | |
| 209 | ? empty({ icon: "commit", title: "No commits on this page", note: "You have paged past the end of this history." }) | |
| 210 | : emptyList("commits", { noAction: true }); | |
| 214 | 211 | |
| 215 | 212 | // ---- the local pages ---- |
| 216 | 213 |
src/web/pages/displays.ts +3 −3
| @@ -7,12 +7,12 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../core/route_timing.ts"; |
| 10 | import { DISPLAYS_NOTE, DISPLAYS_READING, DISPLAYS_SENTENCE, INVALID_TITLE, LIST_WAIT_MS, listedDisplaysWithin, listWait } from "../../display/known.ts"; | |
| 10 | import { DISPLAYS_READING, DISPLAYS_SENTENCE, INVALID_TITLE, LIST_WAIT_MS, listedDisplaysWithin, listWait } from "../../display/known.ts"; | |
| 11 | 11 | import type { Ctx } from "../../http/context.ts"; |
| 12 | 12 | import { pageHead, repoBase, signInFirst } from "../chrome.ts"; |
| 13 | 13 | import { html } from "../html.ts"; |
| 14 | 14 | import { page } from "../layout.ts"; |
| 15 | import { empty } from "../ui.ts"; | |
| 15 | import { emptyList } from "../empty_words.ts"; | |
| 16 | 16 | |
| 17 | 17 | const LAYOUT_WORD = { shelf: "Shelf", grid: "Grid", graph: "Graph" } as const; |
| 18 | 18 | |
| @@ -33,7 +33,7 @@ export async function displaysPage(ctx: Ctx): Promise<Response> { | ||
| 33 | 33 | ${rows.length === 0 && !complete |
| 34 | 34 | ? null |
| 35 | 35 | : rows.length === 0 |
| 36 | ? empty({ icon: "pin", title: "No displays", note: DISPLAYS_NOTE }) | |
| 36 | ? emptyList("displays", { noAction: true }) | |
| 37 | 37 | : html`<div class="table-scroll" role="region" tabindex="0" aria-label="Displays"> |
| 38 | 38 | <table class="table" data-dense data-by="displays"> |
| 39 | 39 | <thead> |
src/web/pages/events.ts +4 −3
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | * links to it). Server-rendered, no script. |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | import { emptyList } from "../empty_words.ts"; | |
| 12 | 13 | import { EVENTS_LIMIT_DEFAULT, eventsPage, validEventsCursor, validEventsKind } from "../../core/events_page.ts"; |
| 13 | 14 | import type { ForgeEvent } from "../../core/events.ts"; |
| 14 | 15 | import { getUsersByIds } from "../../core/users.ts"; |
| @@ -20,7 +21,7 @@ import { pushedBranch } from "../feeds.ts"; | ||
| 20 | 21 | import { html, type Html } from "../html.ts"; |
| 21 | 22 | import { page } from "../layout.ts"; |
| 22 | 23 | import { localScope } from "../scope.ts"; |
| 23 | import { avatar, btn, empty, listCard, pager, row, time } from "../ui.ts"; | |
| 24 | import { avatar, btn, listCard, pager, row, time } from "../ui.ts"; | |
| 24 | 25 | |
| 25 | 26 | /** Where an event has a page: its issue or pull, a push's commits. */ |
| 26 | 27 | function linkOf(base: string, event: ForgeEvent): string | undefined { |
| @@ -74,8 +75,8 @@ export function eventsList(ctx: Ctx): Response { | ||
| 74 | 75 | <div class="mt"> |
| 75 | 76 | ${read.items.length === 0 |
| 76 | 77 | ? kind === null |
| 77 | ? empty({ icon: "activity", title: "No events yet", note: "Pushes, merges and deploys land here." }) | |
| 78 | : empty({ icon: "activity", title: `No ${kind} events`, action: allEvents }) | |
| 78 | ? emptyList("events", { noAction: true }) | |
| 79 | : emptyList("events", { title: `No ${kind} events`, action: allEvents }) | |
| 79 | 80 | : eventRows(ctx, base, narrow, read.items)} |
| 80 | 81 | </div> |
| 81 | 82 | ${pager({ |
src/web/pages/labels.ts +3 −6
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * and the gate are settings.ts's; this module holds only what labels need. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { emptyList } from "../empty_words.ts"; | |
| 8 | 9 | import { LABEL_WORDS } from "../../actions/label_words.ts"; |
| 9 | 10 | import { createLabel, deleteLabel, updateLabel } from "../../actions/repos.ts"; |
| 10 | 11 | import { listLabels, openLabelUse, type Label, type LabelUse } from "../../core/issues.ts"; |
| @@ -14,7 +15,7 @@ import { repoBase, repoNotFound } from "../chrome.ts"; | ||
| 14 | 15 | import { field, type Form } from "../form.ts"; |
| 15 | 16 | import { html, type Html } from "../html.ts"; |
| 16 | 17 | import { flashTo } from "../layout.ts"; |
| 17 | import { btn, confirmAction, empty, labelChip, labelCss, row } from "../ui.ts"; | |
| 18 | import { btn, confirmAction, labelChip, labelCss, row } from "../ui.ts"; | |
| 18 | 19 | import { adminForm } from "../admin_form.ts"; |
| 19 | 20 | import { settingsPageResponse, timedAdminRepo } from "./settings.ts"; |
| 20 | 21 | import { BIND, countAttr } from "../bind.ts"; |
| @@ -101,11 +102,7 @@ export function labelsPage(ctx: Ctx): Response { | ||
| 101 | 102 | |
| 102 | 103 | const list = |
| 103 | 104 | labels.length === 0 |
| 104 | ? empty({ | |
| 105 | icon: "tag", | |
| 106 | title: "No labels yet", | |
| 107 | note: "Labels are this repository's work queue — a handful is usually enough.", | |
| 108 | }) | |
| 105 | ? emptyList("labels", { noAction: true }) | |
| 109 | 106 | : html`<ul class="list setting-list"> |
| 110 | 107 | ${labels.map((l) => labelRow(base, l, counts.get(l.id)))} |
| 111 | 108 | </ul>`; |
src/web/pages/my-repos.ts +3 −2
| @@ -9,7 +9,8 @@ import type { Ctx } from "../../http/context.ts"; | ||
| 9 | 9 | import { repoBase, signInFirst } from "../chrome.ts"; |
| 10 | 10 | import { html } from "../html.ts"; |
| 11 | 11 | import { page } from "../layout.ts"; |
| 12 | import { btn, empty, listCard, row } from "../ui.ts"; | |
| 12 | import { emptyList } from "../empty_words.ts"; | |
| 13 | import { btn, listCard, row } from "../ui.ts"; | |
| 13 | 14 | |
| 14 | 15 | // GET /repos |
| 15 | 16 | export function myReposPage(ctx: Ctx): Response { |
| @@ -20,7 +21,7 @@ export function myReposPage(ctx: Ctx): Response { | ||
| 20 | 21 | const repos = listReposWritableTo(ctx.app.db, user, { limit: 200, withoutArchived: true }); |
| 21 | 22 | const body = |
| 22 | 23 | repos.length === 0 |
| 23 | ? empty({ icon: "repo", title: "No repositories yet", action: btn("New repository", { href: "/new", variant: "primary" }) }) | |
| 24 | ? emptyList("repos") | |
The primary button became a plain link, which is correct under principle 5. On this page the link is the only way to start, and "New repository" is easy to miss as a bare link under two lines of text. Check it at 360px, where the touch target should be at least 44px tall. |
||
| 24 | 25 | : listCard( |
| 25 | 26 | repos.map((r) => |
| 26 | 27 | row({ href: repoBase(r), nav: true, title: html`<span class="truncate">${r.ownerName}/${r.name}</span>` }), |
src/web/pages/releases.ts +3 −2
| @@ -15,11 +15,12 @@ import { lastProof, proofNotice, proveAgain } from "../../release/prove.ts"; | ||
| 15 | 15 | import { listReleases } from "../../release/record.ts"; |
| 16 | 16 | import { releaseStories } from "../../release/story.ts"; |
| 17 | 17 | import { BOOTED, canRollBackTo, mayRead, mayRollBack, rollBackTo } from "../../release/gate.ts"; |
| 18 | import { journeyLine, liveSince, NO_RELEASES_YET } from "../../release/words.ts"; | |
| 18 | import { journeyLine, liveSince } from "../../release/words.ts"; | |
| 19 | 19 | import { notFoundPage, signInFirst, NOT_ADMIN_HERE, SIGN_IN_TO_DO, forbiddenPage } from "../chrome.ts"; |
| 20 | 20 | import { readForm } from "../form.ts"; |
| 21 | 21 | import { html, when, type Html } from "../html.ts"; |
| 22 | 22 | import { flashTo, page } from "../layout.ts"; |
| 23 | import { emptyList } from "../empty_words.ts"; | |
| 23 | 24 | import { badge, btn, row, sha, time } from "../ui.ts"; |
| 24 | 25 | import { holdAs, liftAs } from "../../keeper/hold.ts"; |
| 25 | 26 | import { releaseNowAs } from "../../keeper/now.ts"; |
| @@ -137,7 +138,7 @@ export async function releasesPage(ctx: Ctx): Promise<Response> { | ||
| 137 | 138 | } |
| 138 | 139 | const body = |
| 139 | 140 | rows.length === 0 |
| 140 | ? html`<p class="mt muted">No releases yet. ${NO_RELEASES_YET}</p>` | |
| 141 | ? emptyList("releases", { noAction: true }) | |
| 141 | 142 | : html`<ul class="list setting-list">${rows}</ul>`; |
| 142 | 143 | const response = page({ |
| 143 | 144 | ctx, |
src/web/pages/repo.ts +2 −6
| @@ -140,6 +140,7 @@ import { | ||
| 140 | 140 | time, |
| 141 | 141 | copyField, |
| 142 | 142 | } from "../ui.ts"; |
| 143 | import { emptyList } from "../empty_words.ts"; | |
| 143 | 144 | import { BIND, countAttr, listAttr } from "../bind.ts"; |
| 144 | 145 | |
| 145 | 146 | const MAX_RENDER_BYTES = 1_000_000; |
| @@ -219,12 +220,7 @@ export async function forksPage(ctx: Ctx): Promise<Response> { | ||
| 219 | 220 | <h2${countAttr(BIND.rest)}>${forks.length} fork${forks.length === 1 ? "" : "s"}</h2> |
| 220 | 221 | </div> |
| 221 | 222 | ${lineage.size === 1 |
| 222 | ? empty({ | |
| 223 | icon: "fork", | |
| 224 | title: "No forks yet", | |
| 225 | note: "A fork is a copy under another name that can propose changes back here, and follows this one until it has work of its own.", | |
| 226 | bind: BIND.rest, | |
| 227 | }) | |
| 223 | ? emptyList("forks", { noAction: true, bind: BIND.rest }) | |
| 228 | 224 | : html`${forkRanking(ranked, new Map(tree.map((n) => [n.repo.id, n])), BIND.rest, forkModes, (fork, parent) => keptBehind(ctx.app, fork, parent), forkFollowed)} |
| 229 | 225 | <h3 class="mt">The family, by who follows whom</h3> |
| 230 | 226 | ${lineageCard(lineage, repo.id, ctx.auth.user?.id)}`}`; |
src/web/pages/waves.ts +1 −1
| @@ -116,7 +116,7 @@ export async function wavesPage(ctx: Ctx): Promise<Response> { | ||
| 116 | 116 | action: html`<form method="post" action="${repoBase(repo)}/tell"> |
| 117 | 117 | <input type="hidden" name="text" value="${FIRST_WAVE_TELL}" /> |
| 118 | 118 | <input type="hidden" name="from" value="${repoBase(repo)}/waves" /> |
| 119 | ${btn(EMPTY_WORDS.waves.label, { variant: "primary" })} | |
| 119 | ${btn(EMPTY_WORDS.waves.label ?? "", { variant: "primary" })} | |
Non-blocking: |
||
| 120 | 120 | </form>`, |
| 121 | 121 | } |
| 122 | 122 | : {}), |
test/empty-words-all.test.ts added +130
| @@ -0,0 +1,130 @@ | ||
| 1 | /** | |
| 2 | * One table of empty words (#15851): every empty state a page registers has an entry (a sentence; a | |
| 3 | * reason and one link only where they add something and the place exists), and a page that words | |
| 4 | * its own "No …" empty state is named below until it moves. | |
| 5 | */ | |
| 6 | import { expect, test } from "bun:test"; | |
| 7 | import { readdirSync, readFileSync, statSync } from "node:fs"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { EMPTY_WORDS } from "../src/core/empty_words.ts"; | |
| 10 | ||
| 11 | const walk = (dir: string): string[] => | |
| 12 | readdirSync(dir).flatMap((f) => { | |
| 13 | const p = join(dir, f); | |
| 14 | return statSync(p).isDirectory() ? walk(p) : p.endsWith(".ts") ? [p] : []; | |
| 15 | }); | |
| 16 | const files = walk("src/web").map((p) => [p, readFileSync(p, "utf8")] as const); | |
| 17 | ||
| 18 | // A page's own "No …" empty state, in either form: empty({ title: "No …" }) (one line or several) | |
| 19 | // or an inline <p class="… muted …">No …</p>, whatever classes sit beside muted and whatever | |
| 20 | // follows. The table below is a ratchet: a file may hold no more than its count, and must name the | |
outdated
This exemption list has about 20 pages, which is the issue's own box 1 left undone. It is acceptable only if each page has a follow-up issue; link them in the pull. |
||
| 21 | // count exactly, so moving one to emptyList(kind) shrinks it and a new one fails. A new empty state | |
| 22 | // goes in src/core/empty_words.ts and is drawn with emptyList(kind). | |
| 23 | const OWN_FORM = /empty\(\{\s*(?:icon: [^,]+,\s*)?title: [`"]No |empty\("No |<p class="(?:[^"]* )?muted(?: [^"]*)?">\s*No /g; | |
| 24 | // What is left is split into #15899 (admin, system), #15900 (boards, bets, flows), #15901 | |
| 25 | // (repository pages), #15902 (apps, forges) and #15903 (studio, renderers); #15851 waits for them. | |
| 26 | const OWN_WORDS: Readonly<Record<string, number>> = { | |
| 27 | "src/web/comments.ts": 1, | |
| 28 | "src/web/diff-view.ts": 1, | |
| 29 | "src/web/pages/account.ts": 2, | |
| 30 | "src/web/pages/accounts.ts": 1, | |
| 31 | "src/web/pages/admin-limits.ts": 1, | |
| 32 | "src/web/pages/app_releases.ts": 1, | |
| 33 | "src/web/pages/app_templates.ts": 1, | |
| 34 | "src/web/pages/app_variants.ts": 1, | |
| 35 | "src/web/pages/audit.ts": 1, | |
| 36 | "src/web/pages/bets.ts": 3, | |
| 37 | "src/web/pages/billing.ts": 2, | |
| 38 | "src/web/pages/boards-gates.ts": 1, | |
| 39 | "src/web/pages/boards-held.ts": 1, | |
| 40 | "src/web/pages/boards-holds.ts": 1, | |
| 41 | "src/web/pages/boards.ts": 1, | |
| 42 | "src/web/pages/browse.ts": 1, | |
| 43 | "src/web/pages/build_shots.ts": 1, | |
| 44 | "src/web/pages/capacity.ts": 1, | |
| 45 | "src/web/pages/cloud.ts": 3, | |
| 46 | "src/web/pages/commits.ts": 1, | |
outdated
The regex only catches empty({ title: "No ..." }) on a single line. A |
||
| 47 | "src/web/pages/contribute.ts": 1, | |
| 48 | "src/web/pages/data_view.ts": 3, | |
| 49 | "src/web/pages/display.ts": 1, | |
| 50 | "src/web/pages/economics.ts": 1, | |
| 51 | "src/web/pages/family.ts": 1, | |
| 52 | "src/web/pages/features.ts": 1, | |
| 53 | "src/web/pages/flags.ts": 1, | |
| 54 | "src/web/pages/flow-panel.ts": 1, | |
| 55 | "src/web/pages/flows-all.ts": 1, | |
| 56 | "src/web/pages/forges-refused.ts": 1, | |
| 57 | "src/web/pages/grants.ts": 1, | |
| 58 | "src/web/pages/hosted-forges.ts": 2, | |
| 59 | "src/web/pages/inventory.ts": 1, | |
| 60 | "src/web/pages/issues.ts": 1, | |
| 61 | "src/web/pages/looks.ts": 1, | |
| 62 | "src/web/pages/notes.ts": 1, | |
| 63 | "src/web/pages/origin-flow.ts": 1, | |
| 64 | "src/web/pages/origins.ts": 1, | |
| 65 | "src/web/pages/packs.ts": 2, | |
| 66 | "src/web/pages/pull.ts": 1, | |
| 67 | "src/web/pages/reports.ts": 1, | |
| 68 | "src/web/pages/runners.ts": 1, | |
| 69 | "src/web/pages/settings.ts": 1, | |
| 70 | "src/web/pages/sources.ts": 1, | |
| 71 | "src/web/pages/system.ts": 6, | |
| 72 | "src/web/pages/talk_preview.ts": 3, | |
| 73 | "src/web/pages/teams.ts": 1, | |
| 74 | "src/web/pages/trusted.ts": 1, | |
| 75 | "src/web/pages/visitors.ts": 1, | |
| 76 | "src/web/pages/waves.ts": 1, | |
| 77 | "src/web/render/deps-manifest.ts": 1, | |
| 78 | "src/web/render/ora.ts": 1, | |
| 79 | "src/web/render/sarif.ts": 1, | |
| 80 | "src/web/render/sbom.ts": 1, | |
| 81 | "src/web/settings/devices.ts": 1, | |
| 82 | "src/web/studio/cut_over.ts": 1, | |
| 83 | "src/web/studio/data_move.ts": 1, | |
| 84 | "src/web/studio/explore.ts": 1, | |
| 85 | "src/web/studio/file_holds.ts": 1, | |
| 86 | "src/web/studio/hold.ts": 1, | |
| 87 | "src/web/studio/home.ts": 1, | |
| 88 | "src/web/studio/jobs.ts": 1, | |
| 89 | }; | |
| 90 | const own = (src: string): number => [...src.matchAll(OWN_FORM)].length; | |
| 91 | ||
| 92 | test("every emptyList(kind) a page registers has an entry in the table", () => { | |
| 93 | const missing: string[] = []; | |
| 94 | for (const [p, src] of files) { | |
| 95 | for (const m of src.matchAll(/emptyList\(\s*"([^"]+)"/g)) { | |
| 96 | if (!(m[1]! in EMPTY_WORDS)) missing.push(`${p}: emptyList("${m[1]}") has no entry in src/core/empty_words.ts`); | |
| 97 | } | |
| 98 | } | |
| 99 | expect(missing).toEqual([]); | |
| 100 | }); | |
| 101 | ||
| 102 | test("every entry has a sentence; a reason is one more sentence, never the sentence again", () => { | |
| 103 | for (const [kind, w] of Object.entries(EMPTY_WORDS)) { | |
| 104 | expect(`${kind}: ${/\.$/.test(w.sentence)}`).toBe(`${kind}: true`); | |
| 105 | if (w.reason !== undefined) { | |
| 106 | expect(`${kind}: ${w.reason.length > 10 && /\.$/.test(w.reason) && w.reason !== w.sentence}`).toBe(`${kind}: true`); | |
| 107 | } | |
| 108 | } | |
| 109 | }); | |
| 110 | ||
| 111 | // The unscoped places an empty state may send someone; a repository's list hands in its own href. | |
| 112 | const UNSCOPED = new Set(["/boards/data", "/tell", "/issues", "/apps/new", "/admin/limits", "/new"]); | |
| 113 | ||
| 114 | test("a link is a label and a place that exists; no default href points nowhere", () => { | |
| 115 | for (const [kind, w] of Object.entries(EMPTY_WORDS)) { | |
| 116 | if (w.href !== undefined) { | |
| 117 | expect(`${kind}: ${w.label !== undefined && UNSCOPED.has(w.href)}`).toBe(`${kind}: true`); | |
| 118 | } | |
| 119 | } | |
| 120 | }); | |
| 121 | ||
| 122 | test("a page does not word more bare 'No …' empty states than it is named for", () => { | |
| 123 | const over = files.filter(([p, src]) => own(src) > (OWN_WORDS[p] ?? 0)).map(([p, src]) => `${p}: ${own(src)} > ${OWN_WORDS[p] ?? 0}`); | |
| 124 | expect(over).toEqual([]); | |
| 125 | }); | |
| 126 | ||
| 127 | test("a page that moved to the table is off the list of own words", () => { | |
| 128 | const moved = files.filter(([p, src]) => own(src) < (OWN_WORDS[p] ?? 0)).map(([p, src]) => `${p}: ${own(src)} < ${OWN_WORDS[p]}`); | |
| 129 | expect(moved).toEqual([]); | |
| 130 | }); |
test/releases-page.test.ts +3 −2
| @@ -163,9 +163,10 @@ describe("the releases page", () => { | ||
| 163 | 163 | const res = await fetch(`${s.url}/releases`, { headers: { cookie } }); |
| 164 | 164 | expect(res.status).toBe(200); |
| 165 | 165 | const body = await res.text(); |
| 166 | const at = body.indexOf('<p class="mt muted">No releases yet. '); | |
| 166 | const at = body.indexOf('<div class="empty"'); | |
| 167 | 167 | expect(at).toBeGreaterThan(-1); |
| 168 | const line = body.slice(at, body.indexOf("</p>", at)); | |
| 168 | const line = body.slice(at, body.indexOf("</div>", at)); | |
| 169 | expect(line).toContain("No releases yet."); | |
| 169 | 170 | expect(line.replaceAll("'", "'")).toContain(NO_RELEASES_YET); |
| 170 | 171 | // After the keeper panel, only the muted line: no list, no card. |
| 171 | 172 | const rest = body.slice(at, body.indexOf("</main>")); |
Entries carry hrefs like /branches, /fork, /issues/new that do not exist unscoped; most are only ever used with noAction. Make href/label optional and drop the false ones.