1
1
import { type Interpolation , type Theme } from "@emotion/react" ;
2
2
import Button from "@mui/material/Button" ;
3
3
import AlertTitle from "@mui/material/AlertTitle" ;
4
- import { type FC } from "react" ;
4
+ import { PropsWithChildren , type FC , Children } from "react" ;
5
5
import { useNavigate } from "react-router-dom" ;
6
6
import type * as TypesGen from "api/typesGenerated" ;
7
7
import { Alert , AlertDetail } from "components/Alert/Alert" ;
@@ -19,9 +19,11 @@ import { useTheme } from "@mui/material/styles";
19
19
import { SidebarIconButton } from "components/FullPageLayout/Sidebar" ;
20
20
import HubOutlined from "@mui/icons-material/HubOutlined" ;
21
21
import { ResourcesSidebar } from "./ResourcesSidebar" ;
22
- import { ResourceCard } from "components/Resources/ResourceCard" ;
23
22
import { WorkspacePermissions } from "./permissions" ;
24
23
import { resourceOptionValue , useResourcesNav } from "./useResourcesNav" ;
24
+ import { MemoizedInlineMarkdown } from "components/Markdown/Markdown" ;
25
+ import { SensitiveValue } from "components/Resources/SensitiveValue" ;
26
+ import { CopyableValue } from "components/CopyableValue/CopyableValue" ;
25
27
26
28
export interface WorkspaceProps {
27
29
handleStart : ( buildParameters ?: TypesGen . WorkspaceBuildParameter [ ] ) => void ;
@@ -182,6 +184,9 @@ export const Workspace: FC<WorkspaceProps> = ({
182
184
183
185
< div css = { styles . content } >
184
186
< div css = { styles . dotBackground } >
187
+ { selectedResource && (
188
+ < WorkspaceResourceData resource = { selectedResource } />
189
+ ) }
185
190
< div
186
191
css = { {
187
192
display : "flex" ,
@@ -229,9 +234,10 @@ export const Workspace: FC<WorkspaceProps> = ({
229
234
{ buildLogs }
230
235
231
236
{ selectedResource && (
232
- < ResourceCard
233
- resource = { selectedResource }
234
- agentRow = { ( agent ) => (
237
+ < section
238
+ css = { { display : "flex" , flexDirection : "column" , gap : 24 } }
239
+ >
240
+ { selectedResource . agents ?. map ( ( agent ) => (
235
241
< AgentRow
236
242
key = { agent . id }
237
243
agent = { agent }
@@ -245,8 +251,8 @@ export const Workspace: FC<WorkspaceProps> = ({
245
251
serverAPIVersion = { buildInfo ?. agent_api_version || "" }
246
252
onUpdateAgent = { handleUpdate } // On updating the workspace the agent version is also updated
247
253
/>
248
- ) }
249
- / >
254
+ ) ) }
255
+ </ section >
250
256
) }
251
257
</ div >
252
258
</ div >
@@ -255,6 +261,53 @@ export const Workspace: FC<WorkspaceProps> = ({
255
261
) ;
256
262
} ;
257
263
264
+ const WorkspaceResourceData : FC < { resource : TypesGen . WorkspaceResource } > = ( {
265
+ resource,
266
+ } ) => {
267
+ const metadata = resource . metadata ?? [ ] ;
268
+
269
+ if ( resource . daily_cost > 0 ) {
270
+ metadata . push ( {
271
+ key : "Daily cost" ,
272
+ value : resource . daily_cost . toString ( ) ,
273
+ sensitive : false ,
274
+ } ) ;
275
+ }
276
+
277
+ if ( metadata . length === 0 ) {
278
+ return null ;
279
+ }
280
+
281
+ return (
282
+ < header css = { styles . resourceData } >
283
+ { resource . metadata ?. map ( ( meta ) => {
284
+ return (
285
+ < div css = { styles . resourceDataItem } key = { meta . key } >
286
+ < div css = { styles . resourceDataItemValue } >
287
+ { meta . sensitive ? (
288
+ < SensitiveValue value = { meta . value } />
289
+ ) : (
290
+ < MemoizedInlineMarkdown components = { { p } } >
291
+ { meta . value }
292
+ </ MemoizedInlineMarkdown >
293
+ ) }
294
+ </ div >
295
+ < div css = { styles . resourceDataItemLabel } > { meta . key } </ div >
296
+ </ div >
297
+ ) ;
298
+ } ) }
299
+ </ header >
300
+ ) ;
301
+ } ;
302
+
303
+ const p = ( { children } : PropsWithChildren ) => {
304
+ const childrens = Children . toArray ( children ) ;
305
+ if ( childrens . every ( ( child ) => typeof child === "string" ) ) {
306
+ return < CopyableValue value = { childrens . join ( "" ) } > { children } </ CopyableValue > ;
307
+ }
308
+ return < > { children } </ > ;
309
+ } ;
310
+
258
311
const countAgents = ( resource : TypesGen . WorkspaceResource ) => {
259
312
return resource . agents ? resource . agents . length : 0 ;
260
313
} ;
@@ -264,6 +317,7 @@ const styles = {
264
317
padding : 24 ,
265
318
gridArea : "content" ,
266
319
overflowY : "auto" ,
320
+ position : "relative" ,
267
321
} ,
268
322
269
323
dotBackground : ( theme ) => ( {
@@ -288,4 +342,32 @@ const styles = {
288
342
flexDirection : "column" ,
289
343
} ,
290
344
} ) ,
345
+
346
+ resourceData : ( theme ) => ( {
347
+ padding : 24 ,
348
+ margin : "-48px 0 0 -48px" ,
349
+ display : "flex" ,
350
+ gap : 48 ,
351
+ marginBottom : 24 ,
352
+ fontSize : 14 ,
353
+ background : `linear-gradient(180deg, ${ theme . palette . background . default } 0%, rgba(0, 0, 0, 0) 100%)` ,
354
+ } ) ,
355
+
356
+ resourceDataItem : ( ) => ( {
357
+ lineHeight : "1.5" ,
358
+ } ) ,
359
+
360
+ resourceDataItemLabel : ( theme ) => ( {
361
+ fontSize : 13 ,
362
+ color : theme . palette . text . secondary ,
363
+ textOverflow : "ellipsis" ,
364
+ overflow : "hidden" ,
365
+ whiteSpace : "nowrap" ,
366
+ } ) ,
367
+
368
+ resourceDataItemValue : ( ) => ( {
369
+ textOverflow : "ellipsis" ,
370
+ overflow : "hidden" ,
371
+ whiteSpace : "nowrap" ,
372
+ } ) ,
291
373
} satisfies Record < string , Interpolation < Theme > > ;
0 commit comments