mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-05 22:00:59 +00:00
add externalWallet to CoinMenu
This commit is contained in:
parent
a9246c0c06
commit
42841b0b84
@ -48,5 +48,6 @@ export default [
|
|||||||
id: 'xem',
|
id: 'xem',
|
||||||
coinName: 'NEM',
|
coinName: 'NEM',
|
||||||
url: 'https://nem.io/downloads/',
|
url: 'https://nem.io/downloads/',
|
||||||
|
external: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
@ -7,6 +7,7 @@ import { withRouter } from 'react-router-dom';
|
|||||||
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
||||||
import * as DiscoveryActions from 'actions/DiscoveryActions';
|
import * as DiscoveryActions from 'actions/DiscoveryActions';
|
||||||
import * as RouterActions from 'actions/RouterActions';
|
import * as RouterActions from 'actions/RouterActions';
|
||||||
|
import * as ModalActions from 'actions/ModalActions';
|
||||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
import type { State, Dispatch } from 'flowtype';
|
import type { State, Dispatch } from 'flowtype';
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
|
|||||||
duplicateDevice: bindActionCreators(TrezorConnectActions.duplicateDevice, dispatch),
|
duplicateDevice: bindActionCreators(TrezorConnectActions.duplicateDevice, dispatch),
|
||||||
gotoDeviceSettings: bindActionCreators(RouterActions.gotoDeviceSettings, dispatch),
|
gotoDeviceSettings: bindActionCreators(RouterActions.gotoDeviceSettings, dispatch),
|
||||||
onSelectDevice: bindActionCreators(RouterActions.selectDevice, dispatch),
|
onSelectDevice: bindActionCreators(RouterActions.selectDevice, dispatch),
|
||||||
|
gotoExternalWallet: bindActionCreators(ModalActions.gotoExternalWallet, dispatch),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(
|
export default withRouter(
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import coins from 'constants/coins';
|
import coins from 'constants/coins';
|
||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
@ -5,12 +7,19 @@ import ICONS from 'config/icons';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
|
import Link from 'components/Link';
|
||||||
import Divider from '../Divider';
|
import Divider from '../Divider';
|
||||||
import RowCoin from '../RowCoin';
|
import RowCoin from '../RowCoin';
|
||||||
|
|
||||||
|
import type { Props } from '../common';
|
||||||
|
|
||||||
const Wrapper = styled.div``;
|
const Wrapper = styled.div``;
|
||||||
|
|
||||||
class CoinMenu extends PureComponent {
|
const ExternalWallet = styled.div`
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
||||||
|
|
||||||
|
class CoinMenu extends PureComponent<Props> {
|
||||||
getBaseUrl() {
|
getBaseUrl() {
|
||||||
const { selectedDevice } = this.props.wallet;
|
const { selectedDevice } = this.props.wallet;
|
||||||
let baseUrl = '';
|
let baseUrl = '';
|
||||||
@ -24,6 +33,27 @@ class CoinMenu extends PureComponent {
|
|||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOtherCoins() {
|
||||||
|
return coins.map((coin) => {
|
||||||
|
const row = (
|
||||||
|
<RowCoin
|
||||||
|
coin={{
|
||||||
|
name: coin.coinName,
|
||||||
|
id: coin.id,
|
||||||
|
}}
|
||||||
|
iconRight={{
|
||||||
|
type: ICONS.SKIP,
|
||||||
|
color: colors.TEXT_SECONDARY,
|
||||||
|
size: 27,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (coin.external) return <ExternalWallet key={coin.id} onClick={() => this.props.gotoExternalWallet(coin.id, coin.url)}>{row}</ExternalWallet>;
|
||||||
|
return <Link key={coin.id} href={coin.url} target="_top">{row}</Link>;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { config } = this.props.localStorage;
|
const { config } = this.props.localStorage;
|
||||||
return (
|
return (
|
||||||
@ -46,31 +76,16 @@ class CoinMenu extends PureComponent {
|
|||||||
textRight="(You will be redirected)"
|
textRight="(You will be redirected)"
|
||||||
hasBorder
|
hasBorder
|
||||||
/>
|
/>
|
||||||
{coins.map(coin => (
|
{this.getOtherCoins()}
|
||||||
<a key={coin.id} href={coin.url}>
|
|
||||||
<RowCoin
|
|
||||||
coin={{
|
|
||||||
name: coin.coinName,
|
|
||||||
id: coin.id,
|
|
||||||
}}
|
|
||||||
iconRight={{
|
|
||||||
type: ICONS.SKIP,
|
|
||||||
color: colors.TEXT_SECONDARY,
|
|
||||||
size: 27,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
))}
|
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoinMenu.propTypes = {
|
CoinMenu.propTypes = {
|
||||||
config: PropTypes.object,
|
localStorage: PropTypes.object.isRequired,
|
||||||
wallet: PropTypes.object,
|
wallet: PropTypes.object.isRequired,
|
||||||
selectedDevice: PropTypes.object,
|
gotoExternalWallet: PropTypes.func.isRequired,
|
||||||
localStorage: PropTypes.object,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CoinMenu;
|
export default CoinMenu;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
||||||
import * as DiscoveryActions from 'actions/DiscoveryActions';
|
import * as DiscoveryActions from 'actions/DiscoveryActions';
|
||||||
import * as RouterActions from 'actions/RouterActions';
|
import * as RouterActions from 'actions/RouterActions';
|
||||||
|
import * as ModalActions from 'actions/ModalActions';
|
||||||
import { toggleDeviceDropdown } from 'actions/WalletActions';
|
import { toggleDeviceDropdown } from 'actions/WalletActions';
|
||||||
import type { State } from 'flowtype';
|
import type { State } from 'flowtype';
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ export type DispatchProps = {
|
|||||||
duplicateDevice: typeof TrezorConnectActions.duplicateDevice,
|
duplicateDevice: typeof TrezorConnectActions.duplicateDevice,
|
||||||
gotoDeviceSettings: typeof RouterActions.gotoDeviceSettings,
|
gotoDeviceSettings: typeof RouterActions.gotoDeviceSettings,
|
||||||
onSelectDevice: typeof RouterActions.selectDevice,
|
onSelectDevice: typeof RouterActions.selectDevice,
|
||||||
|
gotoExternalWallet: typeof ModalActions.gotoExternalWallet,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
Loading…
Reference in New Issue
Block a user