1
- import { provisionerJobs } from "api/queries/organizations" ;
2
1
import type { ProvisionerJob } from "api/typesGenerated" ;
3
2
import { Avatar } from "components/Avatar/Avatar" ;
4
3
import { 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" ;
17
5
import {
18
6
ChevronDownIcon ,
19
7
ChevronRightIcon ,
20
8
TriangleAlertIcon ,
21
9
} from "lucide-react" ;
22
10
import { type FC , useState } from "react" ;
23
- import { useQuery } from "react-query" ;
24
11
import { cn } from "utils/cn" ;
25
- import { docs } from "utils/docs" ;
26
12
import { relativeTime } from "utils/time" ;
27
13
import { CancelJobButton } from "./CancelJobButton" ;
28
- import { DataGrid } from "./DataGrid" ;
29
14
import { JobStatusIndicator } from "./JobStatusIndicator" ;
30
15
import { Tag , Tags , TruncateTags } from "./Tags" ;
31
16
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
-
98
17
type JobRowProps = {
99
18
job : ProvisionerJob ;
100
19
} ;
101
20
102
- const JobRow : FC < JobRowProps > = ( { job } ) => {
21
+ export const JobRow : FC < JobRowProps > = ( { job } ) => {
103
22
const metadata = job . metadata ;
104
23
const [ isOpen , setIsOpen ] = useState ( false ) ;
105
24
@@ -133,20 +52,16 @@ const JobRow: FC<JobRowProps> = ({ job }) => {
133
52
< Badge size = "sm" > { job . type } </ Badge >
134
53
</ TableCell >
135
54
< 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 >
150
65
</ TableCell >
151
66
< TableCell >
152
67
< TruncateTags tags = { job . tags } />
@@ -173,7 +88,13 @@ const JobRow: FC<JobRowProps> = ({ job }) => {
173
88
< span className = "[&:first-letter]:uppercase" > { job . error } </ span >
174
89
</ div >
175
90
) }
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
+ >
177
98
< dt > Job ID:</ dt >
178
99
< dd > { job . id } </ dd >
179
100
@@ -206,7 +127,7 @@ const JobRow: FC<JobRowProps> = ({ job }) => {
206
127
) ) }
207
128
</ Tags >
208
129
</ dd >
209
- </ DataGrid >
130
+ </ dl >
210
131
</ TableCell >
211
132
</ TableRow >
212
133
) }
0 commit comments