+
+
{t('showCustomNetworkList')}
+
+ {t('showCustomNetworkListDescription')}
+
+
+
+
+ {
+ this.context.trackEvent({
+ category: EVENT.CATEGORIES.SETTINGS,
+ event: 'Enabled/Disable CustomNetworkList',
+ properties: {
+ action: 'Enabled/Disable CustomNetworkList',
+ legacy_event: true,
+ },
+ });
+ setCustomNetworkListEnabled(!value);
+ }}
+ offLabel={t('off')}
+ onLabel={t('on')}
+ />
+
+
+
+ );
+ }
+
render() {
return (
@@ -295,6 +336,7 @@ export default class ExperimentalTab extends PureComponent {
{this.renderCollectibleDetectionToggle()}
{this.renderEIP1559V2EnabledToggle()}
{this.renderTheme()}
+ {this.renderCustomNetworkListToggle()}
);
}
diff --git a/ui/pages/settings/experimental-tab/experimental-tab.container.js b/ui/pages/settings/experimental-tab/experimental-tab.container.js
index 1fb4124ee..244de6198 100644
--- a/ui/pages/settings/experimental-tab/experimental-tab.container.js
+++ b/ui/pages/settings/experimental-tab/experimental-tab.container.js
@@ -7,6 +7,7 @@ import {
setOpenSeaEnabled,
setEIP1559V2Enabled,
setTheme,
+ setCustomNetworkListEnabled,
} from '../../../store/actions';
import {
getUseTokenDetection,
@@ -14,6 +15,7 @@ import {
getOpenSeaEnabled,
getEIP1559V2Enabled,
getTheme,
+ getIsCustomNetworkListEnabled,
} from '../../../selectors';
import ExperimentalTab from './experimental-tab.component';
@@ -26,6 +28,7 @@ const mapStateToProps = (state) => {
openSeaEnabled: getOpenSeaEnabled(state),
eip1559V2Enabled: getEIP1559V2Enabled(state),
theme: getTheme(state),
+ customNetworkListEnabled: getIsCustomNetworkListEnabled(state),
};
};
@@ -40,6 +43,8 @@ const mapDispatchToProps = (dispatch) => {
setOpenSeaEnabled: (val) => dispatch(setOpenSeaEnabled(val)),
setEIP1559V2Enabled: (val) => dispatch(setEIP1559V2Enabled(val)),
setTheme: (val) => dispatch(setTheme(val)),
+ setCustomNetworkListEnabled: (val) =>
+ dispatch(setCustomNetworkListEnabled(val)),
};
};
diff --git a/ui/pages/settings/networks-tab/networks-form/networks-form.js b/ui/pages/settings/networks-tab/networks-form/networks-form.js
index ef846c638..22c28a170 100644
--- a/ui/pages/settings/networks-tab/networks-form/networks-form.js
+++ b/ui/pages/settings/networks-tab/networks-form/networks-form.js
@@ -522,7 +522,6 @@ const NetworksForm = ({
onConfirm: () => {
resetForm();
dispatch(setSelectedSettingsRpcUrl(''));
- history.push(NETWORKS_ROUTE);
},
}),
);
diff --git a/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.js b/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.js
index 1420e3082..1fad5fdc4 100644
--- a/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.js
+++ b/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.js
@@ -1,18 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useHistory } from 'react-router-dom';
+import { useSelector } from 'react-redux';
import { useI18nContext } from '../../../../hooks/useI18nContext';
-import { ADD_NETWORK_ROUTE } from '../../../../helpers/constants/routes';
+import {
+ ADD_NETWORK_ROUTE,
+ ADD_POPULAR_CUSTOM_NETWORK,
+} from '../../../../helpers/constants/routes';
import Button from '../../../../components/ui/button';
+import { getIsCustomNetworkListEnabled } from '../../../../selectors';
const NetworksFormSubheader = ({ addNewNetwork }) => {
const t = useI18nContext();
const history = useHistory();
+ const addPopularNetworkFeatureToggledOn = useSelector(
+ getIsCustomNetworkListEnabled,
+ );
+
return addNewNetwork ? (
@@ -22,7 +35,9 @@ const NetworksFormSubheader = ({ addNewNetwork }) => {
type="primary"
onClick={(event) => {
event.preventDefault();
- history.push(ADD_NETWORK_ROUTE);
+ addPopularNetworkFeatureToggledOn
+ ? history.push(ADD_POPULAR_CUSTOM_NETWORK)
+ : history.push(ADD_NETWORK_ROUTE);
}}
>
{t('addANetwork')}
diff --git a/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js b/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js
index 099261049..44b5b1768 100644
--- a/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js
+++ b/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js
@@ -1,5 +1,6 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
+import { waitFor } from '@testing-library/react';
import { renderWithProvider } from '../../../../../test/jest/rendering';
import NetworksTabSubheader from '.';
@@ -36,11 +37,11 @@ describe('NetworksTabSubheader Component', () => {
expect(getByRole('button', { text: 'Add a network' })).toBeDefined();
});
it('should render add network form subheader correctly', () => {
- const { queryByText } = renderComponent({
+ const { queryByText, getAllByText } = renderComponent({
addNewNetwork: true,
});
expect(queryByText('Networks')).toBeInTheDocument();
- expect(queryByText('>')).toBeInTheDocument();
+ waitFor(() => expect(getAllByText('>')).toBeInTheDocument());
expect(queryByText('Add a network')).toBeInTheDocument();
});
});
diff --git a/ui/pages/settings/networks-tab/networks-tab.js b/ui/pages/settings/networks-tab/networks-tab.js
index c73787566..35814d419 100644
--- a/ui/pages/settings/networks-tab/networks-tab.js
+++ b/ui/pages/settings/networks-tab/networks-tab.js
@@ -1,11 +1,12 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
-import { useLocation } from 'react-router-dom';
+import { useLocation, useHistory } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { useI18nContext } from '../../../hooks/useI18nContext';
import {
ADD_NETWORK_ROUTE,
+ ADD_POPULAR_CUSTOM_NETWORK,
NETWORKS_FORM_ROUTE,
} from '../../../helpers/constants/routes';
import { setSelectedSettingsRpcUrl } from '../../../store/actions';
@@ -14,6 +15,7 @@ import { getEnvironmentType } from '../../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../shared/constants/app';
import {
getFrequentRpcListDetail,
+ getIsCustomNetworkListEnabled,
getNetworksTabSelectedRpcUrl,
getProvider,
} from '../../../selectors';
@@ -36,6 +38,7 @@ const NetworksTab = ({ addNewNetwork }) => {
const t = useI18nContext();
const dispatch = useDispatch();
const { pathname } = useLocation();
+ const history = useHistory();
const environmentType = getEnvironmentType();
const isFullScreen = environmentType === ENVIRONMENT_TYPE_FULLSCREEN;
@@ -45,6 +48,9 @@ const NetworksTab = ({ addNewNetwork }) => {
const frequentRpcListDetail = useSelector(getFrequentRpcListDetail);
const provider = useSelector(getProvider);
const networksTabSelectedRpcUrl = useSelector(getNetworksTabSelectedRpcUrl);
+ const addPopularNetworkFeatureToggledOn = useSelector(
+ getIsCustomNetworkListEnabled,
+ );
const frequentRpcNetworkListDetails = frequentRpcListDetail.map((rpc) => {
return {
@@ -118,9 +124,16 @@ const NetworksTab = ({ addNewNetwork }) => {