Merge branch 'develop' into code-block-style

This commit is contained in:
Daniel Ternyak 2018-03-21 16:08:56 -05:00 committed by GitHub
commit bec4869e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 33 deletions

View File

@ -20,7 +20,7 @@ export const OfflineBroadcast = connect((state: AppState) => ({ offline: getOffl
const BroadCast: React.SFC<{}> = () => (
<p>
To broadcast this transaction, paste the above into the{' '}
<Link to="pushTx">Broadcast Transaction tab</Link> or{' '}
<Link to="/pushTx">Broadcast Transaction tab</Link> or{' '}
<NewTabLink href="https://etherscan.io/pushTx">etherscan.io/pushTx</NewTabLink>
</p>
);

View File

@ -7,19 +7,42 @@
&-label {
font-size: $font-size-medium;
margin-right: 16px;
margin-right: $space-md;
line-height: $input-height-base;
}
&-select {
flex: 1;
small {
padding-left: 5px;
opacity: 0.5;
font-size: 11px;
@include mono;
}
}
&-custom {
flex: 1;
margin-left: $space-md;
.input-group-input {
margin: 0;
}
}
&-submit {
margin-left: $space-md;
padding-left: $space;
padding-right: $space;
border: none;
}
.form-control {
display: inline-block;
width: auto;
margin: 0 0 0 10px;
}
.Select {
flex-grow: 1;
}
}
&-addresses {

View File

@ -1,3 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
import Select, { Option } from 'react-select';
import translate from 'translations';
import {
DeterministicWalletData,
getDeterministicWallets,
@ -9,14 +13,11 @@ import {
import Modal, { IButton } from 'components/ui/Modal';
import { AppState } from 'reducers';
import { isValidPath } from 'libs/validators';
import React from 'react';
import { connect } from 'react-redux';
import { getNetworkConfig } from 'selectors/config';
import { getTokens, MergedToken } from 'selectors/wallet';
import { UnitDisplay, Input } from 'components/ui';
import './DeterministicWalletsModal.scss';
import { StaticNetworkConfig } from 'types/network';
import Select from 'react-select';
import './DeterministicWalletsModal.scss';
const WALLETS_PER_PAGE = 5;
@ -125,23 +126,36 @@ class DeterministicWalletsModalClass extends React.PureComponent<Props, State> {
onSubmit={this.handleSubmitCustomPath}
>
<span className="DWModal-path-label">Addresses </span>
<Select
name="fieldDPath"
className=""
value={this.state.currentLabel || this.findDPath('value', dPath).value}
onChange={this.handleChangePath}
options={dPaths}
clearable={false}
searchable={false}
/>
{/* TODO/Hack - Custom Paths are temporarily disabled. `false` is used for smallest diff */}
{false && (
<Input
className={isValidPath(customPath) ? '' : 'invalid'}
value={customPath}
placeholder="m/44'/60'/0'/0"
onChange={this.handleChangeCustomPath}
<div className="DWModal-path-select">
<Select
name="fieldDPath"
className=""
value={this.state.currentLabel || this.findDPath('value', dPath).value}
onChange={this.handleChangePath}
options={dPaths.concat([customDPath])}
optionRenderer={this.renderDPathOption}
valueRenderer={this.renderDPathOption}
clearable={false}
searchable={false}
/>
</div>
{this.state.currentLabel === customDPath.label && (
<React.Fragment>
<div className="DWModal-path-custom">
<Input
className={customPath ? (isValidPath(customPath) ? 'valid' : 'invalid') : ''}
value={customPath}
placeholder="m/44'/60'/0'/0"
onChange={this.handleChangeCustomPath}
/>
</div>
<button
className="DWModal-path-submit btn btn-success"
disabled={!isValidPath(customPath)}
>
<i className="fa fa-check" />
</button>
</React.Fragment>
)}
</form>
@ -215,7 +229,7 @@ class DeterministicWalletsModalClass extends React.PureComponent<Props, State> {
const { value: dPathLabel } = newPath;
const { value } = this.findDPath('value', dPathLabel);
if (value === 'custom') {
if (value === customDPath.value) {
this.setState({ isCustomPath: true, currentLabel: dPathLabel });
} else {
this.setState({ isCustomPath: false, currentLabel: dPathLabel });
@ -228,11 +242,12 @@ class DeterministicWalletsModalClass extends React.PureComponent<Props, State> {
};
private handleSubmitCustomPath = (ev: React.FormEvent<HTMLFormElement>) => {
const { customPath, currentLabel } = this.state;
ev.preventDefault();
if (!isValidPath(this.state.customPath)) {
return;
if (currentLabel === customDPath.label && isValidPath(customPath)) {
this.props.onPathChange(customPath);
}
this.props.onPathChange(this.state.customPath);
};
private handleChangeToken = (ev: React.FormEvent<HTMLSelectElement>) => {
@ -257,6 +272,18 @@ class DeterministicWalletsModalClass extends React.PureComponent<Props, State> {
this.setState({ page: Math.max(this.state.page - 1, 0) }, this.getAddresses);
};
private renderDPathOption(option: Option) {
if (option.value === customDPath.value) {
return translate('ADD_Radio_5_PathCustom');
}
return (
<React.Fragment>
{option.label} {option.value && <small>({option.value.toString().replace(' ', '')})</small>}
</React.Fragment>
);
}
private renderWalletRow(wallet: DeterministicWalletData) {
const { desiredToken, network } = this.props;
const { selectedAddress } = this.state;

View File

@ -68,5 +68,5 @@ export const EXTRA_PATHS = [ETH_SINGULAR];
// whitespace strings are evaluated the same way as nospace strings, except they allow optional spaces between each portion of the string
// ie. "m / 44' / 0' / 0'" is valid, "m / 4 4' / 0' / 0'" is invalid
export const dPathRegex = /m\/44'\/[0-9]+\'\/[0-9]+(\'+$|\'+(\/[0-1]+$))/;
export const dPathRegex = /m\/(44|0)'\/[0-9]+\'\/[0-9]+(\'+$|\'+(\/[0-1]+$))/;
// export const whitespaceDPathRegex = /m\s*\/\s*44'\s*\/\s*[0-9]+\'\s*\/\s*[0-9]+(\'+$|\'+\s*(\/\s*[0-1]+$))/;

View File

@ -15,7 +15,7 @@
"bn.js": "4.11.8",
"bootstrap-sass": "3.3.7",
"classnames": "2.2.5",
"electron-updater": "2.21.0",
"electron-updater": "2.21.1",
"ethereum-blockies-base64": "1.0.1",
"ethereumjs-abi": "0.6.5",
"ethereumjs-tx": "1.3.4",
@ -119,7 +119,7 @@
"sass-loader": "6.0.7",
"style-loader": "0.20.3",
"thread-loader": "1.1.5",
"ts-jest": "22.4.1",
"ts-jest": "22.4.2",
"ts-loader": "3.3.1",
"tslint": "5.9.1",
"tslint-config-prettier": "1.10.0",