38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { Badge } from "@/components/ui/badge";
|
|||
|
|
import type { RunStatus } from "@/lib/db/schema";
|
||
|
|
import { cn } from "@/lib/utils";
|
||
|
|
|
||
|
|
const styles: Record<RunStatus, string> = {
|
||
|
|
queued: "bg-muted text-muted-foreground",
|
||
|
|
running: "bg-blue-500/15 text-blue-600 dark:text-blue-400",
|
||
|
|
succeeded: "bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",
|
||
|
|
failed: "bg-destructive/15 text-destructive",
|
||
|
|
cancelled: "bg-muted text-muted-foreground",
|
||
|
|
timed_out: "bg-amber-500/15 text-amber-600 dark:text-amber-400",
|
||
|
|
interrupted: "bg-amber-500/15 text-amber-600 dark:text-amber-400",
|
||
|
|
};
|
||
|
|
|
||
|
|
const labels: Record<RunStatus, string> = {
|
||
|
|
queued: "Queued",
|
||
|
|
running: "Running",
|
||
|
|
succeeded: "Succeeded",
|
||
|
|
failed: "Failed",
|
||
|
|
cancelled: "Cancelled",
|
||
|
|
timed_out: "Timed out",
|
||
|
|
interrupted: "Interrupted",
|
||
|
|
};
|
||
|
|
|
||
|
|
export function RunStatusBadge({ status }: { status: RunStatus }) {
|
||
|
|
return (
|
||
|
|
<Badge
|
||
|
|
className={cn("border-transparent font-medium", styles[status])}
|
||
|
|
variant="outline"
|
||
|
|
>
|
||
|
|
{status === "running" && (
|
||
|
|
<span className="mr-1 inline-block size-1.5 animate-pulse rounded-full bg-current" />
|
||
|
|
)}
|
||
|
|
{labels[status]}
|
||
|
|
</Badge>
|
||
|
|
);
|
||
|
|
}
|