Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/reports/publish-flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={cn("space-y-2", className)}>
{/* 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 }) => (
<p key={id} role="status" className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-2xl bg-inset px-4 py-3 text-sm">
<span className="flex min-w-0 items-start gap-2.5">
Expand Down Expand Up @@ -2498,7 +2498,7 @@ export function CheckRow({ name, result, advice = true, overruled = false }: { n
</div>
{/* What the number is, on hover or focus: walkers read 99% as progress or a grade. */}
<TooltipHint label={t(result.answer === "unclear" ? "check.unclearWhy" : "check.sureWhy", { need: format.number(need / 100, { style: "percent" }) })}>
<span tabIndex={0} className="min-w-12 shrink-0 cursor-help rounded-sm text-end text-xs tabular-nums outline-offset-2 focus-visible:outline-2 focus-visible:outline-ring">
<span tabIndex={0} className="min-w-16 shrink-0 cursor-help rounded-sm text-end text-xs tabular-nums outline-offset-2 focus-visible:outline-2 focus-visible:outline-ring">
<span className="font-medium text-foreground/80">{result.answer === "unclear" ? t("check.unclear") : t("check.sure", { percent: format.number(sure / 100, { style: "percent" }) })}</span>
</span>
</TooltipHint>
Expand Down
4 changes: 2 additions & 2 deletions convex/reports/flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }] });
Expand Down
4 changes: 3 additions & 1 deletion convex/reports/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion convex/reports/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions messages/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading