Public: anyone can read this; the crew can change it.
Design: a connected origin's row and its mirror form use §5's row and field, and origin-row/name/mark and mirror-form leave §5d #4079
scout/forge:scout/3943-design-a-connected-origin-s-row-and-its → main 16 commits fork 4 threads · 4 unresolved
docs/DESIGN.md +1 −1
| @@ -393,7 +393,7 @@ gone, so this list only shrinks. | ||
| 393 | 393 | - **`style/base.ts`** — the page shell (topbar, main, footer) and the layout and text utilities every page leans on: `.bar` `.bare` `.foot` `.grow` `.hide-lg` `.hide-sm` `.js-only` `.live-pill` `.mark` `.mb` `.mt` `.muted` `.narrow` `.narrow-wide` `.num` `.reduced` `.shell` `.shell-wide` `.skip` `.small` `.spacer` `.sr-only` `.stack` `.stack-tight` `.topbar` `.topbar-tools` `.truncate` `.wordmark` |
| 394 | 394 | - **`style/components.ts`** — parts of the §5 components that the table does not spell out — the palette's list, the menu's items, a dialog's head and foot, comments, the theme picker — and a few small helpers beside them: `.cat` `.clone` `.clone-text` `.comment` `.comment-body` `.comment-form` `.dash` `.dialog-body` `.dialog-foot` `.dialog-head` `.empty-title` `.error-note` `.field-row` `.form-actions` `.hex` `.ico` `.ico-loader` `.list` `.live-status` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.passkey` `.passkey-lead` `.passkey-note` `.passkey-off` `.passkey-on` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search` |
| 395 | 395 | - **`style/components.ts`, settings rows** — a list whose rows are settings (limits, capacity): the `<ul class="list setting-list">` lets title and meta wrap instead of ellipsizing, and a row's controls take their own line under 640px. `.row-fields` is the form in that row's trail (input, Save, Default): always visible, never hover-gated, wrapping under the text before it would clip. Use both for any page whose rows show a name, a current value, and a control to change it; use `.row-actions` only for secondary actions (delete, wake, pin, revoke). Flags, telemetry, cloud, people, crew roles and subscription headroom/budget use `.row-fields`. Classes: `.row-fields` `.setting-list` |
| 396 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, following, lineage: `.about` `.act` `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.big` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.chart` `.chart-box` `.commit-body` `.commit-head` `.connect-more` `.connect-path` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.following` `.following-actions` `.following-eyebrow` `.following-foot` `.following-head` `.following-sentence` `.fork-bar` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.handoff` `.handoff-links` `.headroom` `.issue-head` `.issue-meta` `.lineage` `.lineage-children` `.lineage-here` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep` | |
| 396 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, following, lineage: `.about` `.act` `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.big` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.chart` `.chart-box` `.commit-body` `.commit-head` `.connect-more` `.connect-path` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.following` `.following-actions` `.following-eyebrow` `.following-foot` `.following-head` `.following-sentence` `.fork-bar` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.handoff` `.handoff-links` `.headroom` `.issue-head` `.issue-meta` `.lineage` `.lineage-children` `.lineage-here` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.number` `.origin-link` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep` | |
| 397 | 397 | - **`style/content.ts`, code view** — the source view and the syntax-highlight token classes `highlight-html.ts` builds as `tok-${kind}`: `.blob-view` `.ln` `.tok-attribute` `.tok-comment` `.tok-constant` `.tok-decorator` `.tok-deleted` `.tok-emphasis` `.tok-function` `.tok-heading` `.tok-inserted` `.tok-keyword` `.tok-link` `.tok-meta` `.tok-number` `.tok-operator` `.tok-plain` `.tok-property` `.tok-punctuation` `.tok-regex` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable` |
| 398 | 398 | - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r` |
| 399 | 399 | - **`style/content.ts`, diff viewer** — the diff table: its gutters, line kinds, file head and inline review comments: `.add` `.del` `.dh` `.diff` `.diff-body` `.diff-head` `.diff-note` `.diff-path` `.diff-stat` `.diff-stub` `.diff-summary` `.diff-table` `.dl` `.dl-review` `.dn` `.dn-comment` `.nonl` `.rc-hidden` `.rc-resolve` `.rc-resolved` `.wd` |
src/web/pages/origins.ts +20 −23
| @@ -313,31 +313,25 @@ function reauthNote(origin: Origin, mirrors: number): Html { | ||
| 313 | 313 | function originCard(origin: Origin, mirrors: number): Html { |
| 314 | 314 | const base = `/settings/origins/${origin.id}`; |
| 315 | 315 | return card( |
| 316 | html`<div class="origin-row"> | |
| 317 | <span class="origin-mark">${icon(originIcon(origin.kind))}</span> | |
| 318 | <span class="grow"> | |
| 319 | <span class="origin-name" | |
| 320 | >${origin.login}<span class="muted"> @ </span>${hostLabel( | |
| 316 | html`<ul class="list setting-list"> | |
| 317 | ${row({ | |
| 318 | lead: icon(originIcon(origin.kind)), | |
| 319 | title: html`${origin.login}<span class="muted"> @ </span>${hostLabel( | |
| 321 | 320 | origin.webUrl, |
| 322 | )}</span | |
| 323 | > | |
| 324 | <span class="row-meta muted small" | |
| 325 | >${origin.authKind === "oauth" ? "OAuth" : "personal access token"} | |
| 321 | )}`, | |
| 322 | meta: html`${origin.authKind === "oauth" | |
| 323 | ? "OAuth" | |
| 324 | : "personal access token"} | |
| 326 | 325 | · |
| 327 | 326 | ${origin.lastSyncAt === null |
| 328 | 327 | ? html`never synced` |
| 329 | : html`synced ${time(origin.lastSyncAt)}`}</span | |
| 330 | > | |
| 331 | ${when( | |
| 332 | isTrustedHost(URL.parse(origin.webUrl)?.hostname ?? ""), | |
| 333 | () => | |
| 334 | html`<span class="row-meta muted small" | |
| 335 | >trusted internal host</span | |
| 336 | >`, | |
| 337 | )} | |
| 338 | </span> | |
| 339 | ${healthBadge(origin)} | |
| 340 | </div> | |
| 328 | : html`synced ${time(origin.lastSyncAt)}`}${when( | |
| 329 | isTrustedHost(URL.parse(origin.webUrl)?.hostname ?? ""), | |
| 330 | () => html` · trusted internal host`, | |
| 331 | )}`, | |
| 332 | trail: healthBadge(origin), | |
| 333 | })} | |
| 334 | </ul> | |
| 341 | 335 | ${when( |
| 342 | 336 | origin.lastError !== "", |
| 343 | 337 | () => html`<p class="error-note mt">${origin.lastError}</p>`, |
| @@ -1454,7 +1448,7 @@ export async function originReposPage(ctx: Ctx): Promise<Response> { | ||
| 1454 | 1448 | forkable, |
| 1455 | 1449 | () => |
| 1456 | 1450 | html`<form |
| 1457 | class="mirror-form" | |
| 1451 | class="row-fields" | |
| 1458 | 1452 | method="post" |
| 1459 | 1453 | action="${browseBase(origin.id, remote.fullName)}/fork" |
| 1460 | 1454 | > |
| @@ -1476,7 +1470,7 @@ export async function originReposPage(ctx: Ctx): Promise<Response> { | ||
| 1476 | 1470 | })}` |
| 1477 | 1471 | : html`${counted}${forkForm} |
| 1478 | 1472 | <form |
| 1479 | class="mirror-form" | |
| 1473 | class="row-fields" | |
| 1480 | 1474 | method="post" |
| 1481 | 1475 | action="/settings/origins/${origin.id}/mirror" |
| 1482 | 1476 | > |
| @@ -1490,6 +1484,8 @@ export async function originReposPage(ctx: Ctx): Promise<Response> { | ||
| 1490 | 1484 | () => |
| 1491 | 1485 | html`<input |
| 1492 | 1486 | class="input" |
| 1487 | data-size="sm" | |
|
||
| 1488 | data-width="short" | |
| 1493 | 1489 | name="name" |
| 1494 | 1490 | placeholder="local name" |
| 1495 | 1491 | aria-label="Local name for ${remote.fullName}" |
| @@ -1548,6 +1544,7 @@ export async function originReposPage(ctx: Ctx): Promise<Response> { | ||
| 1548 | 1544 | trail, |
| 1549 | 1545 | }); |
| 1550 | 1546 | }), |
| 1547 | { settings: true }, | |
| 1551 | 1548 | ); |
| 1552 | 1549 | |
| 1553 | 1550 | return page({ |
src/web/style/components.ts +3
| @@ -91,6 +91,9 @@ export const components = /* css */ ` | ||
| 91 | 91 | } |
| 92 | 92 | .input[readonly] { background: var(--muted); color: var(--muted-fg); } |
| 93 | 93 | .input[data-size="sm"] { min-height: 28px; padding: 4px 8px; font-size: 13px; } |
| 94 | /* A bounded text input (an optional short name beside a button): it shrinks | |
| 95 | inside .row-fields (min-width:0) before it can push the button off a phone. */ | |
| 96 | .input[data-width="short"] { width: 10rem; } | |
New field variant that §5's input row does not name. Add |
||
| 94 | 97 | textarea.input { |
| 95 | 98 | resize: vertical; min-height: 88px; line-height: 1.55; font-family: inherit; |
| 96 | 99 | field-sizing: content; max-height: 24lh; |
src/web/style/content.ts −5
| @@ -148,9 +148,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); } | ||
| 148 | 148 | .origin-link:hover { color: var(--accent); } |
| 149 | 149 | |
| 150 | 150 | /* The origins settings page. */ |
| 151 | .origin-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } | |
| 152 | .origin-row .origin-mark .ico { color: var(--muted-fg); } | |
| 153 | .origin-name { display: block; font-weight: 560; } | |
| 154 | 151 | .connect-path + .connect-path { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); } |
| 155 | 152 | /* The two OAuth paths, folded away. Both need somebody to register an |
| 156 | 153 | application once, and a page whose first control cannot be used until an |
| @@ -192,8 +189,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); } | ||
| 192 | 189 | .connect-path h3 .ico { color: var(--muted-fg); } |
| 193 | 190 | .steps { margin: 8px 0 12px 18px; padding: 0; color: var(--muted-fg); } |
| 194 | 191 | .steps li + li { margin-top: 6px; } |
| 195 | .mirror-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } | |
| 196 | .mirror-form .input { width: 10rem; padding: 4px 8px; font-size: 13px; } | |
| 197 | 192 | |
| 198 | 193 | /* A device code is read aloud across a room and typed on a phone: it is the |
outdated
A rule keyed on |
||
| 199 | 194 | one place in the product where type is deliberately large. */ |
src/web/ui.ts +7 −3
| @@ -836,12 +836,16 @@ export function card(body: Html, o: CardOptions = {}): Html { | ||
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** A card wrapping a `<ul class="list">` — the shape every listing takes. */ |
| 839 | export function listCard(rows: Html[], o: CardOptions = {}): Html { | |
| 839 | export function listCard( | |
| 840 | rows: Html[], | |
| 841 | o: CardOptions & { settings?: boolean } = {}, | |
| 842 | ): Html { | |
| 843 | const { settings, ...card_ } = o; | |
| 840 | 844 | return card( |
| 841 | html`<ul class="list"> | |
| 845 | html`<ul class="${settings ? "list setting-list" : "list"}"> | |
| 842 | 846 | ${rows} |
| 843 | 847 | </ul>`, |
| 844 | { ...o, pad: false }, | |
| 848 | { ...card_, pad: false }, | |
| 845 | 849 | ); |
| 846 | 850 | } |
| 847 | 851 |
test/trusted-hosts-ui.test.ts +2
| @@ -127,6 +127,8 @@ describe("trusted internal hosts", () => { | ||
| 127 | 127 | expect(page).toContain("Trusted internal hosts"); |
| 128 | 128 | expect(page).toContain("git.internal.test"); |
| 129 | 129 | expect(page.match(/trusted internal host/g)?.length).toBe(1); |
| 130 | // Never synced and trusted: one separator, not a dangling or doubled one. | |
| 131 | expect(page.replace(/\s+/g, " ")).toMatch(/never synced · trusted internal host/); | |
| 130 | 132 | }); |
| 131 | 133 | |
| 132 | 134 | test("migrate lets a non-admin reach a trusted host that resolves privately, not an untrusted one", async () => { |
test/web-origins.test.ts +43
| @@ -14,6 +14,7 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | ||
| 14 | 14 | import { mkdtemp, rm } from "node:fs/promises"; |
| 15 | 15 | import { tmpdir } from "node:os"; |
| 16 | 16 | import { join } from "node:path"; |
| 17 | import { createRepo } from "../src/actions/repos.ts"; | |
| 17 | 18 | import { createApp, type App } from "../src/app.ts"; |
| 18 | 19 | import { serve, type Servers } from "../src/http/server.ts"; |
| 19 | 20 | import { enableApp } from "../src/actions/apps.ts"; |
| @@ -225,6 +226,12 @@ describe("origins on the web", () => { | ||
| 225 | 226 | expect(html).toContain("personal access token"); |
| 226 | 227 | // The one thing that must never be on this page. |
| 227 | 228 | expect(html).not.toContain(ORIGIN_TOKEN); |
| 229 | // Drawn with the shared row, not the page's own classes. | |
| 230 | expect(html).toContain("row-title"); | |
| 231 | // Title and meta wrap on a phone instead of ellipsizing. | |
| 232 | expect(html).toContain('<ul class="list setting-list">'); | |
| 233 | for (const gone of ["origin-row", "origin-name", "origin-mark", "mirror-form"]) | |
| 234 | expect(html).not.toContain(gone); | |
| 228 | 235 | |
| 229 | 236 | const stored = listOrigins(app.db, getUserByName(app.db, "alice")!.id); |
| 230 | 237 | expect(stored).toHaveLength(1); |
| @@ -293,6 +300,42 @@ describe("origins on the web", () => { | ||
| 293 | 300 | expect(html).not.toContain("Mirror all"); |
| 294 | 301 | }); |
| 295 | 302 | |
| 303 | test("a taken name puts a bounded local-name input in a row-fields Mirror form", async () => { | |
| 304 | const id = listOrigins(app.db, getUserByName(app.db, "alice")!.id)[0]!.id; | |
| 305 | const clash = await createRepo(app, getUserByName(app.db, "alice")!, { | |
| 306 | name: "gadgets", | |
| 307 | visibility: "private", | |
| 308 | }); | |
| 309 | expect(clash.ok).toBe(true); | |
| 310 | forgejo.state.repos.push({ | |
| 311 | id: 42, | |
| 312 | fullName: "octo/gadgets", | |
| 313 | cloneUrl: `${originServers.url}/octo/gadgets.git`, | |
| 314 | htmlUrl: `${originServers.url}/octo/gadgets`, | |
| 315 | defaultBranch: "main", | |
| 316 | }); | |
| 317 | try { | |
| 318 | const html = await ( | |
| 319 | await asUser(alice, `/settings/origins/${id}/repos?refresh=1`) | |
| 320 | ).text(); | |
| 321 | const form = html.match( | |
| 322 | /<form\s[^>]*?action="\/settings\/origins\/[^"/]+\/mirror"[\s\S]*?<\/form>/g, | |
| 323 | )!; | |
| 324 | expect(html).toContain('class="list setting-list"'); | |
| 325 | const gadgets = form.find((f) => /gadgets/.test(f))!; | |
| 326 | expect(gadgets).toContain('class="row-fields"'); | |
| 327 | expect(gadgets).toContain('data-width="short"'); | |
| 328 | expect(gadgets).toMatch(/<input[^>]*class="input"/); | |
| 329 | expect(gadgets).toContain('aria-label="Local name for octo/gadgets"'); | |
| 330 | // No clash, no box: the widgets row has only the hidden field. | |
| 331 | const widgets = form.find((f) => /widgets/.test(f))!; | |
| 332 | expect(widgets).toContain('class="row-fields"'); | |
| 333 | expect(widgets).not.toContain("Local name"); | |
| 334 | } finally { | |
| 335 | forgejo.state.repos = forgejo.state.repos.filter((r) => r.id !== 42); | |
| 336 | } | |
| 337 | }); | |
| 338 | ||
| 296 | 339 | test("Mirror starts a job, shows its stages, and lands on the mirror", async () => { |
| 297 | 340 | const id = listOrigins(app.db, getUserByName(app.db, "alice")!.id)[0]!.id; |
| 298 | 341 | const mirrored = await asUser(alice, `/settings/origins/${id}/mirror`, { |
Use class="list setting-list" so the title and the meta line wrap on a phone instead of ellipsizing, and the health badge drops to its own line under 640px.