diff --git a/src/EndpointConfig.js b/src/EndpointConfig.js index 8563c8da..0401080c 100644 --- a/src/EndpointConfig.js +++ b/src/EndpointConfig.js @@ -1,3 +1,14 @@ +export function getMetricsDashboardUrl() { + const matches = window.location.hostname.match('(.*).testnet.solana.com'); + let url = + 'https://metrics.solana.com:3000/d/testnet-beta/testnet-monitor-beta?refresh=5s&from=now-5m&to=now'; + if (matches) { + const testnet = matches[1]; + url += `&var-testnet=testnet-${testnet}`; + } + return url; +} + let EndpointConfig = { BLOCK_EXPLORER_API_BASE: `//${window.location.hostname}:3001`, BLOCK_EXPLORER_RPC_URL: `http://${window.location.hostname}:8899`, diff --git a/src/v1/BxAppBar.jsx b/src/v1/BxAppBar.jsx index 8bbb3a04..b48b7505 100644 --- a/src/v1/BxAppBar.jsx +++ b/src/v1/BxAppBar.jsx @@ -15,6 +15,7 @@ import MapIcon from '@material-ui/icons/Map'; // import AccountCircle from '@material-ui/icons/AccountCircle'; import MoreIcon from '@material-ui/icons/MoreVert'; import Switch from '@material-ui/core/Switch'; +import {getMetricsDashboardUrl} from '../EndpointConfig'; class BxAppBar extends React.Component { state = { @@ -23,15 +24,7 @@ class BxAppBar extends React.Component { }; handleDashboard = event => { - const matches = window.location.hostname.match('(.*).testnet.solana.com'); - let url = - 'https://metrics.solana.com:3000/d/testnet-beta/testnet-monitor-beta?refresh=5s&from=now-5m&to=now'; - if (matches) { - const testnet = matches[1]; - url += `&var-testnet=testnet-${testnet}`; - } - - window.open(url); + window.open(getMetricsDashboardUrl()); }; handleMap = event => { diff --git a/src/v2/Bx2AppBar.jsx b/src/v2/Bx2AppBar.jsx index 2f2802fb..291908d8 100644 --- a/src/v2/Bx2AppBar.jsx +++ b/src/v2/Bx2AppBar.jsx @@ -13,6 +13,7 @@ import DashboardIcon from '@material-ui/icons/Dashboard'; import MapIcon from '@material-ui/icons/Map'; import MoreIcon from '@material-ui/icons/MoreVert'; import Switch from '@material-ui/core/Switch'; +import {getMetricsDashboardUrl} from '../EndpointConfig'; class Bx2AppBar extends React.Component { state = { @@ -21,15 +22,7 @@ class Bx2AppBar extends React.Component { }; handleDashboard = event => { - const matches = window.location.hostname.match('(.*).testnet.solana.com'); - let url = - 'https://metrics.solana.com:3000/d/testnet-beta/testnet-monitor-beta?refresh=5s&from=now-5m&to=now'; - if (matches) { - const testnet = matches[1]; - url += `&var-testnet=testnet-${testnet}`; - } - - window.open(url); + window.open(getMetricsDashboardUrl()); }; handleMap = event => {