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

An app's policy line draws §5's row and badge, and .policy-line leaves the stylesheet #4636

Parked opened this
Closed without merging

scout/forge:scout/4587-an-app-s-policy-line-draws-5-s-row-and-b → main 6 commits fork 1 thread · 1 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
4 files changed +60 −35
docs/DESIGN.md +4
@@ -395,7 +395,11 @@ gone, so this list only shrinks.
395395 A `.field` directly inside a `.bar` drops its bottom margin and the bar aligns to the end, so a labelled input and its button share a baseline
396396 - **`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` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.passkey` `.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`
397397 - **`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`
398 <<<<<<< HEAD
399 - **`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, lineage: `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.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` `.commit-body` `.commit-head` `.domain-records` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.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` `.tok` `.wall-cells` `.where-sep`
400 =======
398401 - **`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, lineage: `.bform` `.bgrid` `.bmanage` `.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` `.commit-body` `.commit-head` `.domain-records` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.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` `.tok` `.wall-cells` `.where-sep`
402 >>>>>>> origin/main
399403 - **`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`
400404 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
401405 - **`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/studio/app.ts +44 −25
@@ -39,6 +39,7 @@ import { liveClientJs, liveMount } from "../live.ts";
3939 import { followingCard, followingOf } from "../pages/following.ts";
4040 import {
4141 avatar,
42 badge,
4243 btn,
4344 card,
4445 envPhrase,
@@ -173,15 +174,25 @@ async function policyLine(
173174 const { standing } = await audit(ctx.app.reposRoot, repo);
174175 if (standing.kind === "unread") return html``;
175176 const href = `/audit#${repo.ownerName}-${repo.name}`;
177 // Rows wrap here (the `setting-list` pattern): the door count and the
178 // knock result are what the line is for, and an ellipsis would take them.

This lines helper repeats listCard (card + ul.list, pad:false). It only exists to add the setting-list class. Fine for now; give listCard an extra-class option later so there is one copy.

179 const lines = (r: Html) =>
180 card(
181 html`<ul class="list setting-list">
182 ${r}
183 </ul>`,
184 { pad: false },
185 );
176186 if (standing.kind === "unsound")
177 return html`<p class="policy-line">
178 ${icon("alert")}
179 <span
180 ><b>Its contract does not read</b>, so an app built on it does not
181 boot.</span
182 >
183 <a href="${href}">See why</a>
184 </p>`;
187 return lines(
188 row({
189 href,
190 lead: icon("alert"),
191 title: html`<b>Its contract does not read</b>`,
192 meta: html`an app built on it does not boot`,
193 trail: badge("unsound", { tone: "danger" }),
194 }),
195 );
185196 const last = latestProbes(ctx.app.db, [record.id]).get(record.id);
186197 const open = standing.open.length;
187198 const said =
@@ -194,23 +205,31 @@ async function policyLine(
194205 : last.verdict === "down"
195206 ? "was not running when knocked on"
196207 : "has no door to knock on";
197 return html`<p class="policy-line" data-tone="${last?.verdict ?? "none"}">
198 ${icon("shield")}
199 <span
200 ><b
201 >${Object.keys(standing.contract.resources).length === 1
202 ? "One resource"
203 : `${Object.keys(standing.contract.resources).length} resources`}</b
204 >,
205 ${open === 0
206 ? "nothing open to anyone"
207 : open === 1
208 ? "one door open to anyone"
209 : `${open} doors open to anyone`};
210 ${said}.</span
211 >
212 <a href="${href}">The table</a>
213 </p>`;
208 const verdict =
209 last === undefined
210 ? { word: "not knocked", tone: "default" as const }
211 : last.verdict === "ok"
212 ? { word: "ok", tone: "success" as const }
213 : last.verdict === "mismatch"
214 ? { word: "mismatch", tone: "danger" as const }
215 : last.verdict === "down"
216 ? { word: "down", tone: "attn" as const }
217 : { word: "no door", tone: "default" as const };
218 const resources = Object.keys(standing.contract.resources).length;
219 return lines(
220 row({
221 href,
222 lead: icon("shield"),
223 title: html`<b>${resources === 1 ? "One resource" : `${resources} resources`}</b>,
224 ${open === 0
225 ? "nothing open to anyone"
226 : open === 1
227 ? "one door open to anyone"
228 : `${open} doors open to anyone`}`,
229 meta: html`${said}`,
230 trail: badge(verdict.word, { tone: verdict.tone }),
231 }),
232 );
214233 }
215234
216235 export async function studioApp(
src/web/style/content.ts −8
@@ -331,14 +331,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
331331 .fg-s7 { fill: var(--series-7); color: var(--series-7); }
332332 /* The records a domain waits on: type, name, value — as a zone file reads. */
333333 .domain-records { margin: 6px 0 2px; padding: 8px 10px; font-size: 12.5px; line-height: 1.6; white-space: pre; overflow-x: auto; scrollbar-width: thin; background: var(--muted); border-radius: var(--radius); }
334 .policy-line {
335 display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
336 margin: 12px 0 0; font-size: 13px; color: var(--muted-fg);
337 }
338 .policy-line .ico { color: var(--faint); flex: none; }
339 .policy-line b { color: var(--fg); font-weight: 600; }
340 .policy-line[data-tone="mismatch"] .ico { color: var(--danger); }
341 .policy-line[data-tone="ok"] .ico { color: var(--success); }
342334 .wall-cells li + li { margin-top: 3px; }
343335 form.inline { display: inline; margin-left: auto; }
344336
test/audit.test.ts +12 −2
@@ -442,7 +442,8 @@ describe("the audit reads every app's policy from git", () => {
442442 headers: { cookie: `${cookie}; forge_mode=studio` },
443443 })
444444 ).text();
445 expect(notes).toContain('class="policy-line"');
445 expect(notes).not.toContain("policy-line");
446 expect(notes).toMatch(/class="badge"[^>]*>\s*not knocked\s*</);
446447 expect(notes).toContain("2 resources");
447448 expect(notes).toContain('href="/audit#alice-notes"');
448449 // The audit page carries that anchor.
@@ -456,6 +457,15 @@ describe("the audit reads every app's policy from git", () => {
456457 headers: { cookie: `${cookie}; forge_mode=studio` },
457458 })
458459 ).text();
459 expect(bare).not.toContain('class="policy-line"');
460 expect(bare).not.toContain('href="/audit#');
461 // A contract that does not read is said, with a word and not a colour.
462 const broken = await (
463 await fetch(`${servers.url}/alice/broken`, {
464 headers: { cookie: `${cookie}; forge_mode=studio` },
465 })
466 ).text();
467 expect(broken).toContain("Its contract does not read");
468 expect(broken).toMatch(/data-variant="danger"[^>]*>\s*unsound\s*</);
469 expect(broken).toContain('href="/audit#alice-broken"');
460470 });
461471 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs