From cea3fe7e68857f7aa9b2beae958b6006fa299f13 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 5 Oct 2018 15:47:51 +0200 Subject: [PATCH] new modal "wallet type" --- src/actions/ModalActions.js | 12 ++++ src/components/modals/device/Type/index.js | 70 ++++++++++++++++++++++ src/components/modals/index.js | 5 ++ src/reducers/ModalReducer.js | 7 +++ 4 files changed, 94 insertions(+) create mode 100644 src/components/modals/device/Type/index.js diff --git a/src/actions/ModalActions.js b/src/actions/ModalActions.js index 25bebdfc..ea2434d9 100644 --- a/src/actions/ModalActions.js +++ b/src/actions/ModalActions.js @@ -112,6 +112,17 @@ export const onDeviceConnect = (device: Device): ThunkAction => (dispatch: Dispa } }; +export const onWalletTypeRequest = (device: TrezorDevice, hidden: boolean): ThunkAction => (dispatch: Dispatch): void => { + dispatch({ + type: MODAL.CLOSE, + }); + dispatch({ + type: CONNECT.RECEIVE_WALLET_TYPE, + device, + hidden, + }); +}; + export default { onPinSubmit, onPassphraseSubmit, @@ -121,4 +132,5 @@ export default { onForgetSingleDevice, onCancel, onDuplicateDevice, + onWalletTypeRequest, }; \ No newline at end of file diff --git a/src/components/modals/device/Type/index.js b/src/components/modals/device/Type/index.js new file mode 100644 index 00000000..3ea87286 --- /dev/null +++ b/src/components/modals/device/Type/index.js @@ -0,0 +1,70 @@ +/* @flow */ + +import React, { Component } from 'react'; +import styled from 'styled-components'; +import { H3 } from 'components/Heading'; +import P from 'components/Paragraph'; +import Button from 'components/Button'; + +import type { Props } from 'components/modals/index'; + +const Wrapper = styled.div` + width: 360px; + padding: 24px 48px; +`; + +const StyledButton = styled(Button)` + margin: 0 0 10px 0; +`; + +const Row = styled.div` + display: flex; + flex-direction: column; + padding: 10px 0; +`; + +class ForgetDevice extends Component { + + constructor(props: Props) { + super(props); + this.keyboardHandler = this.keyboardHandler.bind(this); + } + + componentDidMount() { + window.addEventListener('keydown', this.keyboardHandler, false); + } + + componentWillUnmount() { + window.removeEventListener('keydown', this.keyboardHandler, false); + } + + keyboardHandler(event: KeyboardEvent): void { + if (event.keyCode === 13) { + event.preventDefault(); + this.foo(false); + } + } + + keyboardHandler: (event: KeyboardEvent) => void; + + foo(hidden: boolean) { + this.props.modalActions.onWalletTypeRequest(this.props.modal.device, hidden); + } + + render() { + if (!this.props.modal.opened) return null; + const { device } = this.props.modal; + const { onCancel } = this.props.modalActions; + return ( + +

RequestWalletType for { device.instanceLabel }?

+ + this.foo(false)}>Basic + this.foo(true)}>Hidden + +
+ ); + } +} + +export default ForgetDevice; \ No newline at end of file diff --git a/src/components/modals/index.js b/src/components/modals/index.js index cb13f290..c78f7b3f 100644 --- a/src/components/modals/index.js +++ b/src/components/modals/index.js @@ -29,6 +29,7 @@ import ConfirmUnverifiedAddress from 'components/modals/confirm/UnverifiedAddres import ForgetDevice from 'components/modals/device/Forget'; import RememberDevice from 'components/modals/device/Remember'; import DuplicateDevice from 'components/modals/device/Duplicate'; +import RequestWalletType from 'components/modals/device/Type'; type OwnProps = { } @@ -123,6 +124,10 @@ class Modal extends Component { component = (); break; + case CONNECT.REQUEST_WALLET_TYPE: + component = (); + break; + default: component = null; } diff --git a/src/reducers/ModalReducer.js b/src/reducers/ModalReducer.js index 49b8bc07..8cfde96d 100644 --- a/src/reducers/ModalReducer.js +++ b/src/reducers/ModalReducer.js @@ -32,6 +32,13 @@ export default function modal(state: State = initialState, action: Action): Stat windowType: action.type, }; + case CONNECT.REQUEST_WALLET_TYPE: + return { + opened: true, + device: action.device, + windowType: action.type, + }; + case CONNECT.REMEMBER_REQUEST: return { opened: true,