Browse Source

fetch LdapSecuritySettingsData

kaori 3 years ago
parent
commit
fa23cd8964

+ 1 - 4
packages/app/src/client/services/AdminLdapSecurityContainer.js

@@ -17,13 +17,10 @@ export default class AdminLdapSecurityContainer extends Container {
     super();
 
     this.appContainer = appContainer;
-    this.dummyServerUrl = 0;
-    this.dummyServerUrlForError = 1;
 
     this.state = {
       retrieveError: null,
-      // set dummy value tile for using suspense
-      serverUrl: this.dummyServerUrl,
+      serverUrl: '',
       isUserBind: false,
       ldapBindDN: '',
       ldapBindDNPassword: '',

+ 16 - 18
packages/app/src/components/Admin/Security/LdapSecuritySetting.jsx

@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useEffect } from 'react';
 
 import PropTypes from 'prop-types';
 
@@ -13,23 +13,21 @@ import LdapSecuritySettingContents from './LdapSecuritySettingContents';
 let retrieveErrors = null;
 function LdapSecuritySetting(props) {
   const { adminLdapSecurityContainer } = props;
-  // if (adminLdapSecurityContainer.state.serverUrl === adminLdapSecurityContainer.dummyServerUrl) {
-  //   throw (async() => {
-  //     try {
-  //       await adminLdapSecurityContainer.retrieveSecurityData();
-  //     }
-  //     catch (err) {
-  //       const errs = toArrayIfNot(err);
-  //       toastError(errs);
-  //       retrieveErrors = errs;
-  //       adminLdapSecurityContainer.setState({ serverUrl: adminLdapSecurityContainer.dummyServerUrlForError });
-  //     }
-  //   })();
-  // }
-
-  // if (adminLdapSecurityContainer.state.serverUrl === adminLdapSecurityContainer.dummyServerUrlForError) {
-  //   throw new Error(`${retrieveErrors.length} errors occured`);
-  // }
+
+  useEffect(() => {
+    const fetchLdapSecuritySettingsData = async() => {
+      await adminLdapSecurityContainer.retrieveSecurityData();
+    };
+
+    try {
+      fetchLdapSecuritySettingsData();
+    }
+    catch (err) {
+      const errs = toArrayIfNot(err);
+      toastError(errs);
+      logger.error(errs);
+    }
+  }, [adminLdapSecurityContainer]);
 
   return <LdapSecuritySettingContents />;
 }