Updates
This commit is contained in:
46
frontend/src/components/JobStatusBadge.tsx
Normal file
46
frontend/src/components/JobStatusBadge.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
import { faCircle, faCircleCheck, faCircleNotch, faCircleXmark } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
type Status = "idle" | "running" | "success" | "failed" | string | undefined;
|
||||
|
||||
const statusStyles: Record<
|
||||
"idle" | "running" | "success" | "failed",
|
||||
{ label: string; icon: IconDefinition; className: string; iconClassName?: string }
|
||||
> = {
|
||||
idle: {
|
||||
label: "Idle",
|
||||
icon: faCircle,
|
||||
className: "bg-muted text-muted-foreground border border-border"
|
||||
},
|
||||
running: {
|
||||
label: "Running",
|
||||
icon: faCircleNotch,
|
||||
className: "bg-amber-100 text-amber-800 border border-amber-200",
|
||||
iconClassName: "animate-spin"
|
||||
},
|
||||
success: {
|
||||
label: "Success",
|
||||
icon: faCircleCheck,
|
||||
className: "bg-emerald-100 text-emerald-800 border border-emerald-200"
|
||||
},
|
||||
failed: {
|
||||
label: "Failed",
|
||||
icon: faCircleXmark,
|
||||
className: "bg-red-100 text-red-800 border border-red-200"
|
||||
}
|
||||
};
|
||||
|
||||
export function JobStatusBadge({ status }: { status: Status }) {
|
||||
const normalized = (status || "idle") as keyof typeof statusStyles;
|
||||
const style = statusStyles[normalized] || statusStyles.idle;
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center gap-1 rounded-full px-3 py-1 text-xs font-semibold ${style.className}`}
|
||||
>
|
||||
<FontAwesomeIcon icon={style.icon} className={`h-3.5 w-3.5 ${style.iconClassName || ""}`} />
|
||||
{style.label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user