1
1
import { makeStyles } from "@material-ui/core/styles"
2
- import { Skeleton } from "@material-ui/lab"
3
- import { PortForwardButton } from "components/PortForwardButton/PortForwardButton"
4
2
import { FC , useState } from "react"
5
- import { Workspace , WorkspaceResource } from "../../api/typesGenerated"
6
- import { AppLink } from "../AppLink/AppLink"
7
- import { SSHButton } from "../SSHButton/SSHButton"
3
+ import { WorkspaceAgent , WorkspaceResource } from "../../api/typesGenerated"
8
4
import { Stack } from "../Stack/Stack"
9
- import { TerminalLink } from "../TerminalLink/TerminalLink"
10
5
import { ResourceAvatar } from "./ResourceAvatar"
11
6
import { SensitiveValue } from "./SensitiveValue"
12
- import { AgentLatency } from "./AgentLatency"
13
- import { AgentVersion } from "./AgentVersion"
14
7
import {
15
8
OpenDropdown ,
16
9
CloseDropdown ,
@@ -19,25 +12,13 @@ import IconButton from "@material-ui/core/IconButton"
19
12
import Tooltip from "@material-ui/core/Tooltip"
20
13
import { Maybe } from "components/Conditionals/Maybe"
21
14
import { CopyableValue } from "components/CopyableValue/CopyableValue"
22
- import { AgentStatus } from "./AgentStatus"
23
15
24
16
export interface ResourceCardProps {
25
17
resource : WorkspaceResource
26
- workspace : Workspace
27
- applicationsHost : string | undefined
28
- showApps : boolean
29
- hideSSHButton ?: boolean
30
- serverVersion : string
18
+ agentRow : ( agent : WorkspaceAgent ) => JSX . Element
31
19
}
32
20
33
- export const ResourceCard : FC < ResourceCardProps > = ( {
34
- resource,
35
- workspace,
36
- applicationsHost,
37
- showApps,
38
- hideSSHButton,
39
- serverVersion,
40
- } ) => {
21
+ export const ResourceCard : FC < ResourceCardProps > = ( { resource, agentRow } ) => {
41
22
const [ shouldDisplayAllMetadata , setShouldDisplayAllMetadata ] =
42
23
useState ( false )
43
24
const styles = useStyles ( )
@@ -113,102 +94,7 @@ export const ResourceCard: FC<ResourceCardProps> = ({
113
94
</ Stack >
114
95
115
96
{ resource . agents && resource . agents . length > 0 && (
116
- < div >
117
- { resource . agents . map ( ( agent ) => {
118
- return (
119
- < Stack
120
- key = { agent . id }
121
- direction = "row"
122
- alignItems = "center"
123
- justifyContent = "space-between"
124
- className = { styles . agentRow }
125
- >
126
- < Stack direction = "row" alignItems = "baseline" >
127
- < div className = { styles . agentStatusWrapper } >
128
- < AgentStatus agent = { agent } />
129
- </ div >
130
- < div >
131
- < div className = { styles . agentName } > { agent . name } </ div >
132
- < Stack
133
- direction = "row"
134
- alignItems = "baseline"
135
- className = { styles . agentData }
136
- spacing = { 1 }
137
- >
138
- < span className = { styles . agentOS } >
139
- { agent . operating_system }
140
- </ span >
141
-
142
- < Maybe condition = { agent . status === "connected" } >
143
- < AgentVersion
144
- agent = { agent }
145
- serverVersion = { serverVersion }
146
- />
147
- </ Maybe >
148
-
149
- < AgentLatency agent = { agent } />
150
- </ Stack >
151
- </ div >
152
- </ Stack >
153
-
154
- < Stack
155
- direction = "row"
156
- alignItems = "center"
157
- spacing = { 0.5 }
158
- wrap = "wrap"
159
- maxWidth = "750px"
160
- >
161
- { showApps && agent . status === "connected" && (
162
- < >
163
- { agent . apps . map ( ( app ) => (
164
- < AppLink
165
- key = { app . name }
166
- appsHost = { applicationsHost }
167
- appIcon = { app . icon }
168
- appName = { app . name }
169
- appCommand = { app . command }
170
- appSubdomain = { app . subdomain }
171
- username = { workspace . owner_name }
172
- workspaceName = { workspace . name }
173
- agentName = { agent . name }
174
- health = { app . health }
175
- appSharingLevel = { app . sharing_level }
176
- />
177
- ) ) }
178
-
179
- < TerminalLink
180
- workspaceName = { workspace . name }
181
- agentName = { agent . name }
182
- userName = { workspace . owner_name }
183
- />
184
- { ! hideSSHButton && (
185
- < SSHButton
186
- workspaceName = { workspace . name }
187
- agentName = { agent . name }
188
- />
189
- ) }
190
- { applicationsHost !== undefined && (
191
- < PortForwardButton
192
- host = { applicationsHost }
193
- workspaceName = { workspace . name }
194
- agentId = { agent . id }
195
- agentName = { agent . name }
196
- username = { workspace . owner_name }
197
- />
198
- ) }
199
- </ >
200
- ) }
201
- { showApps && agent . status === "connecting" && (
202
- < >
203
- < Skeleton width = { 80 } height = { 36 } variant = "rect" />
204
- < Skeleton width = { 120 } height = { 36 } variant = "rect" />
205
- </ >
206
- ) }
207
- </ Stack >
208
- </ Stack >
209
- )
210
- } ) }
211
- </ div >
97
+ < div > { resource . agents . map ( agentRow ) } </ div >
212
98
) }
213
99
</ div >
214
100
)
@@ -270,34 +156,4 @@ const useStyles = makeStyles((theme) => ({
270
156
overflow : "hidden" ,
271
157
whiteSpace : "nowrap" ,
272
158
} ,
273
-
274
- agentRow : {
275
- padding : theme . spacing ( 3 , 4 ) ,
276
- backgroundColor : theme . palette . background . paperLight ,
277
- fontSize : 16 ,
278
-
279
- "&:not(:last-child)" : {
280
- borderBottom : `1px solid ${ theme . palette . divider } ` ,
281
- } ,
282
- } ,
283
-
284
- agentStatusWrapper : {
285
- width : theme . spacing ( 4.5 ) ,
286
- display : "flex" ,
287
- justifyContent : "center" ,
288
- } ,
289
-
290
- agentName : {
291
- fontWeight : 600 ,
292
- } ,
293
-
294
- agentOS : {
295
- textTransform : "capitalize" ,
296
- } ,
297
-
298
- agentData : {
299
- fontSize : 14 ,
300
- color : theme . palette . text . secondary ,
301
- marginTop : theme . spacing ( 0.5 ) ,
302
- } ,
303
159
} ) )
0 commit comments