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

small: the '+ New forge' page has one primary next action, with phone and desktop looks on the pull #17818

opened this

Merged 5h 2m ago, live in production

scout/forge:scout/13374-small-the-new-forge-page-has-one-primary → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/13374-small-the-new-forge-page-has-one-primary was merged into main as 6cc8e61.

Review

Sign in to review this change.
3 files changed +20 −10
docs/design/quiet-debt.json −1
@@ -297,7 +297,6 @@
297297 "pagehead": 1
298298 },
299299 "src/web/pages/new-forge.ts": {
300 "row-primary": 1,
301300 "bare-list": 2
302301 },
303302 "src/web/pages/next-steps.ts": {
src/web/pages/new-forge.ts +8 −9
@@ -263,7 +263,7 @@ function formView(
263263 ? html`<p class="error mb" role="alert">${errors["form"]}${values.where !== "" ? html` <a href="${CEILING_PAGE}">Cloud accounts</a>` : null}</p>`
264264 : null}
265265 ${plan}
266 ${recipesView(recipes, errors)}
266 ${recipesView(recipes, errors, plan === null)}
267267 <section class="settings-block">
268268 <h2>Its name and apps</h2>
269269 <form method="post" action="/forges/new" class="stack" id="new-forge">
@@ -440,10 +440,8 @@ function formView(
440440 })}
441441 </details>`}
442442 <div class="form-actions" data-stick>
443 <button class="btn" type="submit" name="do" value="plan">
444 See the plan
445 </button>
446 ${btn("Spawn", { variant: "primary" })}
443 ${btn("See the plan", { name: "do", value: "plan", variant: "outline" })}
outdated

Principle 5, one way to draw a button: use btn("See the plan", { name: "do", value: "plan", variant: "outline" }) instead of a hand-written button element.

444 ${btn("Spawn", { variant: plan === null && recipes.length === 0 ? "primary" : "secondary" })}
447445 </div>
448446 </form>
449447 </section>
@@ -498,9 +496,10 @@ const sayConfig = (c: ForgeConfig): string =>
498496
499497 /**
500498 * Saved recipes: a name for the new forge, Spawn. A budget needs its key again, as a key is never
501 * kept.
499 * kept. The page has one primary action: the first recipe's Spawn when there is no plan on the page
500 * and a recipe is saved; the rest are secondary.
502501 */
503 function recipesView(recipes: readonly Recipe[], errors: Errors): Html | null {
502 function recipesView(recipes: readonly Recipe[], errors: Errors, primary: boolean): Html | null {
504503 if (recipes.length === 0) return null;
505504 return html`<section class="settings-block" id="recipes">
506505 <h2>Your recipes</h2>
@@ -513,8 +512,8 @@ function recipesView(recipes: readonly Recipe[], errors: Errors): Html | null {
513512 ? null
514513 : formField({ label: "AI account key", name: "modelKey", id: `recipe-${i}-key`, type: "password", autocomplete: "off", required: true, hint: `For its $${r.config.budgetUsd} budget; sealed in the new forge, never shown again.` })}
515514 <div class="form-actions">
516 <button class="btn" type="submit" name="do" value="plan">See the plan</button>
517 ${btn("Spawn", { variant: "primary" })}
515 ${btn("See the plan", { name: "do", value: "plan", variant: "outline" })}
516 ${btn("Spawn", { variant: primary && i === 0 ? "primary" : "secondary" })}
518517 </div>
519518 </form>`,
outdated

Same here: the recipe's See the plan should go through btn() with variant "outline", not raw markup.

520519 )}
test/new-forge-refresh.test.ts +12
@@ -14,6 +14,7 @@ import { PAGE_WAIT_MS, isStale, refreshForPage } from "../src/actions/places_ref
1414 import { readTimes, triedTimes } from "../src/cloud/places_read.ts";
1515 import { createUser, getUserByName } from "../src/core/users.ts";
1616 import type { Ctx } from "../src/http/context.ts";
17 import { saveRecipe } from "../src/spawn/recipes.ts";
1718 import { newForgePage } from "../src/web/pages/new-forge.ts";
1819 import { hetzner } from "./helpers/places-fixture.ts";
1920 import { quietLogs } from "./helpers/globals.ts";
@@ -122,3 +123,14 @@ test("a cloud account added just after a fresh look is read by the next visit",
122123 await visit();
123124 expect(triedTimes(app.db)["digitalocean"]).toBeDefined();
124125 });
126
127 test("with saved recipes the page has one primary Spawn (the first recipe's); the rest are secondary", async () => {
128 const alice = getUserByName(app.db, "alice")!;
129 const none = await visit();
130 expect(none.match(/data-variant="primary"/g)?.length ?? 0).toBe(1); // the form's own Spawn
131 for (const name of ["one", "two"]) expect(saveRecipe(app.config.dataDir, alice.id, name, { apps: [] }).ok).toBe(true);
132 const html = await visit();
133 expect(html.match(/data-variant="primary"/g)?.length).toBe(1);
134 expect(html.indexOf('data-variant="primary"')).toBeLessThan(html.indexOf('id="new-forge"'));
135 expect(html.match(/data-variant="outline"[^>]*>\s*See the plan/g)?.length).toBe(3);
136 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs