@@ -14,7 +14,7 @@ import React from 'react';
14
14
import { useTranslation } from 'react-i18next' ;
15
15
import { useDispatch } from 'react-redux' ;
16
16
import { useHistory , useLocation } from 'react-router-dom' ;
17
- import helpers , { ClusterSettings } from '../../../helpers' ;
17
+ import helpers , { ClusterSettings , DEFAULT_NODE_SHELL_LINUX_IMAGE } from '../../../helpers' ;
18
18
import { useCluster , useClustersConf } from '../../../lib/k8s' ;
19
19
import { deleteCluster , parseKubeConfig , renameCluster } from '../../../lib/k8s/apiProxy' ;
20
20
import { setConfig , setStatelessConfig } from '../../../redux/configSlice' ;
@@ -85,6 +85,7 @@ export default function SettingsCluster() {
85
85
const { t } = useTranslation ( [ 'translation' ] ) ;
86
86
const [ defaultNamespace , setDefaultNamespace ] = React . useState ( 'default' ) ;
87
87
const [ userDefaultNamespace , setUserDefaultNamespace ] = React . useState ( '' ) ;
88
+ const [ nodeShellLinuxImage , setNodeShellLinuxImage ] = React . useState ( '' ) ;
88
89
const [ newAllowedNamespace , setNewAllowedNamespace ] = React . useState ( '' ) ;
89
90
const [ clusterSettings , setClusterSettings ] = React . useState < ClusterSettings | null > ( null ) ;
90
91
const [ cluster , setCluster ] = React . useState ( useCluster ( ) || '' ) ;
@@ -217,10 +218,32 @@ export default function SettingsCluster() {
217
218
}
218
219
} , [ location . search , clusters ] ) ;
219
220
221
+ React . useEffect ( ( ) => {
222
+ let timeoutHandle : NodeJS . Timeout | null = null ;
223
+
224
+ if ( isEditingNodeShellLinuxImage ( ) ) {
225
+ // We store the node shell image after a timeout.
226
+ timeoutHandle = setTimeout ( ( ) => {
227
+ storeNewNodeShellLinuxImage ( nodeShellLinuxImage ) ;
228
+ } , 1000 ) ;
229
+ }
230
+
231
+ return ( ) => {
232
+ if ( timeoutHandle ) {
233
+ clearTimeout ( timeoutHandle ) ;
234
+ timeoutHandle = null ;
235
+ }
236
+ } ;
237
+ } , [ nodeShellLinuxImage ] ) ;
238
+
220
239
function isEditingDefaultNamespace ( ) {
221
240
return clusterSettings ?. defaultNamespace !== userDefaultNamespace ;
222
241
}
223
242
243
+ function isEditingNodeShellLinuxImage ( ) {
244
+ return clusterSettings ?. nodeShellLinuxImage !== nodeShellLinuxImage ;
245
+ }
246
+
224
247
function storeNewAllowedNamespace ( namespace : string ) {
225
248
setNewAllowedNamespace ( '' ) ;
226
249
setClusterSettings ( ( settings : ClusterSettings | null ) => {
@@ -265,6 +288,14 @@ export default function SettingsCluster() {
265
288
} ) ;
266
289
}
267
290
291
+ function storeNewNodeShellLinuxImage ( image : string ) {
292
+ setClusterSettings ( ( settings : ClusterSettings | null ) => {
293
+ const newSettings = { ...( settings || { } ) } ;
294
+ newSettings . nodeShellLinuxImage = image ;
295
+ return newSettings ;
296
+ } ) ;
297
+ }
298
+
268
299
const isValidDefaultNamespace = isValidNamespaceFormat ( userDefaultNamespace ) ;
269
300
const isValidCurrentName = isValidClusterNameFormat ( newClusterName ) ;
270
301
const isValidNewAllowedNamespace = isValidNamespaceFormat ( newAllowedNamespace ) ;
@@ -504,6 +535,35 @@ export default function SettingsCluster() {
504
535
</ >
505
536
) ,
506
537
} ,
538
+ {
539
+ name : t ( 'translation|Node Shell Linux Image' ) ,
540
+ value : (
541
+ < TextField
542
+ onChange = { event => {
543
+ let value = event . target . value ;
544
+ value = value . replace ( ' ' , '' ) ;
545
+ setNodeShellLinuxImage ( value ) ;
546
+ } }
547
+ value = { nodeShellLinuxImage }
548
+ placeholder = { DEFAULT_NODE_SHELL_LINUX_IMAGE }
549
+ helperText = { t (
550
+ 'translation|The default image is used for dropping a shell into a node (when not specified directly).'
551
+ ) }
552
+ InputProps = { {
553
+ endAdornment : isEditingNodeShellLinuxImage ( ) ? (
554
+ < Icon
555
+ width = { 24 }
556
+ color = { theme . palette . text . secondary }
557
+ icon = "mdi:progress-check"
558
+ />
559
+ ) : (
560
+ < Icon width = { 24 } icon = "mdi:check-bold" />
561
+ ) ,
562
+ sx : { maxWidth : 250 } ,
563
+ } }
564
+ />
565
+ ) ,
566
+ } ,
507
567
] }
508
568
/>
509
569
</ SectionBox >
0 commit comments