2023-04-27 16:28:08 +02:00
|
|
|
import React, { useContext, useState, useRef, useCallback } from 'react';
|
2023-04-25 22:39:54 +02:00
|
|
|
import classnames from 'classnames';
|
2023-04-13 18:54:03 +02:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import browser from 'webextension-polyfill';
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2023-05-08 19:32:39 +02:00
|
|
|
import { useHistory, matchPath } from 'react-router-dom';
|
2023-08-23 18:36:03 +02:00
|
|
|
import { toChecksumHexAddress } from '@metamask/controller-utils';
|
2023-04-13 18:54:03 +02:00
|
|
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
|
|
|
import {
|
|
|
|
MetaMetricsEventCategory,
|
|
|
|
MetaMetricsEventName,
|
|
|
|
} from '../../../../shared/constants/metametrics';
|
|
|
|
import {
|
2023-05-08 19:32:39 +02:00
|
|
|
BUILD_QUOTE_ROUTE,
|
|
|
|
CONFIRM_TRANSACTION_ROUTE,
|
2023-04-13 18:54:03 +02:00
|
|
|
CONNECTED_ACCOUNTS_ROUTE,
|
|
|
|
DEFAULT_ROUTE,
|
2023-05-08 19:32:39 +02:00
|
|
|
SWAPS_ROUTE,
|
2023-04-13 18:54:03 +02:00
|
|
|
} from '../../../helpers/constants/routes';
|
|
|
|
|
|
|
|
import {
|
|
|
|
AlignItems,
|
|
|
|
BackgroundColor,
|
2023-06-09 18:00:11 +02:00
|
|
|
BlockSize,
|
|
|
|
Display,
|
2023-04-13 18:54:03 +02:00
|
|
|
JustifyContent,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
2023-04-14 00:24:47 +02:00
|
|
|
import {
|
|
|
|
ButtonIcon,
|
2023-05-05 07:21:10 +02:00
|
|
|
ButtonIconSize,
|
2023-04-14 00:24:47 +02:00
|
|
|
IconName,
|
|
|
|
PickerNetwork,
|
2023-07-04 17:17:05 +02:00
|
|
|
Box,
|
2023-08-23 18:36:03 +02:00
|
|
|
IconSize,
|
2023-04-14 00:24:47 +02:00
|
|
|
} from '../../component-library';
|
2023-06-01 23:14:38 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
import { getCustodianIconForAddress } from '../../../selectors/institutional/selectors';
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-04-13 18:54:03 +02:00
|
|
|
import {
|
2023-04-27 16:28:08 +02:00
|
|
|
getCurrentChainId,
|
2023-04-13 18:54:03 +02:00
|
|
|
getCurrentNetwork,
|
2023-04-21 17:28:18 +02:00
|
|
|
getOnboardedInThisUISession,
|
2023-04-13 18:54:03 +02:00
|
|
|
getOriginOfCurrentTab,
|
|
|
|
getSelectedIdentity,
|
2023-04-21 17:28:18 +02:00
|
|
|
getShowProductTour,
|
2023-07-17 18:43:26 +02:00
|
|
|
getTestNetworkBackgroundColor,
|
2023-09-04 17:48:25 +02:00
|
|
|
getUnapprovedTransactions,
|
2023-06-01 23:14:38 +02:00
|
|
|
getSelectedAddress,
|
2023-08-23 18:36:03 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
2023-07-26 11:51:11 +02:00
|
|
|
getTheme,
|
2023-06-01 23:14:38 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-04-13 18:54:03 +02:00
|
|
|
} from '../../../selectors';
|
2023-04-21 17:28:18 +02:00
|
|
|
import { GlobalMenu, ProductTour, AccountPicker } from '..';
|
2023-04-13 18:54:03 +02:00
|
|
|
|
2023-04-21 17:28:18 +02:00
|
|
|
import {
|
|
|
|
hideProductTour,
|
|
|
|
toggleAccountMenu,
|
|
|
|
toggleNetworkMenu,
|
|
|
|
} from '../../../store/actions';
|
2023-04-13 18:54:03 +02:00
|
|
|
import MetafoxLogo from '../../ui/metafox-logo';
|
|
|
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
|
|
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
|
|
|
|
import ConnectedStatusIndicator from '../../app/connected-status-indicator';
|
2023-04-21 17:28:18 +02:00
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
|
|
import { getCompletedOnboarding } from '../../../ducks/metamask/metamask';
|
2023-05-08 19:32:39 +02:00
|
|
|
import { getSendStage, SEND_STAGES } from '../../../ducks/send';
|
2023-05-25 15:30:01 +02:00
|
|
|
import Tooltip from '../../ui/tooltip';
|
2023-08-23 18:36:03 +02:00
|
|
|
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
|
|
|
|
import { MINUTE } from '../../../../shared/constants/time';
|
2023-04-13 18:54:03 +02:00
|
|
|
|
2023-05-08 19:32:39 +02:00
|
|
|
export const AppHeader = ({ location }) => {
|
2023-04-13 18:54:03 +02:00
|
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
|
|
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
|
2023-04-21 17:28:18 +02:00
|
|
|
const [multichainProductTourStep, setMultichainProductTourStep] = useState(1);
|
2023-04-13 18:54:03 +02:00
|
|
|
const menuRef = useRef(false);
|
|
|
|
const origin = useSelector(getOriginOfCurrentTab);
|
|
|
|
const history = useHistory();
|
2023-07-12 13:33:58 +02:00
|
|
|
const isHomePage = location.pathname === DEFAULT_ROUTE;
|
2023-04-13 18:54:03 +02:00
|
|
|
const isUnlocked = useSelector((state) => state.metamask.isUnlocked);
|
2023-04-21 17:28:18 +02:00
|
|
|
const t = useI18nContext();
|
2023-04-27 16:28:08 +02:00
|
|
|
const chainId = useSelector(getCurrentChainId);
|
2023-04-25 22:39:54 +02:00
|
|
|
|
2023-06-01 23:14:38 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const selectedAddress = useSelector(getSelectedAddress);
|
|
|
|
const custodianIcon = useSelector((state) =>
|
|
|
|
getCustodianIconForAddress(state, selectedAddress),
|
|
|
|
);
|
2023-07-26 11:51:11 +02:00
|
|
|
const theme = useSelector((state) => getTheme(state));
|
2023-06-01 23:14:38 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
2023-04-13 18:54:03 +02:00
|
|
|
// Used for account picker
|
|
|
|
const identity = useSelector(getSelectedIdentity);
|
|
|
|
const dispatch = useDispatch();
|
2023-04-21 17:28:18 +02:00
|
|
|
const completedOnboarding = useSelector(getCompletedOnboarding);
|
|
|
|
const onboardedInThisUISession = useSelector(getOnboardedInThisUISession);
|
|
|
|
const showProductTourPopup = useSelector(getShowProductTour);
|
2023-04-13 18:54:03 +02:00
|
|
|
|
|
|
|
// Used for network icon / dropdown
|
|
|
|
const currentNetwork = useSelector(getCurrentNetwork);
|
2023-07-17 18:43:26 +02:00
|
|
|
const testNetworkBackgroundColor = useSelector(getTestNetworkBackgroundColor);
|
2023-04-13 18:54:03 +02:00
|
|
|
|
2023-08-23 18:36:03 +02:00
|
|
|
// Used for copy button
|
|
|
|
const currentAddress = useSelector(getSelectedAddress);
|
|
|
|
const checksummedCurrentAddress = toChecksumHexAddress(currentAddress);
|
|
|
|
const [copied, handleCopy] = useCopyToClipboard(MINUTE);
|
|
|
|
|
2023-04-13 18:54:03 +02:00
|
|
|
const popupStatus = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP;
|
2023-08-23 18:36:03 +02:00
|
|
|
const showConnectedStatus =
|
|
|
|
process.env.MULTICHAIN ||
|
|
|
|
(getEnvironmentType() === ENVIRONMENT_TYPE_POPUP &&
|
|
|
|
origin &&
|
|
|
|
origin !== browser.runtime.id);
|
2023-04-21 17:28:18 +02:00
|
|
|
const showProductTour =
|
|
|
|
completedOnboarding && !onboardedInThisUISession && showProductTourPopup;
|
|
|
|
const productTourDirection = document
|
|
|
|
.querySelector('[dir]')
|
|
|
|
?.getAttribute('dir');
|
2023-04-13 18:54:03 +02:00
|
|
|
|
2023-05-08 19:32:39 +02:00
|
|
|
// Disable the network and account pickers if the user is in
|
|
|
|
// a critical flow
|
|
|
|
const sendStage = useSelector(getSendStage);
|
2023-06-14 20:49:14 +02:00
|
|
|
const isTransactionEditPage = [
|
|
|
|
SEND_STAGES.EDIT,
|
|
|
|
SEND_STAGES.DRAFT,
|
|
|
|
SEND_STAGES.ADD_RECIPIENT,
|
|
|
|
].includes(sendStage);
|
2023-05-08 19:32:39 +02:00
|
|
|
const isConfirmationPage = Boolean(
|
|
|
|
matchPath(location.pathname, {
|
|
|
|
path: CONFIRM_TRANSACTION_ROUTE,
|
|
|
|
exact: false,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
const isSwapsPage = Boolean(
|
|
|
|
matchPath(location.pathname, { path: SWAPS_ROUTE, exact: false }),
|
|
|
|
);
|
|
|
|
const isSwapsBuildQuotePage = Boolean(
|
|
|
|
matchPath(location.pathname, { path: BUILD_QUOTE_ROUTE, exact: false }),
|
|
|
|
);
|
|
|
|
|
2023-09-04 17:48:25 +02:00
|
|
|
const unapprovedTransactions = useSelector(getUnapprovedTransactions);
|
|
|
|
|
|
|
|
const hasUnapprovedTransactions =
|
|
|
|
Object.keys(unapprovedTransactions).length > 0;
|
2023-06-14 20:49:14 +02:00
|
|
|
|
|
|
|
const disableAccountPicker =
|
|
|
|
isConfirmationPage || (isSwapsPage && !isSwapsBuildQuotePage);
|
|
|
|
|
|
|
|
const disableNetworkPicker =
|
|
|
|
isSwapsPage ||
|
2023-05-08 19:32:39 +02:00
|
|
|
isTransactionEditPage ||
|
2023-06-14 20:49:14 +02:00
|
|
|
isConfirmationPage ||
|
|
|
|
hasUnapprovedTransactions;
|
2023-05-08 19:32:39 +02:00
|
|
|
|
2023-04-27 16:28:08 +02:00
|
|
|
// Callback for network dropdown
|
|
|
|
const networkOpenCallback = useCallback(() => {
|
|
|
|
dispatch(toggleNetworkMenu());
|
|
|
|
trackEvent({
|
|
|
|
event: MetaMetricsEventName.NavNetworkMenuOpened,
|
|
|
|
category: MetaMetricsEventCategory.Navigation,
|
|
|
|
properties: {
|
|
|
|
location: 'App header',
|
|
|
|
chain_id: chainId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}, [chainId, dispatch, trackEvent]);
|
|
|
|
|
2023-06-26 19:57:56 +02:00
|
|
|
// This is required to ensure send and confirmation screens
|
|
|
|
// look as desired
|
2023-06-28 17:11:19 +02:00
|
|
|
const headerBottomMargin = !popupStatus && disableNetworkPicker ? 4 : 0;
|
2023-06-26 19:57:56 +02:00
|
|
|
|
2023-04-13 18:54:03 +02:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{isUnlocked && !popupStatus ? (
|
|
|
|
<Box
|
2023-06-09 18:00:11 +02:00
|
|
|
display={[Display.None, Display.Flex]}
|
2023-04-13 18:54:03 +02:00
|
|
|
alignItems={AlignItems.center}
|
|
|
|
margin={2}
|
|
|
|
className="multichain-app-header-logo"
|
|
|
|
data-testid="app-header-logo"
|
|
|
|
justifyContent={JustifyContent.center}
|
|
|
|
>
|
|
|
|
<MetafoxLogo
|
|
|
|
unsetIconHeight
|
2023-05-08 19:32:39 +02:00
|
|
|
onClick={async () => history.push(DEFAULT_ROUTE)}
|
2023-06-01 23:14:38 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
custodyImgSrc={custodianIcon}
|
|
|
|
isUnlocked={isUnlocked}
|
2023-07-26 11:51:11 +02:00
|
|
|
theme={theme}
|
2023-06-01 23:14:38 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-04-13 18:54:03 +02:00
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
) : null}
|
|
|
|
<Box
|
2023-06-09 18:00:11 +02:00
|
|
|
display={Display.Flex}
|
2023-04-25 22:39:54 +02:00
|
|
|
className={classnames('multichain-app-header', {
|
|
|
|
'multichain-app-header-shadow': !isUnlocked || popupStatus,
|
|
|
|
})}
|
2023-06-26 19:57:56 +02:00
|
|
|
marginBottom={headerBottomMargin}
|
2023-04-13 18:54:03 +02:00
|
|
|
alignItems={AlignItems.center}
|
2023-06-09 18:00:11 +02:00
|
|
|
width={BlockSize.Full}
|
2023-04-13 18:54:03 +02:00
|
|
|
backgroundColor={
|
|
|
|
!isUnlocked || popupStatus
|
|
|
|
? BackgroundColor.backgroundDefault
|
|
|
|
: BackgroundColor.backgroundAlternative
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<>
|
|
|
|
{isUnlocked ? (
|
|
|
|
<Box
|
2023-04-25 22:39:54 +02:00
|
|
|
className={classnames('multichain-app-header__contents', {
|
|
|
|
'multichain-app-header-shadow': isUnlocked && !popupStatus,
|
|
|
|
})}
|
2023-04-13 18:54:03 +02:00
|
|
|
alignItems={AlignItems.center}
|
2023-06-09 18:00:11 +02:00
|
|
|
width={BlockSize.Full}
|
2023-04-13 18:54:03 +02:00
|
|
|
backgroundColor={BackgroundColor.backgroundDefault}
|
|
|
|
padding={2}
|
2023-05-05 07:21:10 +02:00
|
|
|
paddingLeft={4}
|
|
|
|
paddingRight={4}
|
2023-04-13 18:54:03 +02:00
|
|
|
gap={2}
|
|
|
|
>
|
2023-05-25 15:30:01 +02:00
|
|
|
{popupStatus ? (
|
|
|
|
<Box className="multichain-app-header__contents__container">
|
|
|
|
<Tooltip title={currentNetwork?.nickname} position="right">
|
2023-06-09 18:00:11 +02:00
|
|
|
<PickerNetwork
|
2023-07-17 18:43:26 +02:00
|
|
|
avatarNetworkProps={{
|
|
|
|
backgroundColor: testNetworkBackgroundColor,
|
|
|
|
}}
|
2023-05-25 15:30:01 +02:00
|
|
|
className="multichain-app-header__contents--avatar-network"
|
|
|
|
ref={menuRef}
|
|
|
|
as="button"
|
|
|
|
src={currentNetwork?.rpcPrefs?.imageUrl}
|
2023-06-09 18:00:11 +02:00
|
|
|
label={currentNetwork?.nickname}
|
|
|
|
aria-label={t('networkMenu')}
|
2023-06-01 23:14:38 +02:00
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
networkOpenCallback();
|
|
|
|
}}
|
2023-06-09 18:00:11 +02:00
|
|
|
display={[Display.Flex, Display.None]} // show on popover hide on desktop
|
2023-05-25 15:30:01 +02:00
|
|
|
disabled={disableNetworkPicker}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</Box>
|
|
|
|
) : (
|
2023-05-08 16:50:13 +02:00
|
|
|
<div>
|
|
|
|
<PickerNetwork
|
2023-07-17 18:43:26 +02:00
|
|
|
avatarNetworkProps={{
|
|
|
|
backgroundColor: testNetworkBackgroundColor,
|
|
|
|
}}
|
2023-05-08 16:50:13 +02:00
|
|
|
margin={2}
|
|
|
|
label={currentNetwork?.nickname}
|
|
|
|
src={currentNetwork?.rpcPrefs?.imageUrl}
|
2023-06-01 23:14:38 +02:00
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
networkOpenCallback();
|
|
|
|
}}
|
2023-06-09 18:00:11 +02:00
|
|
|
display={[Display.None, Display.Flex]} // show on desktop hide on popover
|
2023-05-08 16:50:13 +02:00
|
|
|
className="multichain-app-header__contents__network-picker"
|
2023-05-08 19:32:39 +02:00
|
|
|
disabled={disableNetworkPicker}
|
2023-06-01 23:14:38 +02:00
|
|
|
data-testid="network-display"
|
2023-05-08 16:50:13 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
2023-04-21 17:28:18 +02:00
|
|
|
{showProductTour &&
|
|
|
|
popupStatus &&
|
2023-07-12 13:33:58 +02:00
|
|
|
isHomePage &&
|
2023-04-21 17:28:18 +02:00
|
|
|
multichainProductTourStep === 1 ? (
|
|
|
|
<ProductTour
|
|
|
|
className="multichain-app-header__product-tour"
|
|
|
|
anchorElement={menuRef.current}
|
|
|
|
title={t('switcherTitle')}
|
|
|
|
description={t('switcherTourDescription')}
|
|
|
|
currentStep="1"
|
|
|
|
totalSteps="3"
|
|
|
|
onClick={() =>
|
|
|
|
setMultichainProductTourStep(multichainProductTourStep + 1)
|
|
|
|
}
|
|
|
|
positionObj={productTourDirection === 'rtl' ? '0%' : '88%'}
|
|
|
|
productTourDirection={productTourDirection}
|
2023-04-13 18:54:03 +02:00
|
|
|
/>
|
2023-04-21 17:28:18 +02:00
|
|
|
) : null}
|
2023-04-13 18:54:03 +02:00
|
|
|
|
2023-05-23 21:44:24 +02:00
|
|
|
{identity ? (
|
|
|
|
<AccountPicker
|
|
|
|
address={identity.address}
|
|
|
|
name={identity.name}
|
|
|
|
onClick={() => {
|
|
|
|
dispatch(toggleAccountMenu());
|
2023-04-27 16:28:08 +02:00
|
|
|
|
2023-05-23 21:44:24 +02:00
|
|
|
trackEvent({
|
|
|
|
event: MetaMetricsEventName.NavAccountMenuOpened,
|
|
|
|
category: MetaMetricsEventCategory.Navigation,
|
|
|
|
properties: {
|
|
|
|
location: 'Home',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}}
|
2023-06-14 20:49:14 +02:00
|
|
|
disabled={disableAccountPicker}
|
2023-08-31 15:46:40 +02:00
|
|
|
showAddress={Boolean(process.env.MULTICHAIN)}
|
2023-05-23 21:44:24 +02:00
|
|
|
/>
|
|
|
|
) : null}
|
2023-04-13 18:54:03 +02:00
|
|
|
<Box
|
2023-06-09 18:00:11 +02:00
|
|
|
display={Display.Flex}
|
2023-04-13 18:54:03 +02:00
|
|
|
alignItems={AlignItems.center}
|
2023-05-05 07:21:10 +02:00
|
|
|
justifyContent={JustifyContent.flexEnd}
|
2023-04-13 18:54:03 +02:00
|
|
|
>
|
2023-06-09 18:00:11 +02:00
|
|
|
<Box display={Display.Flex} gap={4}>
|
2023-08-23 18:36:03 +02:00
|
|
|
{showConnectedStatus &&
|
|
|
|
(process.env.MULTICHAIN ? (
|
|
|
|
<Tooltip
|
|
|
|
position="left"
|
|
|
|
title={copied ? t('addressCopied') : null}
|
|
|
|
>
|
|
|
|
<ButtonIcon
|
|
|
|
onClick={() => handleCopy(checksummedCurrentAddress)}
|
|
|
|
iconName={
|
|
|
|
copied ? IconName.CopySuccess : IconName.Copy
|
|
|
|
}
|
|
|
|
size={IconSize.Sm}
|
|
|
|
data-testid="app-header-copy-button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
) : (
|
|
|
|
<Box ref={menuRef}>
|
|
|
|
<ConnectedStatusIndicator
|
|
|
|
onClick={() => {
|
|
|
|
history.push(CONNECTED_ACCOUNTS_ROUTE);
|
|
|
|
trackEvent({
|
|
|
|
event:
|
|
|
|
MetaMetricsEventName.NavConnectedSitesOpened,
|
|
|
|
category: MetaMetricsEventCategory.Navigation,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
))}{' '}
|
2023-06-01 23:14:38 +02:00
|
|
|
{
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
custodianIcon && (
|
|
|
|
<Box
|
2023-06-09 18:00:11 +02:00
|
|
|
display={Display.Flex}
|
2023-06-01 23:14:38 +02:00
|
|
|
alignItems={AlignItems.center}
|
|
|
|
className="custody-logo"
|
|
|
|
data-testid="custody-logo"
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
src={custodianIcon}
|
|
|
|
className="custody-logo--icon"
|
|
|
|
alt=""
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
)
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
}
|
2023-05-05 07:21:10 +02:00
|
|
|
{popupStatus && multichainProductTourStep === 2 ? (
|
|
|
|
<ProductTour
|
|
|
|
className="multichain-app-header__product-tour"
|
|
|
|
anchorElement={menuRef.current}
|
|
|
|
closeMenu={() => setAccountOptionsMenuOpen(false)}
|
|
|
|
prevIcon
|
|
|
|
title={t('permissionsTitle')}
|
|
|
|
description={t('permissionsTourDescription')}
|
|
|
|
currentStep="2"
|
|
|
|
totalSteps="3"
|
|
|
|
prevClick={() =>
|
|
|
|
setMultichainProductTourStep(
|
|
|
|
multichainProductTourStep - 1,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
onClick={() =>
|
|
|
|
setMultichainProductTourStep(
|
|
|
|
multichainProductTourStep + 1,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
positionObj={
|
|
|
|
productTourDirection === 'rtl' ? '76%' : '12%'
|
|
|
|
}
|
|
|
|
productTourDirection={productTourDirection}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
<Box
|
|
|
|
ref={menuRef}
|
2023-06-09 18:00:11 +02:00
|
|
|
display={Display.Flex}
|
2023-05-05 07:21:10 +02:00
|
|
|
justifyContent={JustifyContent.flexEnd}
|
2023-06-09 18:00:11 +02:00
|
|
|
width={BlockSize.Full}
|
2023-05-05 07:21:10 +02:00
|
|
|
>
|
|
|
|
<ButtonIcon
|
|
|
|
iconName={IconName.MoreVertical}
|
|
|
|
data-testid="account-options-menu-button"
|
|
|
|
ariaLabel={t('accountOptions')}
|
2023-04-27 16:28:08 +02:00
|
|
|
onClick={() => {
|
|
|
|
trackEvent({
|
2023-05-05 07:21:10 +02:00
|
|
|
event: MetaMetricsEventName.NavAccountMenuOpened,
|
2023-04-27 16:28:08 +02:00
|
|
|
category: MetaMetricsEventCategory.Navigation,
|
2023-05-05 07:21:10 +02:00
|
|
|
properties: {
|
|
|
|
location: 'Home',
|
|
|
|
},
|
2023-04-27 16:28:08 +02:00
|
|
|
});
|
2023-05-05 07:21:10 +02:00
|
|
|
setAccountOptionsMenuOpen(true);
|
2023-04-27 16:28:08 +02:00
|
|
|
}}
|
2023-05-05 07:21:10 +02:00
|
|
|
size={ButtonIconSize.Sm}
|
2023-04-21 17:28:18 +02:00
|
|
|
/>
|
|
|
|
</Box>
|
2023-05-05 07:21:10 +02:00
|
|
|
</Box>
|
|
|
|
{accountOptionsMenuOpen ? (
|
|
|
|
<GlobalMenu
|
|
|
|
anchorElement={menuRef.current}
|
|
|
|
closeMenu={() => setAccountOptionsMenuOpen(false)}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
{showProductTour &&
|
|
|
|
popupStatus &&
|
|
|
|
multichainProductTourStep === 3 ? (
|
2023-04-21 17:28:18 +02:00
|
|
|
<ProductTour
|
|
|
|
className="multichain-app-header__product-tour"
|
|
|
|
anchorElement={menuRef.current}
|
|
|
|
closeMenu={() => setAccountOptionsMenuOpen(false)}
|
|
|
|
prevIcon
|
2023-05-05 07:21:10 +02:00
|
|
|
title={t('globalTitle')}
|
|
|
|
description={t('globalTourDescription')}
|
|
|
|
currentStep="3"
|
2023-04-21 17:28:18 +02:00
|
|
|
totalSteps="3"
|
|
|
|
prevClick={() =>
|
|
|
|
setMultichainProductTourStep(
|
|
|
|
multichainProductTourStep - 1,
|
|
|
|
)
|
|
|
|
}
|
2023-04-13 18:54:03 +02:00
|
|
|
onClick={() => {
|
2023-05-05 07:21:10 +02:00
|
|
|
hideProductTour();
|
2023-04-13 18:54:03 +02:00
|
|
|
}}
|
2023-05-05 07:21:10 +02:00
|
|
|
positionObj={productTourDirection === 'rtl' ? '88%' : '0%'}
|
|
|
|
productTourDirection={productTourDirection}
|
2023-04-13 18:54:03 +02:00
|
|
|
/>
|
2023-05-05 07:21:10 +02:00
|
|
|
) : null}
|
2023-04-13 18:54:03 +02:00
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
) : (
|
|
|
|
<Box
|
2023-06-09 18:00:11 +02:00
|
|
|
display={Display.Flex}
|
2023-04-25 22:39:54 +02:00
|
|
|
className={classnames('multichain-app-header__lock-contents', {
|
|
|
|
'multichain-app-header-shadow': isUnlocked && !popupStatus,
|
|
|
|
})}
|
2023-04-13 18:54:03 +02:00
|
|
|
alignItems={AlignItems.center}
|
2023-06-09 18:00:11 +02:00
|
|
|
width={BlockSize.Full}
|
2023-04-13 18:54:03 +02:00
|
|
|
justifyContent={JustifyContent.spaceBetween}
|
|
|
|
backgroundColor={BackgroundColor.backgroundDefault}
|
|
|
|
padding={2}
|
|
|
|
gap={2}
|
|
|
|
>
|
2023-05-09 10:06:54 +02:00
|
|
|
<div>
|
|
|
|
<PickerNetwork
|
2023-07-17 18:43:26 +02:00
|
|
|
avatarNetworkProps={{
|
|
|
|
backgroundColor: testNetworkBackgroundColor,
|
|
|
|
}}
|
2023-05-09 10:06:54 +02:00
|
|
|
label={currentNetwork?.nickname}
|
|
|
|
src={currentNetwork?.rpcPrefs?.imageUrl}
|
2023-06-01 23:14:38 +02:00
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
networkOpenCallback();
|
|
|
|
}}
|
2023-05-09 10:06:54 +02:00
|
|
|
className="multichain-app-header__contents__network-picker"
|
2023-06-01 23:14:38 +02:00
|
|
|
data-testid="network-display"
|
2023-05-09 10:06:54 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2023-04-13 18:54:03 +02:00
|
|
|
<MetafoxLogo
|
|
|
|
unsetIconHeight
|
|
|
|
onClick={async () => {
|
|
|
|
history.push(DEFAULT_ROUTE);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
</Box>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AppHeader.propTypes = {
|
|
|
|
/**
|
2023-05-08 19:32:39 +02:00
|
|
|
* The location object for the application
|
2023-04-13 18:54:03 +02:00
|
|
|
*/
|
2023-05-08 19:32:39 +02:00
|
|
|
location: PropTypes.object,
|
2023-04-13 18:54:03 +02:00
|
|
|
};
|