1
- import { makeStyles , Theme , useTheme } from "@material-ui/core/styles"
1
+ import { makeStyles } from "@material-ui/core/styles"
2
2
import { Skeleton } from "@material-ui/lab"
3
3
import { PortForwardButton } from "components/PortForwardButton/PortForwardButton"
4
4
import { FC , useState } from "react"
5
- import {
6
- Workspace ,
7
- WorkspaceAgent ,
8
- WorkspaceAgentStatus ,
9
- WorkspaceResource ,
10
- } from "../../api/typesGenerated"
5
+ import { Workspace , WorkspaceResource } from "../../api/typesGenerated"
11
6
import { AppLink } from "../AppLink/AppLink"
12
7
import { SSHButton } from "../SSHButton/SSHButton"
13
8
import { Stack } from "../Stack/Stack"
@@ -24,23 +19,7 @@ import IconButton from "@material-ui/core/IconButton"
24
19
import Tooltip from "@material-ui/core/Tooltip"
25
20
import { Maybe } from "components/Conditionals/Maybe"
26
21
import { CopyableValue } from "components/CopyableValue/CopyableValue"
27
-
28
- const getAgentStatusColor = ( theme : Theme , agent : WorkspaceAgent ) => {
29
- switch ( agent . status ) {
30
- case "connected" :
31
- return theme . palette . success . light
32
- case "connecting" :
33
- return theme . palette . info . light
34
- case "disconnected" :
35
- return theme . palette . text . secondary
36
- }
37
- }
38
-
39
- const agentStatusLabels : Record < WorkspaceAgentStatus , string > = {
40
- connected : "Connected" ,
41
- connecting : "Connecting..." ,
42
- disconnected : "Disconnected" ,
43
- }
22
+ import { AgentStatus } from "./AgentStatus"
44
23
45
24
export interface ResourceCardProps {
46
25
resource : WorkspaceResource
@@ -59,7 +38,6 @@ export const ResourceCard: FC<ResourceCardProps> = ({
59
38
hideSSHButton,
60
39
serverVersion,
61
40
} ) => {
62
- const theme = useTheme < Theme > ( )
63
41
const [ shouldDisplayAllMetadata , setShouldDisplayAllMetadata ] =
64
42
useState ( false )
65
43
const styles = useStyles ( )
@@ -136,9 +114,6 @@ export const ResourceCard: FC<ResourceCardProps> = ({
136
114
137
115
< div >
138
116
{ resource . agents ?. map ( ( agent ) => {
139
- const statusColor = getAgentStatusColor ( theme , agent )
140
- const statusLabel = agentStatusLabels [ agent . status ]
141
-
142
117
return (
143
118
< Stack
144
119
key = { agent . id }
@@ -148,13 +123,7 @@ export const ResourceCard: FC<ResourceCardProps> = ({
148
123
className = { styles . agentRow }
149
124
>
150
125
< Stack direction = "row" alignItems = "baseline" >
151
- < Tooltip title = { statusLabel } >
152
- < div
153
- role = "status"
154
- className = { styles . agentStatus }
155
- style = { { backgroundColor : statusColor } }
156
- />
157
- </ Tooltip >
126
+ < AgentStatus agent = { agent } />
158
127
< div >
159
128
< div className = { styles . agentName } > { agent . name } </ div >
160
129
< Stack
@@ -279,12 +248,6 @@ const useStyles = makeStyles((theme) => ({
279
248
} ,
280
249
} ,
281
250
282
- agentStatus : {
283
- width : theme . spacing ( 1 ) ,
284
- height : theme . spacing ( 1 ) ,
285
- borderRadius : "100%" ,
286
- } ,
287
-
288
251
agentName : {
289
252
fontWeight : 600 ,
290
253
} ,
0 commit comments