aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pages/create-account/import-account/json.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components/pages/create-account/import-account/json.js')
-rw-r--r--ui/app/components/pages/create-account/import-account/json.js26
1 files changed, 19 insertions, 7 deletions
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 0a3314b2a..1dc2ba534 100644
--- a/ui/app/components/pages/create-account/import-account/json.js
+++ b/ui/app/components/pages/create-account/import-account/json.js
@@ -51,7 +51,7 @@ class JsonImportSubview extends Component {
h('div.new-account-create-form__buttons', {}, [
- h('button.btn-secondary.new-account-create-form__button', {
+ h('button.btn-default.new-account-create-form__button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, [
this.context.t('cancel'),
@@ -82,18 +82,19 @@ class JsonImportSubview extends Component {
}
createNewKeychain () {
+ const { firstAddress, displayWarning, importNewJsonAccount, setSelectedAddress } = this.props
const state = this.state
if (!state) {
const message = this.context.t('validFileImport')
- return this.props.displayWarning(message)
+ return displayWarning(message)
}
const { fileContents } = state
if (!fileContents) {
const message = this.context.t('needImportFile')
- return this.props.displayWarning(message)
+ return displayWarning(message)
}
const passwordInput = document.getElementById('json-password-box')
@@ -101,12 +102,19 @@ class JsonImportSubview extends Component {
if (!password) {
const message = this.context.t('needImportPassword')
- return this.props.displayWarning(message)
+ return displayWarning(message)
}
- this.props.importNewJsonAccount([ fileContents, password ])
- // JS runtime requires caught rejections but failures are handled by Redux
- .catch()
+ importNewJsonAccount([ fileContents, password ])
+ .then(({ selectedAddress }) => {
+ if (selectedAddress) {
+ history.push(DEFAULT_ROUTE)
+ } else {
+ displayWarning('Error importing account.')
+ setSelectedAddress(firstAddress)
+ }
+ })
+ .catch(err => displayWarning(err))
}
}
@@ -114,14 +122,17 @@ JsonImportSubview.propTypes = {
error: PropTypes.string,
goHome: PropTypes.func,
displayWarning: PropTypes.func,
+ firstAddress: PropTypes.string,
importNewJsonAccount: PropTypes.func,
history: PropTypes.object,
+ setSelectedAddress: PropTypes.func,
t: PropTypes.func,
}
const mapStateToProps = state => {
return {
error: state.appState.warning,
+ firstAddress: Object.keys(state.metamask.accounts)[0],
}
}
@@ -130,6 +141,7 @@ const mapDispatchToProps = dispatch => {
goHome: () => dispatch(actions.goHome()),
displayWarning: warning => dispatch(actions.displayWarning(warning)),
importNewJsonAccount: options => dispatch(actions.importNewAccount('JSON File', options)),
+ setSelectedAddress: (address) => dispatch(actions.setSelectedAddress(address)),
}
}