import { useQuery } from 'react-query'; import clsx from 'clsx'; import { getVersionStatus } from '@/portainer/services/api/status.service'; import { useUIState } from '@/portainer/hooks/UIStateProvider'; import { Icon } from '@@/Icon'; import styles from './UpdateNotifications.module.css'; export function UpdateNotification() { const [uiState, setUIState] = useUIState(); const query = useUpdateNotification(); if (!query.data || !query.data.UpdateAvailable) { return null; } const { LatestVersion } = query.data; if ( uiState?.dismissedUpdateVersion?.length > 0 && LatestVersion?.length > 0 && uiState?.dismissedUpdateVersion === LatestVersion ) { return null; } return (
New version available {LatestVersion}
See what's new
); function onDismiss(version: string) { setUIState({ ...uiState, dismissedUpdateVersion: version, }); } } function useUpdateNotification() { return useQuery(['status', 'version'], () => getVersionStatus()); }