aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pages
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2017-12-04 14:24:30 +0800
committerAlexander Tseung <alextsg@gmail.com>2017-12-15 06:11:23 +0800
commitdde39e82b5723ba8056b73f0f823d40c3e702a99 (patch)
tree4143756e6660ac16b896a58dffef612f99770fd5 /ui/app/components/pages
parente226b10a89d87af07c7c35ff1251a8264f3bb1b8 (diff)
downloadtangerine-wallet-browser-dde39e82b5723ba8056b73f0f823d40c3e702a99.tar.gz
tangerine-wallet-browser-dde39e82b5723ba8056b73f0f823d40c3e702a99.tar.zst
tangerine-wallet-browser-dde39e82b5723ba8056b73f0f823d40c3e702a99.zip
Add routes for mascara
Diffstat (limited to 'ui/app/components/pages')
-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
5 files changed, 78 insertions, 25 deletions
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)