aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/account-menu/index.js22
-rw-r--r--ui/app/components/pages/authenticated.js16
-rw-r--r--ui/app/components/pages/keychains/reveal-seed.js5
-rw-r--r--ui/app/components/pages/metamask-route.js28
-rw-r--r--ui/app/components/pages/notice.js16
-rw-r--r--ui/app/components/pages/unauthenticated/index.js38
6 files changed, 83 insertions, 42 deletions
diff --git a/ui/app/components/account-menu/index.js b/ui/app/components/account-menu/index.js
index 0965cba38..0d3b43ae9 100644
--- a/ui/app/components/account-menu/index.js
+++ b/ui/app/components/account-menu/index.js
@@ -8,7 +8,7 @@ const actions = require('../../actions')
const { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu')
const Identicon = require('../identicon')
const { formatBalance } = require('../../util')
-const { SETTINGS_ROUTE, INFO_ROUTE, IMPORT_ACCOUNT_ROUTE } = require('../../routes')
+const { SETTINGS_ROUTE, INFO_ROUTE, IMPORT_ACCOUNT_ROUTE, DEFAULT_ROUTE } = require('../../routes')
module.exports = compose(
withRouter,
@@ -40,22 +40,10 @@ function mapDispatchToProps (dispatch) {
dispatch(actions.displayWarning(null))
dispatch(actions.toggleAccountMenu())
},
- showConfigPage: () => {
- dispatch(actions.showConfigPage())
- dispatch(actions.toggleAccountMenu())
- },
showNewAccountModal: () => {
dispatch(actions.showModal({ name: 'NEW_ACCOUNT' }))
dispatch(actions.toggleAccountMenu())
},
- showImportPage: () => {
- dispatch(actions.showImportPage())
- dispatch(actions.toggleAccountMenu())
- },
- showInfoPage: () => {
- dispatch(actions.showInfoPage())
- dispatch(actions.toggleAccountMenu())
- },
}
}
@@ -64,10 +52,7 @@ AccountMenu.prototype.render = function () {
isAccountMenuOpen,
toggleAccountMenu,
showNewAccountModal,
- showImportPage,
lockMetamask,
- showConfigPage,
- showInfoPage,
history,
} = this.props
@@ -78,7 +63,10 @@ AccountMenu.prototype.render = function () {
}, [
'My Accounts',
h('button.account-menu__logout-button', {
- onClick: lockMetamask,
+ onClick: () => {
+ lockMetamask()
+ history.push(DEFAULT_ROUTE)
+ },
}, 'Log out'),
]),
h(Divider),
diff --git a/ui/app/components/pages/authenticated.js b/ui/app/components/pages/authenticated.js
index 78f3a4225..89bd238d2 100644
--- a/ui/app/components/pages/authenticated.js
+++ b/ui/app/components/pages/authenticated.js
@@ -1,26 +1,26 @@
const { connect } = require('react-redux')
const PropTypes = require('prop-types')
-const { Redirect, Route } = require('react-router-dom')
+const { Redirect } = require('react-router-dom')
const h = require('react-hyperscript')
-const { UNLOCK_ROUTE, INITIALIZE_MENU_ROUTE } = require('../../routes')
+const MetamaskRoute = require('./metamask-route')
+const { UNLOCK_ROUTE, INITIALIZE_ROUTE } = require('../../routes')
const Authenticated = ({ component: Component, isUnlocked, isInitialized, ...props }) => {
-
- const render = props => {
+ const component = renderProps => {
switch (true) {
case isUnlocked:
- return h(Component, { ...props })
+ return h(Component, { ...renderProps })
case !isInitialized:
- return h(Redirect, { to: { pathname: INITIALIZE_MENU_ROUTE } })
+ return h(Redirect, { to: { pathname: INITIALIZE_ROUTE } })
default:
return h(Redirect, { to: { pathname: UNLOCK_ROUTE } })
}
}
return (
- h(Route, {
+ h(MetamaskRoute, {
...props,
- render,
+ component,
})
)
}
diff --git a/ui/app/components/pages/keychains/reveal-seed.js b/ui/app/components/pages/keychains/reveal-seed.js
index dc2cfc23e..029eb7d8e 100644
--- a/ui/app/components/pages/keychains/reveal-seed.js
+++ b/ui/app/components/pages/keychains/reveal-seed.js
@@ -8,7 +8,10 @@ const { DEFAULT_ROUTE } = require('../../../routes')
class RevealSeedPage extends Component {
componentDidMount () {
- document.getElementById('password-box').focus()
+ const passwordBox = document.getElementById('password-box')
+ if (passwordBox) {
+ passwordBox.focus()
+ }
}
checkConfirmation (event) {
diff --git a/ui/app/components/pages/metamask-route.js b/ui/app/components/pages/metamask-route.js
new file mode 100644
index 000000000..23c5b5199
--- /dev/null
+++ b/ui/app/components/pages/metamask-route.js
@@ -0,0 +1,28 @@
+const { connect } = require('react-redux')
+const PropTypes = require('prop-types')
+const { Route } = require('react-router-dom')
+const h = require('react-hyperscript')
+
+const MetamaskRoute = ({ component, mascaraComponent, isMascara, ...props }) => {
+ return (
+ h(Route, {
+ ...props,
+ component: isMascara && mascaraComponent ? mascaraComponent : component,
+ })
+ )
+}
+
+MetamaskRoute.propTypes = {
+ component: PropTypes.func,
+ mascaraComponent: PropTypes.func,
+ isMascara: PropTypes.bool,
+}
+
+const mapStateToProps = state => {
+ const { metamask: { isMascara } } = state
+ return {
+ isMascara,
+ }
+}
+
+module.exports = connect(mapStateToProps)(MetamaskRoute)
diff --git a/ui/app/components/pages/notice.js b/ui/app/components/pages/notice.js
index 8e68cd52b..2329a9147 100644
--- a/ui/app/components/pages/notice.js
+++ b/ui/app/components/pages/notice.js
@@ -53,7 +53,6 @@ class Notice extends Component {
render () {
const { notice = {} } = this.props
const { title, date, body } = notice
- // const state = this.state || { disclaimerDisabled: true }
const { disclaimerDisabled } = this.state
return (
@@ -156,21 +155,6 @@ class Notice extends Component {
const mapStateToProps = state => {
const { metamask } = state
const { noActiveNotices, lastUnreadNotice, lostAccounts } = metamask
- // if (!props.noActiveNotices) {
- // log.debug('rendering notice screen for unread notices.')
- // return h(NoticeScreen, {
- // notice: props.lastUnreadNotice,
- // key: 'NoticeScreen',
- // onConfirm: () => props.dispatch(actions.markNoticeRead(props.lastUnreadNotice)),
- // })
- // } else if (props.lostAccounts && props.lostAccounts.length > 0) {
- // log.debug('rendering notice screen for lost accounts view.')
- // return h(NoticeScreen, {
- // notice: generateLostAccountsNotice(props.lostAccounts),
- // key: 'LostAccountsNotice',
- // onConfirm: () => props.dispatch(actions.markAccountsFound()),
- // })
- // }
return {
noActiveNotices,
diff --git a/ui/app/components/pages/unauthenticated/index.js b/ui/app/components/pages/unauthenticated/index.js
new file mode 100644
index 000000000..f8b5fa172
--- /dev/null
+++ b/ui/app/components/pages/unauthenticated/index.js
@@ -0,0 +1,38 @@
+const { connect } = require('react-redux')
+const PropTypes = require('prop-types')
+const { Redirect } = require('react-router-dom')
+const h = require('react-hyperscript')
+const { INITIALIZE_ROUTE } = require('../../../routes')
+const MetamaskRoute = require('../metamask-route')
+
+const Unauthenticated = ({ component: Component, isInitialized, ...props }) => {
+ const component = renderProps => {
+ return isInitialized
+ ? h(Component, { ...renderProps })
+ : h(Redirect, { to: { pathname: INITIALIZE_ROUTE } })
+ }
+
+ return (
+ h(MetamaskRoute, {
+ ...props,
+ component,
+ })
+ )
+}
+
+Unauthenticated.propTypes = {
+ component: PropTypes.func,
+ isInitialized: PropTypes.bool,
+ isMascara: PropTypes.bool,
+ mascaraComponent: PropTypes.func,
+}
+
+const mapStateToProps = state => {
+ const { metamask: { isInitialized, isMascara } } = state
+ return {
+ isInitialized,
+ isMascara,
+ }
+}
+
+module.exports = connect(mapStateToProps)(Unauthenticated)