diff options
author | sdtsui <szehungdanieltsui@gmail.com> | 2017-08-14 17:06:14 +0800 |
---|---|---|
committer | sdtsui <szehungdanieltsui@gmail.com> | 2017-08-14 17:06:14 +0800 |
commit | dbc539ac558958fee339cb1ab43202385d98d089 (patch) | |
tree | 00296e883ff128f141df51915650fd5075f9cdd7 /ui/app | |
parent | 2eadf72fb772b5b6bd32f04c9d439cc0f1ab0453 (diff) | |
parent | 68c6b2d666719476bff78cbc107a56be3b86dbe1 (diff) | |
download | tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.tar tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.tar.gz tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.tar.bz2 tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.tar.lz tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.tar.xz tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.tar.zst tangerine-wallet-browser-dbc539ac558958fee339cb1ab43202385d98d089.zip |
Merge remote-tracking branch 'mm/master' into NewUI-flat
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/account-detail.js | 121 | ||||
-rw-r--r-- | ui/app/components/buy-button-subview.js | 156 | ||||
-rw-r--r-- | ui/app/components/dropdowns/components/account-dropdowns.js | 11 |
3 files changed, 241 insertions, 47 deletions
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js new file mode 100644 index 000000000..2be5d5c3a --- /dev/null +++ b/ui/app/account-detail.js @@ -0,0 +1,121 @@ +const inherits = require('util').inherits +const extend = require('xtend') +const Component = require('react').Component +const h = require('react-hyperscript') +const connect = require('react-redux').connect +const actions = require('./actions') +const valuesFor = require('./util').valuesFor +const Identicon = require('./components/identicon') +const EthBalance = require('./components/eth-balance') +const TransactionList = require('./components/transaction-list') +const ExportAccountView = require('./components/account-export') +const ethUtil = require('ethereumjs-util') +const EditableLabel = require('./components/editable-label') +const TabBar = require('./components/tab-bar') +const TokenList = require('./components/token-list') +const AccountDropdowns = require('./components/account-dropdowns').AccountDropdowns + +module.exports = connect(mapStateToProps)(AccountDetailScreen) + +function mapStateToProps (state) { + return { + metamask: state.metamask, + identities: state.metamask.identities, + accounts: state.metamask.accounts, + address: state.metamask.selectedAddress, + accountDetail: state.appState.accountDetail, + network: state.metamask.network, + unapprovedMsgs: valuesFor(state.metamask.unapprovedMsgs), + shapeShiftTxList: state.metamask.shapeShiftTxList, + transactions: state.metamask.selectedAddressTxList || [], + conversionRate: state.metamask.conversionRate, + currentCurrency: state.metamask.currentCurrency, + currentAccountTab: state.metamask.currentAccountTab, + tokens: state.metamask.tokens, + } +} + +inherits(AccountDetailScreen, Component) +function AccountDetailScreen () { + Component.call(this) +} + +// Note: This component is no longer used. Leaving the file for reference: +// - structuring routing for add token +// - state required for TxList +// Delete file when those features are complete +AccountDetailScreen.prototype.render = function () {} + +AccountDetailScreen.prototype.subview = function () { + var subview + try { + subview = this.props.accountDetail.subview + } catch (e) { + subview = null + } + + switch (subview) { + case 'transactions': + return this.tabSections() + case 'export': + var state = extend({key: 'export'}, this.props) + return h(ExportAccountView, state) + default: + return this.tabSections() + } +} + +AccountDetailScreen.prototype.tabSections = function () { + const { currentAccountTab } = this.props + + return h('section.tabSection.full-flex-height.grow-tenx', [ + + h(TabBar, { + tabs: [ + { content: 'Sent', key: 'history' }, + { content: 'Tokens', key: 'tokens' }, + ], + defaultTab: currentAccountTab || 'history', + tabSelected: (key) => { + this.props.dispatch(actions.setCurrentAccountTab(key)) + }, + }), + + this.tabSwitchView(), + ]) +} + +AccountDetailScreen.prototype.tabSwitchView = function () { + const props = this.props + const { address, network } = props + const { currentAccountTab, tokens } = this.props + + switch (currentAccountTab) { + case 'tokens': + return h(TokenList, { + userAddress: address, + network, + tokens, + addToken: () => this.props.dispatch(actions.showAddTokenPage()), + }) + default: + return this.transactionList() + } +} + +AccountDetailScreen.prototype.transactionList = function () { + const {transactions, unapprovedMsgs, address, + network, shapeShiftTxList, conversionRate } = this.props + + return h(TransactionList, { + transactions: transactions.sort((a, b) => b.time - a.time), + network, + unapprovedMsgs, + conversionRate, + address, + shapeShiftTxList, + viewPendingTx: (txId) => { + this.props.dispatch(actions.viewPendingTx(txId)) + }, + }) +} diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index 759eb15bd..15281171c 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -8,6 +8,7 @@ const ShapeshiftForm = require('./shapeshift-form') const Loading = require('./loading') const AccountPanel = require('./account-panel') const RadioList = require('./custom-radio-list') +const networkNames = require('../../../app/scripts/config.js').networkNames module.exports = connect(mapStateToProps)(BuyButtonSubview) @@ -30,16 +31,30 @@ function BuyButtonSubview () { } BuyButtonSubview.prototype.render = function () { + return ( + h('div', { + style: { + width: '100%', + }, + }, [ + this.headerSubview(), + this.primarySubview(), + ]) + ) +} + +BuyButtonSubview.prototype.headerSubview = function () { const props = this.props const isLoading = props.isSubLoading - return ( - h('.buy-eth-section.flex-column', { + + h('.flex-column', { style: { alignItems: 'center', }, }, [ - // back button + + // header bar (back button, label) h('.flex-row', { style: { alignItems: 'center', @@ -63,6 +78,8 @@ BuyButtonSubview.prototype.render = function () { }, }, 'Buy Eth'), ]), + + // loading indication h('div', { style: { position: 'absolute', @@ -70,8 +87,10 @@ BuyButtonSubview.prototype.render = function () { left: '49vw', }, }, [ - h(Loading, {isLoading}), + h(Loading, { isLoading }), ]), + + // account panel h('div', { style: { width: '80%', @@ -83,17 +102,92 @@ BuyButtonSubview.prototype.render = function () { account: props.account, }), ]), - h('h3.text-transform-uppercase', { + + h('.flex-row', { style: { - paddingLeft: '15px', - fontFamily: 'Montserrat Light', - width: '100vw', - background: 'rgb(235, 235, 235)', - color: 'rgb(174, 174, 174)', - paddingTop: '4px', - paddingBottom: '4px', + alignItems: 'center', + justifyContent: 'center', }, - }, 'Select Service'), + }, [ + h('h3.text-transform-uppercase.flex-center', { + style: { + paddingLeft: '15px', + width: '100vw', + background: 'rgb(235, 235, 235)', + color: 'rgb(174, 174, 174)', + paddingTop: '4px', + paddingBottom: '4px', + }, + }, 'Select Service'), + ]), + + ]) + + ) +} + + +BuyButtonSubview.prototype.primarySubview = function () { + const props = this.props + const network = props.network + + switch (network) { + case 'loading': + return + + case '1': + return this.mainnetSubview() + + // Ropsten, Rinkeby, Kovan + case '3': + case '4': + case '42': + const networkName = networkNames[network] + const label = `${networkName} Test Faucet` + return ( + h('div.flex-column', { + style: { + alignItems: 'center', + margin: '20px 50px', + }, + }, [ + h('button.text-transform-uppercase', { + onClick: () => this.props.dispatch(actions.buyEth({ network })), + style: { + marginTop: '15px', + }, + }, label), + // Kovan only: Dharma loans beta + network === '42' ? ( + h('button.text-transform-uppercase', { + onClick: () => this.navigateTo('https://borrow.dharma.io/'), + style: { + marginTop: '15px', + }, + }, 'Borrow With Dharma (Beta)') + ) : null, + ]) + ) + + default: + return ( + h('h2.error', 'Unknown network ID') + ) + + } +} + +BuyButtonSubview.prototype.mainnetSubview = function () { + const props = this.props + + return ( + + h('.flex-column', { + style: { + alignItems: 'center', + }, + }, [ + h('.flex-row.selected-exchange', { style: { position: 'relative', @@ -115,6 +209,7 @@ BuyButtonSubview.prototype.render = function () { onClick: this.radioHandler.bind(this), }), ]), + h('h3.text-transform-uppercase', { style: { paddingLeft: '15px', @@ -126,8 +221,10 @@ BuyButtonSubview.prototype.render = function () { paddingBottom: '4px', }, }, props.buyView.subview), + this.formVersionSubview(), ]) + ) } @@ -139,39 +236,6 @@ BuyButtonSubview.prototype.formVersionSubview = function () { } else if (this.props.buyView.formView.shapeshift) { return h(ShapeshiftForm, this.props) } - } else { - return h('div.flex-column', { - style: { - alignItems: 'center', - margin: '20px 50px', - }, - }, [ - h('h3.text-transform-uppercase', { - style: { - width: '225px', - marginBottom: '15px', - }, - }, 'In order to access this feature, please switch to the Main Network'), - ((network === '3') || (network === '4') || (network === '42')) ? h('h3.text-transform-uppercase', 'or go to the') : null, - (network === '3') ? h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), - style: { - marginTop: '15px', - }, - }, 'Ropsten Test Faucet') : null, - (network === '4') ? h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), - style: { - marginTop: '15px', - }, - }, 'Rinkeby Test Faucet') : null, - (network === '42') ? h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), - style: { - marginTop: '15px', - }, - }, 'Kovan Test Faucet') : null, - ]) } } diff --git a/ui/app/components/dropdowns/components/account-dropdowns.js b/ui/app/components/dropdowns/components/account-dropdowns.js index 11d109d73..b59f9bbf4 100644 --- a/ui/app/components/dropdowns/components/account-dropdowns.js +++ b/ui/app/components/dropdowns/components/account-dropdowns.js @@ -56,7 +56,16 @@ class AccountDropdowns extends Component { }, }, ), - h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, identity.name || ''), + h('span', { + style: { + marginLeft: '20px', + fontSize: '24px', + maxWidth: '145px', + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + }, + }, identity.name || ''), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null), ] ) |