diff --git a/components/reports/publish-flow.tsx b/components/reports/publish-flow.tsx index 416b79b97..c4a52e9af 100644 --- a/components/reports/publish-flow.tsx +++ b/components/reports/publish-flow.tsx @@ -771,16 +771,16 @@ export function PublishFlow() { * Reports ready in the person's other workspaces, said where they are looking: each workspace's Publish lists only * its own. Every workspace that holds some has its line, so the lines add up to the count on Publish in the rail. */ -function WaitingElsewhere({ waiting, className }: { waiting: Array<{ name: string; slug: string | null; ready: number; unfinished: number }>; className?: string }) { +function WaitingElsewhere({ waiting, className }: { waiting: Array<{ name: string; slug: string | null; ready: number; unfinished: number; only?: string }>; className?: string }) { const t = useTranslations("publishReports.flow"); if (!waiting.length) return null; return (
{/* A line for each workspace's ready reports, which wait on the person, and one for their own that aren't live yet, which they may have lost: each opens that workspace's reports, the ready ones for the first. */} - {waiting.flatMap(({ name, slug, ready, unfinished }) => [ + {waiting.flatMap(({ name, slug, ready, unfinished, only }) => [ ...(ready ? [{ id: `${slug ?? ""}-ready`, words: slug ? t("waitingIn", { count: ready, name }) : t("waitingOwn", { count: ready }), href: `${slug ? `/o/${slug}` : ""}/publish?view=reports&show=ready`, count: ready }] : []), - ...(unfinished ? [{ id: `${slug ?? ""}-unfinished`, words: slug ? t("unfinishedIn", { count: unfinished, name }) : t("unfinishedOwn", { count: unfinished }), href: `${slug ? `/o/${slug}` : ""}/publish?view=reports`, count: unfinished }] : []), + ...(unfinished ? [{ id: `${slug ?? ""}-unfinished`, words: slug ? t("unfinishedIn", { count: unfinished, name }) : t("unfinishedOwn", { count: unfinished }), href: `${slug ? `/o/${slug}` : ""}/publish?${only ? `report=${only}` : "view=reports"}`, count: unfinished }] : []), ]).map(({ id, words, href, count }) => (

@@ -2498,7 +2498,7 @@ export function CheckRow({ name, result, advice = true, overruled = false }: { n

{/* What the number is, on hover or focus: walkers read 99% as progress or a grade. */} - + {result.answer === "unclear" ? t("check.unclear") : t("check.sure", { percent: format.number(sure / 100, { style: "percent" }) })} diff --git a/convex/reports/flow.test.ts b/convex/reports/flow.test.ts index c6a673e72..e7991260a 100644 --- a/convex/reports/flow.test.ts +++ b/convex/reports/flow.test.ts @@ -185,13 +185,13 @@ describe("a report's details sent under another licence", () => { describe("reports that wait in a person's other workspaces", () => { it("tells an admin of the lab, from their own workspace, and the member who made it that it isn't live yet", async () => { const world = await setup(); - await checked(world, [passed("byline"), passed("harm")], world.member, world.lab); + const labReport = await checked(world, [passed("byline"), passed("harm")], world.member, world.lab); const ownOf = (clerkId: string) => world.t.run(async (ctx) => ensureWorkspace(ctx, { kind: "personal", userId: (await ctx.db.query("users").withIndex("by_clerk_id", (q) => q.eq("clerkId", clerkId)).unique())!._id })); expect(await world.orgAdmin.query(api.reports.flow.waitingElsewhere, { workspaceId: await ownOf("orgadmin") })).toEqual({ ready: 1, workspaces: [{ name: "Learning Lab", slug: "lab", ready: 1, unfinished: 0 }] }); // In the lab itself its own Publish says so, and a member activates nothing. expect(await world.orgAdmin.query(api.reports.flow.waitingElsewhere, { workspaceId: world.lab })).toEqual({ ready: 0, workspaces: [] }); // A member activates nothing, but finds their own report from their own workspace, where they may have landed. - expect(await world.member.query(api.reports.flow.waitingElsewhere, { workspaceId: await ownOf("member") })).toEqual({ ready: 0, workspaces: [{ name: "Learning Lab", slug: "lab", ready: 0, unfinished: 1 }] }); + expect(await world.member.query(api.reports.flow.waitingElsewhere, { workspaceId: await ownOf("member") })).toEqual({ ready: 0, workspaces: [{ name: "Learning Lab", slug: "lab", ready: 0, unfinished: 1, only: labReport.key }] }); // A person's own ready report is said in the lab, where they are only a member. await checked(world, [passed("byline"), passed("harm")]); expect(await world.author.query(api.reports.flow.waitingElsewhere, { workspaceId: world.lab })).toEqual({ ready: 1, workspaces: [{ name: "", slug: null, ready: 1, unfinished: 0 }] }); diff --git a/convex/reports/flow.ts b/convex/reports/flow.ts index 0f7fae674..16220d377 100644 --- a/convex/reports/flow.ts +++ b/convex/reports/flow.ts @@ -961,7 +961,9 @@ export const waitingElsewhereAction = defineUserQuery({ const waitingIn = async (id: Id<"workspaces">, activates: boolean) => { const ready = (report: Doc<"reports">) => activates && stageOf(report, reviewed(id)) === "ready"; const others = activates ? await ctx.db.query("reports").withIndex("by_workspaceId_and_activatedAt", (q) => q.eq("workspaceId", id).eq("activatedAt", undefined)).order("desc").take(ELSEWHERE_REPORTS) : []; - return { ready: others.filter(ready).length, unfinished: mineUnlive.filter((report) => report.workspaceId === id && !ready(report)).length }; + const unfinished = mineUnlive.filter((report) => report.workspaceId === id && !ready(report)); + // The one report, by its key, so the way there opens it rather than the list it would be alone in. + return { ready: others.filter(ready).length, unfinished: unfinished.length, ...(unfinished.length === 1 && { only: unfinished[0]!.key }) }; }; const own = await ctx.db.query("workspaces").withIndex("by_userId", (q) => q.eq("userId", userId)).unique(); // ponytail: the first organizations a person is in are asked about, those they run first, whose ready reports the diff --git a/convex/reports/validators.ts b/convex/reports/validators.ts index a5e01c105..a8c25ffa4 100644 --- a/convex/reports/validators.ts +++ b/convex/reports/validators.ts @@ -577,7 +577,7 @@ export const reportRowsValidator = capped(v.array(authorRowValidator), REPORTS_P /** How many of the organizations a person is an admin of are asked about for reports that wait on them. */ export const ELSEWHERE_WORKSPACES = 20; /** The person's other workspaces that hold reports ready for them to activate: their own, and those organizations. */ -export const waitingWorkspacesValidator = capped(v.array(v.object({ name: v.string(), slug: v.union(v.string(), v.null()), ready: v.number(), /** The person's own reports there that aren't live yet and aren't theirs to activate now: being worked on, checked, reviewed or declined. */ unfinished: v.number() })), ELSEWHERE_WORKSPACES + 1); +export const waitingWorkspacesValidator = capped(v.array(v.object({ name: v.string(), slug: v.union(v.string(), v.null()), ready: v.number(), /** The person's own reports there that aren't live yet and aren't theirs to activate now: being worked on, checked, reviewed or declined. */ unfinished: v.number(), /** The key of the one such report, where there is only one. */ only: v.optional(v.string()) })), ELSEWHERE_WORKSPACES + 1); /** A report's authors by name, as its signed agreement lists them. */ export const signerNamesValidator = capped(v.array(v.string()), DETAIL_CAPS.authors); diff --git a/messages/en-GB.json b/messages/en-GB.json index 9945ff848..7a7c78478 100644 --- a/messages/en-GB.json +++ b/messages/en-GB.json @@ -7031,9 +7031,9 @@ "failed": "Failed", "flagged": "Flagged", "unclear": "Unclear", - "sure": "{percent}", - "sureWhy": "How sure the check is that your report passes. It passes at {need} or more, the line on the bar.", - "unclearWhy": "The check couldn't tell from your report whether it passes. A reviewer looks at it.", + "sure": "{percent} sure", + "sureWhy": "How sure the check is that the report passes. It passes at {need} or more, the line on the bar.", + "unclearWhy": "The check couldn't tell from the report whether it passes. A reviewer looks at it.", "foundIn": "Found in {where}", "foundAs": "Found as", "said": { diff --git a/messages/en-US.json b/messages/en-US.json index cd49b2fc4..c8a453a1a 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -7031,9 +7031,9 @@ "failed": "Failed", "flagged": "Flagged", "unclear": "Unclear", - "sure": "{percent}", - "sureWhy": "How sure the check is that your report passes. It passes at {need} or more, the line on the bar.", - "unclearWhy": "The check couldn't tell from your report whether it passes. A reviewer looks at it.", + "sure": "{percent} sure", + "sureWhy": "How sure the check is that the report passes. It passes at {need} or more, the line on the bar.", + "unclearWhy": "The check couldn't tell from the report whether it passes. A reviewer looks at it.", "foundIn": "Found in {where}", "foundAs": "Found as", "said": {