Public: anyone can read this; the crew can change it.
A guest told "a link to an app does not make you a member" is offered the button that asks an admin; main's sentence rule is green again #12974
Check · Review · Land · Live done — Landed and live in production.
trevato/roles-refusal-leads-somewhere → main 1 commit 1 thread · 1 unresolved
3 files
changed +17
−6
src/core/roles.ts +9 −4
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | * Pure data; who may promote is the action's. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { storedText } from "../kernel/blocked.ts"; | |
| 11 | 12 | import type { Database } from "bun:sqlite"; |
| 12 | 13 | import { isUnclaimed } from "./starts.ts"; |
| 13 | 14 | |
| @@ -48,12 +49,16 @@ export function rolesTable(): string { | ||
| 48 | 49 | return [`| Ability | ${ROLES.join(" | ")} |`, `| --- | ${ROLES.map(() => "---").join(" | ")} |`, ...rows].join("\n"); |
| 49 | 50 | } |
| 50 | 51 | |
| 52 | /** What a guest who came by an app's link is told first. */ | |
| 53 | export const LINK_IS_NOT_MEMBERSHIP = "A link to an app does not make you a member."; | |
| 54 | ||
| 51 | 55 | /** |
| 52 | * The one way in for a guest: a link to an app does not admit them; | |
| 53 | * an admin does, on the People page. | |
| 56 | * The one way in for a guest: a link to an app does not admit them; an admin | |
| 57 | * does. Said to any reader with who can, in words (`kernel/blocked.ts`); a | |
| 58 | * page that knows its reader offers the button that asks an admin beside it | |
| 59 | * (`actions/blocked_words.ts` `notMemberBlocked`). | |
| 54 | 60 | */ |
| 55 | export const BECOME_A_MEMBER = | |
| 56 | "A link to an app does not make you a member. To become one, ask the admin of this forge to make you a member on the People page."; | |
| 61 | export const BECOME_A_MEMBER = storedText(LINK_IS_NOT_MEMBERSHIP, "an admin of this forge", "make you one"); | |
| 57 | 62 | |
| 58 | 63 | /** The words a guest is refused with, on every surface: what they cannot do, and what they can. */ |
| 59 | 64 | export const NOT_A_MEMBER = |
src/web/studio/make_it_yours.ts +4 −2
| @@ -5,6 +5,8 @@ | ||
| 5 | 5 | * `actions/make_it_yours.ts`. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { blockedWay } from "../blocked.ts"; | |
| 9 | import { notMemberBlocked } from "../../actions/blocked_words.ts"; | |
| 8 | 10 | import { COPIES_PER_DAY, makeItYours, receiptWords, undoMakeItYours } from "../../actions/make_it_yours.ts"; |
| 9 | 11 | import type { Ctx } from "../../http/context.ts"; |
| 10 | 12 | import { |
| @@ -18,7 +20,7 @@ import { field, readForm } from "../form.ts"; | ||
| 18 | 20 | import { html, when } from "../html.ts"; |
| 19 | 21 | import { flashTo, page, redirect } from "../layout.ts"; |
| 20 | 22 | import { btn, card, row } from "../ui.ts"; |
| 21 | import { BECOME_A_MEMBER } from "../../core/roles.ts"; | |
| 23 | import { BECOME_A_MEMBER, LINK_IS_NOT_MEMBERSHIP } from "../../core/roles.ts"; | |
| 22 | 24 | import { HELP_BUILD, HELP_BUILD_NEXT } from "../../core/contribute.ts"; |
| 23 | 25 | import type { Repo } from "../../core/repos.ts"; |
| 24 | 26 | import { NOT_A_MEMBER } from "../../core/roles.ts"; |
| @@ -58,7 +60,7 @@ function helpBuildPage(ctx: Ctx, repo: Repo): Response { | ||
| 58 | 60 | body: html`<div class="narrow-wide"> |
| 59 | 61 | ${pageHead(HELP_BUILD, { sub: `${repo.ownerName}/${repo.name}` })} |
| 60 | 62 | ${card(html`<p>${HELP_BUILD_NEXT}</p> |
| 61 | <p class="muted small mt">${BECOME_A_MEMBER}</p> | |
| 63 | <p class="muted small mt">${ctx.auth.user === undefined ? BECOME_A_MEMBER : html`${LINK_IS_NOT_MEMBERSHIP} ${blockedWay(notMemberBlocked(ctx.app, ctx.auth.user, LINK_IS_NOT_MEMBERSHIP))}`}</p> | |
| 62 | 64 | <form method="post" action="${repoBase(repo)}/fork" class="form-actions"> |
| 63 | 65 | ${btn(HELP_BUILD, { variant: "primary", icon: "fork" })} |
| 64 | 66 | ${btn("Not now", { href: repoBase(repo), variant: "ghost" })} |
test/guest-contribute.test.ts +4
| @@ -636,6 +636,10 @@ describe("a stranger's first pull starts from the app's page", () => { | ||
| 636 | 636 | const offer = await (await fetch(`${servers.url}/olive/game/make-it-yours`, { headers: cookie })).text(); |
| 637 | 637 | expect(offer).toContain(HELP_BUILD); |
| 638 | 638 | expect(offer).toContain(BECOME_A_MEMBER); |
| 639 | // With the one button that asks an admin, and the form it submits (`web/blocked.ts`). | |
| 640 | expect(offer).toContain('value="membership '); | |
| 641 | expect(offer).toContain('action="/asks/admin" id="ask-who-can"'); | |
| 642 | expect(BECOME_A_MEMBER).toBe("A link to an app does not make you a member. An admin of this forge can make you one."); | |
| 639 | 643 | expect(NOT_A_MEMBER).toContain(BECOME_A_MEMBER); |
| 640 | 644 | |
| 641 | 645 | const form = { ...cookie, origin: servers.url, "content-type": "application/x-www-form-urlencoded" }; |
new above
offline
Minor: this ternary is hard to read inline. Pull it into a named helper. The behaviour is right.