From 5fe0be722b6514692a68e920ee8058c5d572237d Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 15 Mar 2018 21:59:45 -0230 Subject: Handle i18n with redux. --- ui/app/components/tx-list-item.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui/app/components/tx-list-item.js') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 849d70489..db8621434 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -1,6 +1,6 @@ const Component = require('react').Component const h = require('react-hyperscript') -const connect = require('react-redux').connect +const connect = require('../metamask-connect') const inherits = require('util').inherits const classnames = require('classnames') const abi = require('human-standard-token-abi') @@ -13,7 +13,7 @@ const { conversionUtil, multiplyCurrencies } = require('../conversion-util') const { calcTokenAmount } = require('../token-util') const { getCurrentCurrency } = require('../selectors') -const t = require('../../i18n') +const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps)(TxListItem) @@ -64,7 +64,7 @@ TxListItem.prototype.getAddressText = function () { default: return address ? `${address.slice(0, 10)}...${address.slice(-4)}` - : t('contractDeployment') + : t(this.props.localeMessages, 'contractDeployment') } } -- cgit From d24a0590d363dbe88d383c8faec8eb28809242f0 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Mar 2018 22:11:47 -0230 Subject: i18n redux solution doesn't require importing t() and passing state to each t() call; t is just available on props. --- ui/app/components/tx-list-item.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'ui/app/components/tx-list-item.js') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 3819de195..5e88d38d3 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -14,7 +14,6 @@ const { conversionUtil, multiplyCurrencies } = require('../conversion-util') const { calcTokenAmount } = require('../token-util') const { getCurrentCurrency } = require('../selectors') -const t = require('../../i18n-helper').getMessage module.exports = connect(mapStateToProps, mapDispatchToProps)(TxListItem) @@ -75,7 +74,7 @@ TxListItem.prototype.getAddressText = function () { default: return address ? `${address.slice(0, 10)}...${address.slice(-4)}` - : t(this.props.localeMessages, 'contractDeployment') + : this.props.t('contractDeployment') } } @@ -307,21 +306,21 @@ TxListItem.prototype.txStatusIndicator = function () { let name if (transactionStatus === 'unapproved') { - name = t('unapproved') + name = this.props.t('unapproved') } else if (transactionStatus === 'rejected') { - name = t('rejected') + name = this.props.t('rejected') } else if (transactionStatus === 'approved') { - name = t('approved') + name = this.props.t('approved') } else if (transactionStatus === 'signed') { - name = t('signed') + name = this.props.t('signed') } else if (transactionStatus === 'submitted') { - name = t('submitted') + name = this.props.t('submitted') } else if (transactionStatus === 'confirmed') { - name = t('confirmed') + name = this.props.t('confirmed') } else if (transactionStatus === 'failed') { - name = t('failed') + name = this.props.t('failed') } else if (transactionStatus === 'dropped') { - name = t('dropped') + name = this.props.t('dropped') } return name } -- cgit From 21b6a3442d8cae8c95a3d7e0b9e216d91bc8bd19 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 28 Mar 2018 10:51:16 -0230 Subject: Fix display of unapprovedMessages in txList (old and new ui); includes fix of undefined txParams. --- ui/app/components/tx-list-item.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'ui/app/components/tx-list-item.js') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 5e88d38d3..a411edd89 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -62,20 +62,23 @@ TxListItem.prototype.getAddressText = function () { const { address, txParams = {}, + isMsg, } = this.props const decodedData = txParams.data && abiDecoder.decodeMethod(txParams.data) const { name: txDataName, params = [] } = decodedData || {} const { value } = params[0] || {} - switch (txDataName) { - case 'transfer': - return `${value.slice(0, 10)}...${value.slice(-4)}` - default: - return address - ? `${address.slice(0, 10)}...${address.slice(-4)}` - : this.props.t('contractDeployment') + let addressText + if (txDataName === 'transfer' || address) { + addressText = `${value.slice(0, 10)}...${value.slice(-4)}` + } else if (isMsg) { + addressText = this.props.t('sigRequest') + } else { + addressText = this.props.t('contractDeployment') } + + return addressText } TxListItem.prototype.getSendEtherTotal = function () { @@ -185,6 +188,9 @@ TxListItem.prototype.showRetryButton = function () { transactionId, txParams, } = this.props + if (!txParams) { + return false + } const currentNonce = txParams.nonce const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce) const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted') -- cgit From 01e3293b65bb153325479f7366113e037fee659b Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 29 Mar 2018 10:32:30 -0230 Subject: Ensure correct address used when rendering transfer transactions. --- ui/app/components/tx-list-item.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui/app/components/tx-list-item.js') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index a411edd89..116813547 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -71,7 +71,8 @@ TxListItem.prototype.getAddressText = function () { let addressText if (txDataName === 'transfer' || address) { - addressText = `${value.slice(0, 10)}...${value.slice(-4)}` + const addressToRender = txDataName === 'transfer' ? value : address + addressText = `${addressToRender.slice(0, 10)}...${addressToRender.slice(-4)}` } else if (isMsg) { addressText = this.props.t('sigRequest') } else { -- cgit From 0a711f0de0e342b24988a5da4ca5c64342153210 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 29 Mar 2018 12:30:44 -0230 Subject: Removes t from props via metamask-connect and instead places it on context via a provider. --- ui/app/components/tx-list-item.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'ui/app/components/tx-list-item.js') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 5e88d38d3..622664786 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -1,6 +1,7 @@ const Component = require('react').Component +const PropTypes = require('prop-types') const h = require('react-hyperscript') -const connect = require('../metamask-connect') +const connect = require('react-redux').connect const inherits = require('util').inherits const classnames = require('classnames') const abi = require('human-standard-token-abi') @@ -15,8 +16,13 @@ const { calcTokenAmount } = require('../token-util') const { getCurrentCurrency } = require('../selectors') +TxListItem.contextTypes = { + t: PropTypes.func, +} + module.exports = connect(mapStateToProps, mapDispatchToProps)(TxListItem) + function mapStateToProps (state) { return { tokens: state.metamask.tokens, @@ -74,7 +80,7 @@ TxListItem.prototype.getAddressText = function () { default: return address ? `${address.slice(0, 10)}...${address.slice(-4)}` - : this.props.t('contractDeployment') + : this.context.t('contractDeployment') } } @@ -306,21 +312,21 @@ TxListItem.prototype.txStatusIndicator = function () { let name if (transactionStatus === 'unapproved') { - name = this.props.t('unapproved') + name = this.context.t('unapproved') } else if (transactionStatus === 'rejected') { - name = this.props.t('rejected') + name = this.context.t('rejected') } else if (transactionStatus === 'approved') { - name = this.props.t('approved') + name = this.context.t('approved') } else if (transactionStatus === 'signed') { - name = this.props.t('signed') + name = this.context.t('signed') } else if (transactionStatus === 'submitted') { - name = this.props.t('submitted') + name = this.context.t('submitted') } else if (transactionStatus === 'confirmed') { - name = this.props.t('confirmed') + name = this.context.t('confirmed') } else if (transactionStatus === 'failed') { - name = this.props.t('failed') + name = this.context.t('failed') } else if (transactionStatus === 'dropped') { - name = this.props.t('dropped') + name = this.context.t('dropped') } return name } -- cgit