import { useMemo, useState } from 'react'; import { ReleasesFeed, useEnvironment, useReleases, Networks, } from '@vegaprotocol/environment'; import { t } from '@vegaprotocol/i18n'; import { CopyWithTooltip, ExternalLink, Intent, NotificationBanner, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; const CANONICAL_URL = 'https://vega.trading'; type UpgradeBannerProps = { showVersionChange: boolean; }; export const UpgradeBanner = ({ showVersionChange }: UpgradeBannerProps) => { const [visible, setVisible] = useState(true); const { data } = useReleases(ReleasesFeed.FrontEnd); const { APP_VERSION, VEGA_ENV } = useEnvironment(); /** * Filtering out the release candidates. */ const latest = useMemo(() => { const valid = VEGA_ENV === Networks.MAINNET ? data?.filter((r) => !/-rc$/i.test(r.tagName)) : data; return valid && valid.length > 0 ? valid[0] : undefined; }, [VEGA_ENV, data]); if (!visible || !latest || latest.tagName === APP_VERSION) return null; const versionChange = ( {APP_VERSION} {' '} {' '} {latest.tagName} ); return ( { setVisible(false); }} >
{t('Upgrade to the latest version of Console')}{' '} {showVersionChange && versionChange}
{t('Bookmark')}{' '} {t('vega.trading')} {' '} {'to always see the latest version.'}
); };