@@ -18,15 +18,20 @@ import React, { Fragment, useEffect, useState } from "react";
18
18
import {
19
19
Box ,
20
20
Button ,
21
+ ConsoleIcon ,
21
22
EditIcon ,
22
23
FormLayout ,
23
24
Grid ,
25
+ HelpBox ,
24
26
InputBox ,
25
27
Loader ,
26
28
PageLayout ,
27
29
RefreshIcon ,
28
30
Switch ,
29
31
Tabs ,
32
+ Tooltip ,
33
+ ValuePair ,
34
+ WarnIcon ,
30
35
} from "mds" ;
31
36
import { api } from "api" ;
32
37
import { ConfigurationKV } from "api/consoleApi" ;
@@ -40,7 +45,6 @@ import {
40
45
} from "../../../../systemSlice" ;
41
46
import { ldapFormFields , ldapHelpBoxContents } from "../utils" ;
42
47
import ScreenTitle from "../../Common/ScreenTitle/ScreenTitle" ;
43
- import LabelValuePair from "../../Common/UsageBarWrapper/LabelValuePair" ;
44
48
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper" ;
45
49
import AddIDPConfigurationHelpBox from "../AddIDPConfigurationHelpbox" ;
46
50
import LDAPEntitiesQuery from "./LDAPEntitiesQuery" ;
@@ -63,12 +67,14 @@ const IDPLDAPConfigurationDetails = () => {
63
67
const [ isEnabled , setIsEnabled ] = useState < boolean > ( false ) ;
64
68
const [ hasConfiguration , setHasConfiguration ] = useState < boolean > ( false ) ;
65
69
const [ fields , setFields ] = useState < any > ( { } ) ;
70
+ const [ overrideFields , setOverrideFields ] = useState < any > ( { } ) ;
66
71
const [ record , setRecord ] = useState < ConfigurationKV [ ] | undefined > (
67
72
undefined ,
68
73
) ;
69
74
const [ editMode , setEditMode ] = useState < boolean > ( false ) ;
70
75
const [ resetOpen , setResetOpen ] = useState < boolean > ( false ) ;
71
76
const [ curTab , setCurTab ] = useState < string > ( "configuration" ) ;
77
+ const [ envOverride , setEnvOverride ] = useState < boolean > ( false ) ;
72
78
73
79
const toggleEditMode = ( ) => {
74
80
if ( editMode && record ) {
@@ -79,13 +85,20 @@ const IDPLDAPConfigurationDetails = () => {
79
85
80
86
const parseFields = ( record : ConfigurationKV [ ] ) => {
81
87
let fields : any = { } ;
88
+ let ovrFlds : any = { } ;
82
89
if ( record && record . length > 0 ) {
83
90
const enabled = record . find ( ( item : any ) => item . key === "enable" ) ;
84
91
85
92
let totalCoincidences = 0 ;
93
+ let totalOverride = 0 ;
86
94
87
95
record . forEach ( ( item : any ) => {
88
- fields [ item . key ] = item . value ;
96
+ if ( item . env_override ) {
97
+ fields [ item . key ] = item . env_override . value ;
98
+ ovrFlds [ item . key ] = item . env_override . name ;
99
+ } else {
100
+ fields [ item . key ] = item . value ;
101
+ }
89
102
90
103
if (
91
104
enabledConfigLDAP . includes ( item . key ) &&
@@ -96,16 +109,27 @@ const IDPLDAPConfigurationDetails = () => {
96
109
) {
97
110
totalCoincidences ++ ;
98
111
}
112
+
113
+ if ( enabledConfigLDAP . includes ( item . key ) && item . env_override ) {
114
+ totalOverride ++ ;
115
+ }
99
116
} ) ;
100
- const hasConfig = totalCoincidences === enabledConfigLDAP . length ;
101
- if ( hasConfig && enabled && enabled . value !== "off" ) {
117
+
118
+ const hasConfig = totalCoincidences !== 0 ;
119
+
120
+ if ( hasConfig && ( ( enabled && enabled . value !== "off" ) || ! enabled ) ) {
102
121
setIsEnabled ( true ) ;
103
122
} else {
104
123
setIsEnabled ( false ) ;
105
124
}
106
125
126
+ if ( totalOverride !== 0 ) {
127
+ setEnvOverride ( true ) ;
128
+ }
129
+
107
130
setHasConfiguration ( hasConfig ) ;
108
131
}
132
+ setOverrideFields ( ovrFlds ) ;
109
133
setFields ( fields ) ;
110
134
} ;
111
135
@@ -164,6 +188,7 @@ const IDPLDAPConfigurationDetails = () => {
164
188
setRecord ( keyVals ) ;
165
189
parseFields ( keyVals ) ;
166
190
dispatch ( setServerNeedsRestart ( res . data . restart || false ) ) ;
191
+ setFields ( { ...fields , lookup_bind_password : "" } ) ;
167
192
168
193
if ( ! res . data . restart ) {
169
194
dispatch ( setSnackBarMessage ( "Configuration saved successfully" ) ) ;
@@ -281,22 +306,41 @@ const IDPLDAPConfigurationDetails = () => {
281
306
actions = {
282
307
! editMode ? (
283
308
< Fragment >
284
- < Button
285
- id = { "edit" }
286
- type = "button"
287
- variant = { "callAction" }
288
- icon = { < EditIcon /> }
289
- onClick = { toggleEditMode }
290
- label = { "Edit Configuration" }
291
- disabled = { loading }
292
- />
293
- { hasConfiguration && (
309
+ < Tooltip
310
+ tooltip = {
311
+ envOverride
312
+ ? "Configuration cannot be edited in this module as LDAP environment variables are set for this MinIO instance."
313
+ : ""
314
+ }
315
+ >
294
316
< Button
295
- id = { "is-configuration-enabled" }
296
- onClick = { ( ) => toggleConfiguration ( ! isEnabled ) }
297
- label = { isEnabled ? "Disable LDAP" : "Enable LDAP" }
298
- variant = { isEnabled ? "secondary" : "regular" }
317
+ id = { "edit" }
318
+ type = "button"
319
+ variant = { "callAction" }
320
+ icon = { < EditIcon /> }
321
+ onClick = { toggleEditMode }
322
+ label = { "Edit Configuration" }
323
+ disabled = { loading || envOverride }
299
324
/>
325
+ </ Tooltip >
326
+ { hasConfiguration && (
327
+ < Tooltip
328
+ tooltip = {
329
+ envOverride
330
+ ? "Configuration cannot be disabled / enabled in this module as LDAP environment variables are set for this MinIO instance."
331
+ : ""
332
+ }
333
+ >
334
+ < Button
335
+ id = { "is-configuration-enabled" }
336
+ onClick = { ( ) => toggleConfiguration ( ! isEnabled ) }
337
+ label = {
338
+ isEnabled ? "Disable LDAP" : "Enable LDAP"
339
+ }
340
+ variant = { isEnabled ? "secondary" : "regular" }
341
+ disabled = { envOverride }
342
+ />
343
+ </ Tooltip >
300
344
) }
301
345
< Button
302
346
id = { "refresh-idp-config" }
@@ -337,6 +381,27 @@ const IDPLDAPConfigurationDetails = () => {
337
381
/>
338
382
}
339
383
>
384
+ { editMode && hasConfiguration ? (
385
+ < Box sx = { { marginBottom : 15 } } >
386
+ < HelpBox
387
+ title = {
388
+ < Box
389
+ style = { {
390
+ display : "flex" ,
391
+ justifyContent : "space-between" ,
392
+ alignItems : "center" ,
393
+ flexGrow : 1 ,
394
+ } }
395
+ >
396
+ Lookup Bind Password must be re-entered to
397
+ change LDAP configurations
398
+ </ Box >
399
+ }
400
+ iconComponent = { < WarnIcon /> }
401
+ help = { null }
402
+ />
403
+ </ Box >
404
+ ) : null }
340
405
{ Object . entries ( formFields ) . map ( ( [ key , value ] ) =>
341
406
renderFormField ( key , value ) ,
342
407
) }
@@ -349,7 +414,7 @@ const IDPLDAPConfigurationDetails = () => {
349
414
gap : "15px" ,
350
415
} }
351
416
>
352
- { editMode && (
417
+ { editMode && hasConfiguration && (
353
418
< Button
354
419
id = { "clear" }
355
420
type = "button"
@@ -358,26 +423,22 @@ const IDPLDAPConfigurationDetails = () => {
358
423
label = { "Reset Configuration" }
359
424
/>
360
425
) }
361
- { editMode && (
362
- < Button
363
- id = { "cancel" }
364
- type = "button"
365
- variant = "regular"
366
- onClick = { toggleEditMode }
367
- label = { "Cancel" }
368
- />
369
- ) }
370
- { editMode && (
371
- < Button
372
- id = { "save-key" }
373
- type = "submit"
374
- variant = "callAction"
375
- color = "primary"
376
- disabled = { loading || ! validSave ( ) }
377
- label = { "Save" }
378
- onClick = { saveRecord }
379
- />
380
- ) }
426
+ < Button
427
+ id = { "cancel" }
428
+ type = "button"
429
+ variant = "regular"
430
+ onClick = { toggleEditMode }
431
+ label = { "Cancel" }
432
+ />
433
+ < Button
434
+ id = { "save-key" }
435
+ type = "submit"
436
+ variant = "callAction"
437
+ color = "primary"
438
+ disabled = { loading || ! validSave ( ) }
439
+ label = { "Save" }
440
+ onClick = { saveRecord }
441
+ />
381
442
</ Box >
382
443
</ FormLayout >
383
444
</ Fragment >
@@ -397,20 +458,68 @@ const IDPLDAPConfigurationDetails = () => {
397
458
} ,
398
459
} }
399
460
>
400
- < LabelValuePair
461
+ < ValuePair
401
462
label = { "LDAP Enabled" }
402
463
value = { isEnabled ? "Yes" : "No" }
403
464
/>
404
465
{ hasConfiguration && (
405
466
< Fragment >
406
467
{ Object . entries ( formFields ) . map (
407
- ( [ key , value ] ) => (
408
- < LabelValuePair
409
- key = { key }
410
- label = { value . label }
411
- value = { fields [ key ] ? fields [ key ] : "" }
412
- />
413
- ) ,
468
+ ( [ key , value ] ) => {
469
+ if ( ! value . editOnly ) {
470
+ let label : React . ReactNode = value . label ;
471
+ let val : React . ReactNode = fields [ key ]
472
+ ? fields [ key ]
473
+ : "" ;
474
+
475
+ if ( overrideFields [ key ] ) {
476
+ label = (
477
+ < Box
478
+ sx = { {
479
+ display : "flex" ,
480
+ alignItems : "center" ,
481
+ gap : 5 ,
482
+ "& .min-icon" : {
483
+ height : 20 ,
484
+ width : 20 ,
485
+ } ,
486
+ "& span" : {
487
+ height : 20 ,
488
+ display : "flex" ,
489
+ alignItems : "center" ,
490
+ } ,
491
+ } }
492
+ >
493
+ < span > { value . label } </ span >
494
+ < Tooltip
495
+ tooltip = { `This value is set from the ${ overrideFields [ key ] } environment variable` }
496
+ placement = { "right" }
497
+ >
498
+ < span className = { "muted" } >
499
+ < ConsoleIcon />
500
+ </ span >
501
+ </ Tooltip >
502
+ </ Box >
503
+ ) ;
504
+
505
+ val = (
506
+ < i >
507
+ < span className = { "muted" } >
508
+ { val }
509
+ </ span >
510
+ </ i >
511
+ ) ;
512
+ }
513
+ return (
514
+ < ValuePair
515
+ key = { key }
516
+ label = { label }
517
+ value = { val }
518
+ />
519
+ ) ;
520
+ }
521
+ return null ;
522
+ } ,
414
523
) }
415
524
</ Fragment >
416
525
) }
0 commit comments