From f20701ab634e9c63fa0d7f80784e974f5e0547f2 Mon Sep 17 00:00:00 2001 From: rahulbile Date: Thu, 12 Nov 2020 23:11:41 +0530 Subject: [PATCH] feat(ui): ability to add wallet name in onboarding fix #1262 --- .../Onboarding/Steps/ConnectionConfirm.js | 8 ++++- .../Onboarding/Steps/ConnectionDetails.js | 35 ++++++++++++------- .../Steps/ConnectionDetailsManual.js | 18 +++++++++- .../Steps/ConnectionDetailsString.js | 20 +++++++++-- renderer/components/Onboarding/Steps/Name.js | 2 +- .../Onboarding/Steps/ConnectionConfirm.js | 1 + .../Onboarding/Steps/ConnectionDetails.js | 3 ++ .../Steps/ConnectionDetailsManual.js | 3 ++ 8 files changed, 73 insertions(+), 17 deletions(-) diff --git a/renderer/components/Onboarding/Steps/ConnectionConfirm.js b/renderer/components/Onboarding/Steps/ConnectionConfirm.js index 73f65f75843..916de253815 100644 --- a/renderer/components/Onboarding/Steps/ConnectionConfirm.js +++ b/renderer/components/Onboarding/Steps/ConnectionConfirm.js @@ -18,6 +18,7 @@ class ConnectionConfirm extends React.Component { isLightningGrpcActive: PropTypes.bool, isWalletUnlockerGrpcActive: PropTypes.bool, lndConnect: PropTypes.string, + name: PropTypes.string, startLnd: PropTypes.func.isRequired, startLndCertError: PropTypes.string, startLndHostError: PropTypes.string, @@ -40,10 +41,11 @@ class ConnectionConfirm extends React.Component { handleSubmit = async () => { const { - connectionHost, connectionCert, + connectionHost, connectionMacaroon, connectionString, + name, startLnd, } = this.props const cleanConnectionString = connectionString && connectionString.trim() @@ -57,6 +59,7 @@ class ConnectionConfirm extends React.Component { cert: connectionCert, macaroon: connectionMacaroon, }), + name, }) } @@ -78,6 +81,7 @@ class ConnectionConfirm extends React.Component { type: 'custom', decoder: 'lnd.lndconnect.v1', lndconnectUri, + name, }) } @@ -93,6 +97,7 @@ class ConnectionConfirm extends React.Component { type: 'custom', decoder: 'lnd.lndconnect.v1', lndconnectUri, + name, }) } @@ -106,6 +111,7 @@ class ConnectionConfirm extends React.Component { connectionMacaroon, connectionString, lndConnect, + name, isLightningGrpcActive, isWalletUnlockerGrpcActive, startLndHostError, diff --git a/renderer/components/Onboarding/Steps/ConnectionDetails.js b/renderer/components/Onboarding/Steps/ConnectionDetails.js index 6c2b09cb38e..48535ba0fcd 100644 --- a/renderer/components/Onboarding/Steps/ConnectionDetails.js +++ b/renderer/components/Onboarding/Steps/ConnectionDetails.js @@ -18,11 +18,13 @@ class ConnectionDetails extends React.Component { connectionMacaroon: PropTypes.string, connectionString: PropTypes.string, lndConnect: PropTypes.string, + name: PropTypes.string, setConnectionCert: PropTypes.func.isRequired, setConnectionHost: PropTypes.func.isRequired, setConnectionMacaroon: PropTypes.func.isRequired, setConnectionString: PropTypes.func.isRequired, setLndconnect: PropTypes.func.isRequired, + setName: PropTypes.func.isRequired, startLndCertError: PropTypes.string, startLndHostError: PropTypes.string, startLndMacaroonError: PropTypes.string, @@ -46,22 +48,25 @@ class ConnectionDetails extends React.Component { componentDidUpdate(prevProps, prevState) { const { lndConnect, - setConnectionHost, setConnectionCert, + setConnectionHost, setConnectionMacaroon, setConnectionString, + setName, } = this.props const { formType } = this.state if (formType && formType !== prevState.formType && prevState.formType) { switch (formType) { case FORM_TYPE_CONNECTION_STRING: - setConnectionHost(null) setConnectionCert(null) + setConnectionHost(null) setConnectionMacaroon(null) + setName(null) break case FORM_TYPE_MANUAL: setConnectionString(null) + setName(null) break default: @@ -79,25 +84,27 @@ class ConnectionDetails extends React.Component { render() { const { - wizardApi, - wizardState, - connectionHost, + clearStartLndError, connectionCert, + connectionHost, connectionMacaroon, connectionString, - startLndHostError, - startLndCertError, - startLndMacaroonError, lndConnect, - setLndconnect, - setConnectionHost, + name, setConnectionCert, + setConnectionHost, setConnectionMacaroon, setConnectionString, - clearStartLndError, - validateHost, + setLndconnect, + setName, + startLndCertError, + startLndHostError, + startLndMacaroonError, validateCert, + validateHost, validateMacaroon, + wizardApi, + wizardState, } = this.props const { formType } = this.state @@ -123,8 +130,10 @@ class ConnectionDetails extends React.Component { clearStartLndError={clearStartLndError} connectionString={connectionString} lndConnect={lndConnect} + name={name} setConnectionString={setConnectionString} setLndconnect={setLndconnect} + setName={setName} startLndCertError={startLndCertError} startLndHostError={startLndHostError} startLndMacaroonError={startLndMacaroonError} @@ -139,10 +148,12 @@ class ConnectionDetails extends React.Component { connectionMacaroon={connectionMacaroon} connectionString={connectionString} lndConnect={lndConnect} + name={name} setConnectionCert={setConnectionCert} setConnectionHost={setConnectionHost} setConnectionMacaroon={setConnectionMacaroon} setLndconnect={setLndconnect} + setName={setName} startLndCertError={startLndCertError} startLndHostError={startLndHostError} startLndMacaroonError={startLndMacaroonError} diff --git a/renderer/components/Onboarding/Steps/ConnectionDetailsManual.js b/renderer/components/Onboarding/Steps/ConnectionDetailsManual.js index 972c9e4d59e..eec4836ed19 100644 --- a/renderer/components/Onboarding/Steps/ConnectionDetailsManual.js +++ b/renderer/components/Onboarding/Steps/ConnectionDetailsManual.js @@ -14,10 +14,12 @@ class ConnectionDetailsManual extends React.Component { connectionMacaroon: PropTypes.string, connectionString: PropTypes.string, lndConnect: PropTypes.string, + name: PropTypes.string, setConnectionCert: PropTypes.func.isRequired, setConnectionHost: PropTypes.func.isRequired, setConnectionMacaroon: PropTypes.func.isRequired, setLndconnect: PropTypes.func.isRequired, + setName: PropTypes.func.isRequired, startLndCertError: PropTypes.string, startLndHostError: PropTypes.string, @@ -32,6 +34,7 @@ class ConnectionDetailsManual extends React.Component { static defaultProps = { wizardApi: {}, wizardState: {}, + name: null, } componentDidMount() { @@ -90,10 +93,11 @@ class ConnectionDetailsManual extends React.Component { } handleSubmit = values => { - const { setConnectionHost, setConnectionCert, setConnectionMacaroon } = this.props + const { setConnectionHost, setConnectionCert, setConnectionMacaroon, setName } = this.props setConnectionHost(values.connectionHost) setConnectionCert(values.connectionCert) setConnectionMacaroon(values.connectionMacaroon) + setName(values.name) } validateHost = () => { @@ -124,10 +128,12 @@ class ConnectionDetailsManual extends React.Component { connectionMacaroon, connectionString, lndConnect, + name, setConnectionHost, setConnectionCert, setConnectionMacaroon, setLndconnect, + setName, startLndHostError, startLndCertError, startLndMacaroonError, @@ -211,12 +217,22 @@ class ConnectionDetailsManual extends React.Component { initialValue={connectionMacaroon} isRequired label="Macaroon" + mb={3} name="connectionMacaroon" onBlur={this.validateMacaroon} validateOnBlur={willValidateInline} validateOnChange={willValidateInline} width={1} /> + + } + field="name" + initialValue={name} + label={} + maxLength={30} + name="name" + /> ) }} diff --git a/renderer/components/Onboarding/Steps/ConnectionDetailsString.js b/renderer/components/Onboarding/Steps/ConnectionDetailsString.js index b692a8b26a7..971f636ee65 100644 --- a/renderer/components/Onboarding/Steps/ConnectionDetailsString.js +++ b/renderer/components/Onboarding/Steps/ConnectionDetailsString.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { FormattedMessage, injectIntl } from 'react-intl' import { Box } from 'rebass/styled-components' import { Bar, Header } from 'components/UI' -import { Form, LndConnectionStringInput } from 'components/Form' +import { Form, Input, LndConnectionStringInput } from 'components/Form' import ConnectionDetailsTabs from './ConnectionDetailsTabs' import messages from './messages' @@ -12,8 +12,10 @@ class ConnectionDetailsString extends React.Component { clearStartLndError: PropTypes.func.isRequired, connectionString: PropTypes.string, lndConnect: PropTypes.string, + name: PropTypes.string, setConnectionString: PropTypes.func.isRequired, setLndconnect: PropTypes.func.isRequired, + setName: PropTypes.func.isRequired, startLndCertError: PropTypes.string, startLndHostError: PropTypes.string, @@ -25,6 +27,7 @@ class ConnectionDetailsString extends React.Component { static defaultProps = { wizardApi: {}, wizardState: {}, + name: null, } componentDidMount() { @@ -85,8 +88,9 @@ class ConnectionDetailsString extends React.Component { } handleSubmit = values => { - const { setConnectionString } = this.props + const { setConnectionString, setName } = this.props setConnectionString(values.connectionString) + setName(values.name) } render() { @@ -98,8 +102,10 @@ class ConnectionDetailsString extends React.Component { startLndCertError, startLndMacaroonError, lndConnect, + name, setLndconnect, setConnectionString, + setName, clearStartLndError, ...rest } = this.props @@ -158,11 +164,21 @@ class ConnectionDetailsString extends React.Component { field="connectionString" initialValue={connectionString} isRequired + mb={3} rows="12" validateOnBlur={willValidateInline} validateOnChange={willValidateInline} willAutoFocus /> + + } + field="name" + initialValue={name} + label={} + maxLength={30} + name="name" + /> ) }} diff --git a/renderer/components/Onboarding/Steps/Name.js b/renderer/components/Onboarding/Steps/Name.js index dfb259f1c1f..c56155db9fa 100644 --- a/renderer/components/Onboarding/Steps/Name.js +++ b/renderer/components/Onboarding/Steps/Name.js @@ -19,7 +19,7 @@ class Name extends React.Component { static defaultProps = { wizardApi: {}, wizardState: {}, - name: '', + name: null, } setFormApi = formApi => { diff --git a/renderer/containers/Onboarding/Steps/ConnectionConfirm.js b/renderer/containers/Onboarding/Steps/ConnectionConfirm.js index 4ae458ad3e4..185971df236 100644 --- a/renderer/containers/Onboarding/Steps/ConnectionConfirm.js +++ b/renderer/containers/Onboarding/Steps/ConnectionConfirm.js @@ -11,6 +11,7 @@ const mapStateToProps = state => ({ isLightningGrpcActive: state.lnd.isLightningGrpcActive, isWalletUnlockerGrpcActive: state.lnd.isWalletUnlockerGrpcActive, lndConnect: state.onboarding.lndConnect, + name: state.onboarding.name, startLndHostError: lndSelectors.startLndHostError(state), startLndCertError: lndSelectors.startLndCertError(state), startLndMacaroonError: lndSelectors.startLndMacaroonError(state), diff --git a/renderer/containers/Onboarding/Steps/ConnectionDetails.js b/renderer/containers/Onboarding/Steps/ConnectionDetails.js index 47414ff2a53..816e4459623 100644 --- a/renderer/containers/Onboarding/Steps/ConnectionDetails.js +++ b/renderer/containers/Onboarding/Steps/ConnectionDetails.js @@ -10,6 +10,7 @@ import { setConnectionMacaroon, setConnectionString, setLndconnect, + setName, } from 'reducers/onboarding' const mapStateToProps = state => ({ @@ -19,6 +20,7 @@ const mapStateToProps = state => ({ connectionHost: state.onboarding.connectionHost, connectionCert: state.onboarding.connectionCert, lndConnect: state.onboarding.lndConnect, + name: state.onboarding.name, startLndHostError: lndSelectors.startLndHostError(state), startLndCertError: lndSelectors.startLndCertError(state), startLndMacaroonError: lndSelectors.startLndMacaroonError(state), @@ -33,6 +35,7 @@ const mapDispatchToProps = { setConnectionMacaroon, setConnectionString, setLndconnect, + setName, clearStartLndError, } diff --git a/renderer/containers/Onboarding/Steps/ConnectionDetailsManual.js b/renderer/containers/Onboarding/Steps/ConnectionDetailsManual.js index 024e3800b6a..968779bdf20 100644 --- a/renderer/containers/Onboarding/Steps/ConnectionDetailsManual.js +++ b/renderer/containers/Onboarding/Steps/ConnectionDetailsManual.js @@ -10,6 +10,7 @@ import { setConnectionMacaroon, setConnectionString, setLndconnect, + setName, } from 'reducers/onboarding' const mapStateToProps = state => ({ @@ -19,6 +20,7 @@ const mapStateToProps = state => ({ connectionHost: state.onboarding.connectionHost, connectionCert: state.onboarding.connectionCert, lndConnect: state.onboarding.lndConnect, + name: state.onboarding.name, startLndHostError: lndSelectors.startLndHostError(state), startLndCertError: lndSelectors.startLndCertError(state), startLndMacaroonError: lndSelectors.startLndMacaroonError(state), @@ -33,6 +35,7 @@ const mapDispatchToProps = { setConnectionMacaroon, setConnectionString, setLndconnect, + setName, clearStartLndError, }