diff --git a/docs/2-handbook/swarm/ui.md b/docs/2-handbook/swarm/ui.md index 48a7b8c04..a6c744c21 100644 --- a/docs/2-handbook/swarm/ui.md +++ b/docs/2-handbook/swarm/ui.md @@ -607,9 +607,9 @@ and base branch, and what a reviewer or merger filters on: rule asks for (`1/2`). An approval counts when it stands as the reviewer's latest decision, on the PR's current head, neither stale nor dismissed, and from a reviewer whose approval the rule accepts. A reviewer whose latest review asks for changes shows **changes - requested**. -- **approved**: the approvals meet the rule. A PR into a branch with no - protection rule has nothing to approve, so it counts as approved. + requested**. Filter the column to **complete** for the PRs whose approvals meet + the rule, or **missing** for the rest. A PR into a branch with no protection + rule has nothing to approve, so it counts as complete. - **diff**: the lines the PR adds and removes (`+120 −8`), as the forge counts them. - **conflicts**: the forge can't merge the PR as it stands. - **protected base**: the base branch has a protection rule. A stacked PR targets a diff --git a/frontend/packages/swarm-ui/src/pages/PrReportPage.tsx b/frontend/packages/swarm-ui/src/pages/PrReportPage.tsx index 77a2870bc..089c95f23 100644 --- a/frontend/packages/swarm-ui/src/pages/PrReportPage.tsx +++ b/frontend/packages/swarm-ui/src/pages/PrReportPage.tsx @@ -26,7 +26,7 @@ import { approvalsText, diffSize, diffText, - hasAllApprovals, + approvalsState, prReportUrl, yesNo, type PrReportRow, @@ -125,14 +125,7 @@ const COLUMNS: TableColumn[] = [ ), sortBy: (r) => r.approvals, - }, - { - key: "approved", - header: "approved", - render: (r) => - hasAllApprovals(r) ? : "no", - sortBy: (r) => Number(hasAllApprovals(r)), - filterValues: (r) => [yesNo(hasAllApprovals(r))], + filterValues: (r) => [approvalsState(r)], filterMode: "multiselect", }, { diff --git a/frontend/packages/swarm-ui/src/pages/pr-report.ts b/frontend/packages/swarm-ui/src/pages/pr-report.ts index 6b8e8556c..c3d82e49b 100644 --- a/frontend/packages/swarm-ui/src/pages/pr-report.ts +++ b/frontend/packages/swarm-ui/src/pages/pr-report.ts @@ -55,6 +55,12 @@ export function hasAllApprovals(row: PrReportRow): boolean { return row.approvals >= row.required_approvals; } +/** What the approvals column filters on: whether the PR has all the approvals + * its base branch asks for. */ +export function approvalsState(row: PrReportRow): "complete" | "missing" { + return hasAllApprovals(row) ? "complete" : "missing"; +} + /** The diff size cell: lines added and removed, `+120 −8`. A count the forge * did not give reads as a dash. */ export function diffText(row: PrReportRow): string { diff --git a/frontend/packages/swarm-ui/test/pr-report.test.mjs b/frontend/packages/swarm-ui/test/pr-report.test.mjs index a39648a27..658a3defd 100644 --- a/frontend/packages/swarm-ui/test/pr-report.test.mjs +++ b/frontend/packages/swarm-ui/test/pr-report.test.mjs @@ -2,6 +2,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { + approvalsState, approvalsText, diffSize, diffText, @@ -78,3 +79,18 @@ test("a PR has all approvals when it meets the rule, and an unprotected base alw true, ); }); + +test("the approvals column filters on whether the rule is met", () => { + assert.equal(approvalsState(row({})), "missing"); + assert.equal(approvalsState(row({ approvals: 2 })), "complete"); + assert.equal( + approvalsState( + row({ + targets_protected_branch: false, + required_approvals: 0, + approvals: 0, + }), + ), + "complete", + ); +});