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 { PropsWithChildren , type FC , Children } from "react" ;
4
+ import { type FC } 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" ;
@@ -21,9 +21,7 @@ import HubOutlined from "@mui/icons-material/HubOutlined";
21
21
import { ResourcesSidebar } from "./ResourcesSidebar" ;
22
22
import { WorkspacePermissions } from "./permissions" ;
23
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" ;
24
+ import { ResourceMetadata } from "./ResourceMetadata" ;
27
25
28
26
export interface WorkspaceProps {
29
27
handleStart : ( buildParameters ?: TypesGen . WorkspaceBuildParameter [ ] ) => void ;
@@ -187,7 +185,10 @@ export const Workspace: FC<WorkspaceProps> = ({
187
185
< div css = { styles . content } >
188
186
< div css = { styles . dotBackground } >
189
187
{ selectedResource && (
190
- < WorkspaceResourceData resource = { selectedResource } />
188
+ < ResourceMetadata
189
+ resource = { selectedResource }
190
+ css = { { margin : "-48px 0 24px -48px" } }
191
+ />
191
192
) }
192
193
< div
193
194
css = { {
@@ -282,55 +283,6 @@ export const Workspace: FC<WorkspaceProps> = ({
282
283
) ;
283
284
} ;
284
285
285
- const WorkspaceResourceData : FC < { resource : TypesGen . WorkspaceResource } > = ( {
286
- resource,
287
- } ) => {
288
- const metadata = resource . metadata ? [ ...resource . metadata ] : [ ] ;
289
-
290
- if ( resource . daily_cost > 0 ) {
291
- metadata . push ( {
292
- key : "Daily cost" ,
293
- value : resource . daily_cost . toString ( ) ,
294
- sensitive : false ,
295
- } ) ;
296
- }
297
-
298
- if ( metadata . length === 0 ) {
299
- return null ;
300
- }
301
-
302
- return (
303
- < header css = { styles . resourceData } >
304
- { metadata . map ( ( meta ) => {
305
- return (
306
- < div css = { styles . resourceDataItem } key = { meta . key } >
307
- < div css = { styles . resourceDataItemValue } >
308
- { meta . sensitive ? (
309
- < SensitiveValue value = { meta . value } />
310
- ) : (
311
- < MemoizedInlineMarkdown components = { { p : MetaValue } } >
312
- { meta . value }
313
- </ MemoizedInlineMarkdown >
314
- ) }
315
- </ div >
316
- < div css = { styles . resourceDataItemLabel } > { meta . key } </ div >
317
- </ div >
318
- ) ;
319
- } ) }
320
- </ header >
321
- ) ;
322
- } ;
323
-
324
- const MetaValue = ( { children } : PropsWithChildren ) => {
325
- const childrenArray = Children . toArray ( children ) ;
326
- if ( childrenArray . every ( ( child ) => typeof child === "string" ) ) {
327
- return (
328
- < CopyableValue value = { childrenArray . join ( "" ) } > { children } </ CopyableValue >
329
- ) ;
330
- }
331
- return < > { children } </ > ;
332
- } ;
333
-
334
286
const countAgents = ( resource : TypesGen . WorkspaceResource ) => {
335
287
return resource . agents ? resource . agents . length : 0 ;
336
288
} ;
@@ -365,34 +317,4 @@ const styles = {
365
317
flexDirection : "column" ,
366
318
} ,
367
319
} ) ,
368
-
369
- resourceData : ( theme ) => ( {
370
- padding : 24 ,
371
- margin : "-48px 0 0 -48px" ,
372
- display : "flex" ,
373
- flexWrap : "wrap" ,
374
- gap : 48 ,
375
- rowGap : 24 ,
376
- marginBottom : 24 ,
377
- fontSize : 14 ,
378
- background : `linear-gradient(180deg, ${ theme . palette . background . default } 0%, rgba(0, 0, 0, 0) 100%)` ,
379
- } ) ,
380
-
381
- resourceDataItem : ( ) => ( {
382
- lineHeight : "1.5" ,
383
- } ) ,
384
-
385
- resourceDataItemLabel : ( theme ) => ( {
386
- fontSize : 13 ,
387
- color : theme . palette . text . secondary ,
388
- textOverflow : "ellipsis" ,
389
- overflow : "hidden" ,
390
- whiteSpace : "nowrap" ,
391
- } ) ,
392
-
393
- resourceDataItemValue : ( ) => ( {
394
- textOverflow : "ellipsis" ,
395
- overflow : "hidden" ,
396
- whiteSpace : "nowrap" ,
397
- } ) ,
398
320
} satisfies Record < string , Interpolation < Theme > > ;
0 commit comments