import { useEnvironment } from '@vegaprotocol/environment'; import { t, useNavigatorOnline } from '@vegaprotocol/react-helpers'; import { ButtonLink, Indicator, Intent } from '@vegaprotocol/ui-toolkit'; export const Footer = () => { const { VEGA_URL, blockDifference, setNodeSwitcherOpen } = useEnvironment(); return ( ); }; interface NodeUrlProps { url: string; openNodeSwitcher: () => void; } const NodeUrl = ({ url, openNodeSwitcher }: NodeUrlProps) => { // get base url from api url, api sub domain const urlObj = new URL(url); const nodeUrl = urlObj.origin.replace(/^[^.]+\./g, ''); return {nodeUrl}; }; interface NodeHealthProps { openNodeSwitcher: () => void; blockDiff: number; } // How many blocks behind the most advanced block that is // deemed acceptable for "Good" status const BLOCK_THRESHOLD = 3; export const NodeHealth = ({ blockDiff, openNodeSwitcher, }: NodeHealthProps) => { const online = useNavigatorOnline(); let intent = Intent.Success; let text = 'Operational'; if (!online) { text = t('Offline'); intent = Intent.Danger; } else if (blockDiff < 0) { // Block height query failed and null was returned text = t('Non operational'); intent = Intent.Danger; } else if (blockDiff >= BLOCK_THRESHOLD) { text = t(`${blockDiff} Blocks behind`); intent = Intent.Warning; } return ( {text} ); };