From 019bff0851c584302fa44317fc748b3319be9470 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 13 Feb 2020 13:49:16 +0300 Subject: [PATCH] - client: pass all params to the check_config request --- client/src/install/Setup/Settings.js | 53 +++++++++++++++++++++++----- client/src/install/Setup/index.js | 27 ++------------ 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/client/src/install/Setup/Settings.js b/client/src/install/Setup/Settings.js index 66f1691e..1c4da3fa 100644 --- a/client/src/install/Setup/Settings.js +++ b/client/src/install/Setup/Settings.js @@ -70,7 +70,7 @@ class Settings extends Component { }); } - getStaticIpMessage = (staticIp, handleStaticIp) => { + getStaticIpMessage = (staticIp) => { const { static: status, ip } = staticIp; if (!status) { @@ -89,7 +89,7 @@ class Settings extends Component { @@ -111,12 +111,48 @@ class Settings extends Component { ); }; + handleAutofix = (type) => { + const { + webIp, + webPort, + dnsIp, + dnsPort, + handleFix, + } = this.props; + + const web = { ip: webIp, port: webPort, autofix: false }; + const dns = { ip: dnsIp, port: dnsPort, autofix: false }; + const set_static_ip = false; + + if (type === 'web') { + web.autofix = true; + } else { + dns.autofix = true; + } + + handleFix(web, dns, set_static_ip); + }; + + handleStaticIp = () => { + const { + webIp, + webPort, + dnsIp, + dnsPort, + handleFix, + } = this.props; + + const web = { ip: webIp, port: webPort, autofix: false }; + const dns = { ip: dnsIp, port: dnsPort, autofix: false }; + const set_static_ip = true; + + handleFix(web, dns, set_static_ip); + }; + render() { const { handleSubmit, handleChange, - handleAutofix, - handleStaticIp, webIp, webPort, dnsIp, @@ -185,7 +221,7 @@ class Settings extends Component { @@ -256,7 +292,7 @@ class Settings extends Component { @@ -300,7 +336,7 @@ class Settings extends Component { static_ip_desc - {this.getStaticIpMessage(staticIp, handleStaticIp)} + {this.getStaticIpMessage(staticIp)} @@ -312,7 +348,7 @@ class Settings extends Component { Settings.propTypes = { handleSubmit: PropTypes.func.isRequired, handleChange: PropTypes.func, - handleAutofix: PropTypes.func, + handleFix: PropTypes.func.isRequired, validateForm: PropTypes.func, webIp: PropTypes.string.isRequired, dnsIp: PropTypes.string.isRequired, @@ -329,7 +365,6 @@ Settings.propTypes = { invalid: PropTypes.bool.isRequired, initialValues: PropTypes.object, t: PropTypes.func.isRequired, - handleStaticIp: PropTypes.func.isRequired, }; const selector = formValueSelector('install'); diff --git a/client/src/install/Setup/index.js b/client/src/install/Setup/index.js index 943fece9..82d8f84b 100644 --- a/client/src/install/Setup/index.js +++ b/client/src/install/Setup/index.js @@ -44,28 +44,8 @@ class Setup extends Component { } }, DEBOUNCE_TIMEOUT); - handleAutofix = (type, ip, port) => { - const data = { - ip, - port, - autofix: true, - }; - - if (type === 'web') { - this.props.checkConfig({ - web: { ...data }, - }); - } else { - this.props.checkConfig({ - dns: { ...data }, - }); - } - }; - - handleStaticIp = () => { - this.props.checkConfig({ - set_static_ip: true, - }); + handleFix = (web, dns, set_static_ip) => { + this.props.checkConfig({ web, dns, set_static_ip }); }; openDashboard = (ip, port) => { @@ -103,8 +83,7 @@ class Setup extends Component { onSubmit={this.nextStep} onChange={this.handleFormChange} validateForm={this.handleFormChange} - handleAutofix={this.handleAutofix} - handleStaticIp={this.handleStaticIp} + handleFix={this.handleFix} /> ); case 3: