Browse Source

Issue 51047 - React deprecating ComponentWillMount

Description:  ComponentWillMount has been deemed as unsafe, switching to
              ComponentDidMount is the preferred solution and does not
              seem to affect the UX.

Fixes: https://pagure.io/389-ds-base/issue/51047

Reviewed by: spichugi(Thanks!)
Mark Reynolds 5 years ago
parent
commit
0f446a5494
30 changed files with 63 additions and 103 deletions
  1. 1 1
      src/cockpit/389-console/src/ds.jsx
  2. 2 9
      src/cockpit/389-console/src/lib/database/chaining.jsx
  3. 4 6
      src/cockpit/389-console/src/lib/database/globalPwp.jsx
  4. 1 1
      src/cockpit/389-console/src/lib/database/indexes.jsx
  5. 4 6
      src/cockpit/389-console/src/lib/database/localPwp.jsx
  6. 1 1
      src/cockpit/389-console/src/lib/monitor/monitorTables.jsx
  7. 1 1
      src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx
  8. 1 1
      src/cockpit/389-console/src/lib/plugins/attributeUniqueness.jsx
  9. 1 1
      src/cockpit/389-console/src/lib/plugins/autoMembership.jsx
  10. 1 1
      src/cockpit/389-console/src/lib/plugins/dna.jsx
  11. 1 1
      src/cockpit/389-console/src/lib/plugins/linkedAttributes.jsx
  12. 1 1
      src/cockpit/389-console/src/lib/plugins/managedEntries.jsx
  13. 1 1
      src/cockpit/389-console/src/lib/plugins/memberOf.jsx
  14. 1 1
      src/cockpit/389-console/src/lib/plugins/pluginBasicConfig.jsx
  15. 1 1
      src/cockpit/389-console/src/lib/plugins/referentialIntegrity.jsx
  16. 1 1
      src/cockpit/389-console/src/lib/plugins/retroChangelog.jsx
  17. 1 1
      src/cockpit/389-console/src/lib/plugins/rootDNAccessControl.jsx
  18. 1 1
      src/cockpit/389-console/src/lib/plugins/usn.jsx
  19. 1 1
      src/cockpit/389-console/src/lib/plugins/winsync.jsx
  20. 1 1
      src/cockpit/389-console/src/lib/security/ciphers.jsx
  21. 4 6
      src/cockpit/389-console/src/lib/server/accessLog.jsx
  22. 4 6
      src/cockpit/389-console/src/lib/server/auditLog.jsx
  23. 4 6
      src/cockpit/389-console/src/lib/server/auditfailLog.jsx
  24. 4 6
      src/cockpit/389-console/src/lib/server/errorLog.jsx
  25. 4 6
      src/cockpit/389-console/src/lib/server/ldapi.jsx
  26. 4 6
      src/cockpit/389-console/src/lib/server/sasl.jsx
  27. 3 5
      src/cockpit/389-console/src/lib/server/settings.jsx
  28. 4 7
      src/cockpit/389-console/src/lib/server/tuning.jsx
  29. 4 12
      src/cockpit/389-console/src/security.jsx
  30. 1 5
      src/cockpit/389-console/src/server.jsx

+ 1 - 1
src/cockpit/389-console/src/ds.jsx

@@ -60,7 +60,7 @@ const staticStates = {
 };
 
 export class DSInstance extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         this.loadInstanceList();
         this.updateProgress(25);
     }

+ 2 - 9
src/cockpit/389-console/src/lib/database/chaining.jsx

@@ -45,6 +45,7 @@ export class ChainingDatabaseConfig extends React.Component {
             defBindRetryLimit: this.props.data.defBindRetryLimit,
             defConcurLimit: this.props.data.defConcurLimit,
             defConcurOpLimit: this.props.data.defConcurOpLimit,
+            defConcurBindLimit: this.props.data.defConcurBindLimit,
             defConnLife: this.props.data.defConnLife,
             defHopLimit: this.props.data.defHopLimit,
             defDelay: this.props.data.defDelay,
@@ -538,14 +539,6 @@ export class ChainingDatabaseConfig extends React.Component {
                             <input className="ds-input-auto" type="text" id="defBindConnLimit" onChange={this.handleChange} defaultValue={this.state.defBindConnLimit} />
                         </Col>
                     </Row>
-                    <Row className="ds-margin-top">
-                        <Col componentClass={ControlLabel} sm={4} title="The number of seconds that pass before the server checks for abandoned operations.  (nsabandonedsearchcheckinterval).">
-                            Abandoned Op Check Interval
-                        </Col>
-                        <Col sm={8}>
-                            <input className="ds-input-auto" type="text" id="defSearchCheck" onChange={this.handleChange} defaultValue={this.state.defSearchCheck} />
-                        </Col>
-                    </Row>
                     <Row className="ds-margin-top">
                         <Col componentClass={ControlLabel} sm={4} title="The maximum number of connections allowed over the database link.  (nsoperationconnectionslimit).">
                             Max LDAP Connections
@@ -567,7 +560,7 @@ export class ChainingDatabaseConfig extends React.Component {
                             Max Binds Per Connection
                         </Col>
                         <Col sm={8}>
-                            <input className="ds-input-auto" type="text" id="defOpConnLimit" onChange={this.handleChange} defaultValue={this.state.defOpConnLimit} />
+                            <input className="ds-input-auto" type="text" id="defConcurLimit" onChange={this.handleChange} defaultValue={this.state.defConcurLimit} />
                         </Col>
                     </Row>
                     <Row className="ds-margin-top">

+ 4 - 6
src/cockpit/389-console/src/lib/database/globalPwp.jsx

@@ -103,17 +103,15 @@ export class GlobalPwPolicy extends React.Component {
         this.loadGlobal = this.loadGlobal.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config TODO
         if (!this.state.loaded) {
             this.loadGlobal();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleNavSelect(key) {
         this.setState({ activeKey: key });
     }
@@ -658,7 +656,7 @@ export class GlobalPwPolicy extends React.Component {
                             _passwordbadwords: attrs['passwordbadwords'][0],
                             _passworduserattributes: pwUserAttrs,
                             _passwordadmindn: attrs['passwordadmindn'][0],
-                        })
+                        }), this.props.enableTree()
                     );
                 })
                 .fail(err => {

+ 1 - 1
src/cockpit/389-console/src/lib/database/indexes.jsx

@@ -71,7 +71,7 @@ export class SuffixIndexes extends React.Component {
         this.closeReindexModal = this.closeReindexModal.bind(this);
     }
 
-    componentWillMount () {
+    componentDidMount () {
         this.loadIndexes();
     }
 

+ 4 - 6
src/cockpit/389-console/src/lib/database/localPwp.jsx

@@ -701,17 +701,15 @@ export class LocalPwPolicy extends React.Component {
         this.showDeletePolicy = this.showDeletePolicy.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadPolicies();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     showDeletePolicy(name) {
         this.setState({
             showDeletePolicy: true,
@@ -1406,7 +1404,7 @@ export class LocalPwPolicy extends React.Component {
                         _create_passwordmintokenlength: "0",
                         _create_passwordbadwords: "",
                         _create_passworduserattributes: [],
-                    });
+                    }, this.props.enableTree);
                 })
                 .fail(err => {
                     let errMsg = JSON.parse(err);

+ 1 - 1
src/cockpit/389-console/src/lib/monitor/monitorTables.jsx

@@ -1662,7 +1662,7 @@ class DiskTable extends React.Component {
                     header: {
                         label: "Available Space",
                         props: {
-                            index: 2,
+                            index: 3,
                             rowSpan: 1,
                             colSpan: 1,
                             sort: true

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx

@@ -22,7 +22,7 @@ import "../../css/ds.css";
 // Use default aacount policy name
 
 class AccountPolicy extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount() {
         this.updateFields();
     }
 

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/attributeUniqueness.jsx

@@ -23,7 +23,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class AttributeUniqueness extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.loadConfigs();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/autoMembership.jsx

@@ -20,7 +20,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class AutoMembership extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.loadDefinitions();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/dna.jsx

@@ -21,7 +21,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class DNA extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.loadConfigs();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/linkedAttributes.jsx

@@ -20,7 +20,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class LinkedAttributes extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.loadConfigs();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/managedEntries.jsx

@@ -20,7 +20,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class ManagedEntries extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         this.updateFields();
     }
 

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/memberOf.jsx

@@ -20,7 +20,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class MemberOf extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount(prevProps) {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.getObjectClasses();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/pluginBasicConfig.jsx

@@ -17,7 +17,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class PluginBasicConfig extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount(prevProps) {
         this.updateFields();
     }
 

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/referentialIntegrity.jsx

@@ -19,7 +19,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class ReferentialIntegrity extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount(prevProps) {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.getAttributes();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/retroChangelog.jsx

@@ -17,7 +17,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class RetroChangelog extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount(prevProps) {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.getAttributes();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/rootDNAccessControl.jsx

@@ -6,7 +6,7 @@ import PluginBasicConfig from "./pluginBasicConfig.jsx";
 import "../../css/ds.css";
 
 class RootDNAccessControl extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount(prevProps) {
         this.updateFields();
     }
 

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/usn.jsx

@@ -19,7 +19,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class USN extends React.Component {
-    componentWillMount() {
+    componentDidMount() {
         if (this.props.wasActiveList.includes(5)) {
             if (this.state.firstLoad) {
                 this.loadSuffixList();

+ 1 - 1
src/cockpit/389-console/src/lib/plugins/winsync.jsx

@@ -19,7 +19,7 @@ import { log_cmd } from "../tools.jsx";
 import "../../css/ds.css";
 
 class WinSync extends React.Component {
-    componentWillMount(prevProps) {
+    componentDidMount(prevProps) {
         this.updateFields();
     }
 

+ 1 - 1
src/cockpit/389-console/src/lib/security/ciphers.jsx

@@ -30,7 +30,7 @@ export class Ciphers extends React.Component {
         this.handleCipherChange = this.handleCipherChange.bind(this);
     }
 
-    componentWillMount () {
+    componentDidMount () {
         let cipherPref = "default";
         let allowedCiphers = [];
         let deniedCiphers = [];

+ 4 - 6
src/cockpit/389-console/src/lib/server/accessLog.jsx

@@ -74,17 +74,15 @@ export class ServerAccessLog extends React.Component {
         this.saveConfig = this.saveConfig.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleNavSelect(key) {
         this.setState({ activeKey: key });
     }
@@ -357,7 +355,7 @@ export class ServerAccessLog extends React.Component {
             '_nsslapd-accesslog-logrotationtimeunit': attrs['nsslapd-accesslog-logrotationtimeunit'][0],
             '_nsslapd-accesslog-maxlogsize': attrs['nsslapd-accesslog-maxlogsize'][0],
             '_nsslapd-accesslog-maxlogsperdir': attrs['nsslapd-accesslog-maxlogsperdir'][0],
-        });
+        }, this.props.enableTree);
     }
 
     render() {

+ 4 - 6
src/cockpit/389-console/src/lib/server/auditLog.jsx

@@ -63,17 +63,15 @@ export class ServerAuditLog extends React.Component {
         this.saveConfig = this.saveConfig.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleNavSelect(key) {
         this.setState({ activeKey: key });
     }
@@ -216,7 +214,7 @@ export class ServerAuditLog extends React.Component {
             '_nsslapd-auditlog-logrotationtimeunit': attrs['nsslapd-auditlog-logrotationtimeunit'][0],
             '_nsslapd-auditlog-maxlogsize': attrs['nsslapd-auditlog-maxlogsize'][0],
             '_nsslapd-auditlog-maxlogsperdir': attrs['nsslapd-auditlog-maxlogsperdir'][0],
-        });
+        }, this.props.enableTree);
     }
 
     reloadConfig() {

+ 4 - 6
src/cockpit/389-console/src/lib/server/auditfailLog.jsx

@@ -63,17 +63,15 @@ export class ServerAuditFailLog extends React.Component {
         this.saveConfig = this.saveConfig.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleNavSelect(key) {
         this.setState({ activeKey: key });
     }
@@ -283,7 +281,7 @@ export class ServerAuditFailLog extends React.Component {
             '_nsslapd-auditfaillog-logrotationtimeunit': attrs['nsslapd-auditfaillog-logrotationtimeunit'][0],
             '_nsslapd-auditfaillog-maxlogsize': attrs['nsslapd-auditfaillog-maxlogsize'][0],
             '_nsslapd-auditfaillog-maxlogsperdir': attrs['nsslapd-auditfaillog-maxlogsperdir'][0],
-        });
+        }, this.props.enableTree);
     }
 
     render() {

+ 4 - 6
src/cockpit/389-console/src/lib/server/errorLog.jsx

@@ -83,17 +83,15 @@ export class ServerErrorLog extends React.Component {
         this.saveConfig = this.saveConfig.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleNavSelect(key) {
         this.setState({ activeKey: key });
     }
@@ -290,7 +288,7 @@ export class ServerErrorLog extends React.Component {
             '_nsslapd-errorlog-logrotationtimeunit': attrs['nsslapd-errorlog-logrotationtimeunit'][0],
             '_nsslapd-errorlog-maxlogsize': attrs['nsslapd-errorlog-maxlogsize'][0],
             '_nsslapd-errorlog-maxlogsperdir': attrs['nsslapd-errorlog-maxlogsperdir'][0],
-        });
+        }, this.props.enableTree);
     }
 
     reloadConfig() {

+ 4 - 6
src/cockpit/389-console/src/lib/server/ldapi.jsx

@@ -42,17 +42,15 @@ export class ServerLDAPI extends React.Component {
         this.saveConfig = this.saveConfig.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleChange(e) {
         let value = e.target.type === 'checkbox' ? e.target.checked : e.target.value;
         let attr = e.target.id;
@@ -106,7 +104,7 @@ export class ServerLDAPI extends React.Component {
             '_nsslapd-ldapientrysearchbase': attrs['nsslapd-ldapientrysearchbase'][0],
             '_nsslapd-ldapigidnumbertype': attrs['nsslapd-ldapigidnumbertype'][0],
             '_nsslapd-ldapiuidnumbertype': attrs['nsslapd-ldapiuidnumbertype'][0],
-        });
+        }, this.props.enableTree);
     }
 
     saveConfig() {

+ 4 - 6
src/cockpit/389-console/src/lib/server/sasl.jsx

@@ -69,17 +69,15 @@ export class ServerSASL extends React.Component {
         this.deleteMapping = this.deleteMapping.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleTestRegex() {
         let test_string = this.state.saslTestText;
         let regex = this.state.saslMapRegex;
@@ -345,7 +343,7 @@ export class ServerSASL extends React.Component {
                         loaded: true,
                         tableLoading: false,
                         configLoading: false,
-                    });
+                    }, this.props.enableTree);
                 });
     }
 

+ 3 - 5
src/cockpit/389-console/src/lib/server/settings.jsx

@@ -98,17 +98,15 @@ export class ServerSettings extends React.Component {
         this.reloadAdvanced = this.reloadAdvanced.bind(this);
     }
 
-    componentWillMount() {
+    componentDidMount() {
         // Loading config
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleNavSelect(key) {
         this.setState({ activeKey: key });
     }

+ 4 - 7
src/cockpit/389-console/src/lib/server/tuning.jsx

@@ -54,17 +54,14 @@ export class ServerTuning extends React.Component {
         this.saveConfig = this.saveConfig.bind(this);
     }
 
-    componentWillMount() {
-        // Loading config
+    componentDidMount() {
         if (!this.state.loaded) {
             this.loadConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
-    componentDidMount() {
-        this.props.enableTree();
-    }
-
     handleChange(e) {
         let value = e.target.type === 'checkbox' ? e.target.checked : e.target.value;
         let attr = e.target.id;
@@ -164,7 +161,7 @@ export class ServerTuning extends React.Component {
             '_nsslapd-listen-backlog-size': attrs['nsslapd-listen-backlog-size'][0],
             '_nsslapd-max-filter-nest-level': attrs['nsslapd-max-filter-nest-level'][0],
             '_nsslapd-ndn-cache-max-size': attrs['nsslapd-ndn-cache-max-size'][0],
-        });
+        }, this.props.enableTree());
     }
 
     saveConfig() {

+ 4 - 12
src/cockpit/389-console/src/security.jsx

@@ -87,20 +87,12 @@ export class Security extends React.Component {
         this.reloadConfig = this.reloadConfig.bind(this);
     }
 
-    componentWillMount () {
+    componentDidMount () {
         if (!this.state.loaded) {
             this.setState({securityEnabled: true}, this.setState({securityEnabled: false}));
             this.loadSecurityConfig();
-        }
-    }
-
-    componentDidMount () {
-        this.props.enableTree();
-    }
-
-    componentDidUpdate(prevProps) {
-        if (this.props.serverId !== prevProps.serverId) {
-            this.loadSecurityConfig();
+        } else {
+            this.props.enableTree();
         }
     }
 
@@ -178,7 +170,7 @@ export class Security extends React.Component {
                         {
                             CACerts: certs,
                             loaded: true
-                        })
+                        }), this.props.enableTree()
                     );
                 })
                 .fail(err => {

+ 1 - 5
src/cockpit/389-console/src/server.jsx

@@ -35,14 +35,10 @@ export class Server extends React.Component {
         this.selectNode = this.selectNode.bind(this);
     }
 
-    componentDidUpdate(prevProps) {
+    componentDidMount() {
         if (this.props.wasActiveList.includes(1)) {
             if (this.state.firstLoad) {
                 this.loadConfig();
-            } else {
-                if (this.props.serverId !== prevProps.serverId) {
-                    this.loadConfig();
-                }
             }
         }
     }