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
- import { CatalogItemWithName } from '../types/catalog' ;
7
+ import { CatalogItemRichened } 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
- const YourEnvironment = React . lazy ( ( ) => import ( './tabs/YourEnvironment ' ) ) ;
12
+ const YourTools = React . lazy ( ( ) => import ( './tabs/YourTools ' ) ) ;
15
13
16
14
// Initialize the Docker Desktop client
17
15
const client = createDockerDesktopClient ( ) ;
18
16
19
17
interface CatalogGridProps {
20
- showSettings : ( ) => void ;
21
- setConfiguringItem : ( item : CatalogItemWithName ) => void ;
18
+ appProps : any ; // We'll use this to pass all our hook data
22
19
}
23
20
24
21
const parseDDVersion = ( ddVersion : string ) => {
@@ -32,26 +29,15 @@ const parseDDVersion = (ddVersion: string) => {
32
29
const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again' ;
33
30
34
31
export const CatalogGrid : React . FC < CatalogGridProps > = ( {
35
- setConfiguringItem ,
32
+ appProps ,
36
33
} ) => {
34
+ // Extract all the values we need from appProps
37
35
const {
38
36
catalogItems,
39
37
registryItems,
40
- canRegister,
41
- registerCatalogItem,
42
- unregisterCatalogItem,
43
- tryUpdateSecrets,
44
- secrets
45
- } = useCatalogContext ( ) ;
46
-
47
- const {
48
38
mcpClientStates,
49
- isLoading : mcpLoading
50
- } = useMCPClientContext ( ) ;
51
-
52
- const {
53
- config
54
- } = useConfigContext ( ) ;
39
+ isLoading : mcpLoading ,
40
+ } = appProps ;
55
41
56
42
const [ showReloadModal , setShowReloadModal ] = useState < boolean > ( false ) ;
57
43
const [ search , setSearch ] = useState < string > ( '' ) ;
@@ -91,27 +77,21 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
91
77
}
92
78
93
79
const hasOutOfCatalog = catalogItems . length > 0 && Object . keys ( registryItems ) . length > 0 && ! Object . keys ( registryItems ) . every ( ( i ) =>
94
- catalogItems . some ( ( c ) => c . name === i )
80
+ catalogItems . some ( ( c : CatalogItemRichened ) => c . name === i )
95
81
)
96
82
97
- const sortedCatalogItems = sort !== 'date-desc' ? [ ...catalogItems ] . sort ( ( a , b ) => {
98
- if ( sort === 'name-asc' ) {
99
- return a . name . localeCompare ( b . name ) ;
100
- }
101
- if ( sort === 'name-desc' ) {
102
- return b . name . localeCompare ( a . name ) ;
103
- }
104
- return 0 ;
105
- } ) : catalogItems ;
106
-
107
83
if ( ! ddVersion ) {
108
84
return < >
109
85
< CircularProgress />
110
86
< Typography > Loading Docker Desktop version...</ Typography >
111
87
</ >
112
88
}
113
89
114
- const noConfiguredClients = ! mcpLoading && ! Object . values ( mcpClientStates || { } ) . some ( state => state . exists && state . configured ) ;
90
+ // Check if there are any configured clients
91
+ const noConfiguredClients = ! mcpLoading && mcpClientStates ?
92
+ ! Object . values ( mcpClientStates as Record < string , MCPClientState > ) . some ( state =>
93
+ state . exists && state . configured
94
+ ) : false ;
115
95
116
96
return (
117
97
< >
@@ -186,12 +166,6 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
186
166
} } disableRipple >
187
167
⏰ Most Recent
188
168
</ 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
169
< Divider sx = { { my : 0.5 } } />
196
170
< MenuItem sx = { { fontWeight : sort === 'name-asc' ? 'bold' : 'normal' } } onClick = { ( ) => {
197
171
setOpenMenus ( { ...openMenus , 'demo-customized-menu' : { anchorEl : null , open : false } } )
@@ -213,49 +187,19 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
213
187
< Suspense fallback = { < Box sx = { { display : 'flex' , justifyContent : 'center' , p : 4 } } > < CircularProgress /> </ Box > } >
214
188
{ tab === 0 && (
215
189
< ToolCatalog
216
- registryItems = { registryItems }
217
190
search = { search }
218
- catalogItems = { sortedCatalogItems }
219
191
showMine = { showMine }
220
192
client = { client }
221
- ddVersion = { ddVersion }
222
- canRegister = { canRegister }
223
- register = { registerCatalogItem }
224
- unregister = { unregisterCatalogItem }
225
- onSecretChange = { tryUpdateSecrets }
226
- secrets = { secrets }
227
- setConfiguringItem = { setConfiguringItem }
228
- config = { config || { } }
229
- />
230
- ) }
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
193
/>
251
194
) }
252
195
{ tab === 1 && (
253
196
< YourClients
254
- client = { client }
197
+ appProps = { appProps }
198
+ ddVersion = { ddVersion }
255
199
/>
256
200
) }
257
201
</ Suspense >
258
202
</ Stack >
259
203
</ >
260
204
) ;
261
- } ;
205
+ }
0 commit comments