Skip to content

Commit

Permalink
Issue 51047 - React deprecating ComponentWillMount
Browse files Browse the repository at this point in the history
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!)
  • Loading branch information
mreynolds389 committed Apr 24, 2020
1 parent f921175 commit ae2a2a4
Show file tree
Hide file tree
Showing 30 changed files with 63 additions and 103 deletions.
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/ds.jsx
Expand Up @@ -60,7 +60,7 @@ const staticStates = {
};

export class DSInstance extends React.Component {
componentWillMount() {
componentDidMount() {
this.loadInstanceList();
this.updateProgress(25);
}
Expand Down
11 changes: 2 additions & 9 deletions src/cockpit/389-console/src/lib/database/chaining.jsx
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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">
Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/database/globalPwp.jsx
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/database/indexes.jsx
Expand Up @@ -71,7 +71,7 @@ export class SuffixIndexes extends React.Component {
this.closeReindexModal = this.closeReindexModal.bind(this);
}

componentWillMount () {
componentDidMount () {
this.loadIndexes();
}

Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/database/localPwp.jsx
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/monitor/monitorTables.jsx
Expand Up @@ -1662,7 +1662,7 @@ class DiskTable extends React.Component {
header: {
label: "Available Space",
props: {
index: 2,
index: 3,
rowSpan: 1,
colSpan: 1,
sort: true
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/accountPolicy.jsx
Expand Up @@ -22,7 +22,7 @@ import "../../css/ds.css";
// Use default aacount policy name

class AccountPolicy extends React.Component {
componentWillMount(prevProps) {
componentDidMount() {
this.updateFields();
}

Expand Down
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/autoMembership.jsx
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/dna.jsx
Expand Up @@ -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();
Expand Down
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/managedEntries.jsx
Expand Up @@ -20,7 +20,7 @@ import { log_cmd } from "../tools.jsx";
import "../../css/ds.css";

class ManagedEntries extends React.Component {
componentWillMount() {
componentDidMount() {
this.updateFields();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/memberOf.jsx
Expand Up @@ -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();
Expand Down
Expand Up @@ -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();
}

Expand Down
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/retroChangelog.jsx
Expand Up @@ -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();
Expand Down
Expand Up @@ -6,7 +6,7 @@ import PluginBasicConfig from "./pluginBasicConfig.jsx";
import "../../css/ds.css";

class RootDNAccessControl extends React.Component {
componentWillMount(prevProps) {
componentDidMount(prevProps) {
this.updateFields();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/usn.jsx
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/plugins/winsync.jsx
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/389-console/src/lib/security/ciphers.jsx
Expand Up @@ -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 = [];
Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/server/accessLog.jsx
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/server/auditLog.jsx
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/server/auditfailLog.jsx
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/server/errorLog.jsx
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 4 additions & 6 deletions src/cockpit/389-console/src/lib/server/ldapi.jsx
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit ae2a2a4

Please sign in to comment.