Simplify routing to fix breakage in popup

feature/default_network_editable
Erik Marks 4 years ago
parent 58d19745c9
commit 2393749809
  1. 9
      ui/app/pages/settings/networks-tab/network-form/network-form.component.js
  2. 4
      ui/app/pages/settings/networks-tab/networks-tab.component.js
  3. 12
      ui/app/pages/settings/settings.component.js
  4. 7
      ui/app/pages/settings/settings.container.js

@ -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…
Cancel
Save