From 55309147762860d1af6812513400dc44c964d216 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Tue, 27 Oct 2020 14:55:09 -0700 Subject: [PATCH 01/13] Standardize appearance of network settings --- ui/app/pages/settings/networks-tab/index.scss | 13 ++-- .../network-form/network-form.component.js | 24 +++++- .../networks-tab/networks-tab.component.js | 73 +++++++++++-------- ui/app/pages/settings/settings.component.js | 2 +- ui/app/pages/settings/settings.container.js | 8 +- 5 files changed, 75 insertions(+), 45 deletions(-) diff --git a/ui/app/pages/settings/networks-tab/index.scss b/ui/app/pages/settings/networks-tab/index.scss index 455adb971..f0b66f62d 100644 --- a/ui/app/pages/settings/networks-tab/index.scss +++ b/ui/app/pages/settings/networks-tab/index.scss @@ -2,12 +2,15 @@ &__content { margin-top: 24px; display: flex; + flex-direction: row; height: 100%; max-width: 739px; justify-content: space-between; @media screen and (max-width: 575px) { margin-top: 0; + flex-direction: column; + overflow-x: hidden; } } @@ -78,20 +81,21 @@ &__network-form-row { @media screen and (max-width: 575px) { - display: flex; - flex-direction: column; width: 93%; } &--warning { background-color: #fefae8; border: 1px solid #ffd33d; - width: 93%; border-radius: 5px; box-sizing: border-box; padding: 12px; margin: 12px 0; font-size: 12px; + + @media screen and (max-width: 575px) { + width: 93%; + } } } @@ -121,7 +125,6 @@ @media screen and (max-width: 575px) { max-width: 100vw; width: 100vw; - overflow-y: scroll; } } @@ -130,7 +133,7 @@ @media screen and (max-width: 575px) { display: flex; - padding-top: 19px; + padding-top: 23px; padding-bottom: 23px; justify-content: center; align-items: center; diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index f689c8ace..324c750b9 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -30,6 +30,7 @@ export default class NetworkForm extends PureComponent { blockExplorerUrl: PropTypes.string, rpcPrefs: PropTypes.object, rpcUrls: PropTypes.array, + isFullScreen: PropTypes.bool, } state = { @@ -136,11 +137,12 @@ export default class NetworkForm extends PureComponent { onCancel = () => { const { + isFullScreen, networksTabIsInAddMode, onClear, } = this.props - if (networksTabIsInAddMode) { + if (networksTabIsInAddMode || !isFullScreen) { onClear() } else { this.resetForm() @@ -327,6 +329,7 @@ export default class NetworkForm extends PureComponent { viewOnly, isCurrentRpcTarget, networksTabIsInAddMode, + isFullScreen, } = this.props const { networkName, @@ -337,6 +340,8 @@ export default class NetworkForm extends PureComponent { errors, } = this.state + const deletable = !networksTabIsInAddMode && !isCurrentRpcTarget && !viewOnly + const isSubmitDisabled = ( viewOnly || this.stateIsUnchanged() || @@ -344,7 +349,18 @@ export default class NetworkForm extends PureComponent { !chainId || Object.values(errors).some((x) => x) ) - const deletable = !networksTabIsInAddMode && !isCurrentRpcTarget && !viewOnly + + // The secondary button is either the form cancel button, or a "back" + // button. It is never disabled in the popup, and sometimes disabled in + // the fullscreen UI. + const secondaryButtonDisabled = ( + isFullScreen && (viewOnly || this.stateIsUnchanged()) + ) + const secondaryButtonMessageKey = ( + !isFullScreen && viewOnly + ? 'back' + : 'cancel' + ) return (
@@ -397,9 +413,9 @@ export default class NetworkForm extends PureComponent { -
- ) - : null - } + {isFullScreen && this.renderSubHeader()} +
+ {this.renderNetworksTabContent(isPopup)} + {!networkIsSelected && !networksTabIsInAddMode + ? ( +
+ +
+ ) + : null + } +
) } diff --git a/ui/app/pages/settings/settings.component.js b/ui/app/pages/settings/settings.component.js index d4372eed0..1b0462aa6 100644 --- a/ui/app/pages/settings/settings.component.js +++ b/ui/app/pages/settings/settings.component.js @@ -57,7 +57,7 @@ class SettingsPage extends PureComponent { >
{ - currentPath !== SETTINGS_ROUTE && currentPath !== NETWORKS_ROUTE && ( + currentPath !== SETTINGS_ROUTE && (
history.push(backRoute)} diff --git a/ui/app/pages/settings/settings.container.js b/ui/app/pages/settings/settings.container.js index 8336c0314..51895e4bc 100644 --- a/ui/app/pages/settings/settings.container.js +++ b/ui/app/pages/settings/settings.container.js @@ -8,12 +8,9 @@ import { getEnvironmentType } from '../../../../app/scripts/lib/util' import { getMostRecentOverviewPage } from '../../ducks/history/history' import { + ABOUT_US_ROUTE, ADVANCED_ROUTE, - SECURITY_ROUTE, - GENERAL_ROUTE, ALERTS_ROUTE, - ABOUT_US_ROUTE, - SETTINGS_ROUTE, CONTACT_LIST_ROUTE, CONTACT_ADD_ROUTE, CONTACT_EDIT_ROUTE, @@ -21,6 +18,9 @@ import { CONTACT_MY_ACCOUNTS_ROUTE, CONTACT_MY_ACCOUNTS_EDIT_ROUTE, CONTACT_MY_ACCOUNTS_VIEW_ROUTE, + GENERAL_ROUTE, + SECURITY_ROUTE, + SETTINGS_ROUTE, } from '../../helpers/constants/routes' import Settings from './settings.component' From 27118fdd980271e068065cf990c1665c3edd0a4b Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Tue, 27 Oct 2020 15:36:50 -0700 Subject: [PATCH 02/13] Fix popup network form appearance; code style --- ui/app/pages/settings/networks-tab/index.scss | 27 +++---------------- .../networks-tab/networks-tab.component.js | 15 ----------- .../networks-tab/networks-tab.container.js | 2 +- ui/app/pages/settings/settings.container.js | 18 ++++++------- 4 files changed, 14 insertions(+), 48 deletions(-) diff --git a/ui/app/pages/settings/networks-tab/index.scss b/ui/app/pages/settings/networks-tab/index.scss index f0b66f62d..e30471d41 100644 --- a/ui/app/pages/settings/networks-tab/index.scss +++ b/ui/app/pages/settings/networks-tab/index.scss @@ -25,29 +25,6 @@ } } - &__back-button { - display: none; - - @media screen and (max-width: 575px) { - display: block; - background-image: url('/images/caret-left-black.svg'); - width: 18px; - height: 18px; - opacity: 0.5; - background-size: contain; - background-repeat: no-repeat; - background-position: center; - margin-right: 16px; - cursor: pointer; - position: absolute; - margin-left: 10px; - - [dir='rtl'] & { - transform: rotate(180deg); - } - } - } - &__network-form { flex: 0.5 0 auto; max-width: 343px; @@ -246,6 +223,10 @@ flex-flow: row nowrap; margin: 0.75rem 0; + @media screen and (max-width: 575px) { + width: 93%; + } + .btn-default { margin-right: 0.375rem; } diff --git a/ui/app/pages/settings/networks-tab/networks-tab.component.js b/ui/app/pages/settings/networks-tab/networks-tab.component.js index bc7086738..ba70517e7 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.component.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.component.js @@ -1,7 +1,6 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import classnames from 'classnames' -import { SETTINGS_ROUTE } from '../../../helpers/constants/routes' import { ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_POPUP, @@ -20,7 +19,6 @@ export default class NetworksTab extends PureComponent { static propTypes = { editRpc: PropTypes.func.isRequired, - history: PropTypes.object.isRequired, location: PropTypes.object.isRequired, networkIsSelected: PropTypes.bool, networksTabIsInAddMode: PropTypes.bool, @@ -50,25 +48,12 @@ export default class NetworksTab extends PureComponent { renderSubHeader () { const { - networkIsSelected, setSelectedSettingsRpcUrl, setNetworksTabAddMode, - networksTabIsInAddMode, - networkDefaultedToProvider, } = this.props return (
-
{ - setNetworksTabAddMode(false) - setSelectedSettingsRpcUrl('') - } - : () => this.props.history.push(SETTINGS_ROUTE) - } - /> { this.context.t('networks') }
+ ) + } - ) - } - - + + + )}
) From 4ad5e027bea494ada09736504101cdba793f5ef4 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Wed, 28 Oct 2020 13:54:39 -0700 Subject: [PATCH 05/13] Fix network list arrow styling --- ui/app/pages/settings/networks-tab/index.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/app/pages/settings/networks-tab/index.scss b/ui/app/pages/settings/networks-tab/index.scss index e30471d41..314cc649d 100644 --- a/ui/app/pages/settings/networks-tab/index.scss +++ b/ui/app/pages/settings/networks-tab/index.scss @@ -156,6 +156,7 @@ @media screen and (max-width: 575px) { padding: 20px 23px 21px 17px; border-bottom: 1px solid #d8d8d8; + max-width: 351px; } } @@ -199,6 +200,7 @@ position: absolute; width: 24px; height: 24px; + margin: 0 5px; [dir='rtl'] & { transform: rotate(180deg); From 4a219d9a106a629ffe7b5ceaf829649ec9124c91 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Wed, 28 Oct 2020 14:54:24 -0700 Subject: [PATCH 06/13] Fix network name overflow --- ui/app/pages/settings/networks-tab/index.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/app/pages/settings/networks-tab/index.scss b/ui/app/pages/settings/networks-tab/index.scss index 314cc649d..7bbc13b85 100644 --- a/ui/app/pages/settings/networks-tab/index.scss +++ b/ui/app/pages/settings/networks-tab/index.scss @@ -173,6 +173,10 @@ font-size: 16px; line-height: 23px; color: #6a737d; + width: 70%; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; &:hover { cursor: pointer; From 64883aecb0bacf3e1dc97d7446756b451899b54e Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Wed, 28 Oct 2020 14:54:43 -0700 Subject: [PATCH 07/13] Improve fullscreen network form appearance --- ui/app/pages/settings/networks-tab/index.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/app/pages/settings/networks-tab/index.scss b/ui/app/pages/settings/networks-tab/index.scss index 7bbc13b85..2ee109ecf 100644 --- a/ui/app/pages/settings/networks-tab/index.scss +++ b/ui/app/pages/settings/networks-tab/index.scss @@ -26,7 +26,6 @@ } &__network-form { - flex: 0.5 0 auto; max-width: 343px; max-height: 465px; display: flex; From c3df1aab8d58e6d893360a6ee2fe258892344ba6 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Wed, 28 Oct 2020 15:29:31 -0700 Subject: [PATCH 08/13] Style touchups --- ui/app/pages/settings/networks-tab/index.scss | 12 +++++++++--- .../settings/networks-tab/networks-tab.component.js | 5 ++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ui/app/pages/settings/networks-tab/index.scss b/ui/app/pages/settings/networks-tab/index.scss index 2ee109ecf..10857af57 100644 --- a/ui/app/pages/settings/networks-tab/index.scss +++ b/ui/app/pages/settings/networks-tab/index.scss @@ -2,7 +2,6 @@ &__content { margin-top: 24px; display: flex; - flex-direction: row; height: 100%; max-width: 739px; justify-content: space-between; @@ -11,6 +10,7 @@ margin-top: 0; flex-direction: column; overflow-x: hidden; + align-items: center; } } @@ -26,11 +26,12 @@ } &__network-form { - max-width: 343px; - max-height: 465px; display: flex; + flex: 1 0 auto; flex-direction: column; justify-content: space-between; + max-width: 343px; + max-height: 465px; .page-container__footer { border-top: none; @@ -108,6 +109,7 @@ display: none; @media screen and (max-width: 575px) { + width: 100%; display: flex; padding-top: 23px; padding-bottom: 23px; @@ -150,6 +152,10 @@ &:hover { cursor: pointer; } + + @media screen and (max-width: 575px) { + margin: 0 4px 0 10px; + } } @media screen and (max-width: 575px) { diff --git a/ui/app/pages/settings/networks-tab/networks-tab.component.js b/ui/app/pages/settings/networks-tab/networks-tab.component.js index 4d4b9099b..269d633cd 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.component.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.component.js @@ -226,10 +226,9 @@ export default class NetworksTab extends PureComponent { const { setNetworksTabAddMode, setSelectedSettingsRpcUrl, - networkIsSelected, - networksTabIsInAddMode, history, isFullScreen, + shouldRenderNetworkForm, } = this.props return ( @@ -237,7 +236,7 @@ export default class NetworksTab extends PureComponent { {isFullScreen && this.renderSubHeader()}
{this.renderNetworksTabContent()} - {!networkIsSelected && !networksTabIsInAddMode + {!isFullScreen && !shouldRenderNetworkForm ? (