1
1
import React , { Suspense , useEffect , useState } from 'react' ;
2
2
import { IconButton , Alert , AlertTitle , Stack , Button , Typography , FormGroup , FormControlLabel , Dialog , DialogTitle , DialogContent , Checkbox , Badge , TextField , Tabs , Tab , CircularProgress , Box , Menu , Divider , Switch , MenuItem } from '@mui/material' ;
3
3
import { SwapVert , FolderOpenRounded } from '@mui/icons-material' ;
4
- import { useCatalogContext } from '../context/CatalogContext' ;
5
- import { useMCPClientContext } from '../context/MCPClientContext' ;
6
- import { useConfigContext } from '../context/ConfigContext' ;
7
4
import { createDockerDesktopClient } from '@docker/extension-api-client' ;
8
5
import { ExecResult } from '@docker/extension-api-client-types/dist/v0' ;
9
6
import YourClients from './tabs/YourClients' ;
10
7
import { CatalogItemWithName } from '../types/catalog' ;
11
8
import { CATALOG_LAYOUT_SX } from '../Constants' ;
9
+ import { MCPClientState } from '../MCPClients' ;
12
10
13
11
const ToolCatalog = React . lazy ( ( ) => import ( './tabs/ToolCatalog' ) ) ;
14
12
const YourEnvironment = React . lazy ( ( ) => import ( './tabs/YourEnvironment' ) ) ;
@@ -17,6 +15,7 @@ const YourEnvironment = React.lazy(() => import('./tabs/YourEnvironment'));
17
15
const client = createDockerDesktopClient ( ) ;
18
16
19
17
interface CatalogGridProps {
18
+ appProps : any ; // We'll use this to pass all our hook data
20
19
showSettings : ( ) => void ;
21
20
setConfiguringItem : ( item : CatalogItemWithName ) => void ;
22
21
}
@@ -32,26 +31,22 @@ const parseDDVersion = (ddVersion: string) => {
32
31
const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again' ;
33
32
34
33
export const CatalogGrid : React . FC < CatalogGridProps > = ( {
34
+ appProps,
35
35
setConfiguringItem,
36
36
} ) => {
37
+ // Extract all the values we need from appProps
37
38
const {
38
39
catalogItems,
39
40
registryItems,
40
41
canRegister,
41
42
registerCatalogItem,
42
43
unregisterCatalogItem,
43
44
tryUpdateSecrets,
44
- secrets
45
- } = useCatalogContext ( ) ;
46
-
47
- const {
45
+ secrets,
48
46
mcpClientStates,
49
- isLoading : mcpLoading
50
- } = useMCPClientContext ( ) ;
51
-
52
- const {
47
+ isLoading : mcpLoading ,
53
48
config
54
- } = useConfigContext ( ) ;
49
+ } = appProps ;
55
50
56
51
const [ showReloadModal , setShowReloadModal ] = useState < boolean > ( false ) ;
57
52
const [ search , setSearch ] = useState < string > ( '' ) ;
@@ -91,7 +86,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
91
86
}
92
87
93
88
const hasOutOfCatalog = catalogItems . length > 0 && Object . keys ( registryItems ) . length > 0 && ! Object . keys ( registryItems ) . every ( ( i ) =>
94
- catalogItems . some ( ( c ) => c . name === i )
89
+ catalogItems . some ( ( c : CatalogItemWithName ) => c . name === i )
95
90
)
96
91
97
92
const sortedCatalogItems = sort !== 'date-desc' ? [ ...catalogItems ] . sort ( ( a , b ) => {
@@ -111,7 +106,11 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
111
106
</ >
112
107
}
113
108
114
- const noConfiguredClients = ! mcpLoading && ! Object . values ( mcpClientStates || { } ) . some ( state => state . exists && state . configured ) ;
109
+ // Check if there are any configured clients
110
+ const noConfiguredClients = ! mcpLoading && mcpClientStates ?
111
+ ! Object . values ( mcpClientStates as Record < string , MCPClientState > ) . some ( state =>
112
+ state . exists && state . configured
113
+ ) : false ;
115
114
116
115
return (
117
116
< >
@@ -186,12 +185,6 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
186
185
} } disableRipple >
187
186
⏰ Most Recent
188
187
</ MenuItem >
189
- { /* <MenuItem onClick={() => setOpenMenus({ ...openMenus, 'demo-customized-menu': { anchorEl: null, open: false } }) } disableRipple>
190
- ️🔥 Trending
191
- </MenuItem>
192
- <MenuItem onClick={() => setOpenMenus({ ...openMenus, 'demo-customized-menu': { anchorEl: null, open: false } }) } disableRipple>
193
- ⬇️ Most Downloads
194
- </MenuItem> */ }
195
188
< Divider sx = { { my : 0.5 } } />
196
189
< MenuItem sx = { { fontWeight : sort === 'name-asc' ? 'bold' : 'normal' } } onClick = { ( ) => {
197
190
setOpenMenus ( { ...openMenus , 'demo-customized-menu' : { anchorEl : null , open : false } } )
@@ -228,34 +221,14 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
228
221
config = { config || { } }
229
222
/>
230
223
) }
231
- { /* {tab === 1 && (
232
- <YourTools
233
- registryItems={registryItems}
234
- search={search}
235
- catalogItems={sortedCatalogItems}
236
- unregister={unregisterCatalogItem}
237
- onSecretChange={tryLoadSecrets}
238
- secrets={secrets}
239
- setConfiguringItem={setConfiguringItem}
240
- canRegister={canRegister}
241
- ddVersion={ddVersion}
242
- config={config || {}}
243
- />
244
- )} */ }
245
- { tab === 2 && ddVersion && (
246
- < YourEnvironment
247
- secrets = { secrets }
248
- ddVersion = { ddVersion }
249
- config = { config || { } }
250
- />
251
- ) }
252
224
{ tab === 1 && (
253
225
< YourClients
254
- client = { client }
226
+ appProps = { appProps }
227
+ ddVersion = { ddVersion }
255
228
/>
256
229
) }
257
230
</ Suspense >
258
231
</ Stack >
259
232
</ >
260
233
) ;
261
- } ;
234
+ }
0 commit comments