mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
remove all the Buy, Swap etc. buttons, replace remaining Send with text only
This commit is contained in:
parent
b8c113355d
commit
a44dcd6dec
@ -6,26 +6,17 @@ import { useHistory } from 'react-router-dom';
|
|||||||
|
|
||||||
import Identicon from '../../ui/identicon';
|
import Identicon from '../../ui/identicon';
|
||||||
import { I18nContext } from '../../../contexts/i18n';
|
import { I18nContext } from '../../../contexts/i18n';
|
||||||
import {
|
import { SEND_ROUTE } from '../../../helpers/constants/routes';
|
||||||
SEND_ROUTE,
|
|
||||||
BUILD_QUOTE_ROUTE,
|
|
||||||
} from '../../../helpers/constants/routes';
|
|
||||||
import Tooltip from '../../ui/tooltip';
|
import Tooltip from '../../ui/tooltip';
|
||||||
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
|
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
|
||||||
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
||||||
import {
|
import {
|
||||||
isBalanceCached,
|
isBalanceCached,
|
||||||
getShouldShowFiat,
|
getShouldShowFiat,
|
||||||
getCurrentKeyring,
|
|
||||||
getSwapsDefaultToken,
|
|
||||||
getIsSwapsChain,
|
|
||||||
getIsBuyableChain,
|
|
||||||
getNativeCurrencyImage,
|
getNativeCurrencyImage,
|
||||||
getSelectedAccountCachedBalance,
|
getSelectedAccountCachedBalance,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
|
|
||||||
import IconButton from '../../ui/icon-button';
|
import IconButton from '../../ui/icon-button';
|
||||||
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
|
|
||||||
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
||||||
import {
|
import {
|
||||||
EVENT,
|
EVENT,
|
||||||
@ -38,11 +29,9 @@ import { AssetType } from '../../../../shared/constants/transaction';
|
|||||||
import {
|
import {
|
||||||
ButtonIcon,
|
ButtonIcon,
|
||||||
BUTTON_ICON_SIZES,
|
BUTTON_ICON_SIZES,
|
||||||
Icon,
|
|
||||||
ICON_NAMES,
|
ICON_NAMES,
|
||||||
} from '../../component-library';
|
} from '../../component-library';
|
||||||
import { IconColor } from '../../../helpers/constants/design-system';
|
import { IconColor } from '../../../helpers/constants/design-system';
|
||||||
import useRamps from '../../../hooks/experiences/useRamps';
|
|
||||||
import WalletOverview from './wallet-overview';
|
import WalletOverview from './wallet-overview';
|
||||||
|
|
||||||
const EthOverview = ({ className }) => {
|
const EthOverview = ({ className }) => {
|
||||||
@ -50,17 +39,10 @@ const EthOverview = ({ className }) => {
|
|||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const keyring = useSelector(getCurrentKeyring);
|
|
||||||
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
|
|
||||||
const balanceIsCached = useSelector(isBalanceCached);
|
const balanceIsCached = useSelector(isBalanceCached);
|
||||||
const showFiat = useSelector(getShouldShowFiat);
|
const showFiat = useSelector(getShouldShowFiat);
|
||||||
const balance = useSelector(getSelectedAccountCachedBalance);
|
const balance = useSelector(getSelectedAccountCachedBalance);
|
||||||
const isSwapsChain = useSelector(getIsSwapsChain);
|
|
||||||
const isBuyableChain = useSelector(getIsBuyableChain);
|
|
||||||
const primaryTokenImage = useSelector(getNativeCurrencyImage);
|
const primaryTokenImage = useSelector(getNativeCurrencyImage);
|
||||||
const defaultSwapsToken = useSelector(getSwapsDefaultToken);
|
|
||||||
|
|
||||||
const { openBuyCryptoInPdapp } = useRamps();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WalletOverview
|
<WalletOverview
|
||||||
@ -141,35 +123,9 @@ const EthOverview = ({ className }) => {
|
|||||||
}
|
}
|
||||||
buttons={
|
buttons={
|
||||||
<>
|
<>
|
||||||
<IconButton
|
|
||||||
className="eth-overview__button"
|
|
||||||
Icon={
|
|
||||||
<Icon name={ICON_NAMES.ADD} color={IconColor.primaryInverse} />
|
|
||||||
}
|
|
||||||
disabled={!isBuyableChain}
|
|
||||||
data-testid="eth-overview-buy"
|
|
||||||
label={t('buy')}
|
|
||||||
onClick={() => {
|
|
||||||
openBuyCryptoInPdapp();
|
|
||||||
trackEvent({
|
|
||||||
event: EVENT_NAMES.NAV_BUY_BUTTON_CLICKED,
|
|
||||||
category: EVENT.CATEGORIES.NAVIGATION,
|
|
||||||
properties: {
|
|
||||||
location: 'Home',
|
|
||||||
text: 'Buy',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<IconButton
|
<IconButton
|
||||||
className="eth-overview__button"
|
className="eth-overview__button"
|
||||||
data-testid="eth-overview-send"
|
data-testid="eth-overview-send"
|
||||||
Icon={
|
|
||||||
<Icon
|
|
||||||
name={ICON_NAMES.ARROW_2_RIGHT}
|
|
||||||
color={IconColor.primaryInverse}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={t('send')}
|
label={t('send')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
trackEvent({
|
trackEvent({
|
||||||
@ -188,71 +144,6 @@ const EthOverview = ({ className }) => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
|
||||||
className="eth-overview__button"
|
|
||||||
disabled={!isSwapsChain}
|
|
||||||
Icon={
|
|
||||||
<Icon
|
|
||||||
name={ICON_NAMES.SWAP_HORIZONTAL}
|
|
||||||
color={IconColor.primaryInverse}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onClick={() => {
|
|
||||||
if (isSwapsChain) {
|
|
||||||
trackEvent({
|
|
||||||
event: EVENT_NAMES.NAV_SWAP_BUTTON_CLICKED,
|
|
||||||
category: EVENT.CATEGORIES.SWAPS,
|
|
||||||
properties: {
|
|
||||||
token_symbol: 'ETH',
|
|
||||||
location: EVENT.SOURCE.SWAPS.MAIN_VIEW,
|
|
||||||
text: 'Swap',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
dispatch(setSwapsFromToken(defaultSwapsToken));
|
|
||||||
if (usingHardwareWallet) {
|
|
||||||
global.platform.openExtensionInBrowser(BUILD_QUOTE_ROUTE);
|
|
||||||
} else {
|
|
||||||
history.push(BUILD_QUOTE_ROUTE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
label={t('swap')}
|
|
||||||
tooltipRender={
|
|
||||||
isSwapsChain
|
|
||||||
? null
|
|
||||||
: (contents) => (
|
|
||||||
<Tooltip
|
|
||||||
title={t('currentlyUnavailable')}
|
|
||||||
position="bottom"
|
|
||||||
>
|
|
||||||
{contents}
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
className="eth-overview__button"
|
|
||||||
data-testid="eth-overview-bridge"
|
|
||||||
Icon={
|
|
||||||
<Icon name={ICON_NAMES.BRIDGE} color={IconColor.primaryInverse} />
|
|
||||||
}
|
|
||||||
label={t('bridge')}
|
|
||||||
onClick={() => {
|
|
||||||
const portfolioUrl = process.env.PORTFOLIO_URL;
|
|
||||||
const bridgeUrl = `${portfolioUrl}/bridge`;
|
|
||||||
global.platform.openTab({
|
|
||||||
url: `${bridgeUrl}?metamaskEntry=ext`,
|
|
||||||
});
|
|
||||||
trackEvent({
|
|
||||||
category: EVENT.CATEGORIES.NAVIGATION,
|
|
||||||
event: EVENT_NAMES.BRIDGE_LINK_CLICKED,
|
|
||||||
properties: {
|
|
||||||
location: 'Home',
|
|
||||||
text: 'Bridge',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
className={className}
|
className={className}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 209px;
|
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -20,8 +19,7 @@
|
|||||||
&__buttons {
|
&__buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
height: 68px;
|
margin-bottom: 18px;
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +42,7 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 16px 0;
|
margin: 16px 0 4px 0;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
max-width: 326px;
|
max-width: 326px;
|
||||||
}
|
}
|
||||||
@ -112,7 +110,7 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 16px 0;
|
margin: 16px 0 4px 0;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,22 @@
|
|||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import Identicon from '../../ui/identicon';
|
import Identicon from '../../ui/identicon';
|
||||||
import Tooltip from '../../ui/tooltip';
|
|
||||||
import CurrencyDisplay from '../../ui/currency-display';
|
import CurrencyDisplay from '../../ui/currency-display';
|
||||||
import { I18nContext } from '../../../contexts/i18n';
|
import { I18nContext } from '../../../contexts/i18n';
|
||||||
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
|
import { SEND_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import {
|
|
||||||
SEND_ROUTE,
|
|
||||||
BUILD_QUOTE_ROUTE,
|
|
||||||
} from '../../../helpers/constants/routes';
|
|
||||||
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
||||||
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
|
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
|
||||||
import { startNewDraftTransaction } from '../../../ducks/send';
|
import { startNewDraftTransaction } from '../../../ducks/send';
|
||||||
import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
|
|
||||||
import {
|
|
||||||
getCurrentKeyring,
|
|
||||||
getIsSwapsChain,
|
|
||||||
getIsBuyableChain,
|
|
||||||
} from '../../../selectors';
|
|
||||||
|
|
||||||
import IconButton from '../../ui/icon-button';
|
import IconButton from '../../ui/icon-button';
|
||||||
import { INVALID_ASSET_TYPE } from '../../../helpers/constants/error-keys';
|
import { INVALID_ASSET_TYPE } from '../../../helpers/constants/error-keys';
|
||||||
import { showModal } from '../../../store/actions';
|
import { showModal } from '../../../store/actions';
|
||||||
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
||||||
import {
|
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
|
||||||
EVENT,
|
|
||||||
EVENT_NAMES,
|
|
||||||
CONTEXT_PROPS,
|
|
||||||
} from '../../../../shared/constants/metametrics';
|
|
||||||
import { AssetType } from '../../../../shared/constants/transaction';
|
import { AssetType } from '../../../../shared/constants/transaction';
|
||||||
import useRamps from '../../../hooks/experiences/useRamps';
|
|
||||||
|
|
||||||
import { Icon, ICON_NAMES } from '../../component-library';
|
|
||||||
import { IconColor } from '../../../helpers/constants/design-system';
|
|
||||||
import WalletOverview from './wallet-overview';
|
import WalletOverview from './wallet-overview';
|
||||||
|
|
||||||
const TokenOverview = ({ className, token }) => {
|
const TokenOverview = ({ className, token }) => {
|
||||||
@ -43,21 +24,13 @@ const TokenOverview = ({ className, token }) => {
|
|||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const keyring = useSelector(getCurrentKeyring);
|
|
||||||
const usingHardwareWallet = isHardwareKeyring(keyring.type);
|
|
||||||
const { tokensWithBalances } = useTokenTracker([token]);
|
const { tokensWithBalances } = useTokenTracker([token]);
|
||||||
const balanceToRender = tokensWithBalances[0]?.string;
|
const balanceToRender = tokensWithBalances[0]?.string;
|
||||||
const balance = tokensWithBalances[0]?.balance;
|
|
||||||
const formattedFiatBalance = useTokenFiatAmount(
|
const formattedFiatBalance = useTokenFiatAmount(
|
||||||
token.address,
|
token.address,
|
||||||
balanceToRender,
|
balanceToRender,
|
||||||
token.symbol,
|
token.symbol,
|
||||||
);
|
);
|
||||||
const isSwapsChain = useSelector(getIsSwapsChain);
|
|
||||||
|
|
||||||
const isBuyableChain = useSelector(getIsBuyableChain);
|
|
||||||
|
|
||||||
const { openBuyCryptoInPdapp } = useRamps();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (token.isERC721) {
|
if (token.isERC721) {
|
||||||
@ -90,26 +63,6 @@ const TokenOverview = ({ className, token }) => {
|
|||||||
}
|
}
|
||||||
buttons={
|
buttons={
|
||||||
<>
|
<>
|
||||||
<IconButton
|
|
||||||
className="token-overview__button"
|
|
||||||
Icon={
|
|
||||||
<Icon name={ICON_NAMES.ADD} color={IconColor.primaryInverse} />
|
|
||||||
}
|
|
||||||
label={t('buy')}
|
|
||||||
data-testid="token-overview-buy"
|
|
||||||
onClick={() => {
|
|
||||||
openBuyCryptoInPdapp();
|
|
||||||
trackEvent({
|
|
||||||
event: EVENT_NAMES.NAV_BUY_BUTTON_CLICKED,
|
|
||||||
category: EVENT.CATEGORIES.NAVIGATION,
|
|
||||||
properties: {
|
|
||||||
location: 'Token Overview',
|
|
||||||
text: 'Buy',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
disabled={token.isERC721 || !isBuyableChain}
|
|
||||||
/>
|
|
||||||
<IconButton
|
<IconButton
|
||||||
className="token-overview__button"
|
className="token-overview__button"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@ -136,96 +89,10 @@ const TokenOverview = ({ className, token }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
Icon={
|
|
||||||
<Icon
|
|
||||||
name={ICON_NAMES.ARROW_2_RIGHT}
|
|
||||||
color={IconColor.primaryInverse}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={t('send')}
|
label={t('send')}
|
||||||
data-testid="eth-overview-send"
|
data-testid="eth-overview-send"
|
||||||
disabled={token.isERC721}
|
disabled={token.isERC721}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
|
||||||
className="token-overview__button"
|
|
||||||
disabled={!isSwapsChain}
|
|
||||||
Icon={
|
|
||||||
<Icon
|
|
||||||
name={ICON_NAMES.SWAP_HORIZONTAL}
|
|
||||||
color={IconColor.primaryInverse}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onClick={() => {
|
|
||||||
if (isSwapsChain) {
|
|
||||||
trackEvent({
|
|
||||||
event: EVENT_NAMES.NAV_SWAP_BUTTON_CLICKED,
|
|
||||||
category: EVENT.CATEGORIES.SWAPS,
|
|
||||||
properties: {
|
|
||||||
token_symbol: token.symbol,
|
|
||||||
location: EVENT.SOURCE.SWAPS.TOKEN_VIEW,
|
|
||||||
text: 'Swap',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
dispatch(
|
|
||||||
setSwapsFromToken({
|
|
||||||
...token,
|
|
||||||
address: token.address.toLowerCase(),
|
|
||||||
iconUrl: token.image,
|
|
||||||
balance,
|
|
||||||
string: balanceToRender,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (usingHardwareWallet) {
|
|
||||||
global.platform.openExtensionInBrowser(BUILD_QUOTE_ROUTE);
|
|
||||||
} else {
|
|
||||||
history.push(BUILD_QUOTE_ROUTE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
label={t('swap')}
|
|
||||||
tooltipRender={
|
|
||||||
isSwapsChain
|
|
||||||
? null
|
|
||||||
: (contents) => (
|
|
||||||
<Tooltip
|
|
||||||
title={t('currentlyUnavailable')}
|
|
||||||
position="bottom"
|
|
||||||
disabled={isSwapsChain}
|
|
||||||
>
|
|
||||||
{contents}
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
className="eth-overview__button"
|
|
||||||
Icon={
|
|
||||||
<Icon
|
|
||||||
name={ICON_NAMES.DIAGRAM}
|
|
||||||
color={IconColor.primaryInverse}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={t('portfolio')}
|
|
||||||
data-testid="home__portfolio-site"
|
|
||||||
onClick={() => {
|
|
||||||
const portfolioUrl = process.env.PORTFOLIO_URL;
|
|
||||||
global.platform.openTab({
|
|
||||||
url: `${portfolioUrl}?metamaskEntry=ext`,
|
|
||||||
});
|
|
||||||
trackEvent(
|
|
||||||
{
|
|
||||||
category: EVENT.CATEGORIES.HOME,
|
|
||||||
event: EVENT_NAMES.PORTFOLIO_LINK_CLICKED,
|
|
||||||
properties: {
|
|
||||||
url: portfolioUrl,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
contextPropsIntoEventProperties: [CONTEXT_PROPS.PAGE_TITLE],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
className={className}
|
className={className}
|
||||||
|
@ -6,7 +6,7 @@ const defaultRender = (inner) => inner;
|
|||||||
|
|
||||||
export default function IconButton({
|
export default function IconButton({
|
||||||
onClick,
|
onClick,
|
||||||
Icon,
|
// Icon,
|
||||||
disabled,
|
disabled,
|
||||||
label,
|
label,
|
||||||
tooltipRender,
|
tooltipRender,
|
||||||
@ -25,7 +25,7 @@ export default function IconButton({
|
|||||||
>
|
>
|
||||||
{renderWrapper(
|
{renderWrapper(
|
||||||
<>
|
<>
|
||||||
<div className="icon-button__circle">{Icon}</div>
|
{/* <div className="icon-button__circle">{Icon}</div> */}
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
</>,
|
</>,
|
||||||
)}
|
)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user