Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
feat(ui): ability to add wallet name in onboarding
Browse files Browse the repository at this point in the history
fix #1262
  • Loading branch information
rahulbile committed Nov 14, 2020
1 parent 1b64157 commit f20701a
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 17 deletions.
8 changes: 7 additions & 1 deletion renderer/components/Onboarding/Steps/ConnectionConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand All @@ -57,6 +59,7 @@ class ConnectionConfirm extends React.Component {
cert: connectionCert,
macaroon: connectionMacaroon,
}),
name,
})
}

Expand All @@ -78,6 +81,7 @@ class ConnectionConfirm extends React.Component {
type: 'custom',
decoder: 'lnd.lndconnect.v1',
lndconnectUri,
name,
})
}

Expand All @@ -93,6 +97,7 @@ class ConnectionConfirm extends React.Component {
type: 'custom',
decoder: 'lnd.lndconnect.v1',
lndconnectUri,
name,
})
}

Expand All @@ -106,6 +111,7 @@ class ConnectionConfirm extends React.Component {
connectionMacaroon,
connectionString,
lndConnect,
name,
isLightningGrpcActive,
isWalletUnlockerGrpcActive,
startLndHostError,
Expand Down
35 changes: 23 additions & 12 deletions renderer/components/Onboarding/Steps/ConnectionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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}
Expand All @@ -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}
Expand Down
18 changes: 17 additions & 1 deletion renderer/components/Onboarding/Steps/ConnectionDetailsManual.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,6 +34,7 @@ class ConnectionDetailsManual extends React.Component {
static defaultProps = {
wizardApi: {},
wizardState: {},
name: null,
}

componentDidMount() {
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -124,10 +128,12 @@ class ConnectionDetailsManual extends React.Component {
connectionMacaroon,
connectionString,
lndConnect,
name,
setConnectionHost,
setConnectionCert,
setConnectionMacaroon,
setLndconnect,
setName,
startLndHostError,
startLndCertError,
startLndMacaroonError,
Expand Down Expand Up @@ -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}
/>

<Input
description={<FormattedMessage {...messages.wallet_name_description} />}
field="name"
initialValue={name}
label={<FormattedMessage {...messages.wallet_name_label} />}
maxLength={30}
name="name"
/>
</>
)
}}
Expand Down
20 changes: 18 additions & 2 deletions renderer/components/Onboarding/Steps/ConnectionDetailsString.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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,

Expand All @@ -25,6 +27,7 @@ class ConnectionDetailsString extends React.Component {
static defaultProps = {
wizardApi: {},
wizardState: {},
name: null,
}

componentDidMount() {
Expand Down Expand Up @@ -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() {
Expand All @@ -98,8 +102,10 @@ class ConnectionDetailsString extends React.Component {
startLndCertError,
startLndMacaroonError,
lndConnect,
name,
setLndconnect,
setConnectionString,
setName,
clearStartLndError,
...rest
} = this.props
Expand Down Expand Up @@ -158,11 +164,21 @@ class ConnectionDetailsString extends React.Component {
field="connectionString"
initialValue={connectionString}
isRequired
mb={3}
rows="12"
validateOnBlur={willValidateInline}
validateOnChange={willValidateInline}
willAutoFocus
/>

<Input
description={<FormattedMessage {...messages.wallet_name_description} />}
field="name"
initialValue={name}
label={<FormattedMessage {...messages.wallet_name_label} />}
maxLength={30}
name="name"
/>
</>
)
}}
Expand Down
2 changes: 1 addition & 1 deletion renderer/components/Onboarding/Steps/Name.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Name extends React.Component {
static defaultProps = {
wizardApi: {},
wizardState: {},
name: '',
name: null,
}

setFormApi = formApi => {
Expand Down
1 change: 1 addition & 0 deletions renderer/containers/Onboarding/Steps/ConnectionConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions renderer/containers/Onboarding/Steps/ConnectionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
setConnectionMacaroon,
setConnectionString,
setLndconnect,
setName,
} from 'reducers/onboarding'

const mapStateToProps = state => ({
Expand All @@ -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),
Expand All @@ -33,6 +35,7 @@ const mapDispatchToProps = {
setConnectionMacaroon,
setConnectionString,
setLndconnect,
setName,
clearStartLndError,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
setConnectionMacaroon,
setConnectionString,
setLndconnect,
setName,
} from 'reducers/onboarding'

const mapStateToProps = state => ({
Expand All @@ -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),
Expand All @@ -33,6 +35,7 @@ const mapDispatchToProps = {
setConnectionMacaroon,
setConnectionString,
setLndconnect,
setName,
clearStartLndError,
}

Expand Down

0 comments on commit f20701a

Please sign in to comment.