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

Finish network settings redesign

This commit is contained in:
Erik Marks 2020-10-28 16:10:41 -07:00
parent 8d3091040c
commit 47d94489b7
5 changed files with 55 additions and 34 deletions

View File

@ -7,8 +7,13 @@ import * as actions from '../../../store/actions'
import { import {
openAlert as displayInvalidCustomNetworkAlert, openAlert as displayInvalidCustomNetworkAlert,
} from '../../../ducks/alerts/invalid-custom-network' } from '../../../ducks/alerts/invalid-custom-network'
import { NETWORKS_FORM_ROUTE } from '../../../helpers/constants/routes' import {
import { isPrefixedFormattedHexString } from '../../../../../app/scripts/lib/util' NETWORKS_ROUTE,
NETWORKS_FORM_ROUTE,
} from '../../../helpers/constants/routes'
import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../../app/scripts/lib/enums'
import { getEnvironmentType, isPrefixedFormattedHexString } from '../../../../../app/scripts/lib/util'
import { Dropdown, DropdownMenuItem } from './components/dropdown' import { Dropdown, DropdownMenuItem } from './components/dropdown'
import NetworkDropdownIcon from './components/network-dropdown-icon' import NetworkDropdownIcon from './components/network-dropdown-icon'
@ -44,6 +49,9 @@ function mapDispatchToProps (dispatch) {
setNetworksTabAddMode: (isInAddMode) => { setNetworksTabAddMode: (isInAddMode) => {
dispatch(actions.setNetworksTabAddMode(isInAddMode)) dispatch(actions.setNetworksTabAddMode(isInAddMode))
}, },
setSelectedSettingsRpcUrl: (url) => {
dispatch(actions.setSelectedSettingsRpcUrl(url))
},
displayInvalidCustomNetworkAlert: (networkName) => { displayInvalidCustomNetworkAlert: (networkName) => {
dispatch(displayInvalidCustomNetworkAlert(networkName)) dispatch(displayInvalidCustomNetworkAlert(networkName))
}, },
@ -67,6 +75,7 @@ class NetworkDropdown extends Component {
setRpcTarget: PropTypes.func.isRequired, setRpcTarget: PropTypes.func.isRequired,
hideNetworkDropdown: PropTypes.func.isRequired, hideNetworkDropdown: PropTypes.func.isRequired,
setNetworksTabAddMode: PropTypes.func.isRequired, setNetworksTabAddMode: PropTypes.func.isRequired,
setSelectedSettingsRpcUrl: PropTypes.func.isRequired,
frequentRpcListDetail: PropTypes.array.isRequired, frequentRpcListDetail: PropTypes.array.isRequired,
networkDropdownOpen: PropTypes.bool.isRequired, networkDropdownOpen: PropTypes.bool.isRequired,
history: PropTypes.object.isRequired, history: PropTypes.object.isRequired,
@ -176,7 +185,11 @@ class NetworkDropdown extends Component {
} }
render () { render () {
const { provider: { type: providerType, rpcUrl: activeNetwork }, setNetworksTabAddMode } = this.props const {
provider: { type: providerType, rpcUrl: activeNetwork },
setNetworksTabAddMode,
setSelectedSettingsRpcUrl,
} = this.props
const rpcListDetail = this.props.frequentRpcListDetail const rpcListDetail = this.props.frequentRpcListDetail
const isOpen = this.props.networkDropdownOpen const isOpen = this.props.networkDropdownOpen
const dropdownMenuItemStyle = { const dropdownMenuItemStyle = {
@ -337,8 +350,13 @@ class NetworkDropdown extends Component {
<DropdownMenuItem <DropdownMenuItem
closeMenu={() => this.props.hideNetworkDropdown()} closeMenu={() => this.props.hideNetworkDropdown()}
onClick={() => { onClick={() => {
this.props.history.push(
getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN
? NETWORKS_ROUTE
: NETWORKS_FORM_ROUTE,
)
setSelectedSettingsRpcUrl('')
setNetworksTabAddMode(true) setNetworksTabAddMode(true)
this.props.history.push(NETWORKS_FORM_ROUTE)
}} }}
style={dropdownMenuItemStyle} style={dropdownMenuItemStyle}
> >

View File

@ -100,26 +100,23 @@
max-width: 343px; max-width: 343px;
@media screen and (max-width: 575px) { @media screen and (max-width: 575px) {
flex: 1;
overflow-y: auto;
max-width: 100vw; max-width: 100vw;
width: 100vw; width: 100vw;
} }
} }
&__add-network-button-wrapper { &__networks-list-popup-footer {
display: none; width: 100%;
display: flex;
justify-content: center;
padding-top: 23px;
padding-bottom: 23px;
border-top: 1px solid #d8d8d8;
@media screen and (max-width: 575px) { .button {
width: 100%; width: 178px;
display: flex;
padding-top: 23px;
padding-bottom: 23px;
justify-content: center;
align-items: center;
border-top: 1px solid #d8d8d8;
.button {
width: 178px;
}
} }
} }

View File

@ -238,7 +238,7 @@ export default class NetworksTab extends PureComponent {
{this.renderNetworksTabContent()} {this.renderNetworksTabContent()}
{!isFullScreen && !shouldRenderNetworkForm {!isFullScreen && !shouldRenderNetworkForm
? ( ? (
<div className="networks-tab__add-network-button-wrapper"> <div className="networks-tab__networks-list-popup-footer">
<Button <Button
type="primary" type="primary"
onClick={(event) => { onClick={(event) => {

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Switch, Route, matchPath } from 'react-router-dom' import { Switch, Route, Redirect, matchPath } from 'react-router-dom'
import classnames from 'classnames' import classnames from 'classnames'
import TabBar from '../../components/app/tab-bar' import TabBar from '../../components/app/tab-bar'
import { import {
@ -35,7 +35,8 @@ class SettingsPage extends PureComponent {
currentPath: PropTypes.string, currentPath: PropTypes.string,
history: PropTypes.object, history: PropTypes.object,
isAddressEntryPage: PropTypes.bool, isAddressEntryPage: PropTypes.bool,
isPopupView: PropTypes.bool, isPopup: PropTypes.bool,
isFullScreen: PropTypes.bool,
pathnameI18nKey: PropTypes.string, pathnameI18nKey: PropTypes.string,
initialBreadCrumbRoute: PropTypes.string, initialBreadCrumbRoute: PropTypes.string,
breadCrumbTextKey: PropTypes.string, breadCrumbTextKey: PropTypes.string,
@ -86,13 +87,13 @@ class SettingsPage extends PureComponent {
renderTitle () { renderTitle () {
const { t } = this.context const { t } = this.context
const { isPopupView, pathnameI18nKey, addressName } = this.props const { isPopup, pathnameI18nKey, addressName } = this.props
let titleText let titleText
if (isPopupView && addressName) { if (isPopup && addressName) {
titleText = addressName titleText = addressName
} else if (pathnameI18nKey && isPopupView) { } else if (pathnameI18nKey && isPopup) {
titleText = t(pathnameI18nKey) titleText = t(pathnameI18nKey)
} else { } else {
titleText = t('settings') titleText = t('settings')
@ -109,7 +110,7 @@ class SettingsPage extends PureComponent {
const { t } = this.context const { t } = this.context
const { const {
currentPath, currentPath,
isPopupView, isPopup,
isAddressEntryPage, isAddressEntryPage,
pathnameI18nKey, pathnameI18nKey,
addressName, addressName,
@ -121,7 +122,7 @@ class SettingsPage extends PureComponent {
let subheaderText let subheaderText
if (isPopupView && isAddressEntryPage) { if (isPopup && isAddressEntryPage) {
subheaderText = t('settings') subheaderText = t('settings')
} else if (initialBreadCrumbKey) { } else if (initialBreadCrumbKey) {
subheaderText = t(initialBreadCrumbKey) subheaderText = t(initialBreadCrumbKey)
@ -178,6 +179,8 @@ class SettingsPage extends PureComponent {
} }
renderContent () { renderContent () {
const { isFullScreen } = this.props
return ( return (
<Switch> <Switch>
<Route <Route
@ -205,11 +208,9 @@ class SettingsPage extends PureComponent {
path={NETWORKS_ROUTE} path={NETWORKS_ROUTE}
component={NetworksTab} component={NetworksTab}
/> />
<Route <Route exact path={NETWORKS_FORM_ROUTE}>
exact {isFullScreen ? <Redirect to={NETWORKS_ROUTE} /> : NetworksTab}
path={NETWORKS_FORM_ROUTE} </Route>
component={NetworksTab}
/>
<Route <Route
exact exact
path={SECURITY_ROUTE} path={SECURITY_ROUTE}

View File

@ -3,7 +3,10 @@ import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { getAddressBookEntryName } from '../../selectors' import { getAddressBookEntryName } from '../../selectors'
import { isValidAddress } from '../../helpers/utils/util' import { isValidAddress } from '../../helpers/utils/util'
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums' import {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_FULLSCREEN,
} from '../../../../app/scripts/lib/enums'
import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { getEnvironmentType } from '../../../../app/scripts/lib/util'
import { getMostRecentOverviewPage } from '../../ducks/history/history' import { getMostRecentOverviewPage } from '../../ducks/history/history'
@ -53,7 +56,8 @@ const mapStateToProps = (state, ownProps) => {
const isEditMyAccountsContactPage = Boolean(pathname.match(CONTACT_MY_ACCOUNTS_EDIT_ROUTE)) const isEditMyAccountsContactPage = Boolean(pathname.match(CONTACT_MY_ACCOUNTS_EDIT_ROUTE))
const isNetworksFormPage = Boolean(pathname.match(NETWORKS_FORM_ROUTE)) const isNetworksFormPage = Boolean(pathname.match(NETWORKS_FORM_ROUTE))
const isPopupView = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP const isPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP
const isFullScreen = getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN
const pathnameI18nKey = ROUTES_TO_I18N_KEYS[pathname] const pathnameI18nKey = ROUTES_TO_I18N_KEYS[pathname]
let backRoute = SETTINGS_ROUTE let backRoute = SETTINGS_ROUTE
@ -85,7 +89,8 @@ const mapStateToProps = (state, ownProps) => {
isMyAccountsPage, isMyAccountsPage,
backRoute, backRoute,
currentPath: pathname, currentPath: pathname,
isPopupView, isPopup,
isFullScreen,
pathnameI18nKey, pathnameI18nKey,
addressName, addressName,
initialBreadCrumbRoute, initialBreadCrumbRoute,