Remove previous <Select /> for recent addresses
This commit is contained in:
parent
85cd564fbb
commit
7f03ae4918
|
@ -2,32 +2,24 @@
|
||||||
@import 'common/sass/mixins';
|
@import 'common/sass/mixins';
|
||||||
|
|
||||||
.ViewOnly {
|
.ViewOnly {
|
||||||
& .AddressInput {
|
&-fields {
|
||||||
margin-top: 15px;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
& .input-group-input {
|
&-field {
|
||||||
margin-top: 1rem;
|
display: flex;
|
||||||
}
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
&:nth-of-type(2) {
|
||||||
|
margin-bottom: calc(1rem + 15px);
|
||||||
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-recent {
|
& .AddressField {
|
||||||
text-align: left;
|
width: 100%;
|
||||||
|
|
||||||
&-separator {
|
|
||||||
display: block;
|
|
||||||
margin: $space-sm 0;
|
|
||||||
text-align: center;
|
|
||||||
color: shade-dark(0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.Select {
|
|
||||||
&-option {
|
|
||||||
@include ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Identicon {
|
|
||||||
display: inline-block;
|
|
||||||
margin-right: $space-sm;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import Select, { Option } from 'react-select';
|
|
||||||
|
|
||||||
import translate, { translateRaw } from 'translations';
|
import translate, { translateRaw } from 'translations';
|
||||||
import { AddressOnlyWallet } from 'libs/wallet';
|
import { AddressOnlyWallet } from 'libs/wallet';
|
||||||
import { AppState } from 'features/reducers';
|
import { AppState } from 'features/reducers';
|
||||||
import { getIsValidAddressFn } from 'features/config';
|
import { getIsValidAddressFn } from 'features/config';
|
||||||
import { walletSelectors } from 'features/wallet';
|
import { Input } from 'components/ui';
|
||||||
import { Input, Identicon } from 'components/ui';
|
|
||||||
import { AddressField } from 'components';
|
import { AddressField } from 'components';
|
||||||
import './ViewOnly.scss';
|
import './ViewOnly.scss';
|
||||||
|
|
||||||
|
@ -16,7 +14,6 @@ interface OwnProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
recentAddresses: ReturnType<typeof walletSelectors.getRecentAddresses>;
|
|
||||||
isValidAddress: ReturnType<typeof getIsValidAddressFn>;
|
isValidAddress: ReturnType<typeof getIsValidAddressFn>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,37 +31,15 @@ class ViewOnlyDecryptClass extends PureComponent<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { recentAddresses, isValidAddress } = this.props;
|
const { isValidAddress } = this.props;
|
||||||
const { address, addressFromBook } = this.state;
|
const { address, addressFromBook } = this.state;
|
||||||
const isValid = isValidAddress(address);
|
const isValid = isValidAddress(address);
|
||||||
const or = <em className="ViewOnly-recent-separator">{translate('OR')}</em>;
|
|
||||||
|
|
||||||
const recentOptions = (recentAddresses.map(addr => ({
|
|
||||||
label: (
|
|
||||||
<React.Fragment>
|
|
||||||
<Identicon address={addr} />
|
|
||||||
{addr}
|
|
||||||
</React.Fragment>
|
|
||||||
),
|
|
||||||
value: addr
|
|
||||||
// I hate this assertion, but React elements definitely work as labels
|
|
||||||
})) as any) as Option[];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ViewOnly">
|
<div className="ViewOnly">
|
||||||
<form className="form-group" onSubmit={this.openWalletWithAddress}>
|
<form className="form-group" onSubmit={this.openWalletWithAddress}>
|
||||||
{!!recentOptions.length && (
|
<section className="ViewOnly-fields">
|
||||||
<div className="ViewOnly-recent">
|
<section className="ViewOnly-fields-field">
|
||||||
<Select
|
|
||||||
value={address}
|
|
||||||
onChange={this.handleSelectAddress}
|
|
||||||
options={recentOptions}
|
|
||||||
placeholder={translateRaw('VIEW_ONLY_RECENT')}
|
|
||||||
/>
|
|
||||||
{or}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="ViewOnly-book">
|
|
||||||
<AddressField
|
<AddressField
|
||||||
value={addressFromBook}
|
value={addressFromBook}
|
||||||
showInputLabel={false}
|
showInputLabel={false}
|
||||||
|
@ -73,8 +48,11 @@ class ViewOnlyDecryptClass extends PureComponent<Props, State> {
|
||||||
onChangeOverride={this.handleSelectAddressFromBook}
|
onChangeOverride={this.handleSelectAddressFromBook}
|
||||||
dropdownThreshold={0}
|
dropdownThreshold={0}
|
||||||
/>
|
/>
|
||||||
{or}
|
</section>
|
||||||
</div>
|
<section className="ViewOnly-fields-field">
|
||||||
|
<em>{translate('OR')}</em>
|
||||||
|
</section>
|
||||||
|
<section className="ViewOnly-fields-field">
|
||||||
<Input
|
<Input
|
||||||
isValid={isValid}
|
isValid={isValid}
|
||||||
className="ViewOnly-input"
|
className="ViewOnly-input"
|
||||||
|
@ -85,6 +63,8 @@ class ViewOnlyDecryptClass extends PureComponent<Props, State> {
|
||||||
<button className="ViewOnly-submit btn btn-primary btn-block" disabled={!isValid}>
|
<button className="ViewOnly-submit btn btn-primary btn-block" disabled={!isValid}>
|
||||||
{translate('VIEW_ADDR')}
|
{translate('VIEW_ADDR')}
|
||||||
</button>
|
</button>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -94,11 +74,6 @@ class ViewOnlyDecryptClass extends PureComponent<Props, State> {
|
||||||
this.setState({ address: ev.currentTarget.value });
|
this.setState({ address: ev.currentTarget.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
private handleSelectAddress = (option: Option) => {
|
|
||||||
const address = option && option.value ? option.value.toString() : '';
|
|
||||||
this.setState({ address }, this.openWalletWithAddress);
|
|
||||||
};
|
|
||||||
|
|
||||||
private handleSelectAddressFromBook = (ev: React.FormEvent<HTMLInputElement>) => {
|
private handleSelectAddressFromBook = (ev: React.FormEvent<HTMLInputElement>) => {
|
||||||
const { currentTarget: { value: addressFromBook } } = ev;
|
const { currentTarget: { value: addressFromBook } } = ev;
|
||||||
this.setState({ addressFromBook }, this.openWalletWithAddressBook);
|
this.setState({ addressFromBook }, this.openWalletWithAddressBook);
|
||||||
|
@ -131,6 +106,5 @@ class ViewOnlyDecryptClass extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ViewOnlyDecrypt = connect((state: AppState): StateProps => ({
|
export const ViewOnlyDecrypt = connect((state: AppState): StateProps => ({
|
||||||
recentAddresses: walletSelectors.getRecentAddresses(state),
|
|
||||||
isValidAddress: getIsValidAddressFn(state)
|
isValidAddress: getIsValidAddressFn(state)
|
||||||
}))(ViewOnlyDecryptClass);
|
}))(ViewOnlyDecryptClass);
|
||||||
|
|
Loading…
Reference in New Issue