1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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.
This commit is contained in:
Mark Stacey 2020-11-05 13:04:12 -03:30 committed by GitHub
parent ad478f8393
commit f5265c24ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 0 additions and 121 deletions

View File

@ -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,

View File

@ -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 }} />
}

View File

@ -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,

View File

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

View File

@ -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 />
}
}

View File

@ -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)

View File

@ -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()
})
})
})

View File

@ -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