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

Every destructive confirm names what is lost and the way back in one sentence #16059

Merged opened this

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

Merged

scout/forge:scout/16044-every-destructive-confirm-names-what-is → main 0 commits fork

  • Merged. scout/16044-every-destructive-confirm-names-what-is was merged into main as 949e9e6.

Review

Sign in to review this change.
5 files changed +69 −11
docs/features/danger-confirms.md added +12
@@ -0,0 +1,12 @@
1 ---
2 topic: Your apps
3 row: Stop-as-app and delete confirms say what is lost and the way back
4 ---
5 # Destructive confirms say what is lost and the way back
6
7 Pressing "Stop running as an app" or "Delete this repository" (Settings → Danger zone) opens `/-/confirm`, whose paragraph is two sentences: what is lost, then the way back, or that there is none. Nothing changes until the second button (and, for delete, the typed full name).
8
9 - **Stop running as an app:** production and every preview stop and their data is removed; the code is untouched and running it again starts from empty data.
10 - **Delete this repository:** issues, pulls, comments, webhooks and git objects go; there is no way back, forks are detached first and keep working.
11
12 The words live once in `src/web/danger_words.ts` (`DANGERS`, `dangerDetail`). Terminal: the repository's `:` palette → "Delete this repository" shows the same two sentences before asking for the name (`src/tui/screens/deleterepo.ts`). Test: `test/danger-words.test.ts` fails if an entry lacks either line.
src/tui/screens/deleterepo.ts +2 −5
@@ -6,15 +6,12 @@
66
77 import { deleteRepo } from "../../actions/repos.ts";
88 import { canAdmin, type Repo } from "../../core/repos.ts";
9 import { DELETE_REPO } from "../../web/danger_words.ts";
9 import { DELETE_REPO, dangerDetail } from "../../web/danger_words.ts";
1010 import type { Ctx, Screen } from "../app/app.ts";
1111 import type { Command } from "../app/palette.ts";
1212 import type { Session } from "../session.ts";
1313 import { promptScreen } from "./common.ts";
1414
15 const GOES =
16 "every issue, pull request, comment and webhook, and the git objects; forks are detached first and keep working";
17
1815 /** The prompt floats over whatever is already drawn; this is the empty backdrop it asks for. */
1916 const backdrop: Screen = {
2017 title: DELETE_REPO,
@@ -36,7 +33,7 @@ export function deleteRepoCommands(f: Session, ctx: Ctx, repo: Repo | undefined)
3633 ctx.push(
3734 promptScreen(ctx, backdrop, {
3835 title: `${DELETE_REPO} (cannot be undone)`,
39 label: `Removes ${GOES}. Type ${full}:`,
36 label: `${dangerDetail(DELETE_REPO)} Type ${full}:`,
4037 placeholder: full,
4138 onSubmit: (typed) => {
4239 if (typed !== full) return `Type ${full} to confirm.`;
src/web/danger_words.ts +33
@@ -9,3 +9,36 @@ export const STOP_APP = "Stop running as an app";
99
1010 /** Deletes the repository, its issues, pulls and git objects. */
1111 export const DELETE_REPO = "Delete this repository";
12
13 /** What a destructive confirm says: one sentence for what is lost, one for the way back. */
14 export interface DangerSaid {
15 /** The button's words. */
16 verb: string;
17 /** What is lost, in one sentence. */
18 lost: string;
19 /** The way back in one sentence, or the plain statement that there is none. */
20 wayBack: string;
21 }
22
23 /** Every confirm built from this file, so a test can enumerate them. */
24 export const DANGERS: readonly DangerSaid[] = [
25 {
26 verb: STOP_APP,
27 lost: "Production and every preview stop, and their data directories and checkouts are removed from disk.",
28 wayBack:
29 "The repository and its code are untouched; run it as an app again later and it starts from empty data.",
30 },
31 {
32 verb: DELETE_REPO,
33 lost: "Every issue, pull request, comment and webhook goes with it, and the git objects are removed from disk.",
34 wayBack:
35 "There is no way back: forks are detached first and keep working, but this repository cannot be restored.",
36 },
37 ];
38
39 /** The paragraph a confirm shows for one of the acts above. */
40 export function dangerDetail(verb: string): string {
41 const said = DANGERS.find((d) => d.verb === verb);
42 if (said === undefined) throw new Error(`no danger words for ${verb}`);
43 return `${said.lost} ${said.wayBack}`;
44 }
src/web/pages/search.ts +3 −5
@@ -42,7 +42,7 @@ import type { Ctx } from "../../http/context.ts";
4242 import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts";
4343 import { notFoundPage, pageHead } from "../chrome.ts";
4444 import { html, when, type Html } from "../html.ts";
45 import { DELETE_REPO, STOP_APP } from "../danger_words.ts";
45 import { DELETE_REPO, STOP_APP, dangerDetail } from "../danger_words.ts";
4646 import { icon } from "../icons.ts";
4747 import { page } from "../layout.ts";
4848 import { browseBase } from "../scope.ts";
@@ -641,8 +641,7 @@ const DESTRUCTIVE: {
641641 describe: (m) => ({
642642 verb: DELETE_REPO,
643643 title: `Delete ${m[1]}/${m[2]}?`,
644 detail:
645 "Every issue, pull request, comment and webhook goes with it, and the git objects are removed from disk. Forks are detached first and keep working. This cannot be undone.",
644 detail: dangerDetail(DELETE_REPO),
646645 phrase: `${m[1]}/${m[2]}`,
647646 }),
648647 },
@@ -911,8 +910,7 @@ const DESTRUCTIVE: {
911910 describe: (m) => ({
912911 verb: STOP_APP,
913912 title: `Stop running ${m[1]}/${m[2]} as an app?`,
914 detail:
915 "Production and every preview stop, and their data directories and checkouts are removed from disk. The repository and its code are untouched. Run it as an app again later and it starts from empty data.",
913 detail: dangerDetail(STOP_APP),
916914 phrase: "",
917915 }),
918916 },
test/danger-words.test.ts +19 −1
@@ -7,7 +7,7 @@
77 import { expect, test } from "bun:test";
88 import { readFileSync } from "node:fs";
99 import { join } from "node:path";
10 import { DELETE_REPO, STOP_APP } from "../src/web/danger_words.ts";
10 import { DANGERS, DELETE_REPO, STOP_APP, dangerDetail } from "../src/web/danger_words.ts";
1111
1212 const root = join(import.meta.dir, "..");
1313 const readers = ["src/web/pages/settings.ts", "src/web/pages/search.ts"];
@@ -26,3 +26,21 @@ test("no file that shows them types a sentence out again", () => {
2626 }
2727 }
2828 });
29
30 test("every confirm names what is lost and the way back, each in one sentence", () => {
31 expect(DANGERS.length).toBeGreaterThanOrEqual(2);
32 for (const d of DANGERS) {
33 for (const line of [d.lost, d.wayBack]) {
34 expect({ verb: d.verb, ok: line.trim().length > 20 }).toEqual({ verb: d.verb, ok: true });
35 expect({ verb: d.verb, one: (line.match(/[.!?](\s|$)/g) ?? []).length }).toEqual({ verb: d.verb, one: 1 });
36 }
37 expect(dangerDetail(d.verb)).toBe(`${d.lost} ${d.wayBack}`);
38 }
39 expect(DANGERS.map((d) => d.verb)).toEqual([STOP_APP, DELETE_REPO]);
40 });
41
42 test("the confirm page shows both lines for each", async () => {
43 const text = readFileSync(join(root, "src/web/pages/search.ts"), "utf8");
44 expect(text).toContain("dangerDetail(DELETE_REPO)");
45 expect(text).toContain("dangerDetail(STOP_APP)");
46 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs