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

Closed opened this
Closed without merging

scout/forge:scout/3943-design-a-connected-origin-s-row-and-its → main 16 commits fork 4 threads · 4 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
7 files changed +76 −32
docs/DESIGN.md +1 −1
@@ -393,7 +393,7 @@ gone, so this list only shrinks.
393393 - **`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`
394394 - **`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`
395395 - **`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`
397397 - **`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`
398398 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
399399 - **`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 {
313313 function originCard(origin: Origin, mirrors: number): Html {
314314 const base = `/settings/origins/${origin.id}`;
315315 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">
outdated

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.

317 ${row({
318 lead: icon(originIcon(origin.kind)),
319 title: html`${origin.login}<span class="muted"> @ </span>${hostLabel(
321320 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"}
326325 ·
327326 ${origin.lastSyncAt === null
328327 ? 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>
341335 ${when(
342336 origin.lastError !== "",
343337 () => html`<p class="error-note mt">${origin.lastError}</p>`,
@@ -1454,7 +1448,7 @@ export async function originReposPage(ctx: Ctx): Promise<Response> {
14541448 forkable,
14551449 () =>
14561450 html`<form
1457 class="mirror-form"
1451 class="row-fields"
14581452 method="post"
14591453 action="${browseBase(origin.id, remote.fullName)}/fork"
14601454 >
@@ -1476,7 +1470,7 @@ export async function originReposPage(ctx: Ctx): Promise<Response> {
14761470 })}`
14771471 : html`${counted}${forkForm}
14781472 <form
1479 class="mirror-form"
1473 class="row-fields"
14801474 method="post"
14811475 action="/settings/origins/${origin.id}/mirror"
14821476 >
@@ -1490,6 +1484,8 @@ export async function originReposPage(ctx: Ctx): Promise<Response> {
14901484 () =>
14911485 html`<input
14921486 class="input"
1487 data-size="sm"

data-size="sm" makes this field 28px on a touch screen: the coarse-pointer block in components.ts lifts .btn[data-size=sm] to 36px but has no matching .input rule. Add .input[data-size="sm"] { min-height: 36px; } there, or leave the input at its default size.

1488 data-width="short"
14931489 name="name"
14941490 placeholder="local name"
14951491 aria-label="Local name for ${remote.fullName}"
@@ -1548,6 +1544,7 @@ export async function originReposPage(ctx: Ctx): Promise<Response> {
15481544 trail,
15491545 });
15501546 }),
1547 { settings: true },
15511548 );
15521549
15531550 return page({
src/web/style/components.ts +3
@@ -91,6 +91,9 @@ export const components = /* css */ `
9191 }
9292 .input[readonly] { background: var(--muted); color: var(--muted-fg); }
9393 .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 width=short to the variants cell of the input / textarea / select row in docs/DESIGN.md §5, so the token is part of the system and not page-local.

9497 textarea.input {
9598 resize: vertical; min-height: 88px; line-height: 1.55; font-family: inherit;
9699 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); }
148148 .origin-link:hover { color: var(--accent); }
149149
150150 /* 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; }
154151 .connect-path + .connect-path { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
155152 /* The two OAuth paths, folded away. Both need somebody to register an
156153 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); }
192189 .connect-path h3 .ico { color: var(--muted-fg); }
193190 .steps { margin: 8px 0 12px 18px; padding: 0; color: var(--muted-fg); }
194191 .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; }
197192
198193 /* A device code is read aloud across a room and typed on a phone: it is the
outdated

A rule keyed on [name="name"] is a per-field width override. Make it a sized input token in components.ts (e.g. .input[data-width=short]) and drop this.

199194 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 {
836836 }
837837
838838 /** 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;
840844 return card(
841 html`<ul class="list">
845 html`<ul class="${settings ? "list setting-list" : "list"}">
842846 ${rows}
843847 </ul>`,
844 { ...o, pad: false },
848 { ...card_, pad: false },
845849 );
846850 }
847851
test/trusted-hosts-ui.test.ts +2
@@ -127,6 +127,8 @@ describe("trusted internal hosts", () => {
127127 expect(page).toContain("Trusted internal hosts");
128128 expect(page).toContain("git.internal.test");
129129 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/);
130132 });
131133
132134 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";
1414 import { mkdtemp, rm } from "node:fs/promises";
1515 import { tmpdir } from "node:os";
1616 import { join } from "node:path";
17 import { createRepo } from "../src/actions/repos.ts";
1718 import { createApp, type App } from "../src/app.ts";
1819 import { serve, type Servers } from "../src/http/server.ts";
1920 import { enableApp } from "../src/actions/apps.ts";
@@ -225,6 +226,12 @@ describe("origins on the web", () => {
225226 expect(html).toContain("personal access token");
226227 // The one thing that must never be on this page.
227228 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);
228235
229236 const stored = listOrigins(app.db, getUserByName(app.db, "alice")!.id);
230237 expect(stored).toHaveLength(1);
@@ -293,6 +300,42 @@ describe("origins on the web", () => {
293300 expect(html).not.toContain("Mirror all");
294301 });
295302
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
296339 test("Mirror starts a job, shows its stages, and lands on the mirror", async () => {
297340 const id = listOrigins(app.db, getUserByName(app.db, "alice")!.id)[0]!.id;
298341 const mirrored = await asUser(alice, `/settings/origins/${id}/mirror`, {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs