From 8df77ed93d6a61c74061611abb22f107ef015f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Oliv=C3=A9?= Date: Fri, 18 Aug 2023 18:44:23 +0200 Subject: [PATCH] [MMI] Always redirect to MMI portfolio dashboard upon the user clicking on swaps (#20527) --- .../app/wallet-overview/eth-overview.js | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/ui/components/app/wallet-overview/eth-overview.js b/ui/components/app/wallet-overview/eth-overview.js index 21127d10e..4c10a8edd 100644 --- a/ui/components/app/wallet-overview/eth-overview.js +++ b/ui/components/app/wallet-overview/eth-overview.js @@ -14,39 +14,44 @@ import { getMmiPortfolioEnabled, getMmiPortfolioUrl, } from '../../../selectors/institutional/selectors'; -///: END:ONLY_INCLUDE_IN import { MMI_SWAPS_URL } from '../../../../shared/constants/swaps'; +///: END:ONLY_INCLUDE_IN import { I18nContext } from '../../../contexts/i18n'; import { SEND_ROUTE, + ///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) BUILD_QUOTE_ROUTE, + ///: END:ONLY_INCLUDE_IN } from '../../../helpers/constants/routes'; import Tooltip from '../../ui/tooltip'; import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display'; import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'; import { - getAccountType, isBalanceCached, getShouldShowFiat, - getCurrentKeyring, - getSwapsDefaultToken, getIsSwapsChain, getSelectedAccountCachedBalance, getCurrentChainId, ///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) + getSwapsDefaultToken, + getCurrentKeyring, getIsBridgeChain, getIsBuyableChain, getMetaMetricsId, ///: END:ONLY_INCLUDE_IN } from '../../../selectors'; +///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) import { setSwapsFromToken } from '../../../ducks/swaps/swaps'; -import IconButton from '../../ui/icon-button'; import { isHardwareKeyring } from '../../../helpers/utils/hardware'; +///: END:ONLY_INCLUDE_IN +import IconButton from '../../ui/icon-button'; import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsEventCategory, MetaMetricsEventName, + ///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) MetaMetricsSwapsEventSource, + ///: END:ONLY_INCLUDE_IN } from '../../../../shared/constants/metametrics'; import Spinner from '../../ui/spinner'; import { startNewDraftTransaction } from '../../../ducks/send'; @@ -69,16 +74,15 @@ const EthOverview = ({ className, showAddress }) => { const isBridgeChain = useSelector(getIsBridgeChain); const isBuyableChain = useSelector(getIsBuyableChain); const metaMetricsId = useSelector(getMetaMetricsId); - ///: END:ONLY_INCLUDE_IN const keyring = useSelector(getCurrentKeyring); const usingHardwareWallet = isHardwareKeyring(keyring?.type); + const defaultSwapsToken = useSelector(getSwapsDefaultToken); + ///: END:ONLY_INCLUDE_IN const balanceIsCached = useSelector(isBalanceCached); const showFiat = useSelector(getShouldShowFiat); const balance = useSelector(getSelectedAccountCachedBalance); const isSwapsChain = useSelector(getIsSwapsChain); - const defaultSwapsToken = useSelector(getSwapsDefaultToken); const chainId = useSelector(getCurrentChainId); - const accountType = useSelector(getAccountType); ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) const mmiPortfolioEnabled = useSelector(getMmiPortfolioEnabled); @@ -256,14 +260,13 @@ const EthOverview = ({ className, showAddress }) => { /> } onClick={() => { - if (accountType === 'custody') { - global.platform.openTab({ - url: MMI_SWAPS_URL, - }); - - return; - } + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + global.platform.openTab({ + url: MMI_SWAPS_URL, + }); + ///: END:ONLY_INCLUDE_IN + ///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask) if (isSwapsChain) { trackEvent({ event: MetaMetricsEventName.NavSwapButtonClicked, @@ -282,6 +285,7 @@ const EthOverview = ({ className, showAddress }) => { history.push(BUILD_QUOTE_ROUTE); } } + ///: END:ONLY_INCLUDE_IN }} label={t('swap')} data-testid="token-overview-button-swap"