From cd68bf9d092da9722bf3a1bdb73b4b72d2a774a2 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 27 Jul 2023 11:35:27 -0500 Subject: [PATCH] UX: Remove portfolio from global menu (#20221) * UX: Remove portfolio from global menu * Remove unused locale string * Code-fence the metaMetricsId --- app/_locales/en/messages.json | 3 -- .../multichain/global-menu/global-menu.js | 41 ++----------------- .../global-menu/global-menu.test.js | 12 ------ 3 files changed, 3 insertions(+), 53 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index c0564e7fc..81a89b0a6 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -3248,9 +3248,6 @@ "portfolioDashboard": { "message": "Portfolio Dashboard" }, - "portfolioView": { - "message": "Portfolio view" - }, "preferredLedgerConnectionType": { "message": "Preferred Ledger connection type", "description": "A header for a dropdown in Settings > Advanced. Appears above the ledgerConnectionPreferenceDescription message" diff --git a/ui/components/multichain/global-menu/global-menu.js b/ui/components/multichain/global-menu/global-menu.js index 0d928f8b9..1ab9013b1 100644 --- a/ui/components/multichain/global-menu/global-menu.js +++ b/ui/components/multichain/global-menu/global-menu.js @@ -33,9 +33,6 @@ import { MetaMetricsEventCategory, MetaMetricsContextProp, } from '../../../../shared/constants/metametrics'; -///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) -import { getPortfolioUrl } from '../../../helpers/utils/portfolio'; -///: END:ONLY_INCLUDE_IN ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) import { getMmiPortfolioEnabled, @@ -43,7 +40,9 @@ import { } from '../../../selectors/institutional/selectors'; ///: END:ONLY_INCLUDE_IN import { + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) getMetaMetricsId, + ///: END:ONLY_INCLUDE_IN(build-mmi) getSelectedAddress, ///: BEGIN:ONLY_INCLUDE_IN(snaps) getUnreadNotificationsCount, @@ -69,13 +68,13 @@ export const GlobalMenu = ({ closeMenu, anchorElement }) => { const dispatch = useDispatch(); const trackEvent = useContext(MetaMetricsContext); const history = useHistory(); - const metaMetricsId = useSelector(getMetaMetricsId); const address = useSelector(getSelectedAddress); const hasUnapprovedTransactions = useSelector( (state) => Object.keys(state.metamask.unapprovedTxs).length > 0, ); ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + const metaMetricsId = useSelector(getMetaMetricsId); const mmiPortfolioUrl = useSelector(getMmiPortfolioUrl); const mmiPortfolioEnabled = useSelector(getMmiPortfolioEnabled); ///: END:ONLY_INCLUDE_IN @@ -145,40 +144,6 @@ export const GlobalMenu = ({ closeMenu, anchorElement }) => { ) ///: END:ONLY_INCLUDE_IN } - - { - ///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) - { - const portfolioUrl = getPortfolioUrl('', 'ext', metaMetricsId); - global.platform.openTab({ - url: portfolioUrl, - }); - trackEvent( - { - category: MetaMetricsEventCategory.Home, - event: MetaMetricsEventName.PortfolioLinkClicked, - properties: { - url: portfolioUrl, - location: METRICS_LOCATION, - }, - }, - { - contextPropsIntoEventProperties: [ - MetaMetricsContextProp.PageTitle, - ], - }, - ); - closeMenu(); - }} - data-testid="global-menu-portfolio" - > - {t('portfolioView')} - - ///: END:ONLY_INCLUDE_IN - } - {getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN ? null : ( { }); }); - it('opens the portfolio site when item is clicked', async () => { - global.platform = { openTab: jest.fn() }; - - const { getByTestId } = render(); - fireEvent.click(getByTestId('global-menu-portfolio')); - await waitFor(() => { - expect(global.platform.openTab).toHaveBeenCalledWith({ - url: `/?metamaskEntry=ext&metametricsId=`, - }); - }); - }); - it('opens the support site when item is clicked', async () => { global.platform = { openTab: jest.fn() };