g1t/apps/web/app/components/checks.tsx

35 lines1,454 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Fast pages, required checks on the branch, self-hosted runners, honest incidents1import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from "lucide-react";
Acceptance checks in sandboxes, line comments and review verdicts2
Fast pages, required checks on the branch, self-hosted runners, honest incidents3import type { CheckStatus } from "@g1t/contracts";
Acceptance checks in sandboxes, line comments and review verdicts4
Fast pages, required checks on the branch, self-hosted runners, honest incidents5/**
6 * What a pull request's own check status says. A pull request's checks are
7 * the workflows run on it (see the merge box); this is set when the merge
8 * queue took it out, and on older pull requests, by commands their issue
9 * once had run.
10 */
Acceptance checks in sandboxes, line comments and review verdicts11const LABELS: Record<CheckStatus, string> = {
12 queued: "Checks queued",
13 running: "Checks running",
14 passed: "Checks passed",
Fast pages, required checks on the branch, self-hosted runners, honest incidents15 failed: "Failed in the merge queue",
Acceptance checks in sandboxes, line comments and review verdicts16 errored: "Checks could not run",
17};
18
19export function CheckIcon({ status, size = 15 }: { status: CheckStatus; size?: number }) {
20 if (status === "passed") return <CircleCheck size={size} className="shrink-0 text-accent" />;
21 if (status === "failed") return <CircleX size={size} className="shrink-0 text-danger" />;
22 if (status === "errored") return <TriangleAlert size={size} className="shrink-0 text-muted" />;
23 return <LoaderCircle size={size} className="shrink-0 animate-spin text-info" />;
24}
25
26/** The state of a pull request's checks at a glance, for lists. */
27export function CheckBadge({ status }: { status: CheckStatus | null }) {
28 if (!status) return null;
29 return (
30 <span className="flex shrink-0 items-center gap-1 text-xs text-muted" title={LABELS[status]}>
31 <CheckIcon status={status} size={13} />
32 <span className="sr-only">{LABELS[status]}</span>
33 </span>
34 );
35}