diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 2d5151465..f26eb8c03 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -121,6 +121,9 @@ "addAlias": { "message": "Add alias" }, + "addBlockExplorer": { + "message": "Add a block explorer" + }, "addContact": { "message": "Add contact" }, diff --git a/ui/components/app/menu-bar/account-options-menu.js b/ui/components/app/menu-bar/account-options-menu.js index f712631b4..2d8a22826 100644 --- a/ui/components/app/menu-bar/account-options-menu.js +++ b/ui/components/app/menu-bar/account-options-menu.js @@ -5,10 +5,14 @@ import { useDispatch, useSelector } from 'react-redux'; import { getAccountLink } from '@metamask/etherscan-link'; import { showModal } from '../../../store/actions'; -import { CONNECTED_ROUTE } from '../../../helpers/constants/routes'; +import { + CONNECTED_ROUTE, + NETWORKS_ROUTE, +} from '../../../helpers/constants/routes'; import { getURLHostName } from '../../../helpers/utils/util'; import { Menu, MenuItem } from '../../ui/menu'; import { + getBlockExplorerLinkText, getCurrentChainId, getCurrentKeyring, getRpcPrefsForCurrentProvider, @@ -34,9 +38,30 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) { const { blockExplorerUrl } = rpcPrefs; const blockExplorerUrlSubTitle = getURLHostName(blockExplorerUrl); const trackEvent = useContext(MetaMetricsContext); + const blockExplorerLinkText = useSelector(getBlockExplorerLinkText); const isRemovable = keyring.type !== 'HD Key Tree'; + const routeToAddBlockExplorerUrl = () => { + history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`); + }; + + const openBlockExplorer = () => { + trackEvent({ + event: 'Clicked Block Explorer Link', + category: EVENT.CATEGORIES.NAVIGATION, + properties: { + link_type: 'Account Tracker', + action: 'Account Options', + block_explorer_domain: getURLHostName(addressLink), + }, + }); + global.platform.openTab({ + url: addressLink, + }); + onClose(); + }; + return (