Public: anyone can read this; the crew can change it.
/explore offers a Forges chip beside All, Apps and People #6054
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/6040-explore-offers-a-forges-chip-beside-all → main 2 commits fork 1 thread · 1 unresolved
2 files
changed +13
−0
src/web/studio/explore.ts +1
| @@ -129,6 +129,7 @@ export async function explorePage(ctx: Ctx): Promise<Response> { | ||
| 129 | 129 | { label: "All", kind: "all" as const }, |
| 130 | 130 | { label: "Apps", kind: "app" as const }, |
| 131 | 131 | { label: "People", kind: "person" as const }, |
| 132 | // Forges are a site admin's to see (explore.ts in actions): no chip onto an empty page. | |
| 132 | 133 | ...(ctx.auth.user?.isAdmin === true |
| 133 | 134 | ? [{ label: "Forges", kind: "forge" as const }] |
| 134 | 135 | : []), |
test/explore.test.ts +12
| @@ -338,6 +338,18 @@ describe("explore on a forge with nothing public", () => { | ||
| 338 | 338 | }) |
| 339 | 339 | ).text(); |
| 340 | 340 | |
| 341 | test("the Forges chip is a site admin's: current on kind:forge, sort kept, absent for a guest", async () => { | |
| 342 | const chip = (q: string) => new RegExp(`<a[^>]*href="/explore\\?q=${q}"[^>]*>\\s*Forges</a\\s*>`); | |
| 343 | const sorted = await get(`/explore?q=${encodeURIComponent("sort:forks")}`, true); | |
| 344 | expect(sorted).toContain(`href="/explore?q=${encodeURIComponent("kind:forge sort:forks")}"`); | |
| 345 | const page = await get(`/explore?q=${encodeURIComponent("kind:forge")}`, true); | |
| 346 | const tag = page.match(chip("kind%3Aforge"))?.[0] ?? ""; | |
| 347 | expect(tag).toContain("aria-current"); | |
| 348 | const guest = await get(`/explore?q=${encodeURIComponent("kind:forge")}`, false); | |
| 349 | expect(guest).not.toMatch(/>\s*Forges</); | |
| 350 | expect(guest).toContain("Nothing"); | |
| 351 | }); | |
| 352 | ||
| 341 | 353 | test("no query says nothing is public yet and how to make the first app", async () => { |
| 342 | 354 | const out = await get("/explore", false); |
| 343 | 355 | expect(out).toContain("Nothing public yet"); |
new above
offline
Shown to guests and non-admins, but the data behind it (forges() in src/actions/explore.ts) is admin-only, so for them this chip always lands on an empty result. Either gate the chip as before or open the data to match, and test it.