diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-03-31 07:18:48 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-03-31 07:18:48 +0800 |
commit | ba23843f91ca5046400cea14cea4c0d256578fec (patch) | |
tree | e29ef2a930930d4256bd7f59aa3d0274563bc4cf /ui/app/components/pages | |
parent | bdc4a6964ae83faa8229c50870e3bcc9b9074989 (diff) | |
parent | 8e0f39353dd47c4a201aaf2ee160912846f2e68b (diff) | |
download | tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.tar tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.tar.gz tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.tar.bz2 tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.tar.lz tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.tar.xz tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.tar.zst tangerine-wallet-browser-ba23843f91ca5046400cea14cea4c0d256578fec.zip |
Fix merge conflicts
Diffstat (limited to 'ui/app/components/pages')
8 files changed, 135 insertions, 94 deletions
diff --git a/ui/app/components/pages/add-token.js b/ui/app/components/pages/add-token.js index 61c245c32..a5b5ea57b 100644 --- a/ui/app/components/pages/add-token.js +++ b/ui/app/components/pages/add-token.js @@ -2,7 +2,8 @@ const inherits = require('util').inherits const Component = require('react').Component const classnames = require('classnames') const h = require('react-hyperscript') -const connect = require('../../metamask-connect') +const PropTypes = require('prop-types') +const connect = require('react-redux').connect const R = require('ramda') const Fuse = require('fuse.js') const contractMap = require('eth-contract-metadata') @@ -30,8 +31,13 @@ const { DEFAULT_ROUTE } = require('../../routes') const emptyAddr = '0x0000000000000000000000000000000000000000' +AddTokenScreen.contextTypes = { + t: PropTypes.func, +} + module.exports = connect(mapStateToProps, mapDispatchToProps)(AddTokenScreen) + function mapStateToProps (state) { const { identities, tokens } = state.metamask return { @@ -139,7 +145,7 @@ AddTokenScreen.prototype.validate = function () { if (customAddress) { const validAddress = ethUtil.isValidAddress(customAddress) if (!validAddress) { - errors.customAddress = this.props.t('invalidAddress') + errors.customAddress = this.context.t('invalidAddress') } const validDecimals = customDecimals !== null @@ -147,23 +153,23 @@ AddTokenScreen.prototype.validate = function () { && customDecimals >= 0 && customDecimals < 36 if (!validDecimals) { - errors.customDecimals = this.props.t('decimalsMustZerotoTen') + errors.customDecimals = this.context.t('decimalsMustZerotoTen') } const symbolLen = customSymbol.trim().length const validSymbol = symbolLen > 0 && symbolLen < 10 if (!validSymbol) { - errors.customSymbol = this.props.t('symbolBetweenZeroTen') + errors.customSymbol = this.context.t('symbolBetweenZeroTen') } const ownAddress = identitiesList.includes(standardAddress) if (ownAddress) { - errors.customAddress = this.props.t('personalAddressDetected') + errors.customAddress = this.context.t('personalAddressDetected') } const tokenAlreadyAdded = this.checkExistingAddresses(customAddress) if (tokenAlreadyAdded) { - errors.customAddress = this.props.t('tokenAlreadyAdded') + errors.customAddress = this.context.t('tokenAlreadyAdded') } } else if ( Object.entries(selectedTokens) @@ -171,7 +177,7 @@ AddTokenScreen.prototype.validate = function () { isEmpty && !isSelected ), true) ) { - errors.tokenSelector = this.props.t('mustSelectOne') + errors.tokenSelector = this.context.t('mustSelectOne') } return { @@ -201,7 +207,7 @@ AddTokenScreen.prototype.renderCustomForm = function () { 'add-token__add-custom-field--error': errors.customAddress, }), }, [ - h('div.add-token__add-custom-label', this.props.t('tokenAddress')), + h('div.add-token__add-custom-label', this.context.t('tokenAddress')), h('input.add-token__add-custom-input', { type: 'text', onChange: this.tokenAddressDidChange, @@ -214,7 +220,7 @@ AddTokenScreen.prototype.renderCustomForm = function () { 'add-token__add-custom-field--error': errors.customSymbol, }), }, [ - h('div.add-token__add-custom-label', this.props.t('tokenSymbol')), + h('div.add-token__add-custom-label', this.context.t('tokenSymbol')), h('input.add-token__add-custom-input', { type: 'text', onChange: this.tokenSymbolDidChange, @@ -228,7 +234,7 @@ AddTokenScreen.prototype.renderCustomForm = function () { 'add-token__add-custom-field--error': errors.customDecimals, }), }, [ - h('div.add-token__add-custom-label', this.props.t('decimal')), + h('div.add-token__add-custom-label', this.context.t('decimal')), h('input.add-token__add-custom-input', { type: 'number', onChange: this.tokenDecimalsDidChange, @@ -250,7 +256,7 @@ AddTokenScreen.prototype.renderTokenList = function () { const results = [...addressSearchResult, ...fuseSearchResult] return h('div', [ - results.length > 0 && h('div.add-token__token-icons-title', this.props.t('popularTokens')), + results.length > 0 && h('div.add-token__token-icons-title', this.context.t('popularTokens')), h('div.add-token__token-icons-container', Array(6).fill(undefined) .map((_, i) => { const { logo, symbol, name, address } = results[i] || {} @@ -305,10 +311,10 @@ AddTokenScreen.prototype.renderConfirmation = function () { h('div.add-token', [ h('div.add-token__wrapper', [ h('div.add-token__title-container.add-token__confirmation-title', [ - h('div.add-token__description', this.props.t('likeToAddTokens')), + h('div.add-token__description', this.context.t('likeToAddTokens')), ]), h('div.add-token__content-container.add-token__confirmation-content', [ - h('div.add-token__description.add-token__confirmation-description', this.props.t('balances')), + h('div.add-token__description.add-token__confirmation-description', this.context.t('balances')), h('div.add-token__confirmation-token-list', Object.entries(tokens) .map(([ address, token ]) => ( @@ -327,10 +333,10 @@ AddTokenScreen.prototype.renderConfirmation = function () { h('div.add-token__buttons', [ h('button.btn-secondary--lg.add-token__cancel-button', { onClick: () => this.setState({ isShowingConfirmation: false }), - }, this.props.t('back')), + }, this.context.t('back')), h('button.btn-primary--lg', { onClick: () => addTokens(tokens).then(() => history.push(DEFAULT_ROUTE)), - }, this.props.t('addTokens')), + }, this.context.t('addTokens')), ]), ]) ) @@ -350,14 +356,14 @@ AddTokenScreen.prototype.renderTabs = function () { h('div.add-token__content-container', [ h('div.add-token__info-box', [ h('div.add-token__info-box__close'), - h('div.add-token__info-box__title', this.props.t('whatsThis')), - h('div.add-token__info-box__copy', this.props.t('keepTrackTokens')), - h('div.add-token__info-box__copy--blue', this.props.t('learnMore')), + h('div.add-token__info-box__title', this.context.t('whatsThis')), + h('div.add-token__info-box__copy', this.context.t('keepTrackTokens')), + h('div.add-token__info-box__copy--blue', this.context.t('learnMore')), ]), h('div.add-token__input-container', [ h('input.add-token__input', { type: 'text', - placeholder: this.props.t('searchTokens'), + placeholder: this.context.t('searchTokens'), onChange: e => this.setState({ searchQuery: e.target.value }), }), h('div.add-token__search-input-error-message', errors.tokenSelector), @@ -381,9 +387,9 @@ AddTokenScreen.prototype.render = function () { onClick: () => history.goBack(), }, [ h('i.fa.fa-angle-left.fa-lg'), - h('span', this.props.t('cancel')), + h('span', this.context.t('cancel')), ]), - h('div.add-token__header__title', this.props.t('addTokens')), + h('div.add-token__header__title', this.context.t('addTokens')), !isShowingConfirmation && h('div.add-token__header__tabs', [ h('div.add-token__header__tabs__tab', { @@ -392,7 +398,7 @@ AddTokenScreen.prototype.render = function () { 'add-token__header__tabs__unselected cursor-pointer': displayedTab !== 'SEARCH', }), onClick: () => this.displayTab('SEARCH'), - }, this.props.t('search')), + }, this.context.t('search')), h('div.add-token__header__tabs__tab', { className: classnames('add-token__header__tabs__tab', { @@ -400,7 +406,7 @@ AddTokenScreen.prototype.render = function () { 'add-token__header__tabs__unselected cursor-pointer': displayedTab !== 'CUSTOM_TOKEN', }), onClick: () => this.displayTab('CUSTOM_TOKEN'), - }, this.props.t('customToken')), + }, this.context.t('customToken')), ]), ]), @@ -412,10 +418,10 @@ AddTokenScreen.prototype.render = function () { !isShowingConfirmation && h('div.add-token__buttons', [ h('button.btn-secondary--lg.add-token__cancel-button', { onClick: () => history.goBack(), - }, this.props.t('cancel')), + }, this.context.t('cancel')), h('button.btn-primary--lg.add-token__confirm-button', { onClick: this.onNext, - }, this.props.t('next')), + }, this.context.t('next')), ]), ]) } diff --git a/ui/app/components/pages/create-account/import-account/index.js b/ui/app/components/pages/create-account/import-account/index.js index 26353b670..52d3dcde9 100644 --- a/ui/app/components/pages/create-account/import-account/index.js +++ b/ui/app/components/pages/create-account/import-account/index.js @@ -1,7 +1,8 @@ const inherits = require('util').inherits const Component = require('react').Component const h = require('react-hyperscript') -const connect = require('../../../../metamask-connect') +const PropTypes = require('prop-types') +const connect = require('react-redux').connect import Select from 'react-select' // Subviews @@ -9,8 +10,13 @@ const JsonImportView = require('./json.js') const PrivateKeyImportView = require('./private-key.js') +AccountImportSubview.contextTypes = { + t: PropTypes.func, +} + module.exports = connect()(AccountImportSubview) + inherits(AccountImportSubview, Component) function AccountImportSubview () { Component.call(this) @@ -18,8 +24,8 @@ function AccountImportSubview () { AccountImportSubview.prototype.getMenuItemTexts = function () { return [ - this.props.t('privateKey'), - this.props.t('jsonFile'), + this.context.t('privateKey'), + this.context.t('jsonFile'), ] } @@ -32,7 +38,7 @@ AccountImportSubview.prototype.render = function () { h('div.new-account-import-form', [ h('.new-account-import-disclaimer', [ - h('span', this.props.t('importAccountMsg')), + h('span', this.context.t('importAccountMsg')), h('span', { style: { cursor: 'pointer', @@ -43,12 +49,12 @@ AccountImportSubview.prototype.render = function () { url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts', }) }, - }, this.props.t('here')), + }, this.context.t('here')), ]), h('div.new-account-import-form__select-section', [ - h('div.new-account-import-form__select-label', this.props.t('selectType')), + h('div.new-account-import-form__select-label', this.context.t('selectType')), h(Select, { className: 'new-account-import-form__select', @@ -80,9 +86,9 @@ AccountImportSubview.prototype.renderImportView = function () { const current = type || menuItems[0] switch (current) { - case this.props.t('privateKey'): + case this.context.t('privateKey'): return h(PrivateKeyImportView) - case this.props.t('jsonFile'): + case this.context.t('jsonFile'): return h(JsonImportView) default: return h(JsonImportView) diff --git a/ui/app/components/pages/create-account/import-account/json.js b/ui/app/components/pages/create-account/import-account/json.js index 2e858a8f0..946907a47 100644 --- a/ui/app/components/pages/create-account/import-account/json.js +++ b/ui/app/components/pages/create-account/import-account/json.js @@ -3,7 +3,7 @@ const PropTypes = require('prop-types') const h = require('react-hyperscript') const { withRouter } = require('react-router-dom') const { compose } = require('recompose') -const connect = require('../../../../metamask-connect') +const connect = require('react-redux').connect const actions = require('../../../../actions') const FileInput = require('react-simple-file-input').default const { DEFAULT_ROUTE } = require('../../../../routes') @@ -25,11 +25,11 @@ class JsonImportSubview extends Component { return ( h('div.new-account-import-form__json', [ - h('p', this.props.t('usedByClients')), + h('p', this.context.t('usedByClients')), h('a.warning', { href: HELP_LINK, target: '_blank', - }, this.props.t('fileImportFail')), + }, this.context.t('fileImportFail')), h(FileInput, { readAs: 'text', @@ -44,7 +44,7 @@ class JsonImportSubview extends Component { h('input.new-account-import-form__input-password', { type: 'password', - placeholder: this.props.t('enterPassword'), + placeholder: this.context.t('enterPassword'), id: 'json-password-box', onKeyPress: this.createKeyringOnEnter.bind(this), }), @@ -54,13 +54,13 @@ class JsonImportSubview extends Component { h('button.btn-secondary.new-account-create-form__button', { onClick: () => this.props.history.push(DEFAULT_ROUTE), }, [ - this.props.t('cancel'), + this.context.t('cancel'), ]), h('button.btn-primary.new-account-create-form__button', { onClick: () => this.createNewKeychain(), }, [ - this.props.t('import'), + this.context.t('import'), ]), ]), @@ -85,14 +85,14 @@ class JsonImportSubview extends Component { const state = this.state if (!state) { - const message = this.props.t('validFileImport') + const message = this.context.t('validFileImport') return this.props.displayWarning(message) } const { fileContents } = state if (!fileContents) { - const message = this.props.t('needImportFile') + const message = this.context.t('needImportFile') return this.props.displayWarning(message) } @@ -100,7 +100,7 @@ class JsonImportSubview extends Component { const password = passwordInput.value if (!password) { - const message = this.props.t('needImportPassword') + const message = this.context.t('needImportPassword') return this.props.displayWarning(message) } @@ -131,6 +131,10 @@ const mapDispatchToProps = dispatch => { } } +JsonImportSubview.contextTypes = { + t: PropTypes.func, +} + module.exports = compose( withRouter, connect(mapStateToProps, mapDispatchToProps) diff --git a/ui/app/components/pages/create-account/import-account/private-key.js b/ui/app/components/pages/create-account/import-account/private-key.js index 17a32c10f..0f6789282 100644 --- a/ui/app/components/pages/create-account/import-account/private-key.js +++ b/ui/app/components/pages/create-account/import-account/private-key.js @@ -3,15 +3,21 @@ const Component = require('react').Component const h = require('react-hyperscript') const { withRouter } = require('react-router-dom') const { compose } = require('recompose') -const connect = require('../../../../metamask-connect') +const PropTypes = require('prop-types') +const connect = require('react-redux').connect const actions = require('../../../../actions') const { DEFAULT_ROUTE } = require('../../../../routes') +PrivateKeyImportView.contextTypes = { + t: PropTypes.func, +} + module.exports = compose( withRouter, connect(mapStateToProps, mapDispatchToProps) )(PrivateKeyImportView) + function mapStateToProps (state) { return { error: state.appState.warning, @@ -38,7 +44,7 @@ PrivateKeyImportView.prototype.render = function () { return ( h('div.new-account-import-form__private-key', [ - h('span.new-account-create-form__instruction', this.props.t('pastePrivateKey')), + h('span.new-account-create-form__instruction', this.context.t('pastePrivateKey')), h('div.new-account-import-form__private-key-password-container', [ @@ -55,13 +61,13 @@ PrivateKeyImportView.prototype.render = function () { h('button.btn-secondary--lg.new-account-create-form__button', { onClick: () => this.props.history.push(DEFAULT_ROUTE), }, [ - this.props.t('cancel'), + this.context.t('cancel'), ]), h('button.btn-primary--lg.new-account-create-form__button', { onClick: () => this.createNewKeychain(), }, [ - this.props.t('import'), + this.context.t('import'), ]), ]), diff --git a/ui/app/components/pages/create-account/import-account/seed.js b/ui/app/components/pages/create-account/import-account/seed.js index 15dd98c73..d98909baa 100644 --- a/ui/app/components/pages/create-account/import-account/seed.js +++ b/ui/app/components/pages/create-account/import-account/seed.js @@ -1,10 +1,16 @@ const inherits = require('util').inherits const Component = require('react').Component const h = require('react-hyperscript') -const connect = require('../../../../metamask-connect') +const PropTypes = require('prop-types') +const connect = require('react-redux').connect + +SeedImportSubview.contextTypes = { + t: PropTypes.func, +} module.exports = connect(mapStateToProps)(SeedImportSubview) + function mapStateToProps (state) { return {} } @@ -20,10 +26,10 @@ SeedImportSubview.prototype.render = function () { style: { }, }, [ - this.props.t('pasteSeed'), + this.context.t('pasteSeed'), h('textarea'), h('br'), - h('button', this.props.t('submit')), + h('button', this.context.t('submit')), ]) ) } diff --git a/ui/app/components/pages/create-account/new-account.js b/ui/app/components/pages/create-account/new-account.js index dfe2a2ab1..40fa584be 100644 --- a/ui/app/components/pages/create-account/new-account.js +++ b/ui/app/components/pages/create-account/new-account.js @@ -1,12 +1,12 @@ const { Component } = require('react') const PropTypes = require('prop-types') const h = require('react-hyperscript') -const connect = require('../../../metamask-connect') +const connect = require('react-redux').connect const actions = require('../../../actions') const { DEFAULT_ROUTE } = require('../../../routes') class NewAccountCreateForm extends Component { - constructor (props) { + constructor (props, context) { super(props) const { numberOfExistingAccounts = 0 } = props @@ -14,7 +14,7 @@ class NewAccountCreateForm extends Component { this.state = { newAccountName: '', - defaultAccountName: this.props.t('newAccountNumberName', [newAccountNumber]), + defaultAccountName: context.t('newAccountNumberName', [newAccountNumber]), } } @@ -25,7 +25,7 @@ class NewAccountCreateForm extends Component { return h('div.new-account-create-form', [ h('div.new-account-create-form__input-label', {}, [ - this.props.t('accountName'), + this.context.t('accountName'), ]), h('div.new-account-create-form__input-wrapper', {}, [ @@ -41,7 +41,7 @@ class NewAccountCreateForm extends Component { h('button.btn-secondary--lg.new-account-create-form__button', { onClick: () => history.push(DEFAULT_ROUTE), }, [ - this.props.t('cancel'), + this.context.t('cancel'), ]), h('button.btn-primary--lg.new-account-create-form__button', { @@ -50,7 +50,7 @@ class NewAccountCreateForm extends Component { .then(() => history.push(DEFAULT_ROUTE)) }, }, [ - this.props.t('create'), + this.context.t('create'), ]), ]), @@ -95,4 +95,9 @@ const mapDispatchToProps = dispatch => { } } +NewAccountCreateForm.contextTypes = { + t: PropTypes.func, +} + module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountCreateForm) + diff --git a/ui/app/components/pages/settings/info.js b/ui/app/components/pages/settings/info.js index adb2fdfcd..eb9be66e6 100644 --- a/ui/app/components/pages/settings/info.js +++ b/ui/app/components/pages/settings/info.js @@ -1,7 +1,6 @@ const { Component } = require('react') const PropTypes = require('prop-types') const h = require('react-hyperscript') -const connect = require('../../../metamask-connect') class Info extends Component { renderLogo () { @@ -15,13 +14,13 @@ class Info extends Component { renderInfoLinks () { return ( h('div.settings__content-item.settings__content-item--without-height', [ - h('div.settings__info-link-header', this.props.t('links')), + h('div.settings__info-link-header', this.context.t('links')), h('div.settings__info-link-item', [ h('a', { href: 'https://metamask.io/privacy.html', target: '_blank', }, [ - h('span.settings__info-link', this.props.t('privacyMsg')), + h('span.settings__info-link', this.context.t('privacyMsg')), ]), ]), h('div.settings__info-link-item', [ @@ -29,7 +28,7 @@ class Info extends Component { href: 'https://metamask.io/terms.html', target: '_blank', }, [ - h('span.settings__info-link', this.props.t('terms')), + h('span.settings__info-link', this.context.t('terms')), ]), ]), h('div.settings__info-link-item', [ @@ -37,7 +36,7 @@ class Info extends Component { href: 'https://metamask.io/attributions.html', target: '_blank', }, [ - h('span.settings__info-link', this.props.t('attributions')), + h('span.settings__info-link', this.context.t('attributions')), ]), ]), h('hr.settings__info-separator'), @@ -46,7 +45,7 @@ class Info extends Component { href: 'https://support.metamask.io', target: '_blank', }, [ - h('span.settings__info-link', this.props.t('supportCenter')), + h('span.settings__info-link', this.context.t('supportCenter')), ]), ]), h('div.settings__info-link-item', [ @@ -54,7 +53,7 @@ class Info extends Component { href: 'https://metamask.io/', target: '_blank', }, [ - h('span.settings__info-link', this.props.t('visitWebSite')), + h('span.settings__info-link', this.context.t('visitWebSite')), ]), ]), h('div.settings__info-link-item', [ @@ -62,7 +61,7 @@ class Info extends Component { target: '_blank', href: 'mailto:help@metamask.io?subject=Feedback', }, [ - h('span.settings__info-link', this.props.t('emailUs')), + h('span.settings__info-link', this.context.t('emailUs')), ]), ]), ]) @@ -82,7 +81,7 @@ class Info extends Component { h('div.settings__info-item', [ h( 'div.settings__info-about', - this.props.t('builtInCalifornia') + this.context.t('builtInCalifornia') ), ]), ]), @@ -106,4 +105,8 @@ Info.propTypes = { t: PropTypes.func, } -module.exports = connect()(Info) +Info.contextTypes = { + t: PropTypes.func, +} + +module.exports = Info diff --git a/ui/app/components/pages/settings/settings.js b/ui/app/components/pages/settings/settings.js index 7b3704c4d..05a7379fb 100644 --- a/ui/app/components/pages/settings/settings.js +++ b/ui/app/components/pages/settings/settings.js @@ -3,7 +3,7 @@ const { withRouter } = require('react-router-dom') const { compose } = require('recompose') const PropTypes = require('prop-types') const h = require('react-hyperscript') -const connect = require('../../../metamask-connect') +const connect = require('react-redux').connect const actions = require('../../../actions') const infuraCurrencies = require('../../../infura-conversion.json') const validUrl = require('valid-url') @@ -52,7 +52,7 @@ class Settings extends Component { return h('div.settings__content-row', [ h('div.settings__content-item', [ - h('span', this.props.t('blockiesIdenticon')), + h('span', this.context.t('blockiesIdenticon')), ]), h('div.settings__content-item', [ h('div.settings__content-item-col', [ @@ -72,13 +72,13 @@ class Settings extends Component { return h('div.settings__content-row', [ h('div.settings__content-item', [ - h('span', this.props.t('currentConversion')), + h('span', this.context.t('currentConversion')), h('span.settings__content-description', `Updated ${Date(conversionDate)}`), ]), h('div.settings__content-item', [ h('div.settings__content-item-col', [ h(SimpleDropdown, { - placeholder: this.props.t('selectCurrency'), + placeholder: this.context.t('selectCurrency'), options: getInfuraCurrencyOptions(), selectedOption: currentCurrency, onSelect: newCurrency => setCurrentCurrency(newCurrency), @@ -91,11 +91,12 @@ class Settings extends Component { renderCurrentLocale () { const { updateCurrentLocale, currentLocale } = this.props const currentLocaleMeta = locales.find(locale => locale.code === currentLocale) + const currentLocaleName = currentLocaleMeta ? currentLocaleMeta.name : '' return h('div.settings__content-row', [ h('div.settings__content-item', [ h('span', 'Current Language'), - h('span.settings__content-description', `${currentLocaleMeta.name}`), + h('span.settings__content-description', `${currentLocaleName}`), ]), h('div.settings__content-item', [ h('div.settings__content-item-col', [ @@ -119,31 +120,31 @@ class Settings extends Component { switch (provider.type) { case 'mainnet': - title = this.props.t('currentNetwork') - value = this.props.t('mainnet') + title = this.context.t('currentNetwork') + value = this.context.t('mainnet') color = '#038789' break case 'ropsten': - title = this.props.t('currentNetwork') - value = this.props.t('ropsten') + title = this.context.t('currentNetwork') + value = this.context.t('ropsten') color = '#e91550' break case 'kovan': - title = this.props.t('currentNetwork') - value = this.props.t('kovan') + title = this.context.t('currentNetwork') + value = this.context.t('kovan') color = '#690496' break case 'rinkeby': - title = this.props.t('currentNetwork') - value = this.props.t('rinkeby') + title = this.context.t('currentNetwork') + value = this.context.t('rinkeby') color = '#ebb33f' break default: - title = this.props.t('currentRpc') + title = this.context.t('currentRpc') value = provider.rpcTarget } @@ -164,12 +165,12 @@ class Settings extends Component { return ( h('div.settings__content-row', [ h('div.settings__content-item', [ - h('span', this.props.t('newRPC')), + h('span', this.context.t('newRPC')), ]), h('div.settings__content-item', [ h('div.settings__content-item-col', [ h('input.settings__input', { - placeholder: this.props.t('newRPC'), + placeholder: this.context.t('newRPC'), onChange: event => this.setState({ newRpc: event.target.value }), onKeyPress: event => { if (event.key === 'Enter') { @@ -182,7 +183,7 @@ class Settings extends Component { event.preventDefault() this.validateRpc(this.state.newRpc) }, - }, this.props.t('save')), + }, this.context.t('save')), ]), ]), ]) @@ -198,9 +199,9 @@ class Settings extends Component { const appendedRpc = `http://${newRpc}` if (validUrl.isWebUri(appendedRpc)) { - displayWarning(this.props.t('uriErrorMsg')) + displayWarning(this.context.t('uriErrorMsg')) } else { - displayWarning(this.props.t('invalidRPC')) + displayWarning(this.context.t('invalidRPC')) } } } @@ -209,10 +210,10 @@ class Settings extends Component { return ( h('div.settings__content-row', [ h('div.settings__content-item', [ - h('div', this.props.t('stateLogs')), + h('div', this.context.t('stateLogs')), h( 'div.settings__content-description', - this.props.t('stateLogsDescription') + this.context.t('stateLogsDescription') ), ]), h('div.settings__content-item', [ @@ -221,13 +222,13 @@ class Settings extends Component { onClick (event) { window.logStateString((err, result) => { if (err) { - this.state.dispatch(actions.displayWarning(this.props.t('stateLogError'))) + this.state.dispatch(actions.displayWarning(this.context.t('stateLogError'))) } else { exportAsFile('MetaMask State Logs.json', result) } }) }, - }, this.props.t('downloadStateLogs')), + }, this.context.t('downloadStateLogs')), ]), ]), ]) @@ -239,7 +240,7 @@ class Settings extends Component { return ( h('div.settings__content-row', [ - h('div.settings__content-item', this.props.t('revealSeedWords')), + h('div.settings__content-item', this.context.t('revealSeedWords')), h('div.settings__content-item', [ h('div.settings__content-item-col', [ h('button.btn-primary--lg.settings__button--red', { @@ -247,7 +248,7 @@ class Settings extends Component { event.preventDefault() history.push(REVEAL_SEED_ROUTE) }, - }, this.props.t('revealSeedWords')), + }, this.context.t('revealSeedWords')), ]), ]), ]) @@ -259,7 +260,7 @@ class Settings extends Component { return ( h('div.settings__content-row', [ - h('div.settings__content-item', this.props.t('useOldUI')), + h('div.settings__content-item', this.context.t('useOldUI')), h('div.settings__content-item', [ h('div.settings__content-item-col', [ h('button.btn-primary--lg.settings__button--orange', { @@ -267,7 +268,7 @@ class Settings extends Component { event.preventDefault() setFeatureFlagToBeta() }, - }, this.props.t('useOldUI')), + }, this.context.t('useOldUI')), ]), ]), ]) @@ -278,7 +279,7 @@ class Settings extends Component { const { showResetAccountConfirmationModal } = this.props return h('div.settings__content-row', [ - h('div.settings__content-item', this.props.t('resetAccount')), + h('div.settings__content-item', this.context.t('resetAccount')), h('div.settings__content-item', [ h('div.settings__content-item-col', [ h('button.btn-primary--lg.settings__button--orange', { @@ -286,7 +287,7 @@ class Settings extends Component { event.preventDefault() showResetAccountConfirmationModal() }, - }, this.props.t('resetAccount')), + }, this.context.t('resetAccount')), ]), ]), ]) @@ -356,6 +357,10 @@ const mapDispatchToProps = dispatch => { } } +Settings.contextTypes = { + t: PropTypes.func, +} + module.exports = compose( withRouter, connect(mapStateToProps, mapDispatchToProps) |