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, IconName } from '../../component-library'; 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 (