Remove unnecessary lock page (#9793)

This page appears to serve the sole purpose of locking the extension
and redirecting back to the base route if the page is refreshed during
the onboarding flow. This ineffectual before the vault has been
initialized, and it's a barrier to resuming interrupted onboarding
flows when done after initialization.
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent ad478f8393
commit f5265c24ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      ui/app/helpers/constants/routes.js
  2. 5
      ui/app/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.component.js
  3. 17
      ui/app/pages/first-time-flow/first-time-flow-switch/tests/first-time-flow-switch.test.js
  4. 1
      ui/app/pages/lock/index.js
  5. 26
      ui/app/pages/lock/lock.component.js
  6. 26
      ui/app/pages/lock/lock.container.js
  7. 40
      ui/app/pages/lock/tests/lock.test.js
  8. 3
      ui/app/pages/routes/routes.component.js

@ -1,6 +1,5 @@
const DEFAULT_ROUTE = '/'
const UNLOCK_ROUTE = '/unlock'
const LOCK_ROUTE = '/lock'
const ASSET_ROUTE = '/asset'
const SETTINGS_ROUTE = '/settings'
const GENERAL_ROUTE = '/settings/general'
@ -68,7 +67,6 @@ const ENCRYPTION_PUBLIC_KEY_REQUEST_PATH = '/encryption-public-key-request'
const PATH_NAME_MAP = {
[DEFAULT_ROUTE]: 'Home',
[UNLOCK_ROUTE]: 'Unlock Page',
[LOCK_ROUTE]: 'Lock Page',
[`${ASSET_ROUTE}/:asset`]: `Asset Page`,
[SETTINGS_ROUTE]: 'Settings Page',
[GENERAL_ROUTE]: 'General Settings Page',
@ -135,7 +133,6 @@ export {
ALERTS_ROUTE,
ASSET_ROUTE,
UNLOCK_ROUTE,
LOCK_ROUTE,
SETTINGS_ROUTE,
REVEAL_SEED_ROUTE,
MOBILE_SYNC_ROUTE,

@ -3,7 +3,6 @@ import PropTypes from 'prop-types'
import { Redirect } from 'react-router-dom'
import {
DEFAULT_ROUTE,
LOCK_ROUTE,
INITIALIZE_WELCOME_ROUTE,
INITIALIZE_UNLOCK_ROUTE,
} from '../../../helpers/constants/routes'
@ -22,10 +21,6 @@ export default class FirstTimeFlowSwitch extends PureComponent {
return <Redirect to={{ pathname: DEFAULT_ROUTE }} />
}
if (isUnlocked) {
return <Redirect to={{ pathname: LOCK_ROUTE }} />
}
if (!isInitialized) {
return <Redirect to={{ pathname: INITIALIZE_WELCOME_ROUTE }} />
}

@ -3,7 +3,6 @@ import React from 'react'
import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
import {
DEFAULT_ROUTE,
LOCK_ROUTE,
INITIALIZE_WELCOME_ROUTE,
INITIALIZE_UNLOCK_ROUTE,
} from '../../../../helpers/constants/routes'
@ -35,22 +34,6 @@ describe('FirstTimeFlowSwitch', function () {
)
})
it('redirects to /lock route when isUnlocked is true ', function () {
const props = {
completedOnboarding: false,
isUnlocked: true,
}
const wrapper = mountWithRouter(
<FirstTimeFlowSwitch.WrappedComponent {...props} />,
)
assert.equal(
wrapper.find('Lifecycle').find({ to: { pathname: LOCK_ROUTE } }).length,
1,
)
})
it('redirects to /welcome route when isInitialized is false', function () {
const props = {
completedOnboarding: false,

@ -1 +0,0 @@
export { default } from './lock.container'

@ -1,26 +0,0 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import Loading from '../../components/ui/loading-screen'
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
export default class Lock extends PureComponent {
static propTypes = {
history: PropTypes.object,
isUnlocked: PropTypes.bool,
lockMetamask: PropTypes.func,
}
componentDidMount() {
const { lockMetamask, isUnlocked, history } = this.props
if (isUnlocked) {
lockMetamask().then(() => history.push(DEFAULT_ROUTE))
} else {
history.replace(DEFAULT_ROUTE)
}
}
render() {
return <Loading />
}
}

@ -1,26 +0,0 @@
import { compose } from 'redux'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { lockMetamask } from '../../store/actions'
import Lock from './lock.component'
const mapStateToProps = (state) => {
const {
metamask: { isUnlocked },
} = state
return {
isUnlocked,
}
}
const mapDispatchToProps = (dispatch) => {
return {
lockMetamask: () => dispatch(lockMetamask()),
}
}
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
)(Lock)

@ -1,40 +0,0 @@
import assert from 'assert'
import React from 'react'
import sinon from 'sinon'
import { mountWithRouter } from '../../../../../test/lib/render-helpers'
import Lock from '..'
describe('Lock', function () {
it('replaces history with default route when isUnlocked false', function () {
const props = {
isUnlocked: false,
history: {
replace: sinon.spy(),
},
}
mountWithRouter(<Lock.WrappedComponent {...props} />)
assert.equal(props.history.replace.getCall(0).args[0], '/')
})
it('locks and pushes history with default route when isUnlocked true', function (done) {
const props = {
isUnlocked: true,
lockMetamask: sinon.stub(),
history: {
push: sinon.spy(),
},
}
props.lockMetamask.resolves()
mountWithRouter(<Lock.WrappedComponent {...props} />)
assert(props.lockMetamask.calledOnce)
setImmediate(() => {
assert.equal(props.history.push.getCall(0).args[0], '/')
done()
})
})
})

@ -13,7 +13,6 @@ import Home from '../home'
import Settings from '../settings'
import Authenticated from '../../helpers/higher-order-components/authenticated'
import Initialized from '../../helpers/higher-order-components/initialized'
import Lock from '../lock'
import PermissionsConnect from '../permissions-connect'
import RestoreVaultPage from '../keychains/restore-vault'
import RevealSeedConfirmation from '../keychains/reveal-seed'
@ -43,7 +42,6 @@ import {
DEFAULT_ROUTE,
INITIALIZE_ROUTE,
INITIALIZE_UNLOCK_ROUTE,
LOCK_ROUTE,
MOBILE_SYNC_ROUTE,
NEW_ACCOUNT_ROUTE,
RESTORE_VAULT_ROUTE,
@ -113,7 +111,6 @@ export default class Routes extends Component {
const routes = (
<Switch>
<Route path={LOCK_ROUTE} component={Lock} exact />
<Route path={INITIALIZE_ROUTE} component={FirstTimeFlow} />
<Initialized path={UNLOCK_ROUTE} component={UnlockPage} exact />
<Initialized

Loading…
Cancel
Save