From 65479c86085d024f86d8e242371d26f1d592a05b Mon Sep 17 00:00:00 2001 From: Vasek Mlejnsky Date: Thu, 16 Aug 2018 16:12:18 +0200 Subject: [PATCH 1/3] Config flow to recognise babel aliases --- .flowconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.flowconfig b/.flowconfig index 59ad41d9..faae2174 100644 --- a/.flowconfig +++ b/.flowconfig @@ -30,4 +30,14 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue esproposal.decorators=ignore module.name_mapper='.*\(.less\)' -> 'CSSModule' module.name_mapper='^\(~/\)' -> '/src/' +module.name_mapper='^universal' -> '/src/' +module.name_mapper='^config' -> '/src/js/config' +module.name_mapper='^constants' -> '/src/js/constants' +module.name_mapper='^components' -> '/src/js/components' +module.name_mapper='^actions' -> '/src/js/actions' +module.name_mapper='^reducers' -> '/src/js/reducers' +module.name_mapper='^support' -> '/src/js/support' +module.name_mapper='^utils' -> '/src/js/utils' +module.name_mapper='^services' -> '/src/js/services' +module.name_mapper='^views' -> '/src/js/views' module.system=haste From 87d485cf828d587d598627119dcdcf2a0245607b Mon Sep 17 00:00:00 2001 From: Vasek Mlejnsky Date: Thu, 16 Aug 2018 16:12:32 +0200 Subject: [PATCH 2/3] Cleanup & eslint error fixes --- .../components/LeftNavigation/Container.js | 27 ++------------- .../components/LeftNavigation/Row/index.js | 1 - .../components/LeftNavigation/common.js | 34 +++++++++++++++---- .../selection/AccountSelection.js | 24 ++++++------- .../LeftNavigation/selection/CoinSelection.js | 16 ++++----- .../selection/DeviceSelection.js | 10 +++--- 6 files changed, 50 insertions(+), 62 deletions(-) diff --git a/src/js/views/Device/components/LeftNavigation/Container.js b/src/js/views/Device/components/LeftNavigation/Container.js index c22d2b19..7a5fa81a 100644 --- a/src/js/views/Device/components/LeftNavigation/Container.js +++ b/src/js/views/Device/components/LeftNavigation/Container.js @@ -8,35 +8,14 @@ import * as TrezorConnectActions from 'actions/TrezorConnectActions'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { State, Dispatch } from 'flowtype'; +import type { StateProps, DispatchProps } from './common'; + import LeftNavigation from './index'; type OwnProps = { } -type StateProps = { - connect: $ElementType, - accounts: $ElementType, - router: $ElementType, - deviceDropdownOpened: boolean, - fiat: $ElementType, - localStorage: $ElementType, - discovery: $ElementType, - wallet: $ElementType, - devices: $ElementType, - pending: $ElementType, -} - -type DispatchProps = { - toggleDeviceDropdown: typeof toggleDeviceDropdown, - addAccount: typeof TrezorConnectActions.addAccount, - acquireDevice: typeof TrezorConnectActions.acquire, - forgetDevice: typeof TrezorConnectActions.forget, - duplicateDevice: typeof TrezorConnectActions.duplicateDevice, - gotoDeviceSettings: typeof TrezorConnectActions.gotoDeviceSettings, - onSelectDevice: typeof TrezorConnectActions.onSelectDevice, -} - const mapStateToProps: MapStateToProps = (state: State, own: OwnProps): StateProps => ({ connect: state.connect, accounts: state.accounts, @@ -63,4 +42,4 @@ const mapDispatchToProps: MapDispatchToProps export default withRouter( connect(mapStateToProps, mapDispatchToProps)(LeftNavigation), -); \ No newline at end of file +); diff --git a/src/js/views/Device/components/LeftNavigation/Row/index.js b/src/js/views/Device/components/LeftNavigation/Row/index.js index 6436531f..de5f8209 100644 --- a/src/js/views/Device/components/LeftNavigation/Row/index.js +++ b/src/js/views/Device/components/LeftNavigation/Row/index.js @@ -2,7 +2,6 @@ import styled, { css } from 'styled-components'; import React from 'react'; import PropTypes from 'prop-types'; -import colors from 'config/colors'; import { TRANSITION_TIME } from 'config/variables'; const Wrapper = styled.div` diff --git a/src/js/views/Device/components/LeftNavigation/common.js b/src/js/views/Device/components/LeftNavigation/common.js index b8d60525..4a5a8f72 100644 --- a/src/js/views/Device/components/LeftNavigation/common.js +++ b/src/js/views/Device/components/LeftNavigation/common.js @@ -1,8 +1,28 @@ -import PropTypes from 'prop-types'; +/* @flow */ +import * as TrezorConnectActions from 'actions/TrezorConnectActions'; +import { toggleDeviceDropdown } from 'actions/WalletActions'; -export const coinProp = { - coin: PropTypes.shape({ - img: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - }).isRequired, -}; +export type StateProps = { + connect: $ElementType, + accounts: $ElementType, + router: $ElementType, + deviceDropdownOpened: boolean, + fiat: $ElementType, + localStorage: $ElementType, + discovery: $ElementType, + wallet: $ElementType, + devices: $ElementType, + pending: $ElementType, +} + +export type DispatchProps = { + toggleDeviceDropdown: typeof toggleDeviceDropdown, + addAccount: typeof TrezorConnectActions.addAccount, + acquireDevice: typeof TrezorConnectActions.acquire, + forgetDevice: typeof TrezorConnectActions.forget, + duplicateDevice: typeof TrezorConnectActions.duplicateDevice, + gotoDeviceSettings: typeof TrezorConnectActions.gotoDeviceSettings, + onSelectDevice: typeof TrezorConnectActions.onSelectDevice, +} + +export type Props = StateProps & DispatchProps; \ No newline at end of file diff --git a/src/js/views/Device/components/LeftNavigation/selection/AccountSelection.js b/src/js/views/Device/components/LeftNavigation/selection/AccountSelection.js index c43ee67a..d9243213 100644 --- a/src/js/views/Device/components/LeftNavigation/selection/AccountSelection.js +++ b/src/js/views/Device/components/LeftNavigation/selection/AccountSelection.js @@ -1,26 +1,22 @@ /* @flow */ - - -import React, { PureComponent } from 'react'; -import { Link, NavLink } from 'react-router-dom'; import BigNumber from 'bignumber.js'; - -import { findDeviceAccounts } from 'reducers/AccountsReducer'; -import * as stateUtils from 'reducers/utils'; +import colors from 'config/colors'; import Loader from 'components/common/LoaderCircle'; +import PropTypes from 'prop-types'; +import React from 'react'; +import styled, { css } from 'styled-components'; +import * as stateUtils from 'reducers/utils'; import Tooltip from 'rc-tooltip'; -import colors from 'config/colors'; +import { NavLink } from 'react-router-dom'; +import { findDeviceAccounts } from 'reducers/AccountsReducer'; import { FONT_SIZE, BORDER_WIDTH } from 'config/variables'; -import styled, { css } from 'styled-components'; -import Row from '../Row'; -import PropTypes from 'prop-types'; -//import AsideRowAccount from './row/account/AsideRowAccount'; - -import type { TrezorDevice, Accounts } from 'flowtype'; +import type { Accounts } from 'flowtype'; import type { Props } from './index'; +import Row from '../Row'; + const RowAccountWrapper = styled.div` height: 64px; diff --git a/src/js/views/Device/components/LeftNavigation/selection/CoinSelection.js b/src/js/views/Device/components/LeftNavigation/selection/CoinSelection.js index c3cafddb..b86466c9 100644 --- a/src/js/views/Device/components/LeftNavigation/selection/CoinSelection.js +++ b/src/js/views/Device/components/LeftNavigation/selection/CoinSelection.js @@ -1,7 +1,6 @@ /* @flow */ import coins from 'constants/coins'; import colors from 'config/colors'; -import { FONT_SIZE } from 'config/variables'; import Icon from 'components/common/Icon'; import ICONS from 'config/icons'; import { NavLink } from 'react-router-dom'; @@ -9,15 +8,11 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import styled from 'styled-components'; -import { ICON_SIZE } from 'config/variables'; -import { coinProp } from '../common'; +import { FONT_SIZE, ICON_SIZE } from 'config/variables'; + import Divider from '../Divider'; import Row from '../Row'; -import type { TrezorDevice } from 'flowtype'; -import type { Props } from './index'; - - const CoinNameWrapper = styled.div` display: flex; align-items: center; @@ -43,7 +38,6 @@ const CoinName = ({

{text}

); - CoinName.propTypes = { coinImg: PropTypes.string.isRequired, text: PropTypes.string.isRequired, @@ -77,9 +71,11 @@ const RowCoin = ({ ); - RowCoin.propTypes = { - ...coinProp, + coin: PropTypes.shape({ + img: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + }).isRequired, icon: PropTypes.shape({ type: PropTypes.string.isRequired, color: PropTypes.string.isRequired, diff --git a/src/js/views/Device/components/LeftNavigation/selection/DeviceSelection.js b/src/js/views/Device/components/LeftNavigation/selection/DeviceSelection.js index 276da1bc..06c60079 100644 --- a/src/js/views/Device/components/LeftNavigation/selection/DeviceSelection.js +++ b/src/js/views/Device/components/LeftNavigation/selection/DeviceSelection.js @@ -1,14 +1,12 @@ /* @flow */ - - import React, { Component } from 'react'; -import Select from 'react-select'; import TrezorConnect from 'trezor-connect'; -import AsideDivider from '../Divider'; - import type { TrezorDevice } from 'flowtype'; -import type { Props } from './index'; + +import type { Props } from '../common'; + +import AsideDivider from '../Divider'; export const DeviceSelect = (props: Props) => { const { devices } = props; From 113b2535e0a5ebd7d1c78abc929f8befe3761fdf Mon Sep 17 00:00:00 2001 From: Vasek Mlejnsky Date: Thu, 16 Aug 2018 16:26:44 +0200 Subject: [PATCH 3/3] Rename 'Selection' components to 'Menu' in 'LeftNavigation' --- .../AccountMenu/index.js} | 36 +++++++------- .../CoinMenu/index.js} | 48 +++++++++---------- .../DeviceMenu/index.js} | 0 .../LeftNavigation/NavigationMenu/index.js | 4 ++ .../LeftNavigation/Selection/index.js | 4 -- .../Wallet/components/LeftNavigation/index.js | 14 +++--- 6 files changed, 53 insertions(+), 53 deletions(-) rename src/js/views/Wallet/components/LeftNavigation/{Selection/AccountSelection.js => NavigationMenu/AccountMenu/index.js} (91%) rename src/js/views/Wallet/components/LeftNavigation/{Selection/CoinSelection.js => NavigationMenu/CoinMenu/index.js} (86%) rename src/js/views/Wallet/components/LeftNavigation/{Selection/DeviceSelection.js => NavigationMenu/DeviceMenu/index.js} (100%) create mode 100644 src/js/views/Wallet/components/LeftNavigation/NavigationMenu/index.js delete mode 100644 src/js/views/Wallet/components/LeftNavigation/Selection/index.js diff --git a/src/js/views/Wallet/components/LeftNavigation/Selection/AccountSelection.js b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/AccountMenu/index.js similarity index 91% rename from src/js/views/Wallet/components/LeftNavigation/Selection/AccountSelection.js rename to src/js/views/Wallet/components/LeftNavigation/NavigationMenu/AccountMenu/index.js index eecbff04..611ff1fd 100644 --- a/src/js/views/Wallet/components/LeftNavigation/Selection/AccountSelection.js +++ b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/AccountMenu/index.js @@ -45,22 +45,22 @@ const RowAccountWrapper = styled.div` const RowAccount = ({ accountIndex, balance, url, isSelected = false, }) => ( - - - - Account #{accountIndex + 1} - {balance ? ( - {balance} - ) : ( - Loading... - )} - - - -); + + + + Account #{accountIndex + 1} + {balance ? ( + {balance} + ) : ( + Loading... + )} + + + + ); RowAccount.propTypes = { accountIndex: PropTypes.number.isRequired, url: PropTypes.string.isRequired, @@ -68,7 +68,7 @@ RowAccount.propTypes = { isSelected: PropTypes.bool, }; -const AccountSelection = (props: Props): ?React$Element => { +const AccountMenu = (props: Props): ?React$Element => { const selected = props.wallet.selectedDevice; if (!selected) return null; @@ -204,4 +204,4 @@ const AccountSelection = (props: Props): ?React$Element => { ); }; -export default AccountSelection; +export default AccountMenu; diff --git a/src/js/views/Wallet/components/LeftNavigation/Selection/CoinSelection.js b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/CoinMenu/index.js similarity index 86% rename from src/js/views/Wallet/components/LeftNavigation/Selection/CoinSelection.js rename to src/js/views/Wallet/components/LeftNavigation/NavigationMenu/CoinMenu/index.js index 3379af09..b3b36c7a 100644 --- a/src/js/views/Wallet/components/LeftNavigation/Selection/CoinSelection.js +++ b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/CoinMenu/index.js @@ -31,13 +31,13 @@ const Logo = styled.div` const CoinName = ({ coinImg, text, }) => ( - - -

{text}

-
-); + + +

{text}

+
+ ); CoinName.propTypes = { coinImg: PropTypes.string.isRequired, text: PropTypes.string.isRequired, @@ -56,21 +56,21 @@ const RowCoinWrapper = styled.div` const RowCoin = ({ coin, icon, }) => ( - - - - {icon && ( - + + - )} - - -); + {icon && ( + + )} + + + ); RowCoin.propTypes = { coin: PropTypes.shape({ img: PropTypes.string.isRequired, @@ -83,7 +83,7 @@ RowCoin.propTypes = { }; -class CoinSelection extends Component { +class CoinMenu extends Component { getBaseUrl() { const { selectedDevice } = this.props.wallet; let baseUrl = ''; @@ -147,11 +147,11 @@ class CoinSelection extends Component { } } -CoinSelection.propTypes = { +CoinMenu.propTypes = { config: PropTypes.object, wallet: PropTypes.object, selectedDevice: PropTypes.object, localStorage: PropTypes.object, }; -export default CoinSelection; +export default CoinMenu; diff --git a/src/js/views/Wallet/components/LeftNavigation/Selection/DeviceSelection.js b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/DeviceMenu/index.js similarity index 100% rename from src/js/views/Wallet/components/LeftNavigation/Selection/DeviceSelection.js rename to src/js/views/Wallet/components/LeftNavigation/NavigationMenu/DeviceMenu/index.js diff --git a/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/index.js b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/index.js new file mode 100644 index 00000000..aab425a4 --- /dev/null +++ b/src/js/views/Wallet/components/LeftNavigation/NavigationMenu/index.js @@ -0,0 +1,4 @@ +export { default as AccountMenu } from './AccountMenu'; +export { default as CoinMenu } from './CoinMenu'; +export { DeviceSelect } from './DeviceMenu'; +export { DeviceDropdown } from './DeviceMenu'; diff --git a/src/js/views/Wallet/components/LeftNavigation/Selection/index.js b/src/js/views/Wallet/components/LeftNavigation/Selection/index.js deleted file mode 100644 index 2d5ec492..00000000 --- a/src/js/views/Wallet/components/LeftNavigation/Selection/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as AccountSelection } from './AccountSelection'; -export { default as CoinSelection } from './CoinSelection'; -export { DeviceSelect } from './DeviceSelection'; -export { DeviceDropdown } from './DeviceSelection'; diff --git a/src/js/views/Wallet/components/LeftNavigation/index.js b/src/js/views/Wallet/components/LeftNavigation/index.js index 6554e706..8476eefe 100644 --- a/src/js/views/Wallet/components/LeftNavigation/index.js +++ b/src/js/views/Wallet/components/LeftNavigation/index.js @@ -5,11 +5,11 @@ import styled from 'styled-components'; import type { TrezorDevice } from 'flowtype'; import { - AccountSelection, - CoinSelection, + AccountMenu, + CoinMenu, DeviceSelect, DeviceDropdown, -} from './Selection'; +} from './Menu'; import StickyContainer from './StickyContainer'; import type { Props } from './index'; @@ -72,7 +72,7 @@ const LeftNavigation = (props: Props): React$Element - // + // // // ); } else if (selected.features && !selected.features.bootloader_mode && selected.features.initialized) { @@ -81,7 +81,7 @@ const LeftNavigation = (props: Props): React$Element - // + // // // ); } @@ -97,8 +97,8 @@ const LeftNavigation = (props: Props): React$Element - {animationType === 'slide-left' && } - {animationType === 'slide-right' && } + {animationType === 'slide-left' && } + {animationType === 'slide-right' && } )}