@@ -18,15 +18,20 @@ import React, { Fragment, useEffect, useState } from "react";
1818import {
1919 Box ,
2020 Button ,
21+ ConsoleIcon ,
2122 EditIcon ,
2223 FormLayout ,
2324 Grid ,
25+ HelpBox ,
2426 InputBox ,
2527 Loader ,
2628 PageLayout ,
2729 RefreshIcon ,
2830 Switch ,
2931 Tabs ,
32+ Tooltip ,
33+ ValuePair ,
34+ WarnIcon ,
3035} from "mds" ;
3136import { api } from "api" ;
3237import { ConfigurationKV } from "api/consoleApi" ;
@@ -40,7 +45,6 @@ import {
4045} from "../../../../systemSlice" ;
4146import { ldapFormFields , ldapHelpBoxContents } from "../utils" ;
4247import ScreenTitle from "../../Common/ScreenTitle/ScreenTitle" ;
43- import LabelValuePair from "../../Common/UsageBarWrapper/LabelValuePair" ;
4448import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper" ;
4549import AddIDPConfigurationHelpBox from "../AddIDPConfigurationHelpbox" ;
4650import LDAPEntitiesQuery from "./LDAPEntitiesQuery" ;
@@ -63,12 +67,14 @@ const IDPLDAPConfigurationDetails = () => {
6367 const [ isEnabled , setIsEnabled ] = useState < boolean > ( false ) ;
6468 const [ hasConfiguration , setHasConfiguration ] = useState < boolean > ( false ) ;
6569 const [ fields , setFields ] = useState < any > ( { } ) ;
70+ const [ overrideFields , setOverrideFields ] = useState < any > ( { } ) ;
6671 const [ record , setRecord ] = useState < ConfigurationKV [ ] | undefined > (
6772 undefined ,
6873 ) ;
6974 const [ editMode , setEditMode ] = useState < boolean > ( false ) ;
7075 const [ resetOpen , setResetOpen ] = useState < boolean > ( false ) ;
7176 const [ curTab , setCurTab ] = useState < string > ( "configuration" ) ;
77+ const [ envOverride , setEnvOverride ] = useState < boolean > ( false ) ;
7278
7379 const toggleEditMode = ( ) => {
7480 if ( editMode && record ) {
@@ -79,13 +85,20 @@ const IDPLDAPConfigurationDetails = () => {
7985
8086 const parseFields = ( record : ConfigurationKV [ ] ) => {
8187 let fields : any = { } ;
88+ let ovrFlds : any = { } ;
8289 if ( record && record . length > 0 ) {
8390 const enabled = record . find ( ( item : any ) => item . key === "enable" ) ;
8491
8592 let totalCoincidences = 0 ;
93+ let totalOverride = 0 ;
8694
8795 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+ }
89102
90103 if (
91104 enabledConfigLDAP . includes ( item . key ) &&
@@ -96,16 +109,27 @@ const IDPLDAPConfigurationDetails = () => {
96109 ) {
97110 totalCoincidences ++ ;
98111 }
112+
113+ if ( enabledConfigLDAP . includes ( item . key ) && item . env_override ) {
114+ totalOverride ++ ;
115+ }
99116 } ) ;
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 ) ) {
102121 setIsEnabled ( true ) ;
103122 } else {
104123 setIsEnabled ( false ) ;
105124 }
106125
126+ if ( totalOverride !== 0 ) {
127+ setEnvOverride ( true ) ;
128+ }
129+
107130 setHasConfiguration ( hasConfig ) ;
108131 }
132+ setOverrideFields ( ovrFlds ) ;
109133 setFields ( fields ) ;
110134 } ;
111135
@@ -164,6 +188,7 @@ const IDPLDAPConfigurationDetails = () => {
164188 setRecord ( keyVals ) ;
165189 parseFields ( keyVals ) ;
166190 dispatch ( setServerNeedsRestart ( res . data . restart || false ) ) ;
191+ setFields ( { ...fields , lookup_bind_password : "" } ) ;
167192
168193 if ( ! res . data . restart ) {
169194 dispatch ( setSnackBarMessage ( "Configuration saved successfully" ) ) ;
@@ -281,22 +306,41 @@ const IDPLDAPConfigurationDetails = () => {
281306 actions = {
282307 ! editMode ? (
283308 < 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+ >
294316 < 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 }
299324 />
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 >
300344 ) }
301345 < Button
302346 id = { "refresh-idp-config" }
@@ -337,6 +381,27 @@ const IDPLDAPConfigurationDetails = () => {
337381 />
338382 }
339383 >
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 }
340405 { Object . entries ( formFields ) . map ( ( [ key , value ] ) =>
341406 renderFormField ( key , value ) ,
342407 ) }
@@ -349,7 +414,7 @@ const IDPLDAPConfigurationDetails = () => {
349414 gap : "15px" ,
350415 } }
351416 >
352- { editMode && (
417+ { editMode && hasConfiguration && (
353418 < Button
354419 id = { "clear" }
355420 type = "button"
@@ -358,26 +423,22 @@ const IDPLDAPConfigurationDetails = () => {
358423 label = { "Reset Configuration" }
359424 />
360425 ) }
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+ />
381442 </ Box >
382443 </ FormLayout >
383444 </ Fragment >
@@ -397,20 +458,68 @@ const IDPLDAPConfigurationDetails = () => {
397458 } ,
398459 } }
399460 >
400- < LabelValuePair
461+ < ValuePair
401462 label = { "LDAP Enabled" }
402463 value = { isEnabled ? "Yes" : "No" }
403464 />
404465 { hasConfiguration && (
405466 < Fragment >
406467 { 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+ } ,
414523 ) }
415524 </ Fragment >
416525 ) }
0 commit comments