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

Do not display experiment settings tab when there are no settings to show (#17765)

This commit is contained in:
ryanml 2023-02-20 18:29:50 -07:00 committed by PeterYinusa
parent 970a5d4a77
commit 2a6bcff4e2

View File

@ -72,6 +72,9 @@ class SettingsPage extends PureComponent {
searchText: '',
};
shouldRenderExperimentalTab =
process.env.TRANSACTION_SECURITY_PROVIDER || process.env.NFTS_V1;
componentDidMount() {
this.handleConversionDate();
}
@ -252,63 +255,65 @@ class SettingsPage extends PureComponent {
renderTabs() {
const { history, currentPath } = this.props;
const { t } = this.context;
const tabs = [
{
content: t('general'),
icon: <i className="fa fa-cog" />,
key: GENERAL_ROUTE,
},
{
content: t('advanced'),
icon: <i className="fas fa-sliders-h" />,
key: ADVANCED_ROUTE,
},
{
content: t('contacts'),
icon: <Icon name={ICON_NAMES.BOOK} />,
key: CONTACT_LIST_ROUTE,
},
///: BEGIN:ONLY_INCLUDE_IN(flask)
{
content: t('snaps'),
icon: (
<i className="fa fa-flask" title={t('snapsSettingsDescription')} />
),
key: SNAPS_LIST_ROUTE,
},
///: END:ONLY_INCLUDE_IN
{
content: t('securityAndPrivacy'),
icon: <i className="fa fa-lock" />,
key: SECURITY_ROUTE,
},
{
content: t('alerts'),
icon: <Icon name={ICON_NAMES.NOTIFICATION} />,
key: ALERTS_ROUTE,
},
{
content: t('networks'),
icon: <i className="fa fa-plug" />,
key: NETWORKS_ROUTE,
},
];
if (this.shouldRenderExperimentalTab) {
tabs.push({
content: t('experimental'),
icon: <i className="fa fa-flask" />,
key: EXPERIMENTAL_ROUTE,
});
}
tabs.push({
content: t('about'),
icon: <i className="fa fa-info-circle" />,
key: ABOUT_US_ROUTE,
});
return (
<TabBar
tabs={[
{
content: t('general'),
icon: <i className="fa fa-cog" />,
key: GENERAL_ROUTE,
},
{
content: t('advanced'),
icon: <i className="fas fa-sliders-h" />,
key: ADVANCED_ROUTE,
},
{
content: t('contacts'),
icon: <i className="fa fa-address-book" />,
key: CONTACT_LIST_ROUTE,
},
///: BEGIN:ONLY_INCLUDE_IN(flask)
{
content: t('snaps'),
icon: (
<i
className="fa fa-flask"
title={t('snapsSettingsDescription')}
/>
),
key: SNAPS_LIST_ROUTE,
},
///: END:ONLY_INCLUDE_IN
{
content: t('securityAndPrivacy'),
icon: <i className="fa fa-lock" />,
key: SECURITY_ROUTE,
},
{
content: t('alerts'),
icon: <i className="fa fa-bell" />,
key: ALERTS_ROUTE,
},
{
content: t('networks'),
icon: <i className="fa fa-plug" />,
key: NETWORKS_ROUTE,
},
{
content: t('experimental'),
icon: <i className="fa fa-flask" />,
key: EXPERIMENTAL_ROUTE,
},
{
content: t('about'),
icon: <i className="fa fa-info-circle" />,
key: ABOUT_US_ROUTE,
},
]}
tabs={tabs}
isActive={(key) => {
if (key === GENERAL_ROUTE && currentPath === SETTINGS_ROUTE) {
return true;
@ -352,7 +357,9 @@ class SettingsPage extends PureComponent {
render={() => <AddNetwork />}
/>
<Route exact path={SECURITY_ROUTE} component={SecurityTab} />
<Route exact path={EXPERIMENTAL_ROUTE} component={ExperimentalTab} />
{this.shouldRenderExperimentalTab ? (
<Route exact path={EXPERIMENTAL_ROUTE} component={ExperimentalTab} />
) : null}
<Route exact path={CONTACT_LIST_ROUTE} component={ContactListTab} />
<Route exact path={CONTACT_ADD_ROUTE} component={ContactListTab} />
<Route