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 #4674
scout/forge:scout/4587-an-app-s-policy-line-draws-5-s-row-and-b → main 10 commits fork
4 files
changed +57
−36
docs/DESIGN.md +1 −1
| @@ -395,7 +395,7 @@ gone, so this list only shrinks. | ||
| 395 | 395 | 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 |
| 396 | 396 | - **`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` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search` |
| 397 | 397 | - **`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 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, 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` `.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` `.steps` `.sub` `.sys-pair` `.table-wrap` `.tok` `.where-sep` | |
| 398 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, 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` `.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` `.steps` `.sub` `.sys-pair` `.table-wrap` `.tok` `.where-sep` | |
| 399 | 399 | - **`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` |
| 400 | 400 | - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r` |
| 401 | 401 | - **`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"; | ||
| 39 | 39 | import { followingCard, followingOf } from "../pages/following.ts"; |
| 40 | 40 | import { |
| 41 | 41 | avatar, |
| 42 | badge, | |
| 42 | 43 | btn, |
| 43 | 44 | card, |
| 44 | 45 | envPhrase, |
| @@ -173,15 +174,25 @@ async function policyLine( | ||
| 173 | 174 | const { standing } = await audit(ctx.app.reposRoot, repo); |
| 174 | 175 | if (standing.kind === "unread") return html``; |
| 175 | 176 | 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. | |
| 179 | const lines = (r: Html) => | |
| 180 | card( | |
| 181 | html`<ul class="list setting-list"> | |
| 182 | ${r} | |
| 183 | </ul>`, | |
| 184 | { pad: false }, | |
| 185 | ); | |
| 176 | 186 | 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 | ); | |
| 185 | 196 | const last = latestProbes(ctx.app.db, [record.id]).get(record.id); |
| 186 | 197 | const open = standing.open.length; |
| 187 | 198 | const said = |
| @@ -194,23 +205,31 @@ async function policyLine( | ||
| 194 | 205 | : last.verdict === "down" |
| 195 | 206 | ? "was not running when knocked on" |
| 196 | 207 | : "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 | ); | |
| 214 | 233 | } |
| 215 | 234 | |
| 216 | 235 | export async function studioApp( |
src/web/style/content.ts −8
| @@ -297,14 +297,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); } | ||
| 297 | 297 | .fg-s7 { fill: var(--series-7); color: var(--series-7); } |
| 298 | 298 | /* The records a domain waits on: type, name, value — as a zone file reads. */ |
| 299 | 299 | .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); } |
| 300 | .policy-line { | |
| 301 | display: flex; align-items: center; gap: 8px; flex-wrap: wrap; | |
| 302 | margin: 12px 0 0; font-size: 13px; color: var(--muted-fg); | |
| 303 | } | |
| 304 | .policy-line .ico { color: var(--faint); flex: none; } | |
| 305 | .policy-line b { color: var(--fg); font-weight: 600; } | |
| 306 | .policy-line[data-tone="mismatch"] .ico { color: var(--danger); } | |
| 307 | .policy-line[data-tone="ok"] .ico { color: var(--success); } | |
| 308 | 300 | form.inline { display: inline; margin-left: auto; } |
| 309 | 301 | |
| 310 | 302 | /* The studio's front door: the public apps, live first, as pictures. */ |
test/audit.test.ts +12 −2
| @@ -442,7 +442,8 @@ describe("the audit reads every app's policy from git", () => { | ||
| 442 | 442 | headers: { cookie: `${cookie}; forge_mode=studio` }, |
| 443 | 443 | }) |
| 444 | 444 | ).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*</); | |
| 446 | 447 | expect(notes).toContain("2 resources"); |
| 447 | 448 | expect(notes).toContain('href="/audit#alice-notes"'); |
| 448 | 449 | // The audit page carries that anchor. |
| @@ -456,6 +457,15 @@ describe("the audit reads every app's policy from git", () => { | ||
| 456 | 457 | headers: { cookie: `${cookie}; forge_mode=studio` }, |
| 457 | 458 | }) |
| 458 | 459 | ).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"'); | |
| 460 | 470 | }); |
| 461 | 471 | }); |
new above
offline