Merge branch 'develop' of github.com:MetaMask/metamask-extension into initial-trezor-support

feature/default_network_editable
brunobar79 6 years ago
commit cb53d5122c
  1. 3
      app/_locales/en/messages.json
  2. 4
      test/integration/lib/tx-list-items.js
  3. 37
      ui/app/components/send/currency-display/currency-display.js
  4. 10
      ui/app/components/tx-list-item.js
  5. 10
      ui/app/css/itcss/components/transaction-list.scss

@ -623,6 +623,9 @@
"noDeposits": { "noDeposits": {
"message": "No deposits received" "message": "No deposits received"
}, },
"noConversionRateAvailable":{
"message": "No Conversion Rate Available"
},
"noTransactionHistory": { "noTransactionHistory": {
"message": "No transaction history." "message": "No transaction history."
}, },

@ -31,8 +31,8 @@ async function runTxListItemsTest (assert, done) {
assert.equal($(unapprovedTx).hasClass('tx-list-pending-item-container'), true, 'unapprovedTx has the correct class') assert.equal($(unapprovedTx).hasClass('tx-list-pending-item-container'), true, 'unapprovedTx has the correct class')
const retryTx = txListItems[1] const retryTx = txListItems[1]
const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-link') const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-container span')
assert.equal(retryTxLink[0].textContent, 'Increase the gas price on your transaction', 'retryTx has expected link') assert.equal(retryTxLink[0].textContent, 'Taking too long? Increase the gas price on your transaction', 'retryTx has expected link')
const approvedTx = txListItems[2] const approvedTx = txListItems[2]
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.tx-list-status') const approvedTxRenderedStatus = await findAsync($(approvedTx), '.tx-list-status')

@ -6,6 +6,11 @@ const { removeLeadingZeroes } = require('../send.utils')
const currencyFormatter = require('currency-formatter') const currencyFormatter = require('currency-formatter')
const currencies = require('currency-formatter/currencies') const currencies = require('currency-formatter/currencies')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const PropTypes = require('prop-types')
CurrencyDisplay.contextTypes = {
t: PropTypes.func,
}
module.exports = CurrencyDisplay module.exports = CurrencyDisplay
@ -75,6 +80,12 @@ CurrencyDisplay.prototype.getValueToRender = function ({ selectedToken, conversi
CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) { CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) {
const { primaryCurrency, convertedCurrency, conversionRate } = this.props const { primaryCurrency, convertedCurrency, conversionRate } = this.props
if (conversionRate === 0 || conversionRate === null || conversionRate === undefined) {
if (nonFormattedValue !== 0) {
return null
}
}
let convertedValue = conversionUtil(nonFormattedValue, { let convertedValue = conversionUtil(nonFormattedValue, {
fromNumericBase: 'dec', fromNumericBase: 'dec',
fromCurrency: primaryCurrency, fromCurrency: primaryCurrency,
@ -82,16 +93,15 @@ CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValu
numberOfDecimals: 2, numberOfDecimals: 2,
conversionRate, conversionRate,
}) })
convertedValue = Number(convertedValue).toFixed(2)
convertedValue = Number(convertedValue).toFixed(2)
const upperCaseCurrencyCode = convertedCurrency.toUpperCase() const upperCaseCurrencyCode = convertedCurrency.toUpperCase()
return currencies.find(currency => currency.code === upperCaseCurrencyCode) return currencies.find(currency => currency.code === upperCaseCurrencyCode)
? currencyFormatter.format(Number(convertedValue), { ? currencyFormatter.format(Number(convertedValue), {
code: upperCaseCurrencyCode, code: upperCaseCurrencyCode,
}) })
: convertedValue : convertedValue
} }
CurrencyDisplay.prototype.handleChange = function (newVal) { CurrencyDisplay.prototype.handleChange = function (newVal) {
this.setState({ valueToRender: removeLeadingZeroes(newVal) }) this.setState({ valueToRender: removeLeadingZeroes(newVal) })
@ -105,13 +115,24 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) {
return (valueLength + decimalPointDeficit + 0.75) + 'ch' return (valueLength + decimalPointDeficit + 0.75) + 'ch'
} }
CurrencyDisplay.prototype.onlyRenderConversions = function (convertedValueToRender) {
const {
convertedBalanceClassName = 'currency-display__converted-value',
convertedCurrency,
} = this.props
return h('div', {
className: convertedBalanceClassName,
}, convertedValueToRender == null
? this.context.t('noConversionRateAvailable')
: `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`
)
}
CurrencyDisplay.prototype.render = function () { CurrencyDisplay.prototype.render = function () {
const { const {
className = 'currency-display', className = 'currency-display',
primaryBalanceClassName = 'currency-display__input', primaryBalanceClassName = 'currency-display__input',
convertedBalanceClassName = 'currency-display__converted-value',
primaryCurrency, primaryCurrency,
convertedCurrency,
readOnly = false, readOnly = false,
inError = false, inError = false,
onBlur, onBlur,
@ -157,11 +178,7 @@ CurrencyDisplay.prototype.render = function () {
]), ]),
]), ]), this.onlyRenderConversions(convertedValueToRender),
h('div', {
className: convertedBalanceClassName,
}, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`),
]) ])

@ -307,11 +307,7 @@ TxListItem.prototype.render = function () {
]), ]),
]), ]),
this.showRetryButton() && h('div.tx-list-item-retry-container', [ this.showRetryButton() && h('.tx-list-item-retry-container', {
h('span.tx-list-item-retry-copy', 'Taking too long?'),
h('span.tx-list-item-retry-link', {
onClick: (event) => { onClick: (event) => {
event.stopPropagation() event.stopPropagation()
if (isTokenTx) { if (isTokenTx) {
@ -319,8 +315,8 @@ TxListItem.prototype.render = function () {
} }
this.resubmit() this.resubmit()
}, },
}, 'Increase the gas price on your transaction'), }, [
h('span', 'Taking too long? Increase the gas price on your transaction'),
]), ]),
]), // holding on icon from design ]), // holding on icon from design

@ -129,12 +129,14 @@
.tx-list-item-retry-container { .tx-list-item-retry-container {
background: #d1edff; background: #d1edff;
width: 100%; width: 100%;
border-radius: 4px; border-radius: 12px;
font-size: 0.8em; font-size: .75rem;
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-left: 44px; margin-left: 44px;
width: calc(100% - 44px); width: calc(100% - 44px);
padding: 4px;
cursor: pointer;
@media screen and (min-width: 576px) and (max-width: 679px) { @media screen and (min-width: 576px) and (max-width: 679px) {
flex-flow: column; flex-flow: column;
@ -151,10 +153,6 @@
} }
} }
.tx-list-item-retry-copy {
font-family: Roboto;
}
.tx-list-item-retry-link { .tx-list-item-retry-link {
text-decoration: underline; text-decoration: underline;
margin-left: 6px; margin-left: 6px;

Loading…
Cancel
Save