@@ -2,7 +2,7 @@ import { v1 } from '@docker/extension-api-client-types';
2
2
import CheckOutlined from '@mui/icons-material/CheckOutlined' ;
3
3
import Close from '@mui/icons-material/Close' ;
4
4
import CloseOutlined from '@mui/icons-material/CloseOutlined' ;
5
- import DeleteOutlined from '@mui/icons-material/DeleteOutlined ' ;
5
+ import EditOutlinedIcon from '@mui/icons-material/EditOutlined ' ;
6
6
import Launch from '@mui/icons-material/Launch' ;
7
7
import {
8
8
Alert ,
@@ -17,7 +17,6 @@ import {
17
17
DialogTitle ,
18
18
IconButton ,
19
19
Link ,
20
- OutlinedInput ,
21
20
Paper ,
22
21
Stack ,
23
22
Switch ,
@@ -34,16 +33,20 @@ import {
34
33
Typography ,
35
34
useTheme ,
36
35
} from '@mui/material' ;
37
- import { useEffect , useState } from 'react' ;
36
+ import { useEffect , useRef , useState } from 'react' ;
38
37
39
- import { ASSIGNED_SECRET_PLACEHOLDER , getUnsupportedSecretMessage , MCP_POLICY_NAME } from '../../Constants' ;
38
+ import {
39
+ ASSIGNED_SECRET_PLACEHOLDER ,
40
+ getUnsupportedSecretMessage ,
41
+ MCP_POLICY_NAME ,
42
+ } from '../../Constants' ;
43
+ import { formatName } from '../../formatName' ;
40
44
import { useCatalogOperations } from '../../queries/useCatalog' ;
41
45
import { useConfig } from '../../queries/useConfig' ;
46
+ import useDDInfo from '../../queries/useDDInfo' ;
42
47
import { useSecrets } from '../../queries/useSecrets' ;
43
48
import { CatalogItemRichened } from '../../types/catalog' ;
44
49
import ConfigEditor from './ConfigEditor' ;
45
- import { formatName } from '../../formatName' ;
46
- import useDDInfo from '../../queries/useDDInfo' ;
47
50
48
51
interface TabPanelProps {
49
52
children ?: React . ReactNode ;
@@ -86,6 +89,9 @@ const ConfigurationModal = ({
86
89
const [ localSecrets , setLocalSecrets ] = useState <
87
90
{ [ key : string ] : string | undefined } | undefined
88
91
> ( undefined ) ;
92
+
93
+ const inputRefs = useRef < HTMLInputElement [ ] > ( [ ] ) ;
94
+
89
95
const theme = useTheme ( ) ;
90
96
91
97
const { isLoading : secretsLoading , mutate : mutateSecret } =
@@ -293,7 +299,13 @@ const ConfigurationModal = ({
293
299
</ TableCell >
294
300
< TableCell >
295
301
< Link
296
- onClick = { ( ) => client . host . openExternal ( `${ catalogItem . readme } #tool-${ tool . name . replaceAll ( ' ' , '-' ) } ` || '' ) }
302
+ onClick = { ( ) =>
303
+ client . host . openExternal (
304
+ `${
305
+ catalogItem . readme
306
+ } #tool-${ tool . name . replaceAll ( ' ' , '-' ) } ` || ''
307
+ )
308
+ }
297
309
href = "#"
298
310
target = "_blank"
299
311
>
@@ -317,7 +329,7 @@ const ConfigurationModal = ({
317
329
minHeight : '180px' ,
318
330
} }
319
331
>
320
- < Stack direction = "column" spacing = { 2 } >
332
+ < Stack direction = "column" spacing = { 2 } >
321
333
< ConfigEditor catalogItem = { catalogItem } client = { client } />
322
334
< Stack >
323
335
< Typography variant = "subtitle2" > Secrets</ Typography >
@@ -332,13 +344,13 @@ const ConfigurationModal = ({
332
344
</ Alert >
333
345
) }
334
346
{ ddInfo ?. hasSecretSupport &&
335
- catalogItem . secrets &&
336
- catalogItem . secrets ?. length > 0 ? (
337
- catalogItem . secrets . map ( ( secret ) => {
347
+ catalogItem . secrets &&
348
+ catalogItem . secrets ?. length > 0 ? (
349
+ catalogItem . secrets . map ( ( secret , index ) => {
338
350
const secretEdited =
339
351
( secret . assigned &&
340
352
localSecrets [ secret . name ] !==
341
- ASSIGNED_SECRET_PLACEHOLDER ) ||
353
+ ASSIGNED_SECRET_PLACEHOLDER ) ||
342
354
( ! secret . assigned &&
343
355
localSecrets [ secret . name ] !== '' ) ;
344
356
return (
@@ -350,6 +362,10 @@ const ConfigurationModal = ({
350
362
>
351
363
< TextField
352
364
size = "small"
365
+ inputRef = { ( element ) =>
366
+ ( inputRefs . current [ index ] = element )
367
+ }
368
+ disabled = { secret . assigned }
353
369
key = { secret . name }
354
370
label = { secret . name }
355
371
value = { localSecrets [ secret . name ] }
@@ -365,21 +381,28 @@ const ConfigurationModal = ({
365
381
{ secret . assigned && ! secretEdited && (
366
382
< IconButton
367
383
size = "small"
368
- color = "error"
369
384
onClick = { ( ) => {
385
+ setLocalSecrets ( {
386
+ ...localSecrets ,
387
+ [ secret . name ] : '' ,
388
+ } ) ;
389
+ // We need to enable the input to be able to focus on it
390
+ inputRefs . current [ index ] . disabled = false ;
391
+ inputRefs . current [ index ] . focus ( ) ;
370
392
mutateSecret . mutateAsync ( {
371
393
name : secret . name ,
372
394
value : undefined ,
373
395
policies : [ MCP_POLICY_NAME ] ,
374
396
} ) ;
375
397
} }
376
398
>
377
- < DeleteOutlined />
399
+ < EditOutlinedIcon fontSize = "small" />
378
400
</ IconButton >
379
401
) }
380
402
{ secretEdited && (
381
403
< ButtonGroup >
382
404
< IconButton
405
+ size = "small"
383
406
onClick = { async ( ) => {
384
407
await mutateSecret . mutateAsync ( {
385
408
name : secret . name ,
@@ -389,10 +412,12 @@ const ConfigurationModal = ({
389
412
} }
390
413
>
391
414
< CheckOutlined
415
+ fontSize = "small"
392
416
sx = { { color : 'success.main' } }
393
417
/>
394
418
</ IconButton >
395
419
< IconButton
420
+ size = "small"
396
421
onClick = { async ( ) => {
397
422
setLocalSecrets ( {
398
423
...localSecrets ,
@@ -402,7 +427,10 @@ const ConfigurationModal = ({
402
427
} ) ;
403
428
} }
404
429
>
405
- < CloseOutlined sx = { { color : 'error.main' } } />
430
+ < CloseOutlined
431
+ fontSize = "small"
432
+ sx = { { color : 'error.main' } }
433
+ />
406
434
</ IconButton >
407
435
</ ButtonGroup >
408
436
) }
@@ -417,10 +445,9 @@ const ConfigurationModal = ({
417
445
</ Stack >
418
446
</ TabPanel >
419
447
</ >
420
- )
421
- }
422
- </ DialogContent >
423
- </ Dialog >
448
+ ) }
449
+ </ DialogContent >
450
+ </ Dialog >
424
451
) ;
425
452
} ;
426
453
0 commit comments