1
- import React , { useEffect , useState } from 'react' ;
2
- import { Card , CardContent , IconButton , Alert , Stack , Button , Typography , Grid2 , Select , MenuItem , FormControl , InputLabel , Switch , FormGroup , FormControlLabel , Dialog , DialogTitle , DialogContent , Checkbox , Badge , BadgeProps , Link , TextField , Tabs , Tab , Tooltip , InputAdornment , CircularProgress } from '@mui/material' ;
3
- import { CatalogItemWithName , CatalogItemCard , CatalogItem } from './PromptCard' ;
4
- import AddIcon from '@mui/icons-material/Add' ;
5
- import { Ref } from '../Refs' ;
1
+ import React , { Suspense , useEffect , useState } from 'react' ;
2
+ import { IconButton , Alert , Stack , Button , Typography , FormGroup , FormControlLabel , Dialog , DialogTitle , DialogContent , Checkbox , Badge , BadgeProps , Link , TextField , Tabs , Tab , Tooltip , CircularProgress , Box } from '@mui/material' ;
3
+ import { CatalogItemWithName , CatalogItem } from './PromptCard' ;
6
4
import { v1 } from "@docker/extension-api-client-types" ;
7
5
import { parse , stringify } from 'yaml' ;
8
6
import { getRegistry , syncConfigWithRegistry , syncRegistryWithConfig } from '../Registry' ;
9
7
import { FolderOpenRounded , Search , Settings } from '@mui/icons-material' ;
10
8
import { tryRunImageSync } from '../FileWatcher' ;
11
- import { CATALOG_URL , DD_BUILD_WITH_SECRET_SUPPORT , MCP_POLICY_NAME , POLL_INTERVAL } from '../Constants' ;
12
- import { SecretList } from './SecretList' ;
9
+ import { CATALOG_URL , POLL_INTERVAL } from '../Constants' ;
13
10
import Secrets from '../Secrets' ;
14
11
import { ParsedParameters } from './PromptConfig' ;
15
12
13
+ const ToolCatalog = React . lazy ( ( ) => import ( './tabs/ToolCatalog' ) ) ;
14
+ const YourTools = React . lazy ( ( ) => import ( './tabs/YourTools' ) ) ;
15
+ const YourEnvironment = React . lazy ( ( ) => import ( './tabs/YourEnvironment' ) ) ;
16
+
16
17
interface CatalogGridProps {
17
18
registryItems : { [ key : string ] : { ref : string , config : any } } ;
18
19
canRegister : boolean ;
@@ -184,7 +185,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
184
185
} } > registry.yaml</ Button > } severity = "info" >
185
186
< Typography sx = { { width : '100%' } } > You have some prompts registered which are not available in the catalog.</ Typography >
186
187
</ Alert > }
187
- < Tabs value = { tab } onChange = { ( e , v ) => setTab ( v ) } sx = { { mb : 0 , mt : 1 } } >
188
+ < Tabs value = { tab } onChange = { ( _ , newValue ) => setTab ( newValue ) } sx = { { width : '100%' } } >
188
189
< Tooltip title = "These are all of the tiles you have available across the catalog." >
189
190
< Tab sx = { { fontSize : '1.5em' } } label = "Tool Catalog" />
190
191
</ Tooltip >
@@ -210,63 +211,34 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
210
211
</ Badge >
211
212
</ IconButton >
212
213
</ Stack >
213
- </ FormGroup >
214
-
215
- { tab === 0 && < Grid2 container spacing = { 1 } width = '90vw' maxWidth = { 1000 } >
216
- { filteredCatalogItems . map ( ( catalogItem ) => {
217
- const expectedProperties = catalogItem . config ?. map ( ( c : { name : string , parameters : ParsedParameters } ) => Object . keys ( c . parameters ) ) . flat ( ) || [ ]
218
- const hasAllConfig = ! expectedProperties . length || expectedProperties . every ( ( p : string ) => config [ catalogItem . name ] ?. [ p ] )
219
- return (
220
- < Grid2 size = { { xs : 12 , sm : 6 , md : 4 } } key = { catalogItem . name } >
221
- < CatalogItemCard
222
- hasAllConfig = { hasAllConfig }
223
- setConfiguringItem = { setConfiguringItem }
224
- openUrl = { ( ) => {
225
- client . host . openExternal ( Ref . fromRef ( catalogItem . ref ) . toURL ( true ) ) ;
226
- } }
227
- item = { catalogItem }
228
- ddVersion = { ddVersion }
229
- canRegister = { canRegister }
230
- registered = { Object . keys ( registryItems ) . some ( ( i ) => i === catalogItem . name ) }
231
- register = { registerCatalogItem }
232
- unregister = { unregisterCatalogItem }
233
- onSecretChange = { async ( secret ) => {
234
- await Secrets . addSecret ( client , { name : secret . name , value : secret . value , policies : [ MCP_POLICY_NAME ] } )
235
- loadSecrets ( ) ;
236
- } }
237
- secrets = { secrets }
238
- />
239
- </ Grid2 >
240
- )
241
- } ) }
242
- < Grid2 size = { 12 } >
243
- < Card sx = { { height : '100%' , display : 'flex' , justifyContent : 'center' , alignItems : 'center' } } >
244
- < CardContent >
245
- < IconButton sx = { { height : '100%' } } onClick = { ( ) => {
246
- client . host . openExternal ( 'https://vonwig.github.io/prompts.docs/tools/docs/' ) ;
247
- } } >
248
- < AddIcon sx = { { width : '100%' , height : 100 } } />
249
- </ IconButton >
250
- </ CardContent >
251
- </ Card >
252
- </ Grid2 >
253
- </ Grid2 > }
254
- { tab === 1 && < Grid2 container spacing = { 1 } width = '90vw' maxWidth = { 1000 } >
255
- { Object . entries ( registryItems ) . map ( ( [ name , item ] ) => {
256
- const hasAllConfig = item . config ?. map ( ( c : any ) => c . name ) . every ( ( c : any ) => config [ name ] ?. [ c ] )
257
- return (
258
- name . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) && < Grid2 size = { { xs : 12 , sm : 6 , md : 4 } } key = { name } >
259
- < CatalogItemCard hasAllConfig = { hasAllConfig } ddVersion = { ddVersion } item = { catalogItems . find ( ( i ) => i . name === name ) ! } openUrl = { ( ) => {
260
- client . host . openExternal ( Ref . fromRef ( item . ref ) . toURL ( true ) ) ;
261
- } } canRegister = { canRegister } registered = { true } register = { registerCatalogItem } unregister = { unregisterCatalogItem } onSecretChange = { async ( secret ) => {
262
- await Secrets . addSecret ( client , { name : secret . name , value : secret . value , policies : [ MCP_POLICY_NAME ] } )
263
- loadSecrets ( ) ;
264
- } } secrets = { secrets } setConfiguringItem = { setConfiguringItem } />
265
- </ Grid2 >
266
- )
267
- } ) }
268
- </ Grid2 > }
269
- { tab === 2 && ddVersion && < SecretList secrets = { secrets } ddVersion = { ddVersion } /> }
270
- </ Stack >
214
+ </ FormGroup >
215
+
216
+ < Suspense fallback = { < Box sx = { { display : 'flex' , justifyContent : 'center' , p : 4 } } > < CircularProgress /> </ Box > } >
217
+ { tab === 0 && (
218
+ < ToolCatalog
219
+ search = { search }
220
+ catalogItems = { catalogItems }
221
+ client = { client }
222
+ />
223
+ ) }
224
+ { tab === 1 && (
225
+ < YourTools
226
+ search = { search }
227
+ registryItems = { registryItems }
228
+ config = { config }
229
+ ddVersion = { ddVersion }
230
+ canRegister = { canRegister }
231
+ setConfiguringItem = { setConfiguringItem }
232
+ secrets = { secrets }
233
+ />
234
+ ) }
235
+ { tab === 2 && ddVersion && (
236
+ < YourEnvironment
237
+ secrets = { secrets }
238
+ ddVersion = { ddVersion }
239
+ />
240
+ ) }
241
+ </ Suspense >
242
+ </ Stack >
271
243
) ;
272
244
} ;
0 commit comments