Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
Browse files Browse the repository at this point in the history
… initial-trezor-support
  • Loading branch information
brunobar79 committed Jul 18, 2018
2 parents cb97517 + 89911dd commit cb53d51
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 33 deletions.
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@
"noDeposits": {
"message": "No deposits received"
},
"noConversionRateAvailable":{
"message": "No Conversion Rate Available"
},
"noTransactionHistory": {
"message": "No transaction history."
},
Expand Down
4 changes: 2 additions & 2 deletions test/integration/lib/tx-list-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ async function runTxListItemsTest (assert, done) {
assert.equal($(unapprovedTx).hasClass('tx-list-pending-item-container'), true, 'unapprovedTx has the correct class')

const retryTx = txListItems[1]
const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-link')
assert.equal(retryTxLink[0].textContent, 'Increase the gas price on your transaction', 'retryTx has expected link')
const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-container span')
assert.equal(retryTxLink[0].textContent, 'Taking too long? Increase the gas price on your transaction', 'retryTx has expected link')

const approvedTx = txListItems[2]
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.tx-list-status')
Expand Down
39 changes: 28 additions & 11 deletions ui/app/components/send/currency-display/currency-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const { removeLeadingZeroes } = require('../send.utils')
const currencyFormatter = require('currency-formatter')
const currencies = require('currency-formatter/currencies')
const ethUtil = require('ethereumjs-util')
const PropTypes = require('prop-types')

CurrencyDisplay.contextTypes = {
t: PropTypes.func,
}

module.exports = CurrencyDisplay

Expand Down Expand Up @@ -75,23 +80,28 @@ CurrencyDisplay.prototype.getValueToRender = function ({ selectedToken, conversi
CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) {
const { primaryCurrency, convertedCurrency, conversionRate } = this.props

if (conversionRate === 0 || conversionRate === null || conversionRate === undefined) {
if (nonFormattedValue !== 0) {
return null
}
}

let convertedValue = conversionUtil(nonFormattedValue, {
fromNumericBase: 'dec',
fromCurrency: primaryCurrency,
toCurrency: convertedCurrency,
numberOfDecimals: 2,
conversionRate,
})
convertedValue = Number(convertedValue).toFixed(2)

convertedValue = Number(convertedValue).toFixed(2)
const upperCaseCurrencyCode = convertedCurrency.toUpperCase()

return currencies.find(currency => currency.code === upperCaseCurrencyCode)
? currencyFormatter.format(Number(convertedValue), {
code: upperCaseCurrencyCode,
})
: convertedValue
}
: convertedValue
}

CurrencyDisplay.prototype.handleChange = function (newVal) {
this.setState({ valueToRender: removeLeadingZeroes(newVal) })
Expand All @@ -105,13 +115,24 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) {
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 () {
const {
className = 'currency-display',
primaryBalanceClassName = 'currency-display__input',
convertedBalanceClassName = 'currency-display__converted-value',
primaryCurrency,
convertedCurrency,
readOnly = false,
inError = false,
onBlur,
Expand Down Expand Up @@ -157,11 +178,7 @@ CurrencyDisplay.prototype.render = function () {

]),

]),

h('div', {
className: convertedBalanceClassName,
}, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`),
]), this.onlyRenderConversions(convertedValueToRender),

])

Expand Down
24 changes: 10 additions & 14 deletions ui/app/components/tx-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,16 @@ TxListItem.prototype.render = function () {
]),
]),

this.showRetryButton() && h('div.tx-list-item-retry-container', [

h('span.tx-list-item-retry-copy', 'Taking too long?'),

h('span.tx-list-item-retry-link', {
onClick: (event) => {
event.stopPropagation()
if (isTokenTx) {
this.setSelectedToken(txParams.to)
}
this.resubmit()
},
}, 'Increase the gas price on your transaction'),

this.showRetryButton() && h('.tx-list-item-retry-container', {
onClick: (event) => {
event.stopPropagation()
if (isTokenTx) {
this.setSelectedToken(txParams.to)
}
this.resubmit()
},
}, [
h('span', 'Taking too long? Increase the gas price on your transaction'),
]),

]), // holding on icon from design
Expand Down
10 changes: 4 additions & 6 deletions ui/app/css/itcss/components/transaction-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@
.tx-list-item-retry-container {
background: #d1edff;
width: 100%;
border-radius: 4px;
font-size: 0.8em;
border-radius: 12px;
font-size: .75rem;
display: flex;
justify-content: center;
margin-left: 44px;
width: calc(100% - 44px);
padding: 4px;
cursor: pointer;

@media screen and (min-width: 576px) and (max-width: 679px) {
flex-flow: column;
Expand All @@ -151,10 +153,6 @@
}
}

.tx-list-item-retry-copy {
font-family: Roboto;
}

.tx-list-item-retry-link {
text-decoration: underline;
margin-left: 6px;
Expand Down

0 comments on commit cb53d51

Please sign in to comment.