mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Simplify routing to fix breakage in popup
This commit is contained in:
parent
58d19745c9
commit
2393749809
@ -68,10 +68,6 @@ export default class NetworkForm extends PureComponent {
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
// onClear will push the network settings route unless was pass false.
|
||||
// Since we call onClear to cause this component to be unmounted, the
|
||||
// route will already have been updated, and we avoid setting it twice.
|
||||
this.props.onClear(false)
|
||||
this.setState({
|
||||
rpcUrl: '',
|
||||
chainId: '',
|
||||
@ -80,6 +76,11 @@ export default class NetworkForm extends PureComponent {
|
||||
blockExplorerUrl: '',
|
||||
errors: {},
|
||||
})
|
||||
|
||||
// onClear will push the network settings route unless was pass false.
|
||||
// Since we call onClear to cause this component to be unmounted, the
|
||||
// route will already have been updated, and we avoid setting it twice.
|
||||
this.props.onClear(false)
|
||||
}
|
||||
|
||||
resetForm () {
|
||||
|
@ -101,7 +101,9 @@ export default class NetworksTab extends PureComponent {
|
||||
onClick={() => {
|
||||
setNetworksTabAddMode(false)
|
||||
setSelectedSettingsRpcUrl(rpcUrl)
|
||||
!isFullScreen && history.push(NETWORKS_FORM_ROUTE)
|
||||
if (!isFullScreen) {
|
||||
history.push(NETWORKS_FORM_ROUTE)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<NetworkDropdownIcon
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Switch, Route, Redirect, matchPath } from 'react-router-dom'
|
||||
import { Switch, Route, matchPath } from 'react-router-dom'
|
||||
import classnames from 'classnames'
|
||||
import TabBar from '../../components/app/tab-bar'
|
||||
import {
|
||||
@ -11,7 +11,6 @@ import {
|
||||
ABOUT_US_ROUTE,
|
||||
SETTINGS_ROUTE,
|
||||
NETWORKS_ROUTE,
|
||||
NETWORKS_FORM_ROUTE,
|
||||
CONTACT_LIST_ROUTE,
|
||||
CONTACT_ADD_ROUTE,
|
||||
CONTACT_EDIT_ROUTE,
|
||||
@ -36,7 +35,6 @@ class SettingsPage extends PureComponent {
|
||||
history: PropTypes.object,
|
||||
isAddressEntryPage: PropTypes.bool,
|
||||
isPopup: PropTypes.bool,
|
||||
isFullScreen: PropTypes.bool,
|
||||
pathnameI18nKey: PropTypes.string,
|
||||
initialBreadCrumbRoute: PropTypes.string,
|
||||
breadCrumbTextKey: PropTypes.string,
|
||||
@ -130,7 +128,7 @@ class SettingsPage extends PureComponent {
|
||||
subheaderText = t(pathnameI18nKey || 'general')
|
||||
}
|
||||
|
||||
return currentPath !== NETWORKS_ROUTE && (
|
||||
return !currentPath?.startsWith(NETWORKS_ROUTE) && (
|
||||
<div className="settings-page__subheader">
|
||||
<div
|
||||
className={classnames({ 'settings-page__subheader--link': initialBreadCrumbRoute })}
|
||||
@ -179,8 +177,6 @@ class SettingsPage extends PureComponent {
|
||||
}
|
||||
|
||||
renderContent () {
|
||||
const { isFullScreen } = this.props
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Route
|
||||
@ -204,13 +200,9 @@ class SettingsPage extends PureComponent {
|
||||
component={AlertsTab}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={NETWORKS_ROUTE}
|
||||
component={NetworksTab}
|
||||
/>
|
||||
<Route exact path={NETWORKS_FORM_ROUTE}>
|
||||
{isFullScreen ? <Redirect to={NETWORKS_ROUTE} /> : NetworksTab}
|
||||
</Route>
|
||||
<Route
|
||||
exact
|
||||
path={SECURITY_ROUTE}
|
||||
|
@ -3,10 +3,7 @@ import { connect } from 'react-redux'
|
||||
import { withRouter } from 'react-router-dom'
|
||||
import { getAddressBookEntryName } from '../../selectors'
|
||||
import { isValidAddress } from '../../helpers/utils/util'
|
||||
import {
|
||||
ENVIRONMENT_TYPE_POPUP,
|
||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||
} from '../../../../app/scripts/lib/enums'
|
||||
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
|
||||
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
||||
import { getMostRecentOverviewPage } from '../../ducks/history/history'
|
||||
|
||||
@ -57,7 +54,6 @@ const mapStateToProps = (state, ownProps) => {
|
||||
const isNetworksFormPage = Boolean(pathname.match(NETWORKS_FORM_ROUTE))
|
||||
|
||||
const isPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP
|
||||
const isFullScreen = getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN
|
||||
const pathnameI18nKey = ROUTES_TO_I18N_KEYS[pathname]
|
||||
|
||||
let backRoute = SETTINGS_ROUTE
|
||||
@ -90,7 +86,6 @@ const mapStateToProps = (state, ownProps) => {
|
||||
backRoute,
|
||||
currentPath: pathname,
|
||||
isPopup,
|
||||
isFullScreen,
|
||||
pathnameI18nKey,
|
||||
addressName,
|
||||
initialBreadCrumbRoute,
|
||||
|
Loading…
x
Reference in New Issue
Block a user