#51048 Issue 51047 - React deprecating ComponentWillMount
Closed 3 years ago by spichugi. Opened 3 years ago by mreynolds.
mreynolds/389-ds-base issue51047  into  master

@@ -60,7 +60,7 @@ 

  };

  

  export class DSInstance extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          this.loadInstanceList();

          this.updateProgress(25);

      }

@@ -45,6 +45,7 @@ 

              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,
@@ -539,14 +540,6 @@ 

                          </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

                          </Col>
@@ -567,7 +560,7 @@ 

                              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">

@@ -103,17 +103,15 @@ 

          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 @@ 

                              _passwordbadwords: attrs['passwordbadwords'][0],

                              _passworduserattributes: pwUserAttrs,

                              _passwordadmindn: attrs['passwordadmindn'][0],

-                         })

+                         }), this.props.enableTree()

                      );

                  })

                  .fail(err => {

@@ -71,7 +71,7 @@ 

          this.closeReindexModal = this.closeReindexModal.bind(this);

      }

  

-     componentWillMount () {

+     componentDidMount () {

          this.loadIndexes();

      }

  

@@ -701,17 +701,15 @@ 

          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 @@ 

                          _create_passwordmintokenlength: "0",

                          _create_passwordbadwords: "",

                          _create_passworduserattributes: [],

-                     });

+                     }, this.props.enableTree);

                  })

                  .fail(err => {

                      let errMsg = JSON.parse(err);

@@ -1662,7 +1662,7 @@ 

                      header: {

                          label: "Available Space",

                          props: {

-                             index: 2,

+                             index: 3,

                              rowSpan: 1,

                              colSpan: 1,

                              sort: true

@@ -22,7 +22,7 @@ 

  // Use default aacount policy name

  

  class AccountPolicy extends React.Component {

-     componentWillMount(prevProps) {

+     componentDidMount() {

          this.updateFields();

      }

  

@@ -23,7 +23,7 @@ 

  import "../../css/ds.css";

  

  class AttributeUniqueness extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          if (this.props.wasActiveList.includes(5)) {

              if (this.state.firstLoad) {

                  this.loadConfigs();

@@ -20,7 +20,7 @@ 

  import "../../css/ds.css";

  

  class AutoMembership extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          if (this.props.wasActiveList.includes(5)) {

              if (this.state.firstLoad) {

                  this.loadDefinitions();

@@ -21,7 +21,7 @@ 

  import "../../css/ds.css";

  

  class DNA extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          if (this.props.wasActiveList.includes(5)) {

              if (this.state.firstLoad) {

                  this.loadConfigs();

@@ -20,7 +20,7 @@ 

  import "../../css/ds.css";

  

  class LinkedAttributes extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          if (this.props.wasActiveList.includes(5)) {

              if (this.state.firstLoad) {

                  this.loadConfigs();

@@ -20,7 +20,7 @@ 

  import "../../css/ds.css";

  

  class ManagedEntries extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          this.updateFields();

      }

  

@@ -20,7 +20,7 @@ 

  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();

@@ -17,7 +17,7 @@ 

  import "../../css/ds.css";

  

  class PluginBasicConfig extends React.Component {

-     componentWillMount(prevProps) {

+     componentDidMount(prevProps) {

          this.updateFields();

      }

  

@@ -19,7 +19,7 @@ 

  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();

@@ -17,7 +17,7 @@ 

  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();

@@ -6,7 +6,7 @@ 

  import "../../css/ds.css";

  

  class RootDNAccessControl extends React.Component {

-     componentWillMount(prevProps) {

+     componentDidMount(prevProps) {

          this.updateFields();

      }

  

@@ -19,7 +19,7 @@ 

  import "../../css/ds.css";

  

  class USN extends React.Component {

-     componentWillMount() {

+     componentDidMount() {

          if (this.props.wasActiveList.includes(5)) {

              if (this.state.firstLoad) {

                  this.loadSuffixList();

@@ -19,7 +19,7 @@ 

  import "../../css/ds.css";

  

  class WinSync extends React.Component {

-     componentWillMount(prevProps) {

+     componentDidMount(prevProps) {

          this.updateFields();

      }

  

@@ -30,7 +30,7 @@ 

          this.handleCipherChange = this.handleCipherChange.bind(this);

      }

  

-     componentWillMount () {

+     componentDidMount () {

          let cipherPref = "default";

          let allowedCiphers = [];

          let deniedCiphers = [];

@@ -74,17 +74,15 @@ 

          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 @@ 

              '_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() {

@@ -63,17 +63,15 @@ 

          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 @@ 

              '_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() {

@@ -63,17 +63,15 @@ 

          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 @@ 

              '_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() {

@@ -83,17 +83,15 @@ 

          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 @@ 

              '_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() {

@@ -42,17 +42,15 @@ 

          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 @@ 

              '_nsslapd-ldapientrysearchbase': attrs['nsslapd-ldapientrysearchbase'][0],

              '_nsslapd-ldapigidnumbertype': attrs['nsslapd-ldapigidnumbertype'][0],

              '_nsslapd-ldapiuidnumbertype': attrs['nsslapd-ldapiuidnumbertype'][0],

-         });

+         }, this.props.enableTree);

      }

  

      saveConfig() {

@@ -69,17 +69,15 @@ 

          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 @@ 

                          loaded: true,

                          tableLoading: false,

                          configLoading: false,

-                     });

+                     }, this.props.enableTree);

                  });

      }

  

@@ -98,17 +98,15 @@ 

          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 });

      }

@@ -54,17 +54,14 @@ 

          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 @@ 

              '_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() {

@@ -87,20 +87,12 @@ 

          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 @@ 

                          {

                              CACerts: certs,

                              loaded: true

-                         })

+                         }), this.props.enableTree()

                      );

                  })

                  .fail(err => {

@@ -35,14 +35,10 @@ 

          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();

-                 }

              }

          }

      }

Description:

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

Also fixed some other minor bugs I found.

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

Reviewed by: ?

Everything works as it did. Ack!

Everything works as it did. Ack!

Thanks for double checking!

rebased onto 0f446a5

3 years ago

Pull-Request has been merged by mreynolds

3 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/4101

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata
Changes Summary 30
+1 -1
file changed
src/cockpit/389-console/src/ds.jsx
+2 -9
file changed
src/cockpit/389-console/src/lib/database/chaining.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/database/globalPwp.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/database/indexes.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/database/localPwp.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/monitor/monitorTables.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/attributeUniqueness.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/autoMembership.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/dna.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/linkedAttributes.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/managedEntries.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/memberOf.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/pluginBasicConfig.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/referentialIntegrity.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/retroChangelog.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/rootDNAccessControl.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/usn.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/plugins/winsync.jsx
+1 -1
file changed
src/cockpit/389-console/src/lib/security/ciphers.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/server/accessLog.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/server/auditLog.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/server/auditfailLog.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/server/errorLog.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/server/ldapi.jsx
+4 -6
file changed
src/cockpit/389-console/src/lib/server/sasl.jsx
+3 -5
file changed
src/cockpit/389-console/src/lib/server/settings.jsx
+4 -7
file changed
src/cockpit/389-console/src/lib/server/tuning.jsx
+4 -12
file changed
src/cockpit/389-console/src/security.jsx
+1 -5
file changed
src/cockpit/389-console/src/server.jsx