swarm-ui: match the try-out page to the backend's limits
The repo check takes the endpoint's own character set and refuses . and .. parts. The running and expired messages say a run can last up to half an hour and that a controller restart drops the result.
This commit is contained in:
parent
a4a4381cf6
commit
c5b66dc5a0
3 changed files with 16 additions and 9 deletions
|
|
@ -31,9 +31,9 @@ import "./ReviewTryOutPage.css";
|
|||
|
||||
const TRY_OUT = "/api/review-classifier/try-out";
|
||||
const POLL_MS = 2000;
|
||||
// More classifications than this are not offered a row. Keep it in step with
|
||||
// the try-out endpoint's own cap, which answers a longer list with a 400 that
|
||||
// the page shows as it is; the backend has no way to report it yet.
|
||||
// More classifications than this are not offered a row. It is the try-out
|
||||
// endpoint's own cap, which answers a longer list with a 400 that the page
|
||||
// shows as it is.
|
||||
const MAX_CLASSIFICATIONS = 10;
|
||||
|
||||
let nextKey = 0;
|
||||
|
|
@ -88,7 +88,8 @@ export function ReviewTryOutPage() {
|
|||
if (cancelled) return;
|
||||
if (res.status === 404) {
|
||||
stop({
|
||||
detail: "the result expired before it was read: run it again",
|
||||
detail:
|
||||
"the result is gone, because it expired or the controller restarted: run it again",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -214,7 +215,8 @@ export function ReviewTryOutPage() {
|
|||
<Panel title="result" icon="📋">
|
||||
{running ? (
|
||||
<p class="ui-tryout-running" role="status">
|
||||
Running — a run takes a minute or more ({elapsed}s so far).
|
||||
Running — a run takes a minute or more, and up to half an hour for
|
||||
a long list ({elapsed}s so far).
|
||||
</p>
|
||||
) : null}
|
||||
{error ? (
|
||||
|
|
|
|||
|
|
@ -50,10 +50,15 @@ export interface TryOutResult {
|
|||
error?: string;
|
||||
}
|
||||
|
||||
const REPO = /^[^/\s]+\/[^/\s]+$/;
|
||||
// Characters the endpoint accepts in each half of a repo: letters, digits, `.`,
|
||||
// `_` and `-`, other than `.` and `..` themselves.
|
||||
const SEGMENT = /^(?!\.{1,2}$)[A-Za-z0-9._-]+$/;
|
||||
|
||||
export function repoProblem(repo: string): string | null {
|
||||
return REPO.test(repo.trim()) ? null : "a repo is owner/name";
|
||||
const parts = repo.trim().split("/");
|
||||
return parts.length === 2 && parts.every((p) => SEGMENT.test(p))
|
||||
? null
|
||||
: "a repo is owner/name, with letters, digits, . _ and - in each part";
|
||||
}
|
||||
|
||||
export function prNumber(pr: string): number | null {
|
||||
|
|
|
|||
Loading…
Reference in a new issue