7
7
Card ,
8
8
CardContent ,
9
9
CardHeader ,
10
+ Chip ,
10
11
CircularProgress ,
11
12
Collapse ,
12
13
Divider ,
@@ -15,6 +16,7 @@ import {
15
16
ListItem ,
16
17
ListItemText ,
17
18
Stack ,
19
+ Theme ,
18
20
Typography
19
21
} from '@mui/material' ;
20
22
import { useEffect , useState } from 'react' ;
@@ -24,6 +26,7 @@ import ContinueIcon from '../../assets/continue.svg';
24
26
import CursorIcon from '../../assets/cursor.svg' ;
25
27
import GordonIcon from '../../assets/gordon-icon.png' ;
26
28
import { CATALOG_LAYOUT_SX , DOCKER_MCP_COMMAND } from '../../Constants' ;
29
+ import { LinkOff , LinkOffOutlined , LinkOutlined } from '@mui/icons-material' ;
27
30
28
31
// Initialize the Docker Desktop client
29
32
const client = createDockerDesktopClient ( ) ;
@@ -39,6 +42,19 @@ const iconMap = {
39
42
'Continue.dev' : ContinueIcon ,
40
43
} ;
41
44
45
+ const ConnectButtonStyle = ( theme : Theme ) => ( {
46
+ fontSize : '14px' ,
47
+ p : 1 ,
48
+ alignItems : 'center' ,
49
+ justifyContent : 'center' ,
50
+ [ theme . breakpoints . down ( 'sm' ) ] : {
51
+ p : '2px' ,
52
+ '& .MuiTypography-root' : {
53
+ fontSize : '12px' ,
54
+ } ,
55
+ } ,
56
+ } ) ;
57
+
42
58
const MCPClientSettings = ( { appProps } : MCPClientSettingsProps ) => {
43
59
// Extract all the values we need from appProps
44
60
const { mcpClientStates, updateMCPClientStates } = appProps ;
@@ -127,6 +143,7 @@ function ClientSetting({
127
143
mcpClientState : any ;
128
144
appProps : any ;
129
145
} ) {
146
+
130
147
const [ expanded , setExpanded ] = useState ( false ) ;
131
148
132
149
// Extract all the values we need from appProps
@@ -149,78 +166,75 @@ function ClientSetting({
149
166
/>
150
167
)
151
168
}
152
- title = { < Typography variant = "subtitle2" > { name } </ Typography > }
169
+ title = { < Typography variant = "subtitle2" > { name } { mcpClientState . exists ? '' : < Chip sx = { { ml : 1 } } label = "Not detected" color = "error" size = "small" /> } </ Typography > }
153
170
subheader = {
154
- mcpClientState . exists ? (
155
- < Typography
156
- variant = "body2"
157
- sx = { {
158
- color : 'text.secondary ' ,
159
- alignItems : 'center ' ,
160
- display : 'flex ' ,
161
- cursor : 'pointer' ,
162
- } }
163
- onClick = { ( ) => setExpanded ( ! expanded ) }
164
- >
165
- Manual configuration
166
- { expanded ? (
171
+ < Typography
172
+ variant = "body2"
173
+ sx = { {
174
+ color : 'text.secondary' ,
175
+ alignItems : 'center ' ,
176
+ display : 'flex ' ,
177
+ cursor : 'pointer ' ,
178
+ } }
179
+ onClick = { ( ) => setExpanded ( ! expanded ) }
180
+ >
181
+ Manual configuration
182
+ {
183
+ expanded ? (
167
184
< KeyboardArrowDownIcon fontSize = "small" />
168
185
) : (
169
186
< KeyboardArrowRightIcon fontSize = "small" />
170
- ) }
171
- </ Typography >
172
- ) : (
173
- < Typography
174
- variant = "body2"
175
- sx = { {
176
- color : 'text.secondary' ,
177
- } }
178
- >
179
- Client not installed
180
- </ Typography >
181
- )
187
+ )
188
+ }
189
+ </ Typography >
182
190
}
183
191
action = {
184
- < Stack direction = "row" spacing = { 1 } >
185
- { mcpClientState . exists && mcpClientState . configured && (
186
- < Button
187
- onClick = { async ( ) => {
188
- setButtonsLoading ( {
189
- ...buttonsLoading ,
190
- [ name ] : true ,
191
- } ) ;
192
- try {
193
- await disconnectClient ( name ) ;
194
- } finally {
192
+ < Stack direction = "row" spacing = { 1 } >
193
+ {
194
+ mcpClientState . exists && mcpClientState . configured && (
195
+ < Button
196
+ color = "warning"
197
+ onClick = { async ( ) => {
195
198
setButtonsLoading ( {
196
199
...buttonsLoading ,
197
- [ name ] : false ,
200
+ [ name ] : true ,
198
201
} ) ;
202
+ try {
203
+ await disconnectClient ( name ) ;
204
+ } finally {
205
+ setButtonsLoading ( {
206
+ ...buttonsLoading ,
207
+ [ name ] : false ,
208
+ } ) ;
209
+ }
210
+ } }
211
+ disabled = {
212
+ buttonsLoading [ name ] ||
213
+ Boolean ( mcpClientState . preventAutoConnectMessage )
199
214
}
200
- } }
201
- disabled = { buttonsLoading [ name ] }
202
- color = "warning"
203
- size = "small"
204
- >
205
- < Stack direction = "row" alignItems = "center" spacing = { 1 } >
206
- { ( buttonsLoading [ name ] && (
207
- < >
208
- < Typography sx = { { fontSize : 12 , width : 70 } } >
209
- Connect
210
- </ Typography >
211
- < CircularProgress size = { 12 } / >
212
- < />
213
- ) ) || (
214
- < Typography sx = { { fontSize : 12 , width : 90 } } >
215
- Disconnect
216
- </ Typography >
217
- ) }
218
- </ Stack >
219
- </ Button >
220
- ) }
215
+ >
216
+ < Stack direction = "row" alignItems = "center" spacing = { 1 } sx = { ConnectButtonStyle } >
217
+ { ( buttonsLoading [ name ] && (
218
+ < >
219
+ < LinkOutlined / >
220
+ < Typography >
221
+ Connect
222
+ </ Typography >
223
+ < CircularProgress size = { 12 } / >
224
+ </ >
225
+ ) ) || (
226
+ < >
227
+ < LinkOffOutlined />
228
+ < Typography >
229
+ Disconnect
230
+ </ Typography >
231
+ </ >
232
+ ) }
233
+ </ Stack >
234
+ </ Button >
235
+ ) }
221
236
{ mcpClientState . exists && ! mcpClientState . configured && (
222
237
< Button
223
- sx = { { fontSize : 12 } }
224
238
onClick = { async ( ) => {
225
239
setButtonsLoading ( {
226
240
...buttonsLoading ,
@@ -231,70 +245,86 @@ function ClientSetting({
231
245
} finally {
232
246
setButtonsLoading ( {
233
247
...buttonsLoading ,
234
- [ name ] : false ,
248
+ [ name ] : true ,
235
249
} ) ;
250
+ try {
251
+ await connectClient ( name ) ;
252
+ } finally {
253
+ setButtonsLoading ( {
254
+ ...buttonsLoading ,
255
+ [ name ] : false ,
256
+ } ) ;
257
+ }
236
258
}
237
259
} }
238
260
disabled = { buttonsLoading [ name ] }
239
261
color = "primary"
240
262
size = "small"
241
263
>
242
- < Stack direction = "row" alignItems = "center" spacing = { 1 } >
264
+ < Stack direction = "row" alignItems = "center" spacing = { 1 } sx = { ConnectButtonStyle } >
243
265
{ ( buttonsLoading [ name ] && (
244
266
< >
245
- < Typography sx = { { fontSize : 12 , width : 70 } } >
267
+ < LinkOffOutlined />
268
+ < Typography >
246
269
Disconnect
247
270
</ Typography >
248
271
< CircularProgress size = { 12 } />
249
272
</ >
250
273
) ) || (
251
- < Typography sx = { { fontSize : 12 , width : 90 } } >
252
- Connect
253
- </ Typography >
274
+ < >
275
+ < LinkOutlined />
276
+ < Typography >
277
+ Connect
278
+ </ Typography >
279
+ </ >
254
280
) }
255
281
</ Stack >
256
282
</ Button >
257
283
) }
258
- { ! mcpClientState . exists && (
259
- < Button
260
- sx = { { fontSize : 12 } }
261
- size = "small"
262
- disabled
263
- onClick = { async ( ) => {
264
- setButtonsLoading ( {
265
- ...buttonsLoading ,
266
- [ name ] : true ,
267
- } ) ;
268
- try {
269
- await connectClient ( name ) ;
270
- } finally {
284
+ {
285
+ ! mcpClientState . exists && (
286
+ < Button
287
+ size = "small"
288
+ variant = "outlined"
289
+ onClick = { async ( ) => {
271
290
setButtonsLoading ( {
272
291
...buttonsLoading ,
273
- [ name ] : false ,
292
+ [ name ] : true ,
274
293
} ) ;
275
- }
276
- } }
277
- >
278
- < Stack direction = "row" alignItems = "center" spacing = { 1 } >
279
- { ( buttonsLoading [ name ] && (
280
- < >
281
- < Typography sx = { { fontSize : 12 , width : 70 } } >
282
- Disconnect
283
- </ Typography >
284
- < CircularProgress size = { 12 } />
285
- </ >
286
- ) ) || (
287
- < Typography sx = { { fontSize : 12 , width : 90 } } >
288
- Connect
289
- </ Typography >
290
- ) }
291
- </ Stack >
292
- </ Button >
293
- ) }
294
- </ Stack >
294
+ try {
295
+ await connectClient ( name ) ;
296
+ } finally {
297
+ setButtonsLoading ( {
298
+ ...buttonsLoading ,
299
+ [ name ] : true ,
300
+ } ) ;
301
+ }
302
+ } }
303
+ >
304
+ < Stack direction = "row" alignItems = "center" spacing = { 1 } sx = { ConnectButtonStyle } >
305
+ { ( buttonsLoading [ name ] && (
306
+ < >
307
+ < LinkOffOutlined />
308
+ < Typography >
309
+ Attempt disconnect
310
+ </ Typography >
311
+ < CircularProgress size = { 12 } />
312
+ </ >
313
+ ) ) || (
314
+ < >
315
+ < LinkOutlined />
316
+ < Typography >
317
+ Attempt connection
318
+ </ Typography >
319
+ </ >
320
+ ) }
321
+ </ Stack >
322
+ </ Button >
323
+ ) }
324
+ </ Stack >
295
325
}
296
326
/>
297
- < Collapse in = { expanded } timeout = "auto" unmountOnExit >
327
+ < Collapse in = { expanded } timeout = "auto" unmountOnExit >
298
328
< CardContent >
299
329
< Stack direction = "column" justifyContent = "center" spacing = { 1 } >
300
330
< Stack direction = "row" alignItems = "center" spacing = { 1 } >
@@ -345,8 +375,8 @@ function ClientSetting({
345
375
) }
346
376
</ List >
347
377
</ CardContent >
348
- </ Collapse >
349
- </ Card >
378
+ </ Collapse >
379
+ </ Card >
350
380
) ;
351
381
}
352
382
0 commit comments