mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 04:46:10 +01:00
eb51460cae
* UX: Multichain: App header * Export app header, provide required information, put feature flag in place * Provide available data * Implement account picker -- centered and opens account popover * Remove backgrounds, use isUnlocked * Fix placement of the global menu * Show logo when unlocked * Add selector for getting current network, provide props to AvatarNetwork and PickerNetwork * Wire up the network menu to the header * fixed ui for all the screens * updated story for header * fixed import and header settings * updated lint error * fixed tests * updated header * removed test * updated snapshot test * updated network menu * updated changes * removed comment from menu bar * updated css * updated test for network list menu * updated stylesheet * updated ButtonIcon import --------- Co-authored-by: NidhiKJha <menidhikjha@gmail.com>
69 lines
2.5 KiB
JavaScript
69 lines
2.5 KiB
JavaScript
import React, { useState, useContext, useRef } from 'react';
|
|
import browser from 'webextension-polyfill';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { useSelector } from 'react-redux';
|
|
import SelectedAccount from '../selected-account';
|
|
import ConnectedStatusIndicator from '../connected-status-indicator';
|
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
|
|
import {
|
|
MetaMetricsEventCategory,
|
|
MetaMetricsEventName,
|
|
} from '../../../../shared/constants/metametrics';
|
|
import { CONNECTED_ACCOUNTS_ROUTE } from '../../../helpers/constants/routes';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import { getOriginOfCurrentTab } from '../../../selectors';
|
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
|
import { ButtonIcon } from '../../component-library/button-icon/deprecated';
|
|
import { ICON_NAMES } from '../../component-library/icon/deprecated';
|
|
import AccountOptionsMenu from './account-options-menu';
|
|
|
|
export default function MenuBar() {
|
|
const t = useI18nContext();
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
const history = useHistory();
|
|
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
|
|
const origin = useSelector(getOriginOfCurrentTab);
|
|
const ref = useRef(false);
|
|
|
|
const showStatus =
|
|
getEnvironmentType() === ENVIRONMENT_TYPE_POPUP &&
|
|
origin &&
|
|
origin !== browser.runtime.id;
|
|
|
|
return (
|
|
<div className="menu-bar">
|
|
{showStatus ? (
|
|
<ConnectedStatusIndicator
|
|
onClick={() => history.push(CONNECTED_ACCOUNTS_ROUTE)}
|
|
/>
|
|
) : null}
|
|
<SelectedAccount />
|
|
<span style={{ display: 'inherit' }} ref={ref}>
|
|
<ButtonIcon
|
|
iconName={ICON_NAMES.MORE_VERTICAL}
|
|
className="menu-bar__account-options"
|
|
data-testid="account-options-menu-button"
|
|
ariaLabel={t('accountOptions')}
|
|
onClick={() => {
|
|
trackEvent({
|
|
event: MetaMetricsEventName.NavAccountMenuOpened,
|
|
category: MetaMetricsEventCategory.Navigation,
|
|
properties: {
|
|
location: 'Home',
|
|
},
|
|
});
|
|
setAccountOptionsMenuOpen(true);
|
|
}}
|
|
/>
|
|
</span>
|
|
{accountOptionsMenuOpen && (
|
|
<AccountOptionsMenu
|
|
anchorElement={ref.current}
|
|
onClose={() => setAccountOptionsMenuOpen(false)}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|