@@ -6,7 +6,7 @@ import React from 'react';
6
6
import { useTranslation } from 'react-i18next' ;
7
7
import { useDispatch } from 'react-redux' ;
8
8
import { useHistory } from 'react-router-dom' ;
9
- import helpers , { ClusterSettings } from '../../../helpers' ;
9
+ import helpers , { ClusterSettings , DEFAULT_NODE_SHELL_LINUX_IMAGE } from '../../../helpers' ;
10
10
import { useCluster , useClustersConf } from '../../../lib/k8s' ;
11
11
import { deleteCluster } from '../../../lib/k8s/apiProxy' ;
12
12
import { setConfig } from '../../../redux/configSlice' ;
@@ -53,6 +53,7 @@ export default function SettingsCluster() {
53
53
const { t } = useTranslation ( [ 'translation' ] ) ;
54
54
const [ defaultNamespace , setDefaultNamespace ] = React . useState ( 'default' ) ;
55
55
const [ userDefaultNamespace , setUserDefaultNamespace ] = React . useState ( '' ) ;
56
+ const [ nodeShellLinuxImage , setNodeShellLinuxImage ] = React . useState ( '' ) ;
56
57
const [ newAllowedNamespace , setNewAllowedNamespace ] = React . useState ( '' ) ;
57
58
const [ clusterSettings , setClusterSettings ] = React . useState < ClusterSettings | null > ( null ) ;
58
59
const classes = useStyles ( ) ;
@@ -127,10 +128,32 @@ export default function SettingsCluster() {
127
128
} ;
128
129
} , [ userDefaultNamespace ] ) ;
129
130
131
+ React . useEffect ( ( ) => {
132
+ let timeoutHandle : NodeJS . Timeout | null = null ;
133
+
134
+ if ( isEditingNodeShellLinuxImage ( ) ) {
135
+ // We store the node shell image after a timeout.
136
+ timeoutHandle = setTimeout ( ( ) => {
137
+ storeNewNodeShellLinuxImage ( nodeShellLinuxImage ) ;
138
+ } , 1000 ) ;
139
+ }
140
+
141
+ return ( ) => {
142
+ if ( timeoutHandle ) {
143
+ clearTimeout ( timeoutHandle ) ;
144
+ timeoutHandle = null ;
145
+ }
146
+ } ;
147
+ } , [ nodeShellLinuxImage ] ) ;
148
+
130
149
function isEditingDefaultNamespace ( ) {
131
150
return clusterSettings ?. defaultNamespace !== userDefaultNamespace ;
132
151
}
133
152
153
+ function isEditingNodeShellLinuxImage ( ) {
154
+ return clusterSettings ?. nodeShellLinuxImage !== nodeShellLinuxImage ;
155
+ }
156
+
134
157
if ( ! cluster ) {
135
158
return null ;
136
159
}
@@ -163,6 +186,14 @@ export default function SettingsCluster() {
163
186
} ) ;
164
187
}
165
188
189
+ function storeNewNodeShellLinuxImage ( image : string ) {
190
+ setClusterSettings ( ( settings : ClusterSettings | null ) => {
191
+ const newSettings = { ...( settings || { } ) } ;
192
+ newSettings . nodeShellLinuxImage = image ;
193
+ return newSettings ;
194
+ } ) ;
195
+ }
196
+
166
197
const isValidDefaultNamespace = isValidNamespaceFormat ( userDefaultNamespace ) ;
167
198
const isValidNewAllowedNamespace = isValidNamespaceFormat ( newAllowedNamespace ) ;
168
199
const invalidNamespaceMessage = t (
@@ -295,6 +326,35 @@ export default function SettingsCluster() {
295
326
</ >
296
327
) ,
297
328
} ,
329
+ {
330
+ name : t ( 'translation|Node Shell Linux Image' ) ,
331
+ value : (
332
+ < TextField
333
+ onChange = { event => {
334
+ let value = event . target . value ;
335
+ value = value . replace ( ' ' , '' ) ;
336
+ setNodeShellLinuxImage ( value ) ;
337
+ } }
338
+ value = { nodeShellLinuxImage }
339
+ placeholder = { DEFAULT_NODE_SHELL_LINUX_IMAGE }
340
+ helperText = { t (
341
+ 'translation|The default image is used for dropping a shell into a node (when not specified directly).'
342
+ ) }
343
+ InputProps = { {
344
+ endAdornment : isEditingNodeShellLinuxImage ( ) ? (
345
+ < Icon
346
+ width = { 24 }
347
+ color = { theme . palette . text . secondary }
348
+ icon = "mdi:progress-check"
349
+ />
350
+ ) : (
351
+ < Icon width = { 24 } icon = "mdi:check-bold" />
352
+ ) ,
353
+ className : classes . input ,
354
+ } }
355
+ />
356
+ ) ,
357
+ } ,
298
358
] }
299
359
/>
300
360
</ SectionBox >
0 commit comments