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

The flags page's form draws §5's row-fields, and .flag-form leaves the stylesheet #5184

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/4891-the-flags-page-s-form-draws-5-s-row-fiel → main 1 commit fork

  • Merged. mason/4891-the-flags-page-s-form-draws-5-s-row-fiel was merged into main as 4af9aa7.

Review

Sign in to review this change.
4 files changed +18 −10
docs/DESIGN.md −1
@@ -498,7 +498,6 @@ the same line (#4888).
498498 - `.fg-s6`
499499 - `.fg-s7`
500500 - `.filters`
501 - `.flag-form`
502501 - `.front-admin`
503502 - `.front-crew`
504503 - `.front-featured`
src/web/pages/flags.ts +1 −1
@@ -88,7 +88,7 @@ export function flagsPage(ctx: Ctx): Response {
8888 <span class="mono">${decl.default ? "on" : "off"}</span> · owner
8989 ${issueLink(repo, decl.issue)} ·
9090 live: ${summary(v)}<br /><span class="mono">${usesLine(week, month)}</span>`,
91 trail: html`<form class="row-fields flag-form" method="post" action="/settings/flags">
91 trail: html`<form class="row-fields" method="post" action="/settings/flags">
9292 <input type="hidden" name="name" value="${name}" />
9393 <select class="input" name="forge" aria-label="${name} for the forge">
9494 <option value="" ${v?.forge === undefined ? "selected" : ""}>forge: default</option>
src/web/style/content.ts −8
@@ -208,14 +208,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
208208 .row:has(.headroom) { flex-wrap: wrap; }
209209 .row:has(.headroom) .row-trail { flex-basis: 100%; flex-wrap: wrap; }
210210 }
211 /* Settings → Flags: a flag's controls wrap under its text on a phone, never sideways. */
212 .flag-form { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
213 @media (max-width: 640px) {
214 .row:has(.flag-form) { flex-wrap: wrap; }
215 .row:has(.flag-form) .row-trail { flex-basis: 100%; min-width: 0; }
216 .flag-form { justify-content: flex-start; }
217 .flag-form .input { min-width: 0; flex: 1 1 8rem; }
218 }
219211 .chart-box { color: var(--accent); aspect-ratio: 720 / 260; max-width: 720px; }
220212 .chart-box .chart { display: block; width: 100%; height: auto; }
221213 .chart-box text { fill: var(--muted-fg); font-family: var(--mono); }
test/flags-settings.test.ts +17
@@ -89,6 +89,23 @@ describe("settings → flags", () => {
8989 expect(reg.flag("alpha")).toBe(false);
9090 });
9191
92 test("each flag's form is §5d's row-fields, posting its own name and fields (#4891)", async () => {
93 const cookie = await login("alice");
94 const text = await (await fetch(`${servers.url}/settings/flags`, { headers: { cookie } })).text();
95 expect(text).not.toContain("flag-form");
96 const forms = text.match(/<form class="row-fields" method="post" action="\/settings\/flags">[\s\S]*?<\/form>/g) ?? [];
97 expect(forms.length).toBe(Object.keys(reg.decls).length);
98 const form = forms[0]!;
99 expect(form).toContain('<input type="hidden" name="name" value="alpha" />');
100 for (const field of ['name="forge"', 'name="users"', 'name="roles"', 'name="percent"', 'name="clear"'])
101 expect(form).toContain(field);
102
103 expect((await post(cookie, { name: "alpha", forge: "off", percent: "5" })).status).toBe(303);
104 expect(reg.value("alpha")).toEqual({ forge: false, percent: 5 });
105 await post(cookie, { name: "alpha", clear: "1" });
106 expect(reg.value("alpha")).toBeUndefined();
107 });
108
92109 test("a bad value, an unknown flag and a foreign origin change nothing", async () => {
93110 const cookie = await login("alice");
94111 await post(cookie, { name: "alpha", percent: "101" });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs