11import React , { Suspense , useEffect , useState } from 'react' ;
22import { 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' ;
33import { SwapVert , FolderOpenRounded } from '@mui/icons-material' ;
4- import { useCatalogContext } from '../context/CatalogContext' ;
5- import { useMCPClientContext } from '../context/MCPClientContext' ;
6- import { useConfigContext } from '../context/ConfigContext' ;
74import { createDockerDesktopClient } from '@docker/extension-api-client' ;
85import { ExecResult } from '@docker/extension-api-client-types/dist/v0' ;
96import YourClients from './tabs/YourClients' ;
10- import { CatalogItemWithName } from '../types/catalog' ;
7+ import { CatalogItemRichened } from '../types/catalog' ;
118import { CATALOG_LAYOUT_SX } from '../Constants' ;
9+ import { MCPClientState } from '../MCPClients' ;
1210
1311const ToolCatalog = React . lazy ( ( ) => import ( './tabs/ToolCatalog' ) ) ;
14- const YourEnvironment = React . lazy ( ( ) => import ( './tabs/YourEnvironment ' ) ) ;
12+ const YourTools = React . lazy ( ( ) => import ( './tabs/YourTools ' ) ) ;
1513
1614// Initialize the Docker Desktop client
1715const client = createDockerDesktopClient ( ) ;
1816
1917interface CatalogGridProps {
20- showSettings : ( ) => void ;
21- setConfiguringItem : ( item : CatalogItemWithName ) => void ;
18+ appProps : any ; // We'll use this to pass all our hook data
2219}
2320
2421const parseDDVersion = ( ddVersion : string ) => {
@@ -32,26 +29,15 @@ const parseDDVersion = (ddVersion: string) => {
3229const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again' ;
3330
3431export const CatalogGrid : React . FC < CatalogGridProps > = ( {
35- setConfiguringItem ,
32+ appProps ,
3633} ) => {
34+ // Extract all the values we need from appProps
3735 const {
3836 catalogItems,
3937 registryItems,
40- canRegister,
41- registerCatalogItem,
42- unregisterCatalogItem,
43- tryUpdateSecrets,
44- secrets
45- } = useCatalogContext ( ) ;
46-
47- const {
4838 mcpClientStates,
49- isLoading : mcpLoading
50- } = useMCPClientContext ( ) ;
51-
52- const {
53- config
54- } = useConfigContext ( ) ;
39+ isLoading : mcpLoading ,
40+ } = appProps ;
5541
5642 const [ showReloadModal , setShowReloadModal ] = useState < boolean > ( false ) ;
5743 const [ search , setSearch ] = useState < string > ( '' ) ;
@@ -91,27 +77,21 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
9177 }
9278
9379 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 )
9581 )
9682
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-
10783 if ( ! ddVersion ) {
10884 return < >
10985 < CircularProgress />
11086 < Typography > Loading Docker Desktop version...</ Typography >
11187 </ >
11288 }
11389
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 ;
11595
11696 return (
11797 < >
@@ -186,12 +166,6 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
186166 } } disableRipple >
187167 ⏰ Most Recent
188168 </ 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> */ }
195169 < Divider sx = { { my : 0.5 } } />
196170 < MenuItem sx = { { fontWeight : sort === 'name-asc' ? 'bold' : 'normal' } } onClick = { ( ) => {
197171 setOpenMenus ( { ...openMenus , 'demo-customized-menu' : { anchorEl : null , open : false } } )
@@ -213,49 +187,19 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
213187 < Suspense fallback = { < Box sx = { { display : 'flex' , justifyContent : 'center' , p : 4 } } > < CircularProgress /> </ Box > } >
214188 { tab === 0 && (
215189 < ToolCatalog
216- registryItems = { registryItems }
217190 search = { search }
218- catalogItems = { sortedCatalogItems }
219191 showMine = { showMine }
220192 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 || { } }
250193 />
251194 ) }
252195 { tab === 1 && (
253196 < YourClients
254- client = { client }
197+ appProps = { appProps }
198+ ddVersion = { ddVersion }
255199 />
256200 ) }
257201 </ Suspense >
258202 </ Stack >
259203 </ >
260204 ) ;
261- } ;
205+ }
0 commit comments