@@ -5,33 +5,19 @@ import {
55 ClockIcon ,
66 HourglassIcon ,
77 ProhibitIcon ,
8- PulseIcon ,
98 XCircleIcon ,
109} from "@phosphor-icons/react" ;
11- import type { WorkflowRun } from "openworkflow/internal" ;
10+ import type { WorkflowRunCounts } from "openworkflow/internal" ;
1211
1312export interface WorkflowStatsProps {
14- runs : WorkflowRun [ ] ;
13+ workflowRunCounts : WorkflowRunCounts ;
1514}
1615
17- export function WorkflowStats ( { runs } : WorkflowStatsProps ) {
18- // this computes stats from real run data as a placeholder until the backend
19- // is updated to provide aggregated stats
20- const completed = runs . filter (
21- ( r ) => r . status === "completed" || r . status === "succeeded" ,
22- ) . length ;
23- const running = runs . filter ( ( r ) => r . status === "running" ) . length ;
24- const failed = runs . filter ( ( r ) => r . status === "failed" ) . length ;
25- const pending = runs . filter ( ( r ) => r . status === "pending" ) . length ;
26- const sleeping = runs . filter ( ( r ) => r . status === "sleeping" ) . length ;
27- const canceled = runs . filter ( ( r ) => r . status === "canceled" ) . length ;
16+ export function WorkflowStats ( { workflowRunCounts } : WorkflowStatsProps ) {
17+ const { pending, running, sleeping, completed, failed, canceled } =
18+ workflowRunCounts ;
2819
2920 const stats = [
30- {
31- label : "Total Runs" ,
32- value : runs . length . toLocaleString ( ) ,
33- icon : PulseIcon ,
34- } ,
3521 { label : "Pending" , value : pending . toLocaleString ( ) , icon : ClockIcon } ,
3622 {
3723 label : "Running" ,
@@ -61,17 +47,13 @@ export function WorkflowStats({ runs }: WorkflowStatsProps) {
6147 ] ;
6248
6349 return (
64- < div className = "grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-7 " >
65- { stats . map ( ( stat , index ) => {
50+ < div className = "grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 xl:grid-cols-6 " >
51+ { stats . map ( ( stat ) => {
6652 const Icon = stat . icon ;
6753 return (
6854 < Card
6955 key = { stat . label }
70- className = { `bg-card border-border hover:border-primary/50 p-3 transition-colors sm:p-5 ${
71- index === 0
72- ? "col-span-2 sm:col-span-3 lg:col-span-2 xl:col-span-1"
73- : ""
74- } `}
56+ className = "bg-card border-border hover:border-primary/50 p-3 transition-colors sm:p-5"
7557 >
7658 < div className = "flex items-start justify-between" >
7759 < div className = "space-y-1" >
0 commit comments