aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/accounts
diff options
context:
space:
mode:
authornyatla <nyatla39@gmail.com>2018-04-10 16:14:28 +0800
committernyatla <nyatla39@gmail.com>2018-04-10 16:14:28 +0800
commitcc246528b509b80e560715f3b315acf0764e99e7 (patch)
treea04cc12e6c11345bf751726f15fa9d3dd6be4733 /ui/app/accounts
parentbc0487006c623f1c81c186ba5b2a7137efb940ec (diff)
parentb91bd818c7c2aec2952036a2f69ab05e0690a06e (diff)
downloadtangerine-wallet-browser-cc246528b509b80e560715f3b315acf0764e99e7.tar.gz
tangerine-wallet-browser-cc246528b509b80e560715f3b315acf0764e99e7.tar.zst
tangerine-wallet-browser-cc246528b509b80e560715f3b315acf0764e99e7.zip
Merge tag 'v4.5.5'
# Conflicts: # app/_locales/ja/messages.json # package-lock.json messages.jsonのローカライズ
Diffstat (limited to 'ui/app/accounts')
-rw-r--r--ui/app/accounts/import/index.js40
-rw-r--r--ui/app/accounts/import/json.js24
-rw-r--r--ui/app/accounts/import/private-key.js16
-rw-r--r--ui/app/accounts/import/seed.js11
-rw-r--r--ui/app/accounts/new-account/create-form.js19
-rw-r--r--ui/app/accounts/new-account/index.js13
6 files changed, 75 insertions, 48 deletions
diff --git a/ui/app/accounts/import/index.js b/ui/app/accounts/import/index.js
index fc9031a65..52d3dcde9 100644
--- a/ui/app/accounts/import/index.js
+++ b/ui/app/accounts/import/index.js
@@ -1,43 +1,44 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
+const PropTypes = require('prop-types')
const connect = require('react-redux').connect
-const t = require('../../../i18n')
import Select from 'react-select'
// Subviews
const JsonImportView = require('./json.js')
const PrivateKeyImportView = require('./private-key.js')
-const menuItems = [
- t('privateKey'),
- t('jsonFile'),
-]
-module.exports = connect(mapStateToProps)(AccountImportSubview)
-
-function mapStateToProps (state) {
- return {
- menuItems,
- }
+AccountImportSubview.contextTypes = {
+ t: PropTypes.func,
}
+module.exports = connect()(AccountImportSubview)
+
+
inherits(AccountImportSubview, Component)
function AccountImportSubview () {
Component.call(this)
}
+AccountImportSubview.prototype.getMenuItemTexts = function () {
+ return [
+ this.context.t('privateKey'),
+ this.context.t('jsonFile'),
+ ]
+}
+
AccountImportSubview.prototype.render = function () {
- const props = this.props
const state = this.state || {}
- const { menuItems } = props
+ const menuItems = this.getMenuItemTexts()
const { type } = state
return (
h('div.new-account-import-form', [
h('.new-account-import-disclaimer', [
- h('span', t('importAccountMsg')),
+ h('span', this.context.t('importAccountMsg')),
h('span', {
style: {
cursor: 'pointer',
@@ -48,12 +49,12 @@ AccountImportSubview.prototype.render = function () {
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts',
})
},
- }, t('here')),
+ }, this.context.t('here')),
]),
h('div.new-account-import-form__select-section', [
- h('div.new-account-import-form__select-label', t('selectType')),
+ h('div.new-account-import-form__select-label', this.context.t('selectType')),
h(Select, {
className: 'new-account-import-form__select',
@@ -79,16 +80,15 @@ AccountImportSubview.prototype.render = function () {
}
AccountImportSubview.prototype.renderImportView = function () {
- const props = this.props
const state = this.state || {}
const { type } = state
- const { menuItems } = props
+ const menuItems = this.getMenuItemTexts()
const current = type || menuItems[0]
switch (current) {
- case t('privateKey'):
+ case this.context.t('privateKey'):
return h(PrivateKeyImportView)
- case t('jsonFile'):
+ case this.context.t('jsonFile'):
return h(JsonImportView)
default:
return h(JsonImportView)
diff --git a/ui/app/accounts/import/json.js b/ui/app/accounts/import/json.js
index eeba73e77..e53c1c9ca 100644
--- a/ui/app/accounts/import/json.js
+++ b/ui/app/accounts/import/json.js
@@ -4,7 +4,7 @@ const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('../../actions')
const FileInput = require('react-simple-file-input').default
-const t = require('../../../i18n')
+
const HELP_LINK = 'https://support.metamask.io/kb/article/7-importing-accounts'
@@ -24,11 +24,11 @@ class JsonImportSubview extends Component {
return (
h('div.new-account-import-form__json', [
- h('p', t('usedByClients')),
+ h('p', this.context.t('usedByClients')),
h('a.warning', {
href: HELP_LINK,
target: '_blank',
- }, t('fileImportFail')),
+ }, this.context.t('fileImportFail')),
h(FileInput, {
readAs: 'text',
@@ -43,7 +43,7 @@ class JsonImportSubview extends Component {
h('input.new-account-import-form__input-password', {
type: 'password',
- placeholder: t('enterPassword'),
+ placeholder: this.context.t('enterPassword'),
id: 'json-password-box',
onKeyPress: this.createKeyringOnEnter.bind(this),
}),
@@ -53,13 +53,13 @@ class JsonImportSubview extends Component {
h('button.btn-secondary.new-account-create-form__button', {
onClick: () => this.props.goHome(),
}, [
- t('cancel'),
+ this.context.t('cancel'),
]),
h('button.btn-primary.new-account-create-form__button', {
onClick: () => this.createNewKeychain(),
}, [
- t('import'),
+ this.context.t('import'),
]),
]),
@@ -84,14 +84,14 @@ class JsonImportSubview extends Component {
const state = this.state
if (!state) {
- const message = t('validFileImport')
+ const message = this.context.t('validFileImport')
return this.props.displayWarning(message)
}
const { fileContents } = state
if (!fileContents) {
- const message = t('needImportFile')
+ const message = this.context.t('needImportFile')
return this.props.displayWarning(message)
}
@@ -99,7 +99,7 @@ class JsonImportSubview extends Component {
const password = passwordInput.value
if (!password) {
- const message = t('needImportPassword')
+ const message = this.context.t('needImportPassword')
return this.props.displayWarning(message)
}
@@ -112,6 +112,7 @@ JsonImportSubview.propTypes = {
goHome: PropTypes.func,
displayWarning: PropTypes.func,
importNewJsonAccount: PropTypes.func,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
@@ -128,4 +129,9 @@ const mapDispatchToProps = dispatch => {
}
}
+JsonImportSubview.contextTypes = {
+ t: PropTypes.func,
+}
+
module.exports = connect(mapStateToProps, mapDispatchToProps)(JsonImportSubview)
+
diff --git a/ui/app/accounts/import/private-key.js b/ui/app/accounts/import/private-key.js
index 13c8da722..0d2898cda 100644
--- a/ui/app/accounts/import/private-key.js
+++ b/ui/app/accounts/import/private-key.js
@@ -1,12 +1,17 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
+const PropTypes = require('prop-types')
const connect = require('react-redux').connect
const actions = require('../../actions')
-const t = require('../../../i18n')
+
+PrivateKeyImportView.contextTypes = {
+ t: PropTypes.func,
+}
module.exports = connect(mapStateToProps, mapDispatchToProps)(PrivateKeyImportView)
+
function mapStateToProps (state) {
return {
error: state.appState.warning,
@@ -25,6 +30,7 @@ function mapDispatchToProps (dispatch) {
inherits(PrivateKeyImportView, Component)
function PrivateKeyImportView () {
+ this.createKeyringOnEnter = this.createKeyringOnEnter.bind(this)
Component.call(this)
}
@@ -34,14 +40,14 @@ PrivateKeyImportView.prototype.render = function () {
return (
h('div.new-account-import-form__private-key', [
- h('span.new-account-create-form__instruction', t('pastePrivateKey')),
+ h('span.new-account-create-form__instruction', this.context.t('pastePrivateKey')),
h('div.new-account-import-form__private-key-password-container', [
h('input.new-account-import-form__input-password', {
type: 'password',
id: 'private-key-box',
- onKeyPress: () => this.createKeyringOnEnter(),
+ onKeyPress: e => this.createKeyringOnEnter(e),
}),
]),
@@ -51,13 +57,13 @@ PrivateKeyImportView.prototype.render = function () {
h('button.btn-secondary--lg.new-account-create-form__button', {
onClick: () => goHome(),
}, [
- t('cancel'),
+ this.context.t('cancel'),
]),
h('button.btn-primary--lg.new-account-create-form__button', {
onClick: () => this.createNewKeychain(),
}, [
- t('import'),
+ this.context.t('import'),
]),
]),
diff --git a/ui/app/accounts/import/seed.js b/ui/app/accounts/import/seed.js
index 9ffc669a2..d98909baa 100644
--- a/ui/app/accounts/import/seed.js
+++ b/ui/app/accounts/import/seed.js
@@ -1,11 +1,16 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
+const PropTypes = require('prop-types')
const connect = require('react-redux').connect
-const t = require('../../../i18n')
+
+SeedImportSubview.contextTypes = {
+ t: PropTypes.func,
+}
module.exports = connect(mapStateToProps)(SeedImportSubview)
+
function mapStateToProps (state) {
return {}
}
@@ -21,10 +26,10 @@ SeedImportSubview.prototype.render = function () {
style: {
},
}, [
- t('pasteSeed'),
+ this.context.t('pasteSeed'),
h('textarea'),
h('br'),
- h('button', t('submit')),
+ h('button', this.context.t('submit')),
])
)
}
diff --git a/ui/app/accounts/new-account/create-form.js b/ui/app/accounts/new-account/create-form.js
index c820cdf6d..48c74192a 100644
--- a/ui/app/accounts/new-account/create-form.js
+++ b/ui/app/accounts/new-account/create-form.js
@@ -1,12 +1,11 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
-const { connect } = require('react-redux')
+const connect = require('react-redux').connect
const actions = require('../../actions')
-const t = require('../../../i18n')
class NewAccountCreateForm extends Component {
- constructor (props) {
+ constructor (props, context) {
super(props)
const { numberOfExistingAccounts = 0 } = props
@@ -14,7 +13,7 @@ class NewAccountCreateForm extends Component {
this.state = {
newAccountName: '',
- defaultAccountName: t('newAccountNumberName', [newAccountNumber]),
+ defaultAccountName: context.t('newAccountNumberName', [newAccountNumber]),
}
}
@@ -25,7 +24,7 @@ class NewAccountCreateForm extends Component {
return h('div.new-account-create-form', [
h('div.new-account-create-form__input-label', {}, [
- t('accountName'),
+ this.context.t('accountName'),
]),
h('div.new-account-create-form__input-wrapper', {}, [
@@ -41,13 +40,13 @@ class NewAccountCreateForm extends Component {
h('button.btn-secondary--lg.new-account-create-form__button', {
onClick: () => this.props.goHome(),
}, [
- t('cancel'),
+ this.context.t('cancel'),
]),
h('button.btn-primary--lg.new-account-create-form__button', {
onClick: () => this.props.createAccount(newAccountName || defaultAccountName),
}, [
- t('create'),
+ this.context.t('create'),
]),
]),
@@ -62,6 +61,7 @@ NewAccountCreateForm.propTypes = {
createAccount: PropTypes.func,
goHome: PropTypes.func,
numberOfExistingAccounts: PropTypes.number,
+ t: PropTypes.func,
}
const mapStateToProps = state => {
@@ -97,4 +97,9 @@ const mapDispatchToProps = dispatch => {
}
}
+NewAccountCreateForm.contextTypes = {
+ t: PropTypes.func,
+}
+
module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountCreateForm)
+
diff --git a/ui/app/accounts/new-account/index.js b/ui/app/accounts/new-account/index.js
index 854568c77..207cf7760 100644
--- a/ui/app/accounts/new-account/index.js
+++ b/ui/app/accounts/new-account/index.js
@@ -1,9 +1,9 @@
const Component = require('react').Component
const h = require('react-hyperscript')
+const PropTypes = require('prop-types')
const inherits = require('util').inherits
const connect = require('react-redux').connect
const actions = require('../../actions')
-const t = require('../../../i18n')
const { getCurrentViewContext } = require('../../selectors')
const classnames = require('classnames')
@@ -37,8 +37,13 @@ function AccountDetailsModal (props) {
}
}
+AccountDetailsModal.contextTypes = {
+ t: PropTypes.func,
+}
+
module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountDetailsModal)
+
AccountDetailsModal.prototype.render = function () {
const { displayedForm, displayForm } = this.props
@@ -46,7 +51,7 @@ AccountDetailsModal.prototype.render = function () {
h('div.new-account__header', [
- h('div.new-account__title', t('newAccount')),
+ h('div.new-account__title', this.context.t('newAccount')),
h('div.new-account__tabs', [
@@ -56,7 +61,7 @@ AccountDetailsModal.prototype.render = function () {
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'CREATE',
}),
onClick: () => displayForm('CREATE'),
- }, t('createDen')),
+ }, this.context.t('createDen')),
h('div.new-account__tabs__tab', {
className: classnames('new-account__tabs__tab', {
@@ -64,7 +69,7 @@ AccountDetailsModal.prototype.render = function () {
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'IMPORT',
}),
onClick: () => displayForm('IMPORT'),
- }, t('import')),
+ }, this.context.t('import')),
]),