mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-01 03:40:53 +00:00
refacotred modals components
This commit is contained in:
parent
49ca5992fd
commit
e59c9ec714
55
src/components/modals/Container.js
Normal file
55
src/components/modals/Container.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* @flow */
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
|
import ModalActions from 'actions/ModalActions';
|
||||||
|
import ReceiveActions from 'actions/ReceiveActions';
|
||||||
|
|
||||||
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
|
import type { State, Dispatch } from 'flowtype';
|
||||||
|
|
||||||
|
import Modal from './index';
|
||||||
|
|
||||||
|
type OwnProps = { }
|
||||||
|
|
||||||
|
type StateProps = {
|
||||||
|
modal: $ElementType<State, 'modal'>,
|
||||||
|
accounts: $ElementType<State, 'accounts'>,
|
||||||
|
devices: $ElementType<State, 'devices'>,
|
||||||
|
connect: $ElementType<State, 'connect'>,
|
||||||
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
|
sendForm: $ElementType<State, 'sendForm'>,
|
||||||
|
receive: $ElementType<State, 'receive'>,
|
||||||
|
localStorage: $ElementType<State, 'localStorage'>,
|
||||||
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
|
}
|
||||||
|
|
||||||
|
type DispatchProps = {
|
||||||
|
modalActions: typeof ModalActions,
|
||||||
|
receiveActions: typeof ReceiveActions,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Props = StateProps & DispatchProps;
|
||||||
|
|
||||||
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State): StateProps => ({
|
||||||
|
modal: state.modal,
|
||||||
|
accounts: state.accounts,
|
||||||
|
devices: state.devices,
|
||||||
|
connect: state.connect,
|
||||||
|
selectedAccount: state.selectedAccount,
|
||||||
|
sendForm: state.sendForm,
|
||||||
|
receive: state.receive,
|
||||||
|
localStorage: state.localStorage,
|
||||||
|
wallet: state.wallet,
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
||||||
|
modalActions: bindActionCreators(ModalActions, dispatch),
|
||||||
|
receiveActions: bindActionCreators(ReceiveActions, dispatch),
|
||||||
|
});
|
||||||
|
|
||||||
|
// export default connect(mapStateToProps, mapDispatchToProps)(Modal);
|
||||||
|
export default withRouter(
|
||||||
|
connect(mapStateToProps, mapDispatchToProps)(Modal),
|
||||||
|
);
|
@ -1,13 +1,16 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import H3 from 'components/Heading';
|
|
||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
import P from 'components/Paragraph';
|
|
||||||
import { FONT_SIZE } from 'config/variables';
|
import { FONT_SIZE } from 'config/variables';
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import H3 from 'components/Heading';
|
||||||
|
import P from 'components/Paragraph';
|
||||||
|
|
||||||
|
import type { Props } from '../../Container';
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
width: 390px;
|
width: 390px;
|
||||||
@ -49,4 +52,8 @@ const ConfirmAddress = (props: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ConfirmAddress.propTypes = {
|
||||||
|
selectedAccount: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default ConfirmAddress;
|
export default ConfirmAddress;
|
@ -1,16 +1,24 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import icons from 'config/icons';
|
||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
|
import { LINE_HEIGHT } from 'config/variables';
|
||||||
|
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import icons from 'config/icons';
|
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import { LINE_HEIGHT } from 'config/variables';
|
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
sendForm: $ElementType<BaseProps, 'sendForm'>;
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
width: 390px;
|
width: 390px;
|
||||||
@ -40,9 +48,6 @@ const Label = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const ConfirmSignTx = (props: Props) => {
|
const ConfirmSignTx = (props: Props) => {
|
||||||
if (props.modal.context !== CONTEXT_DEVICE) return null;
|
|
||||||
const { device } = props.modal;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
amount,
|
amount,
|
||||||
address,
|
address,
|
||||||
@ -54,7 +59,7 @@ const ConfirmSignTx = (props: Props) => {
|
|||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Header>
|
<Header>
|
||||||
<Icon icon={icons.T1} size={60} color={colors.TEXT_SECONDARY} />
|
<Icon icon={icons.T1} size={60} color={colors.TEXT_SECONDARY} />
|
||||||
<H3>Confirm transaction on { device.label } device</H3>
|
<H3>Confirm transaction on { props.device.label } device</H3>
|
||||||
<P isSmaller>Details are shown on display</P>
|
<P isSmaller>Details are shown on display</P>
|
||||||
</Header>
|
</Header>
|
||||||
<Content>
|
<Content>
|
||||||
@ -69,4 +74,9 @@ const ConfirmSignTx = (props: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ConfirmSignTx.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
sendForm: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default ConfirmSignTx;
|
export default ConfirmSignTx;
|
@ -1,16 +1,27 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import icons from 'config/icons';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
|
||||||
import { H2 } from 'components/Heading';
|
import { H2 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import styled from 'styled-components';
|
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import colors from 'config/colors';
|
|
||||||
import icons from 'config/icons';
|
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import Link from 'components/Link';
|
import Link from 'components/Link';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
account: $ElementType<$ElementType<BaseProps, 'selectedAccount'>, 'account'>;
|
||||||
|
showAddress: $ElementType<$ElementType<BaseProps, 'receiveActions'>, 'showAddress'>;
|
||||||
|
showUnverifiedAddress: $ElementType<$ElementType<BaseProps, 'receiveActions'>, 'showUnverifiedAddress'>;
|
||||||
|
onCancel: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onCancel'>;
|
||||||
|
}
|
||||||
|
|
||||||
const StyledLink = styled(Link)`
|
const StyledLink = styled(Link)`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -57,24 +68,20 @@ class ConfirmUnverifiedAddress extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
verifyAddress() {
|
verifyAddress() {
|
||||||
const { account } = this.props.selectedAccount;
|
const { account, onCancel, showAddress } = this.props;
|
||||||
if (!account) return;
|
if (!account) return;
|
||||||
this.props.modalActions.onCancel();
|
onCancel();
|
||||||
this.props.receiveActions.showAddress(account.addressPath);
|
showAddress(account.addressPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
showUnverifiedAddress() {
|
showUnverifiedAddress() {
|
||||||
this.props.modalActions.onCancel();
|
const { onCancel, showUnverifiedAddress } = this.props;
|
||||||
this.props.receiveActions.showUnverifiedAddress();
|
onCancel();
|
||||||
|
showUnverifiedAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
const { device, account, onCancel } = this.props;
|
||||||
const { device } = this.props.modal;
|
|
||||||
|
|
||||||
const {
|
|
||||||
onCancel,
|
|
||||||
} = this.props.modalActions;
|
|
||||||
|
|
||||||
let deviceStatus: string;
|
let deviceStatus: string;
|
||||||
let claim: string;
|
let claim: string;
|
||||||
@ -97,7 +104,7 @@ class ConfirmUnverifiedAddress extends PureComponent<Props> {
|
|||||||
<H2>{ deviceStatus }</H2>
|
<H2>{ deviceStatus }</H2>
|
||||||
<StyledP isSmaller>To prevent phishing attacks, you should verify the address on your TREZOR first. { claim } to continue with the verification process.</StyledP>
|
<StyledP isSmaller>To prevent phishing attacks, you should verify the address on your TREZOR first. { claim } to continue with the verification process.</StyledP>
|
||||||
<Row>
|
<Row>
|
||||||
<StyledButton onClick={() => (!this.props.selectedAccount.account ? this.verifyAddress() : 'false')}>Try again</StyledButton>
|
<StyledButton onClick={() => (!account ? this.verifyAddress() : 'false')}>Try again</StyledButton>
|
||||||
<StyledButton isWhite onClick={() => this.showUnverifiedAddress()}>Show unverified address</StyledButton>
|
<StyledButton isWhite onClick={() => this.showUnverifiedAddress()}>Show unverified address</StyledButton>
|
||||||
</Row>
|
</Row>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
@ -105,4 +112,12 @@ class ConfirmUnverifiedAddress extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfirmUnverifiedAddress.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
account: PropTypes.object.isRequired,
|
||||||
|
showAddress: PropTypes.func.isRequired,
|
||||||
|
showUnverifiedAddress: PropTypes.func.isRequired,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default ConfirmUnverifiedAddress;
|
export default ConfirmUnverifiedAddress;
|
@ -1,19 +1,30 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import icons from 'config/icons';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
import { FONT_SIZE } from 'config/variables';
|
||||||
|
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import Input from 'components/inputs/Input';
|
import Input from 'components/inputs/Input';
|
||||||
import { getDuplicateInstanceNumber } from 'reducers/utils';
|
|
||||||
import { FONT_SIZE } from 'config/variables';
|
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import icons from 'config/icons';
|
|
||||||
import colors from 'config/colors';
|
|
||||||
import Link from 'components/Link';
|
import Link from 'components/Link';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from 'components/modals/index';
|
import { getDuplicateInstanceNumber } from 'reducers/utils';
|
||||||
|
|
||||||
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
devices: $ElementType<BaseProps, 'devices'>;
|
||||||
|
onDuplicateDevice: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onDuplicateDevice'>;
|
||||||
|
onCancel: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onCancel'>;
|
||||||
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
defaultName: string;
|
defaultName: string;
|
||||||
@ -63,17 +74,14 @@ const ErrorMessage = styled.div`
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default class DuplicateDevice extends PureComponent<Props, State> {
|
class DuplicateDevice extends PureComponent<Props, State> {
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
if (props.modal.context !== CONTEXT_DEVICE) return;
|
const instance = getDuplicateInstanceNumber(props.devices, props.device);
|
||||||
const { device } = props.modal;
|
|
||||||
|
|
||||||
const instance = getDuplicateInstanceNumber(props.devices, device);
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
defaultName: `${device.label} (${instance.toString()})`,
|
defaultName: `${props.device.label} (${instance.toString()})`,
|
||||||
instance,
|
instance,
|
||||||
instanceName: null,
|
instanceName: null,
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
@ -115,16 +123,12 @@ export default class DuplicateDevice extends PureComponent<Props, State> {
|
|||||||
keyboardHandler: (event: KeyboardEvent) => void;
|
keyboardHandler: (event: KeyboardEvent) => void;
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return;
|
|
||||||
const extended: Object = { instanceName: this.state.instanceName, instance: this.state.instance };
|
const extended: Object = { instanceName: this.state.instanceName, instance: this.state.instance };
|
||||||
this.props.modalActions.onDuplicateDevice({ ...this.props.modal.device, ...extended });
|
this.props.onDuplicateDevice({ ...this.props.device, ...extended });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
const { device, onCancel } = this.props;
|
||||||
|
|
||||||
const { device } = this.props.modal;
|
|
||||||
const { onCancel } = this.props.modalActions;
|
|
||||||
const {
|
const {
|
||||||
defaultName,
|
defaultName,
|
||||||
instanceName,
|
instanceName,
|
||||||
@ -168,4 +172,13 @@ export default class DuplicateDevice extends PureComponent<Props, State> {
|
|||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DuplicateDevice.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
devices: PropTypes.array.isRequired,
|
||||||
|
onDuplicateDevice: PropTypes.func.isRequired,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DuplicateDevice;
|
@ -1,13 +1,21 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
onForgetSingleDevice: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onForgetSingleDevice'>;
|
||||||
|
onCancel: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onCancel'>;
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
width: 360px;
|
width: 360px;
|
||||||
@ -48,25 +56,27 @@ class ForgetDevice extends PureComponent<Props> {
|
|||||||
keyboardHandler: (event: KeyboardEvent) => void;
|
keyboardHandler: (event: KeyboardEvent) => void;
|
||||||
|
|
||||||
forget() {
|
forget() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return;
|
this.props.onForgetSingleDevice(this.props.device);
|
||||||
this.props.modalActions.onForgetSingleDevice(this.props.modal.device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
|
||||||
const { device } = this.props.modal;
|
|
||||||
const { onCancel } = this.props.modalActions;
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<H3>Forget { device.instanceLabel }?</H3>
|
<H3>Forget { this.props.device.instanceLabel }?</H3>
|
||||||
<StyledP isSmaller>Forgetting only removes the device from the list on the left, your coins are still safe and you can access them by reconnecting your TREZOR again.</StyledP>
|
<StyledP isSmaller>Forgetting only removes the device from the list on the left, your coins are still safe and you can access them by reconnecting your TREZOR again.</StyledP>
|
||||||
<Row>
|
<Row>
|
||||||
<StyledButton onClick={() => this.forget()}>Forget</StyledButton>
|
<StyledButton onClick={() => this.forget()}>Forget</StyledButton>
|
||||||
<StyledButton isWhite onClick={onCancel}>Don't forget</StyledButton>
|
<StyledButton isWhite onClick={this.props.onCancel}>Don't forget</StyledButton>
|
||||||
</Row>
|
</Row>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForgetDevice.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
onForgetSingleDevice: PropTypes.func.isRequired,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default ForgetDevice;
|
export default ForgetDevice;
|
@ -1,13 +1,22 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import Loader from 'components/Loader';
|
import Loader from 'components/Loader';
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
instances: ?Array<TrezorDevice>;
|
||||||
|
onRememberDevice: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onRememberDevice'>;
|
||||||
|
onForgetDevice: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onForgetDevice'>;
|
||||||
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
countdown: number;
|
countdown: number;
|
||||||
@ -48,7 +57,7 @@ const StyledLoader = styled(Loader)`
|
|||||||
left: 200px;
|
left: 200px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default class RememberDevice extends PureComponent<Props, State> {
|
class RememberDevice extends PureComponent<Props, State> {
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@ -63,8 +72,7 @@ export default class RememberDevice extends PureComponent<Props, State> {
|
|||||||
// TODO: possible race condition,
|
// TODO: possible race condition,
|
||||||
// device could be already connected but it didn't emit Device.CONNECT event yet
|
// device could be already connected but it didn't emit Device.CONNECT event yet
|
||||||
window.clearInterval(this.state.ticker);
|
window.clearInterval(this.state.ticker);
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return;
|
this.props.onForgetDevice(this.props.device);
|
||||||
this.props.modalActions.onForgetDevice(this.props.modal.device);
|
|
||||||
} else {
|
} else {
|
||||||
this.setState(previousState => ({
|
this.setState(previousState => ({
|
||||||
countdown: previousState.countdown - 1,
|
countdown: previousState.countdown - 1,
|
||||||
@ -98,14 +106,11 @@ export default class RememberDevice extends PureComponent<Props, State> {
|
|||||||
keyboardHandler: (event: KeyboardEvent) => void;
|
keyboardHandler: (event: KeyboardEvent) => void;
|
||||||
|
|
||||||
forget() {
|
forget() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return;
|
this.props.onForgetDevice(this.props.device);
|
||||||
this.props.modalActions.onForgetDevice(this.props.modal.device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
const { device, instances, onRememberDevice } = this.props;
|
||||||
const { device, instances } = this.props.modal;
|
|
||||||
const { onRememberDevice } = this.props.modalActions;
|
|
||||||
|
|
||||||
let { label } = device;
|
let { label } = device;
|
||||||
const devicePlural: string = instances && instances.length > 1 ? 'devices or to remember them' : 'device or to remember it';
|
const devicePlural: string = instances && instances.length > 1 ? 'devices or to remember them' : 'device or to remember it';
|
||||||
@ -143,4 +148,13 @@ export default class RememberDevice extends PureComponent<Props, State> {
|
|||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RememberDevice.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
instances: PropTypes.array.isRequired,
|
||||||
|
onRememberDevice: PropTypes.func.isRequired,
|
||||||
|
onForgetDevice: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RememberDevice;
|
@ -1,19 +1,28 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled, { css } from 'styled-components';
|
import styled, { css } from 'styled-components';
|
||||||
|
|
||||||
|
import icons from 'config/icons';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import Tooltip from 'components/Tooltip';
|
import Tooltip from 'components/Tooltip';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import Link from 'components/Link';
|
import Link from 'components/Link';
|
||||||
import colors from 'config/colors';
|
|
||||||
import icons from 'config/icons';
|
|
||||||
import WalletTypeIcon from 'components/images/WalletType';
|
import WalletTypeIcon from 'components/images/WalletType';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from 'components/modals/index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
onWalletTypeRequest: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onWalletTypeRequest'>;
|
||||||
|
onCancel: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onCancel'>;
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
width: 360px;
|
width: 360px;
|
||||||
@ -89,15 +98,11 @@ class WalletType extends PureComponent<Props> {
|
|||||||
keyboardHandler: (event: KeyboardEvent) => void;
|
keyboardHandler: (event: KeyboardEvent) => void;
|
||||||
|
|
||||||
changeType(hidden: boolean, state: ?string) {
|
changeType(hidden: boolean, state: ?string) {
|
||||||
const { modal } = this.props;
|
this.props.onWalletTypeRequest(this.props.device, hidden, state);
|
||||||
if (modal.context !== CONTEXT_DEVICE) return;
|
|
||||||
this.props.modalActions.onWalletTypeRequest(modal.device, hidden, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
const { device, onCancel } = this.props;
|
||||||
const { device } = this.props.modal;
|
|
||||||
const { onCancel } = this.props.modalActions;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
@ -110,7 +115,7 @@ class WalletType extends PureComponent<Props> {
|
|||||||
/>
|
/>
|
||||||
</StyledLink>
|
</StyledLink>
|
||||||
)}
|
)}
|
||||||
<StyledHeading>Change wallet type for { device.instanceLabel }</StyledHeading>
|
<StyledHeading>{ device.state ? 'Change' : 'Select' } wallet type for { device.instanceLabel }</StyledHeading>
|
||||||
<Content isTop>
|
<Content isTop>
|
||||||
<Header>
|
<Header>
|
||||||
<WalletTypeIcon type="standard" size={32} color={colors.TEXT_PRIMARY} />
|
<WalletTypeIcon type="standard" size={32} color={colors.TEXT_PRIMARY} />
|
||||||
@ -148,4 +153,10 @@ class WalletType extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WalletType.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
onWalletTypeRequest: PropTypes.func.isRequired,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default WalletType;
|
export default WalletType;
|
@ -11,7 +11,11 @@ import Link from 'components/Link';
|
|||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
|
|
||||||
import type { Props } from 'components/modals/index';
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
onCancel: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onCancel'>;
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
width: 360px;
|
width: 360px;
|
||||||
@ -26,24 +30,21 @@ const StyledLink = styled(Link)`
|
|||||||
top: 10px;
|
top: 10px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Confirmation = (props: Props) => {
|
const Confirmation = (props: Props) => (
|
||||||
const { onCancel } = props.modalActions;
|
<Wrapper>
|
||||||
return (
|
<StyledLink onClick={props.onCancel}>
|
||||||
<Wrapper>
|
<Icon
|
||||||
<StyledLink onClick={onCancel}>
|
size={20}
|
||||||
<Icon
|
color={colors.TEXT_SECONDARY}
|
||||||
size={20}
|
icon={icons.CLOSE}
|
||||||
color={colors.TEXT_SECONDARY}
|
/>
|
||||||
icon={icons.CLOSE}
|
</StyledLink>
|
||||||
/>
|
<Header>
|
||||||
</StyledLink>
|
<Icon icon={icons.T1} size={60} color={colors.TEXT_SECONDARY} />
|
||||||
<Header>
|
<H3>NEM Wallet</H3>
|
||||||
<Icon icon={icons.T1} size={60} color={colors.TEXT_SECONDARY} />
|
<P isSmaller>If you enter a wrong passphrase, you will not unlock the desired hidden wallet.</P>
|
||||||
<H3>NEM Wallet</H3>
|
</Header>
|
||||||
<P isSmaller>If you enter a wrong passphrase, you will not unlock the desired hidden wallet.</P>
|
</Wrapper>
|
||||||
</Header>
|
);
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Confirmation;
|
export default Confirmation;
|
@ -1,67 +1,39 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { withRouter } from 'react-router-dom';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import colors from 'config/colors';
|
|
||||||
import { CSSTransition } from 'react-transition-group';
|
import { CSSTransition } from 'react-transition-group';
|
||||||
|
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
|
||||||
import { UI } from 'trezor-connect';
|
import { UI } from 'trezor-connect';
|
||||||
|
|
||||||
import ModalActions from 'actions/ModalActions';
|
|
||||||
import ReceiveActions from 'actions/ReceiveActions';
|
|
||||||
|
|
||||||
import * as MODAL from 'actions/constants/modal';
|
import * as MODAL from 'actions/constants/modal';
|
||||||
import * as RECEIVE from 'actions/constants/receive';
|
import * as RECEIVE from 'actions/constants/receive';
|
||||||
import * as CONNECT from 'actions/constants/TrezorConnect';
|
import * as CONNECT from 'actions/constants/TrezorConnect';
|
||||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
|
||||||
import type { State, Dispatch } from 'flowtype';
|
|
||||||
|
|
||||||
|
// device context
|
||||||
import Pin from 'components/modals/pin/Pin';
|
import Pin from 'components/modals/pin/Pin';
|
||||||
import InvalidPin from 'components/modals/pin/Invalid';
|
import InvalidPin from 'components/modals/pin/Invalid';
|
||||||
|
|
||||||
import Passphrase from 'components/modals/passphrase/Passphrase';
|
import Passphrase from 'components/modals/passphrase/Passphrase';
|
||||||
import PassphraseType from 'components/modals/passphrase/Type';
|
import PassphraseType from 'components/modals/passphrase/Type';
|
||||||
|
|
||||||
import ConfirmSignTx from 'components/modals/confirm/SignTx';
|
import ConfirmSignTx from 'components/modals/confirm/SignTx';
|
||||||
import ConfirmUnverifiedAddress from 'components/modals/confirm/UnverifiedAddress';
|
import ConfirmUnverifiedAddress from 'components/modals/confirm/UnverifiedAddress';
|
||||||
|
|
||||||
import ForgetDevice from 'components/modals/device/Forget';
|
import ForgetDevice from 'components/modals/device/Forget';
|
||||||
import RememberDevice from 'components/modals/device/Remember';
|
import RememberDevice from 'components/modals/device/Remember';
|
||||||
import DuplicateDevice from 'components/modals/device/Duplicate';
|
import DuplicateDevice from 'components/modals/device/Duplicate';
|
||||||
import WalletType from 'components/modals/device/WalletType';
|
import WalletType from 'components/modals/device/WalletType';
|
||||||
|
|
||||||
|
// external context
|
||||||
import NemWallet from 'components/modals/external/NemWallet';
|
import NemWallet from 'components/modals/external/NemWallet';
|
||||||
|
|
||||||
type OwnProps = { }
|
import type { Props } from './Container';
|
||||||
|
|
||||||
type StateProps = {
|
|
||||||
modal: $ElementType<State, 'modal'>,
|
|
||||||
accounts: $ElementType<State, 'accounts'>,
|
|
||||||
devices: $ElementType<State, 'devices'>,
|
|
||||||
connect: $ElementType<State, 'connect'>,
|
|
||||||
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
|
||||||
sendForm: $ElementType<State, 'sendForm'>,
|
|
||||||
receive: $ElementType<State, 'receive'>,
|
|
||||||
localStorage: $ElementType<State, 'localStorage'>,
|
|
||||||
wallet: $ElementType<State, 'wallet'>,
|
|
||||||
}
|
|
||||||
|
|
||||||
type DispatchProps = {
|
|
||||||
modalActions: typeof ModalActions,
|
|
||||||
receiveActions: typeof ReceiveActions,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
|
||||||
|
|
||||||
const Fade = (props: { children: React.Node}) => (
|
const Fade = (props: { children: React.Node}) => (
|
||||||
<CSSTransition
|
<CSSTransition
|
||||||
{...props}
|
{...props}
|
||||||
timeout={1000}
|
timeout={1000}
|
||||||
classNames="fade"
|
classNames="fade"
|
||||||
>
|
>{ props.children }
|
||||||
{ props.children }
|
|
||||||
</CSSTransition>
|
</CSSTransition>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -88,85 +60,124 @@ const ModalWindow = styled.div`
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
class Modal extends React.PureComponent<Props> {
|
// get modal component with device context
|
||||||
render() {
|
const getDeviceContextModal = (props: Props) => {
|
||||||
if (this.props.modal.context === MODAL.CONTEXT_NONE) return null;
|
const { modal, modalActions } = props;
|
||||||
|
if (modal.context !== MODAL.CONTEXT_DEVICE) return null;
|
||||||
|
|
||||||
const { windowType } = this.props.modal;
|
switch (modal.windowType) {
|
||||||
let component = null;
|
case UI.REQUEST_PIN:
|
||||||
switch (windowType) {
|
return (
|
||||||
case UI.REQUEST_PIN:
|
<Pin
|
||||||
component = (<Pin {...this.props} />);
|
device={modal.device}
|
||||||
break;
|
onPinSubmit={modalActions.onPinSubmit}
|
||||||
case UI.INVALID_PIN:
|
/>);
|
||||||
component = (<InvalidPin {...this.props} />);
|
|
||||||
break;
|
|
||||||
case UI.REQUEST_PASSPHRASE:
|
|
||||||
component = (<Passphrase {...this.props} />);
|
|
||||||
break;
|
|
||||||
case 'ButtonRequest_SignTx':
|
|
||||||
component = (<ConfirmSignTx {...this.props} />);
|
|
||||||
break;
|
|
||||||
case 'ButtonRequest_PassphraseType':
|
|
||||||
component = (<PassphraseType {...this.props} />);
|
|
||||||
break;
|
|
||||||
case RECEIVE.REQUEST_UNVERIFIED:
|
|
||||||
component = (<ConfirmUnverifiedAddress {...this.props} />);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONNECT.REMEMBER_REQUEST:
|
case UI.INVALID_PIN:
|
||||||
component = (<RememberDevice {...this.props} />);
|
return <InvalidPin device={modal.device} />;
|
||||||
break;
|
|
||||||
|
|
||||||
case CONNECT.FORGET_REQUEST:
|
case UI.REQUEST_PASSPHRASE:
|
||||||
component = (<ForgetDevice {...this.props} />);
|
return (
|
||||||
break;
|
<Passphrase
|
||||||
|
device={modal.device}
|
||||||
|
selectedDevice={props.wallet.selectedDevice}
|
||||||
|
onPassphraseSubmit={modalActions.onPassphraseSubmit}
|
||||||
|
/>);
|
||||||
|
|
||||||
case CONNECT.TRY_TO_DUPLICATE:
|
case 'ButtonRequest_PassphraseType':
|
||||||
component = (<DuplicateDevice {...this.props} />);
|
return <PassphraseType device={modal.device} />;
|
||||||
break;
|
|
||||||
|
|
||||||
case CONNECT.REQUEST_WALLET_TYPE:
|
case 'ButtonRequest_SignTx':
|
||||||
component = (<WalletType {...this.props} />);
|
return <ConfirmSignTx device={modal.device} sendForm={props.sendForm} />;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'xem':
|
case RECEIVE.REQUEST_UNVERIFIED:
|
||||||
component = (<NemWallet {...this.props} />);
|
return (
|
||||||
break;
|
<ConfirmUnverifiedAddress
|
||||||
default:
|
device={modal.device}
|
||||||
component = null;
|
account={props.selectedAccount.account}
|
||||||
}
|
onCancel={modalActions.onCancel}
|
||||||
|
showAddress={props.receiveActions.showAddress}
|
||||||
|
showUnverifiedAddress={props.receiveActions.showUnverifiedAddress}
|
||||||
|
/>);
|
||||||
|
|
||||||
return (
|
case CONNECT.REMEMBER_REQUEST:
|
||||||
<Fade key="1">
|
return (
|
||||||
<ModalContainer>
|
<RememberDevice
|
||||||
<ModalWindow>
|
device={modal.device}
|
||||||
{ component }
|
instances={modal.instances}
|
||||||
</ModalWindow>
|
onRememberDevice={modalActions.onRememberDevice}
|
||||||
</ModalContainer>
|
onForgetDevice={modalActions.onForgetDevice}
|
||||||
</Fade>
|
/>);
|
||||||
);
|
|
||||||
|
case CONNECT.FORGET_REQUEST:
|
||||||
|
return (
|
||||||
|
<ForgetDevice
|
||||||
|
device={modal.device}
|
||||||
|
onForgetSingleDevice={modalActions.onForgetSingleDevice}
|
||||||
|
onCancel={modalActions.onCancel}
|
||||||
|
/>);
|
||||||
|
|
||||||
|
case CONNECT.TRY_TO_DUPLICATE:
|
||||||
|
return (
|
||||||
|
<DuplicateDevice
|
||||||
|
device={modal.device}
|
||||||
|
devices={props.devices}
|
||||||
|
onDuplicateDevice={modalActions.onDuplicateDevice}
|
||||||
|
onCancel={modalActions.onCancel}
|
||||||
|
/>);
|
||||||
|
|
||||||
|
case CONNECT.REQUEST_WALLET_TYPE:
|
||||||
|
return (
|
||||||
|
<WalletType
|
||||||
|
device={modal.device}
|
||||||
|
onWalletTypeRequest={modalActions.onWalletTypeRequest}
|
||||||
|
onCancel={modalActions.onCancel}
|
||||||
|
/>);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State): StateProps => ({
|
// get modal component with external context
|
||||||
modal: state.modal,
|
const getExternalContextModal = (props: Props) => {
|
||||||
accounts: state.accounts,
|
const { modal, modalActions } = props;
|
||||||
devices: state.devices,
|
if (modal.context !== MODAL.CONTEXT_EXTERNAL_WALLET) return null;
|
||||||
connect: state.connect,
|
|
||||||
selectedAccount: state.selectedAccount,
|
|
||||||
sendForm: state.sendForm,
|
|
||||||
receive: state.receive,
|
|
||||||
localStorage: state.localStorage,
|
|
||||||
wallet: state.wallet,
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
switch (modal.windowType) {
|
||||||
modalActions: bindActionCreators(ModalActions, dispatch),
|
case 'xem':
|
||||||
receiveActions: bindActionCreators(ReceiveActions, dispatch),
|
return (<NemWallet onCancel={modalActions.onCancel} />);
|
||||||
});
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// export default connect(mapStateToProps, mapDispatchToProps)(Modal);
|
// modal container component
|
||||||
export default withRouter(
|
const Modal = (props: Props) => {
|
||||||
connect(mapStateToProps, mapDispatchToProps)(Modal),
|
const { modal } = props;
|
||||||
);
|
if (modal.context === MODAL.CONTEXT_NONE) return null;
|
||||||
|
|
||||||
|
let component = null;
|
||||||
|
switch (modal.context) {
|
||||||
|
case MODAL.CONTEXT_DEVICE:
|
||||||
|
component = getDeviceContextModal(props);
|
||||||
|
break;
|
||||||
|
case MODAL.CONTEXT_EXTERNAL_WALLET:
|
||||||
|
component = getExternalContextModal(props);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Fade key="modal-fade">
|
||||||
|
<ModalContainer>
|
||||||
|
<ModalWindow>
|
||||||
|
{ component }
|
||||||
|
</ModalWindow>
|
||||||
|
</ModalContainer>
|
||||||
|
</Fade>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Modal;
|
||||||
|
@ -1,16 +1,25 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
import { FONT_SIZE, TRANSITION } from 'config/variables';
|
import { FONT_SIZE, TRANSITION } from 'config/variables';
|
||||||
|
|
||||||
import { H2 } from 'components/Heading';
|
import { H2 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import Checkbox from 'components/Checkbox';
|
import Checkbox from 'components/Checkbox';
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import Input from 'components/inputs/Input';
|
import Input from 'components/inputs/Input';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
selectedDevice: ?TrezorDevice;
|
||||||
|
onPassphraseSubmit: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onPassphraseSubmit'>;
|
||||||
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
deviceLabel: string,
|
deviceLabel: string,
|
||||||
@ -80,13 +89,10 @@ const LinkButton = styled(Button)`
|
|||||||
class Passphrase extends PureComponent<Props, State> {
|
class Passphrase extends PureComponent<Props, State> {
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const { device, selectedDevice } = props;
|
||||||
if (props.modal.context !== CONTEXT_DEVICE) return;
|
|
||||||
const { device } = props.modal;
|
|
||||||
|
|
||||||
// Check if this device is already known
|
// Check if this device is already known
|
||||||
// if device is already known then only one input is presented
|
// if device is already known then only one input is presented
|
||||||
const { selectedDevice } = props.wallet;
|
|
||||||
let deviceLabel = device.label;
|
let deviceLabel = device.label;
|
||||||
let shouldShowSingleInput = false;
|
let shouldShowSingleInput = false;
|
||||||
if (selectedDevice && selectedDevice.path === device.path) {
|
if (selectedDevice && selectedDevice.path === device.path) {
|
||||||
@ -104,8 +110,6 @@ class Passphrase extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
state: State;
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.passphraseInput.focus();
|
this.passphraseInput.focus();
|
||||||
|
|
||||||
@ -179,7 +183,7 @@ class Passphrase extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitPassphrase(shouldLeavePassphraseBlank: boolean = false) {
|
submitPassphrase(shouldLeavePassphraseBlank: boolean = false) {
|
||||||
const { onPassphraseSubmit } = this.props.modalActions;
|
const { onPassphraseSubmit } = this.props;
|
||||||
const passphrase = this.state.passphraseInputValue;
|
const passphrase = this.state.passphraseInputValue;
|
||||||
|
|
||||||
// Reset state so same passphrase isn't filled when the modal will be visible again
|
// Reset state so same passphrase isn't filled when the modal will be visible again
|
||||||
@ -203,8 +207,6 @@ class Passphrase extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<H2>Enter {this.state.deviceLabel} passphrase</H2>
|
<H2>Enter {this.state.deviceLabel} passphrase</H2>
|
||||||
@ -273,4 +275,10 @@ class Passphrase extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Passphrase.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
selectedDevice: PropTypes.object.isRequired,
|
||||||
|
onPassphraseSubmit: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default Passphrase;
|
export default Passphrase;
|
@ -1,15 +1,21 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Icon from 'components/Icon';
|
import PropTypes from 'prop-types';
|
||||||
import colors from 'config/colors';
|
|
||||||
import icons from 'config/icons';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import icons from 'config/icons';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
|
||||||
|
import Icon from 'components/Icon';
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from 'components/modals/index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
width: 360px;
|
width: 360px;
|
||||||
@ -18,19 +24,18 @@ const Wrapper = styled.div`
|
|||||||
|
|
||||||
const Header = styled.div``;
|
const Header = styled.div``;
|
||||||
|
|
||||||
const Confirmation = (props: Props) => {
|
const PassphraseType = (props: Props) => (
|
||||||
if (props.modal.context !== CONTEXT_DEVICE) return null;
|
<Wrapper>
|
||||||
const { device } = props.modal;
|
<Header>
|
||||||
|
<Icon icon={icons.T1} size={60} color={colors.TEXT_SECONDARY} />
|
||||||
|
<H3>Complete the action on { props.device.label } device</H3>
|
||||||
|
<P isSmaller>If you enter a wrong passphrase, you will not unlock the desired hidden wallet.</P>
|
||||||
|
</Header>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
PassphraseType.propTypes = {
|
||||||
<Wrapper>
|
device: PropTypes.object.isRequired,
|
||||||
<Header>
|
|
||||||
<Icon icon={icons.T1} size={60} color={colors.TEXT_SECONDARY} />
|
|
||||||
<H3>Complete the action on { device.label } device</H3>
|
|
||||||
<P isSmaller>If you enter a wrong passphrase, you will not unlock the desired hidden wallet.</P>
|
|
||||||
</Header>
|
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Confirmation;
|
export default PassphraseType;
|
@ -1,27 +1,31 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { H3 } from 'components/Heading';
|
import { H3 } from 'components/Heading';
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
padding: 24px 48px;
|
padding: 24px 48px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const InvalidPin = (props: Props) => {
|
const InvalidPin = (props: Props) => (
|
||||||
if (props.modal.context !== CONTEXT_DEVICE) return null;
|
<Wrapper>
|
||||||
|
<H3>Entered PIN for { props.device.label } is not correct</H3>
|
||||||
|
<P isSmaller>Retrying...</P>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
const { device } = props.modal;
|
InvalidPin.propTypes = {
|
||||||
return (
|
device: PropTypes.object.isRequired,
|
||||||
<Wrapper>
|
|
||||||
<H3>Entered PIN for { device.label } is not correct</H3>
|
|
||||||
<P isSmaller>Retrying...</P>
|
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default InvalidPin;
|
export default InvalidPin;
|
@ -1,15 +1,24 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import P from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
import { H2 } from 'components/Heading';
|
import { H2 } from 'components/Heading';
|
||||||
import React, { PureComponent } from 'react';
|
|
||||||
import Link from 'components/Link';
|
import Link from 'components/Link';
|
||||||
import styled from 'styled-components';
|
|
||||||
import Button from 'components/Button';
|
import Button from 'components/Button';
|
||||||
import { CONTEXT_DEVICE } from 'actions/constants/modal';
|
|
||||||
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
|
||||||
import PinButton from './components/Button';
|
import PinButton from './components/Button';
|
||||||
import PinInput from './components/Input';
|
import PinInput from './components/Input';
|
||||||
|
|
||||||
import type { Props } from '../../index';
|
import type { Props as BaseProps } from '../../Container';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice;
|
||||||
|
onPinSubmit: $ElementType<$ElementType<BaseProps, 'modalActions'>, 'onPinSubmit'>;
|
||||||
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
pin: string;
|
pin: string;
|
||||||
@ -75,7 +84,7 @@ class Pin extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyboardHandler(event: KeyboardEvent): void {
|
keyboardHandler(event: KeyboardEvent): void {
|
||||||
const { onPinSubmit } = this.props.modalActions;
|
const { onPinSubmit } = this.props;
|
||||||
const { pin } = this.state;
|
const { pin } = this.state;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -133,9 +142,7 @@ class Pin extends PureComponent<Props, State> {
|
|||||||
keyboardHandler: (event: KeyboardEvent) => void;
|
keyboardHandler: (event: KeyboardEvent) => void;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.modal.context !== CONTEXT_DEVICE) return null;
|
const { device, onPinSubmit } = this.props;
|
||||||
const { onPinSubmit } = this.props.modalActions;
|
|
||||||
const { device } = this.props.modal;
|
|
||||||
const { pin } = this.state;
|
const { pin } = this.state;
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
@ -174,4 +181,9 @@ class Pin extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pin.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
onPinSubmit: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default Pin;
|
export default Pin;
|
@ -11,7 +11,7 @@ import type { State } from 'flowtype';
|
|||||||
|
|
||||||
import Header from 'components/Header';
|
import Header from 'components/Header';
|
||||||
import Footer from 'components/Footer';
|
import Footer from 'components/Footer';
|
||||||
import ModalContainer from 'components/modals';
|
import ModalContainer from 'components/modals/Container';
|
||||||
import AppNotifications from 'components/notifications/App';
|
import AppNotifications from 'components/notifications/App';
|
||||||
import ContextNotifications from 'components/notifications/Context';
|
import ContextNotifications from 'components/notifications/Context';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user