The reports tab gets a "pull requests" card under the issue report. It lists
the open PRs of every repo, or of one picked in a repo select, with the
columns a reviewer or merger filters on: author, labels, requested
reviewers, base branch, WIP (the forge's draft flag), approvals against the
base branch's protection rule, has all approvals, conflicts, protected base
and CI. Every column sorts, the small-set columns filter by picking values,
and the browser keeps the filters and the repo. No filter applies at first.
swarm-controller resolves each row so the page makes no calls of its own:
GET /api/pr-report and GET /api/repos/{org}/{repo}/pr-report. The required
approvals come from the first matching branch protection rule (an
unprotected base asks for none); an approval counts when it is the
reviewer's latest decision, on the current head, neither stale nor
dismissed and official.
A free-text table cell gets a minimum width, so a table with many columns
scrolls sideways instead of wrapping a title to a word a line.
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
// Pure helpers for the issue report's repo filter: the report URL and the
|
|
// select's options. Kept out of the page so the cases are unit tested.
|
|
|
|
/** Select value for "every repo". It cannot collide with a real
|
|
* `owner/name`, which always has a slash. */
|
|
export const ALL_REPOS = "";
|
|
|
|
export interface RepoOption {
|
|
value: string;
|
|
label: string;
|
|
}
|
|
|
|
/** The report URL for a repo filter. The path parts are encoded, so a name
|
|
* with `?`, `#` or `%` stays one path segment. A filter without a slash
|
|
* is not a repo, so it reads as all repos. */
|
|
export function reportUrl(repoFilter: string): string {
|
|
const i = repoFilter.indexOf("/");
|
|
if (i < 0) return "/api/issue-report";
|
|
const org = encodeURIComponent(repoFilter.slice(0, i));
|
|
const name = encodeURIComponent(repoFilter.slice(i + 1));
|
|
return `/api/repos/${org}/${name}/issue-report`;
|
|
}
|
|
|
|
/** The select's options. A remembered repo that the list lacks keeps its
|
|
* own option, so the select shows what the table is filtered to. Once the
|
|
* list has loaded, the label says why the repo is not in it. */
|
|
export function repoOptions(
|
|
repos: string[] | null,
|
|
selected: string,
|
|
/** What the missing repo has none of: "issues", or "pull requests". */
|
|
what = "issues",
|
|
): RepoOption[] {
|
|
const options: RepoOption[] = [
|
|
{ value: ALL_REPOS, label: "all repos" },
|
|
...(repos ?? []).map((r) => ({ value: r, label: r })),
|
|
];
|
|
if (selected !== ALL_REPOS && !(repos ?? []).includes(selected)) {
|
|
options.push({
|
|
value: selected,
|
|
label: repos === null ? selected : `${selected} (no open ${what})`,
|
|
});
|
|
}
|
|
return options;
|
|
}
|