-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFlows.tsx
More file actions
83 lines (75 loc) · 2.27 KB
/
Flows.tsx
File metadata and controls
83 lines (75 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { useEffect } from "react";
import { useQuery } from "urql";
import { DataTable, type Column } from "@/components/DataTable";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { RefreshCwIcon } from "lucide-react";
const REGISTERED_FLOWS_QUERY = `
query RegisteredFlows {
registeredFlows { name entrypoint image tags }
}
`;
interface FlowRow {
name: string;
entrypoint: string;
image: string;
tags: string[];
}
export function Flows() {
const [result, reexecute] = useQuery({ query: REGISTERED_FLOWS_QUERY });
const flows: FlowRow[] = result.data?.registeredFlows || [];
function refetch() {
reexecute({ requestPolicy: "network-only" });
}
useEffect(() => {
const interval = setInterval(refetch, 30000);
return () => clearInterval(interval);
}, []);
const columns: Column<FlowRow>[] = [
{
header: "Flow Name",
cell: (row) => <span className="text-sm font-medium">{row.name}</span>,
},
{
header: "Entrypoint",
cell: (row) => <code className="text-xs font-mono">{row.entrypoint}</code>,
},
{
header: "Image",
cell: (row) => <code className="text-xs font-mono">{row.image || "-"}</code>,
},
{
header: "Tags",
cell: (row) => (
<div className="flex flex-wrap gap-1">
{row.tags.length > 0
? row.tags.map((t) => (
<Badge key={t} variant="secondary">{t}</Badge>
))
: <span className="text-sm text-muted-foreground">-</span>}
</div>
),
},
];
return (
<div className="space-y-6">
<div className="flex items-start justify-between">
<div>
<h2 className="text-2xl font-bold">Flows</h2>
<p className="text-muted-foreground">
{flows.length} registered flow{flows.length === 1 ? "" : "s"}
</p>
</div>
<Button variant="outline" onClick={refetch}>
<RefreshCwIcon className="h-4 w-4" />
</Button>
</div>
<DataTable
columns={columns}
data={flows}
loading={result.fetching}
emptyMessage="No flows registered. Flows are deployed when PREFECT_API_URL is configured and flow plugins are installed."
/>
</div>
);
}