diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-07-07 08:58:46 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-07-07 08:58:46 +0800 |
commit | 7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2 (patch) | |
tree | 5364558379541311895ddd20c2675739541da5e4 /ui | |
parent | 2c89cd722ed66f9f8522913b1a5bbc55ce5a7ca6 (diff) | |
download | tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.tar tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.tar.gz tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.tar.bz2 tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.tar.lz tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.tar.xz tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.tar.zst tangerine-wallet-browser-7058dc4ee3d00f4d4e407c656cf671b2d4fd62f2.zip |
Began reworking tx conf view
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/account-panel.js | 2 | ||||
-rw-r--r-- | ui/app/components/mini-account-panel.js | 105 | ||||
-rw-r--r-- | ui/app/components/pending-tx-details.js | 83 | ||||
-rw-r--r-- | ui/app/css/lib.css | 6 | ||||
-rw-r--r-- | ui/app/reducers.js | 1 | ||||
-rw-r--r-- | ui/app/util.js | 14 | ||||
-rw-r--r-- | ui/lib/contract-namer.js | 17 |
7 files changed, 210 insertions, 18 deletions
diff --git a/ui/app/components/account-panel.js b/ui/app/components/account-panel.js index d50522fa2..abaaf8163 100644 --- a/ui/app/components/account-panel.js +++ b/ui/app/components/account-panel.js @@ -22,7 +22,7 @@ AccountPanel.prototype.render = function () { var panelState = { key: `accountPanel${identity.address}`, identiconKey: identity.address, - identiconLabel: identity.name, + identiconLabel: identity.name || '', attributes: [ { key: 'ADDRESS', diff --git a/ui/app/components/mini-account-panel.js b/ui/app/components/mini-account-panel.js new file mode 100644 index 000000000..745ff2077 --- /dev/null +++ b/ui/app/components/mini-account-panel.js @@ -0,0 +1,105 @@ +const inherits = require('util').inherits +const Component = require('react').Component +const h = require('react-hyperscript') +const Identicon = require('./identicon') +const formatBalance = require('../util').formatBalance +const TransactionIcon = require('./transaction-list-item-icon') + +module.exports = AccountPanel + + +inherits(AccountPanel, Component) +function AccountPanel () { + Component.call(this) +} + +AccountPanel.prototype.render = function () { + var props = this.props + var picOrder = props.picOrder || 'left' + var isFauceting = props.isFauceting + const { attrs, imageSeed } = props + + return ( + + h('.identity-panel.flex-row.flex-left', { + style: { + cursor: props.onClick ? 'pointer' : undefined, + }, + onClick: props.onClick, + }, [ + + this.genIcon(imageSeed, picOrder), + + h('div.flex-column.flex-justify-center', { + style: { + lineHeight: '15px', + order: 2, + display: 'flex', + alignItems: picOrder === 'left' ? 'flex-begin' : 'flex-end', + }, + }, [ + + props.attrs.map((attr) => { + return h('span.font-small', { + key: `mini-${attr}`, + style: { + fontFamily: 'Montserrat UltraLight, Montserrat Light, Montserrat', + }, + }, attr) + }), + + ]), + + ]) + ) +} + +AccountPanel.prototype.genIcon= function(seed, picOrder) { + const props = this.props + + // When there is no seed value, this is a contract creation. + // We then show the contract icon. + if (!seed) { + return h('.identicon-wrapper.flex-column.select-none', { + style: { + order: picOrder === 'left' ? 1 : 3, + }, + }, [ + h('i.fa.fa-file-text-o.fa-lg', { + style: { + fontSize: '42px', + transform: 'translate(0px, -16px)', + }, + }) + ]) + } + + // If there was a seed, we return an identicon for that address. + return h('.identicon-wrapper.flex-column.select-none', { + style: { + order: picOrder === 'left' ? 1 : 3, + }, + }, [ + h(Identicon, { + address: seed, + imageify: props.imageifyIdenticons, + }), + ]) +} + +function balanceOrFaucetingIndication (account, isFauceting) { + // Temporarily deactivating isFauceting indication + // because it shows fauceting for empty restored accounts. + if (/* isFauceting*/ false) { + return { + key: 'Account is auto-funding.', + value: 'Please wait.', + } + } else { + return { + key: 'BALANCE', + value: formatBalance(account.balance), + } + } +} + diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js index 2ba613f20..0d972ea05 100644 --- a/ui/app/components/pending-tx-details.js +++ b/ui/app/components/pending-tx-details.js @@ -2,10 +2,11 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits -const AccountPanel = require('./account-panel') +const MiniAccountPanel = require('./mini-account-panel') const addressSummary = require('../util').addressSummary const readableDate = require('../util').readableDate const formatBalance = require('../util').formatBalance +const nameForAddress = require('../../lib/contract-namer') module.exports = PendingTxDetails @@ -14,12 +15,10 @@ function PendingTxDetails () { Component.call(this) } -PendingTxDetails.prototype.render = function () { - var state = this.props - return this.renderGeneric(h, state) -} +const PTXP = PendingTxDetails.prototype -PendingTxDetails.prototype.renderGeneric = function (h, state) { +PTXP.render = function () { + var state = this.props var txData = state.txData var txParams = txData.txParams || {} @@ -27,17 +26,39 @@ PendingTxDetails.prototype.renderGeneric = function (h, state) { var identity = state.identities[address] || { address: address } var account = state.accounts[address] || { address: address } - return ( + var isContractDeploy = !('to' in txParams) + return ( h('div', [ - // account that will sign - h(AccountPanel, { - showFullAddress: true, - identity: identity, - account: account, - imageifyIdenticons: state.imageifyIdenticons, - }), + h('.flex-row.flex-center', { + style: { + maxWidth: '100%', + }, + }, [ + + h(MiniAccountPanel, { + attrs: [ + identity.name, + addressSummary(address, 6, 4, false), + formatBalance(identity.balance), + ], + imageSeed: address, + imageifyIdenticons: state.imageifyIdenticons, + picOrder: 'right', + }), + + h('img', { + src: 'images/forward-carrat.svg', + style: { + padding: '5px 6px 0px 10px', + height: '48px', + }, + }), + + this.miniAccountPanelForRecipient(), + + ]), // tx data h('.tx-data.flex-column.flex-justify-center.flex-grow.select-none', [ @@ -59,7 +80,39 @@ PendingTxDetails.prototype.renderGeneric = function (h, state) { ]), ]) - ) +} +PTXP.miniAccountPanelForRecipient = function() { + var state = this.props + var txData = state.txData + + var txParams = txData.txParams || {} + var address = txParams.from || state.selectedAddress + var identity = state.identities[address] || { address: address } + var account = state.accounts[address] || { address: address } + + var isContractDeploy = !('to' in txParams) + + // If it's not a contract deploy, send to the account + if (!isContractDeploy) { + return h(MiniAccountPanel, { + attrs: [ + nameForAddress(txParams.to), + addressSummary(txParams.to, 6, 4, false), + ], + imageSeed: address, + imageifyIdenticons: state.imageifyIdenticons, + picOrder: 'left', + }) + } else { + return h(MiniAccountPanel, { + attrs: [ + 'New Contract' + ], + imageifyIdenticons: state.imageifyIdenticons, + picOrder: 'left', + }) + } } + diff --git a/ui/app/css/lib.css b/ui/app/css/lib.css index a7da11e77..22b26d4f1 100644 --- a/ui/app/css/lib.css +++ b/ui/app/css/lib.css @@ -220,3 +220,9 @@ hr.horizontal-line { .invisible { visibility: hidden; } + +.one-line-concat { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} diff --git a/ui/app/reducers.js b/ui/app/reducers.js index f198758ea..8a8f1c72b 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -35,6 +35,7 @@ function rootReducer (state, action) { state.appState = reduceApp(state, action) + console.log(JSON.stringify(state)) return state } diff --git a/ui/app/util.js b/ui/app/util.js index 4181b096f..d0ee57dee 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -21,6 +21,7 @@ for (var currency in valueTable) { module.exports = { valuesFor: valuesFor, addressSummary: addressSummary, + miniAddressSummary: miniAddressSummary, isAllOneCase: isAllOneCase, isValidAddress: isValidAddress, numericBalance: numericBalance, @@ -43,10 +44,19 @@ function valuesFor (obj) { .map(function (key) { return obj[key] }) } -function addressSummary (address) { +function addressSummary (address, firstSegLength = 10, lastSegLength = 4, includeHex = true) { + if (!address) return '' + let checked = ethUtil.toChecksumAddress(address) + if (!includeHex) { + checked = ethUtil.stripHexPrefix(checked) + } + return checked ? checked.slice(0, firstSegLength) + '...' + checked.slice(checked.length - lastSegLength) : '...' +} + +function miniAddressSummary (address) { if (!address) return '' var checked = ethUtil.toChecksumAddress(address) - return checked ? checked.slice(0, 2 + 8) + '...' + checked.slice(-4) : '...' + return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...' } function isValidAddress (address) { diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js new file mode 100644 index 000000000..eae066ad5 --- /dev/null +++ b/ui/lib/contract-namer.js @@ -0,0 +1,17 @@ +/* CONTRACT NAMER + * + * Takes an address, + * Returns a nicname if we have one stored, + * otherwise returns null. + */ + +const nicknames = {} + +module.exports = function(address) { + + if (address in nicknames) { + return nicknames[address] + } + + return null +} |