aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/token-view-balance
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-08-24 07:44:38 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-08-24 07:45:28 +0800
commit342522c6cf23670f931e69ba822eedfd2d6ee252 (patch)
tree7aac360f85308b3022d6f673a5c572385854e690 /ui/app/components/token-view-balance
parent2d76ee754b1dd2473d744ce2dba2a3501c9a149c (diff)
downloadtangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.gz
tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.zst
tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.zip
Fix naming, add eth.getCode check for actions, fix translations for statuses
Diffstat (limited to 'ui/app/components/token-view-balance')
-rw-r--r--ui/app/components/token-view-balance/index.js1
-rw-r--r--ui/app/components/token-view-balance/index.scss76
-rw-r--r--ui/app/components/token-view-balance/tests/token-view-balance.component.test.js71
-rw-r--r--ui/app/components/token-view-balance/token-view-balance.component.js94
-rw-r--r--ui/app/components/token-view-balance/token-view-balance.container.js30
5 files changed, 0 insertions, 272 deletions
diff --git a/ui/app/components/token-view-balance/index.js b/ui/app/components/token-view-balance/index.js
deleted file mode 100644
index e0509096a..000000000
--- a/ui/app/components/token-view-balance/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './token-view-balance.container'
diff --git a/ui/app/components/token-view-balance/index.scss b/ui/app/components/token-view-balance/index.scss
deleted file mode 100644
index b522a10f9..000000000
--- a/ui/app/components/token-view-balance/index.scss
+++ /dev/null
@@ -1,76 +0,0 @@
-.token-view-balance {
- display: flex;
- justify-content: space-between;
- align-items: center;
- flex: 1;
- height: 54px;
-
- &__balance {
- margin-left: 12px;
- display: flex;
- flex-direction: column;
-
- @media screen and (max-width: $break-small) {
- align-items: center;
- margin: 16px 0;
- }
- }
-
- &__token-balance {
- margin-left: 12px;
- font-size: 1.5rem;
-
- @media screen and (max-width: $break-small) {
- margin-bottom: 12px;
- font-size: 1.75rem;
- }
- }
-
- &__primary-balance {
- font-size: 1.5rem;
-
- @media screen and (max-width: $break-small) {
- margin-bottom: 12px;
- font-size: 1.75rem;
- }
- }
-
- &__secondary-balance {
- font-size: 1.15rem;
- color: #a0a0a0;
- }
-
- &__balance-container {
- flex: 1;
- display: flex;
- flex-direction: row;
- align-items: center;
-
- @media screen and (max-width: $break-small) {
- flex-direction: column;
- }
- }
-
- &__buttons {
- display: flex;
- flex-direction: row;
-
- @media screen and (max-width: $break-small) {
- margin-bottom: 16px;
- }
- }
-
- &__button {
- min-width: initial;
- width: 100px;
-
- &:not(:last-child) {
- margin-right: 12px;
- }
- }
-
- @media screen and (max-width: $break-small) {
- flex-direction: column;
- height: initial
- }
-}
diff --git a/ui/app/components/token-view-balance/tests/token-view-balance.component.test.js b/ui/app/components/token-view-balance/tests/token-view-balance.component.test.js
deleted file mode 100644
index 909b4dc7f..000000000
--- a/ui/app/components/token-view-balance/tests/token-view-balance.component.test.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import React from 'react'
-import assert from 'assert'
-import { shallow } from 'enzyme'
-import sinon from 'sinon'
-import TokenBalance from '../../token-balance'
-import CurrencyDisplay from '../../currency-display'
-import { SEND_ROUTE } from '../../../routes'
-import TokenViewBalance from '../token-view-balance.component'
-
-const propsMethodSpies = {
- showDepositModal: sinon.spy(),
-}
-
-const historySpies = {
- push: sinon.spy(),
-}
-
-const t = (str1, str2) => str2 ? str1 + str2 : str1
-
-describe('TokenViewBalance Component', () => {
- afterEach(() => {
- propsMethodSpies.showDepositModal.resetHistory()
- historySpies.push.resetHistory()
- })
-
- it('should render ETH balance properly', () => {
- const wrapper = shallow(<TokenViewBalance
- showDepositModal={propsMethodSpies.showDepositModal}
- history={historySpies}
- network="3"
- ethBalance={123}
- fiatBalance={456}
- currentCurrency="usd"
- />, { context: { t } })
-
- assert.equal(wrapper.find('.token-view-balance').length, 1)
- assert.equal(wrapper.find('.token-view-balance__button').length, 2)
- assert.equal(wrapper.find(CurrencyDisplay).length, 2)
-
- const buttons = wrapper.find('.token-view-balance__buttons')
- assert.equal(propsMethodSpies.showDepositModal.callCount, 0)
- buttons.childAt(0).simulate('click')
- assert.equal(propsMethodSpies.showDepositModal.callCount, 1)
- assert.equal(historySpies.push.callCount, 0)
- buttons.childAt(1).simulate('click')
- assert.equal(historySpies.push.callCount, 1)
- assert.equal(historySpies.push.getCall(0).args[0], SEND_ROUTE)
- })
-
- it('should render token balance properly', () => {
- const token = {
- address: '0x35865238f0bec9d5ce6abff0fdaebe7b853dfcc5',
- decimals: '2',
- symbol: 'ABC',
- }
-
- const wrapper = shallow(<TokenViewBalance
- showDepositModal={propsMethodSpies.showDepositModal}
- history={historySpies}
- network="3"
- ethBalance={123}
- fiatBalance={456}
- currentCurrency="usd"
- selectedToken={token}
- />, { context: { t } })
-
- assert.equal(wrapper.find('.token-view-balance').length, 1)
- assert.equal(wrapper.find('.token-view-balance__button').length, 1)
- assert.equal(wrapper.find(TokenBalance).length, 1)
- })
-})
diff --git a/ui/app/components/token-view-balance/token-view-balance.component.js b/ui/app/components/token-view-balance/token-view-balance.component.js
deleted file mode 100644
index 89e9246e2..000000000
--- a/ui/app/components/token-view-balance/token-view-balance.component.js
+++ /dev/null
@@ -1,94 +0,0 @@
-import React, { PureComponent } from 'react'
-import PropTypes from 'prop-types'
-import Button from '../button'
-import Identicon from '../identicon'
-import TokenBalance from '../token-balance'
-import CurrencyDisplay from '../currency-display'
-import { SEND_ROUTE } from '../../routes'
-import { ETH } from '../../constants/common'
-
-export default class TokenViewBalance extends PureComponent {
- static contextTypes = {
- t: PropTypes.func,
- }
-
- static propTypes = {
- showDepositModal: PropTypes.func,
- selectedToken: PropTypes.object,
- history: PropTypes.object,
- network: PropTypes.string,
- balance: PropTypes.string,
- }
-
- renderBalance () {
- const { selectedToken, balance } = this.props
-
- return selectedToken
- ? (
- <TokenBalance
- token={selectedToken}
- withSymbol
- className="token-view-balance__token-balance"
- />
- ) : (
- <div className="token-view-balance__balance">
- <CurrencyDisplay
- className="token-view-balance__primary-balance"
- value={balance}
- currency={ETH}
- numberOfDecimals={3}
- />
- <CurrencyDisplay
- className="token-view-balance__secondary-balance"
- value={balance}
- />
- </div>
- )
- }
-
- renderButtons () {
- const { t } = this.context
- const { selectedToken, showDepositModal, history } = this.props
-
- return (
- <div className="token-view-balance__buttons">
- {
- !selectedToken && (
- <Button
- type="primary"
- className="token-view-balance__button"
- onClick={() => showDepositModal()}
- >
- { t('deposit') }
- </Button>
- )
- }
- <Button
- type="primary"
- className="token-view-balance__button"
- onClick={() => history.push(SEND_ROUTE)}
- >
- { t('send') }
- </Button>
- </div>
- )
- }
-
- render () {
- const { network, selectedToken } = this.props
-
- return (
- <div className="token-view-balance">
- <div className="token-view-balance__balance-container">
- <Identicon
- diameter={50}
- address={selectedToken && selectedToken.address}
- network={network}
- />
- { this.renderBalance() }
- </div>
- { this.renderButtons() }
- </div>
- )
- }
-}
diff --git a/ui/app/components/token-view-balance/token-view-balance.container.js b/ui/app/components/token-view-balance/token-view-balance.container.js
deleted file mode 100644
index f6cdc30e1..000000000
--- a/ui/app/components/token-view-balance/token-view-balance.container.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import { connect } from 'react-redux'
-import { withRouter } from 'react-router-dom'
-import { compose } from 'recompose'
-import TokenViewBalance from './token-view-balance.component'
-import { getSelectedToken, getSelectedAddress } from '../../selectors'
-import { showModal } from '../../actions'
-
-const mapStateToProps = state => {
- const selectedAddress = getSelectedAddress(state)
- const { metamask: { network, accounts } } = state
- const account = accounts[selectedAddress]
- const { balance } = account
-
- return {
- selectedToken: getSelectedToken(state),
- network,
- balance,
- }
-}
-
-const mapDispatchToProps = dispatch => {
- return {
- showDepositModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER' })),
- }
-}
-
-export default compose(
- withRouter,
- connect(mapStateToProps, mapDispatchToProps)
-)(TokenViewBalance)