diff --git a/web/src/app/[workflow_id]/page.tsx b/web/src/app/[workflow_id]/page.tsx index 79ec293..9ec0365 100644 --- a/web/src/app/[workflow_id]/page.tsx +++ b/web/src/app/[workflow_id]/page.tsx @@ -1,8 +1,10 @@ +import { LoadingIcon } from "@/components/LoadingIcon"; import { MachineSelect, RunWorkflowButton, VersionSelect, } from "@/components/VersionSelect"; +import { Badge } from "@/components/ui/badge"; import { Card, CardContent, @@ -47,6 +49,7 @@ export async function findAllRuns(workflow_id: string) { return await db.query.workflowRunsTable.findMany({ where: eq(workflowRunsTable.workflow_version_id, workflowVersion?.id), + orderBy: desc(workflowRunsTable.created_at), with: { machine: { columns: { @@ -123,10 +126,32 @@ async function RunsTable(props: { workflow_id: string }) { {run.version.version} {run.machine.name} {getRelativeTime(run.created_at)} - {run.status} + + + ))} ); } + +function StatusBadge({ + run, +}: { + run: Awaited>[0]; +}) { + switch (run.status) { + case "running": + return ( + + {run.status} + + ); + case "success": + return {run.status}; + case "failed": + return {run.status}; + } + return {run.status}; +} diff --git a/web/src/components/ui/badge.tsx b/web/src/components/ui/badge.tsx new file mode 100644 index 0000000..0e58f77 --- /dev/null +++ b/web/src/components/ui/badge.tsx @@ -0,0 +1,37 @@ +import { cn } from "@/lib/utils"; +import { cva, type VariantProps } from "class-variance-authority"; +import * as React from "react"; + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + success: + "border-transparent bg-green-200 text-secondary-foreground hover:bg-green-200/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +); + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ); +} + +export { Badge, badgeVariants };