1- import { provisionerJobs } from "api/queries/organizations" ;
21import type { ProvisionerJob } from "api/typesGenerated" ;
32import { Avatar } from "components/Avatar/Avatar" ;
43import { Badge } from "components/Badge/Badge" ;
5- import { Button } from "components/Button/Button" ;
6- import { EmptyState } from "components/EmptyState/EmptyState" ;
7- import { Link } from "components/Link/Link" ;
8- import { Loader } from "components/Loader/Loader" ;
9- import {
10- Table ,
11- TableBody ,
12- TableCell ,
13- TableHead ,
14- TableHeader ,
15- TableRow ,
16- } from "components/Table/Table" ;
4+ import { TableCell , TableRow } from "components/Table/Table" ;
175import {
186 ChevronDownIcon ,
197 ChevronRightIcon ,
208 TriangleAlertIcon ,
219} from "lucide-react" ;
2210import { type FC , useState } from "react" ;
23- import { useQuery } from "react-query" ;
2411import { cn } from "utils/cn" ;
25- import { docs } from "utils/docs" ;
2612import { relativeTime } from "utils/time" ;
2713import { CancelJobButton } from "./CancelJobButton" ;
28- import { DataGrid } from "./DataGrid" ;
2914import { JobStatusIndicator } from "./JobStatusIndicator" ;
3015import { Tag , Tags , TruncateTags } from "./Tags" ;
3116
32- type ProvisionerJobsPageProps = {
33- orgId : string ;
34- } ;
35-
36- export const ProvisionerJobsPage : FC < ProvisionerJobsPageProps > = ( {
37- orgId,
38- } ) => {
39- const {
40- data : jobs ,
41- isLoadingError,
42- refetch,
43- } = useQuery ( provisionerJobs ( orgId ) ) ;
44-
45- return (
46- < section className = "flex flex-col gap-8" >
47- < h2 className = "sr-only" > Provisioner jobs</ h2 >
48- < p className = "text-sm text-content-secondary m-0 mt-2" >
49- Provisioner Jobs are the individual tasks assigned to Provisioners when
50- the workspaces are being built.{ " " }
51- < Link href = { docs ( "/admin/provisioners" ) } > View docs</ Link >
52- </ p >
53-
54- < Table >
55- < TableHeader >
56- < TableRow >
57- < TableHead > Created</ TableHead >
58- < TableHead > Type</ TableHead >
59- < TableHead > Template</ TableHead >
60- < TableHead > Tags</ TableHead >
61- < TableHead > Status</ TableHead >
62- < TableHead />
63- </ TableRow >
64- </ TableHeader >
65- < TableBody >
66- { jobs ? (
67- jobs . length > 0 ? (
68- jobs . map ( ( j ) => < JobRow key = { j . id } job = { j } /> )
69- ) : (
70- < TableRow >
71- < TableCell colSpan = { 999 } >
72- < EmptyState message = "No provisioner jobs found" />
73- </ TableCell >
74- </ TableRow >
75- )
76- ) : isLoadingError ? (
77- < TableRow >
78- < TableCell colSpan = { 999 } >
79- < EmptyState
80- message = "Error loading the provisioner jobs"
81- cta = { < Button onClick = { ( ) => refetch ( ) } > Retry</ Button > }
82- />
83- </ TableCell >
84- </ TableRow >
85- ) : (
86- < TableRow >
87- < TableCell colSpan = { 999 } >
88- < Loader />
89- </ TableCell >
90- </ TableRow >
91- ) }
92- </ TableBody >
93- </ Table >
94- </ section >
95- ) ;
96- } ;
97-
9817type JobRowProps = {
9918 job : ProvisionerJob ;
10019} ;
10120
102- const JobRow : FC < JobRowProps > = ( { job } ) => {
21+ export const JobRow : FC < JobRowProps > = ( { job } ) => {
10322 const metadata = job . metadata ;
10423 const [ isOpen , setIsOpen ] = useState ( false ) ;
10524
@@ -133,20 +52,16 @@ const JobRow: FC<JobRowProps> = ({ job }) => {
13352 < Badge size = "sm" > { job . type } </ Badge >
13453 </ TableCell >
13554 < TableCell >
136- { job . metadata . template_name ? (
137- < div className = "flex items-center gap-1 whitespace-nowrap" >
138- < Avatar
139- variant = "icon"
140- src = { metadata . template_icon }
141- fallback = {
142- metadata . template_display_name || metadata . template_name
143- }
144- />
145- { metadata . template_display_name ?? metadata . template_name }
146- </ div >
147- ) : (
148- < span className = "whitespace-nowrap" > Not linked</ span >
149- ) }
55+ < div className = "flex items-center gap-1 whitespace-nowrap" >
56+ < Avatar
57+ variant = "icon"
58+ src = { metadata . template_icon }
59+ fallback = {
60+ metadata . template_display_name || metadata . template_name
61+ }
62+ />
63+ { metadata . template_display_name || metadata . template_name }
64+ </ div >
15065 </ TableCell >
15166 < TableCell >
15267 < TruncateTags tags = { job . tags } />
@@ -173,7 +88,13 @@ const JobRow: FC<JobRowProps> = ({ job }) => {
17388 < span className = "[&:first-letter]:uppercase" > { job . error } </ span >
17489 </ div >
17590 ) }
176- < DataGrid >
91+ < dl
92+ className = { cn ( [
93+ "text-xs text-content-secondary" ,
94+ "m-0 grid grid-cols-[auto_1fr] gap-x-4 items-center" ,
95+ "[&_dd]:text-content-primary [&_dd]:font-mono [&_dd]:leading-[22px] [&_dt]:font-medium" ,
96+ ] ) }
97+ >
17798 < dt > Job ID:</ dt >
17899 < dd > { job . id } </ dd >
179100
@@ -206,7 +127,7 @@ const JobRow: FC<JobRowProps> = ({ job }) => {
206127 ) ) }
207128 </ Tags >
208129 </ dd >
209- </ DataGrid >
130+ </ dl >
210131 </ TableCell >
211132 </ TableRow >
212133 ) }
0 commit comments