Watch
0
0
Fork
You've already forked hyperhive
0

review try-out: show why the open-PR button is disabled

The form's one hint put the PR number first, so with the PR field empty
(which opening a PR doesn't need) it hid the repo or row problem that
was actually disabling the open-PR button. runProblem now checks the
rows first and the PR number last, and is tested.

Refs #5259
This commit is contained in:
atlas 2026-10-14 18:07:42 +02:00 • committed by mara
commit be2e64fa89
3 changed files with 28 additions and 3 deletions

View file

@ -41,6 +41,7 @@ import {
prNumber,
repoProblem,
rowsProblem,
runProblem,
toBody,
type ClassificationDraft,
type OpenPrAnswer,
@ -218,9 +219,7 @@ export function ReviewTryOutPage() {
}, [runId]);
const openPrProblem = rowsProblem(repo, drafts);
const problem =
(prNumber(pr) === null ? "a PR number is a whole number above 0" : null) ??
openPrProblem;
const problem = runProblem(repo, pr, drafts);
async function run(e: Event) {
e.preventDefault();

View file

@ -164,6 +164,21 @@ export function rowsProblem(
);
}
/** What keeps the rows from a run, or null: everything `rowsProblem` checks,
* then the PR number. The page shows this one reason for both of its buttons,
* so whatever disables opening a PR comes before the PR number it doesn't
* need. */
export function runProblem(
repo: string,
pr: string,
drafts: ClassificationDraft[],
): string | null {
return (
rowsProblem(repo, drafts) ??
(prNumber(pr) === null ? "a PR number is a whole number above 0" : null)
);
}
export function toBody(d: ClassificationDraft): ClassificationBody {
return {
name: d.name.trim(),