Public: anyone can read this; the crew can change it.
An archived origin's missing-scope warning is one plain line with its action, not a boxed alert card #10031
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/10000-an-archived-origin-s-missing-scope-warni → main 2 commits fork
2 files
changed +23
−18
src/web/pages/origin-archived.ts +13 −18
| @@ -17,7 +17,7 @@ import { | ||
| 17 | 17 | import type { Ctx } from "../../http/context.ts"; |
| 18 | 18 | import { field, readForm } from "../form.ts"; |
| 19 | 19 | import { html, when, type Html } from "../html.ts"; |
| 20 | import { badge, btn, card, empty, listCard, row, time } from "../ui.ts"; | |
| 20 | import { badge, btn, empty, listCard, row, time } from "../ui.ts"; | |
| 21 | 21 | import { accountOnly, hostLabel, notFoundNote, shell } from "./origins.ts"; |
| 22 | 22 | |
| 23 | 23 | const selectAllJs = /* js */ ` |
| @@ -127,23 +127,18 @@ async function render( | ||
| 127 | 127 | Restoring a repository makes it writable again. Apps the platform spun |
| 128 | 128 | down when it was archived may need starting there. |
| 129 | 129 | </p> |
| 130 | ${when(!canWrite, () => | |
| 131 | card( | |
| 132 | html`<p role="alert"> | |
| 133 | This token cannot restore anything: it is missing | |
| 134 | <strong>${scopeWords(missingWrite)}</strong> | |
| 135 | (<code>${missingWrite.join(", ")}</code>). Replace it on the origins | |
| 136 | page, and this page will offer Restore. | |
| 137 | </p> | |
| 138 | <div class="bar mt"> | |
| 139 | ${btn("Replace the token", { | |
| 140 | href: "/settings/origins", | |
| 141 | size: "sm", | |
| 142 | variant: "primary", | |
| 143 | })} | |
| 144 | </div>`, | |
| 145 | { tone: "attn", extra: "mb" }, | |
| 146 | ), | |
| 130 | ${when( | |
| 131 | !canWrite, | |
| 132 | () => html`<p class="small mb"> | |
| 133 | This token cannot restore anything: it is missing | |
| 134 | <strong>${scopeWords(missingWrite)}</strong> | |
| 135 | (<code>${missingWrite.join(", ")}</code>). | |
| 136 | ${btn("Replace the token", { | |
| 137 | href: "/settings/origins", | |
| 138 | size: "sm", | |
| 139 | variant: "ghost", | |
| 140 | })} | |
| 141 | </p>`, | |
| 147 | 142 | )} |
| 148 | 143 | ${when( |
| 149 | 144 | options.notice !== undefined, |
test/web-origin-archived.test.ts +10
| @@ -225,6 +225,16 @@ describe("restoring archived repositories", () => { | ||
| 225 | 225 | const { text } = await get(adaCookie); |
| 226 | 226 | expect(text).toContain("Repository: Read and write"); |
| 227 | 227 | expect(text).toContain("write:repository"); |
| 228 | expect(text).toContain("This token cannot restore anything"); | |
| 229 | expect(text).toContain("Replace the token"); | |
| 230 | expect(text).not.toContain('role="alert"'); | |
| 231 | // Everything in <main> above the list's form: no card, so no alert box. | |
| 232 | const above = text.slice( | |
| 233 | text.indexOf("<main"), | |
| 234 | text.indexOf('<form method="post" action="' + path), | |
| 235 | ); | |
| 236 | expect(above).toContain("This token cannot restore anything"); | |
| 237 | expect(above).not.toContain('class="card'); | |
| 228 | 238 | expect(text).not.toContain(`name="one"`); |
| 229 | 239 | expect(patches()).toBe(0); |
| 230 | 240 | expect(fake.state.repos[0]!.archived).toBe(true); |