From d4842b089ecd633c0d17024da99355ae2c3cc023 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 25 Mar 2021 14:25:22 -0500 Subject: [PATCH] Fix 10562 - Hide the suggested token pane when not on Mainnet or test network (#10702) --- ui/app/pages/add-token/add-token.component.js | 24 +++++++++++++------ ui/app/pages/add-token/add-token.container.js | 2 ++ ui/app/pages/add-token/add-token.test.js | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ui/app/pages/add-token/add-token.component.js b/ui/app/pages/add-token/add-token.component.js index 1bf17facf..103756e72 100644 --- a/ui/app/pages/add-token/add-token.component.js +++ b/ui/app/pages/add-token/add-token.component.js @@ -28,6 +28,7 @@ class AddToken extends Component { clearPendingTokens: PropTypes.func, tokens: PropTypes.array, identities: PropTypes.object, + showSearchTab: PropTypes.bool.isRequired, mostRecentOverviewPage: PropTypes.string.isRequired, }; @@ -315,14 +316,23 @@ class AddToken extends Component { } renderTabs() { - return ( - - {this.renderSearchToken()} - - {this.renderCustomTokenForm()} - - + const { showSearchTab } = this.props; + const tabs = []; + + if (showSearchTab) { + tabs.push( + + {this.renderSearchToken()} + , + ); + } + tabs.push( + + {this.renderCustomTokenForm()} + , ); + + return {tabs}; } render() { diff --git a/ui/app/pages/add-token/add-token.container.js b/ui/app/pages/add-token/add-token.container.js index 490b34583..ab8bf24c8 100644 --- a/ui/app/pages/add-token/add-token.container.js +++ b/ui/app/pages/add-token/add-token.container.js @@ -2,6 +2,7 @@ import { connect } from 'react-redux'; import { setPendingTokens, clearPendingTokens } from '../../store/actions'; import { getMostRecentOverviewPage } from '../../ducks/history/history'; +import { getIsMainnet } from '../../selectors/selectors'; import AddToken from './add-token.component'; const mapStateToProps = (state) => { @@ -13,6 +14,7 @@ const mapStateToProps = (state) => { mostRecentOverviewPage: getMostRecentOverviewPage(state), tokens, pendingTokens, + showSearchTab: getIsMainnet(state) || process.env.IN_TEST === 'true', }; }; diff --git a/ui/app/pages/add-token/add-token.test.js b/ui/app/pages/add-token/add-token.test.js index 9e4c14aca..4c1394085 100644 --- a/ui/app/pages/add-token/add-token.test.js +++ b/ui/app/pages/add-token/add-token.test.js @@ -26,6 +26,7 @@ describe('Add Token', function () { tokens: [], identities: {}, mostRecentOverviewPage: '/', + showSearchTab: true, }; describe('Add Token', function () {