2022-08-29 22:00:12 +00:00
|
|
|
import clsx from 'clsx';
|
2022-11-28 02:00:28 +00:00
|
|
|
import { DownloadCloud } from 'lucide-react';
|
2022-06-23 07:25:56 +00:00
|
|
|
|
2022-11-13 08:10:18 +00:00
|
|
|
import { useUIState } from '@/react/hooks/useUIState';
|
2022-12-11 06:58:22 +00:00
|
|
|
import { useSystemVersion } from '@/react/portainer/system/useSystemVersion';
|
2022-08-29 22:00:12 +00:00
|
|
|
|
|
|
|
import { Icon } from '@@/Icon';
|
2022-06-23 07:25:56 +00:00
|
|
|
|
|
|
|
import styles from './UpdateNotifications.module.css';
|
|
|
|
|
|
|
|
export function UpdateNotification() {
|
2022-09-20 18:14:24 +00:00
|
|
|
const uiStateStore = useUIState();
|
2022-12-11 06:58:22 +00:00
|
|
|
const query = useSystemVersion();
|
2022-06-23 07:25:56 +00:00
|
|
|
|
|
|
|
if (!query.data || !query.data.UpdateAvailable) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { LatestVersion } = query.data;
|
|
|
|
|
2022-08-29 22:00:12 +00:00
|
|
|
if (
|
2022-09-20 18:14:24 +00:00
|
|
|
!!uiStateStore.dismissedUpdateVersion &&
|
2022-08-29 22:00:12 +00:00
|
|
|
LatestVersion?.length > 0 &&
|
2022-09-20 18:14:24 +00:00
|
|
|
uiStateStore.dismissedUpdateVersion === LatestVersion
|
2022-08-29 22:00:12 +00:00
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-06-23 07:25:56 +00:00
|
|
|
return (
|
2022-08-29 22:00:12 +00:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
styles.root,
|
|
|
|
'rounded border py-2',
|
|
|
|
'bg-blue-11 th-dark:bg-gray-warm-11',
|
|
|
|
'border-blue-9 th-dark:border-gray-warm-9'
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div className={clsx(styles.dismissTitle, 'vertical-center')}>
|
2022-11-28 02:00:28 +00:00
|
|
|
<Icon icon={DownloadCloud} mode="primary" size="md" />
|
2022-08-29 22:00:12 +00:00
|
|
|
<span className="space-left">
|
|
|
|
New version available {LatestVersion}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={clsx(styles.actions)}>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className={clsx(styles.dismissBtn, 'space-right')}
|
|
|
|
onClick={() => onDismiss(LatestVersion)}
|
|
|
|
>
|
|
|
|
Dismiss
|
|
|
|
</button>
|
|
|
|
<a
|
|
|
|
className="hyperlink space-left"
|
|
|
|
target="_blank"
|
|
|
|
href={`https://github.com/portainer/portainer/releases/tag/${LatestVersion}`}
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
See what's new
|
|
|
|
</a>
|
|
|
|
</div>
|
2022-06-23 07:25:56 +00:00
|
|
|
</div>
|
|
|
|
);
|
2022-08-29 22:00:12 +00:00
|
|
|
|
|
|
|
function onDismiss(version: string) {
|
2022-09-20 18:14:24 +00:00
|
|
|
uiStateStore.dismissUpdateVersion(version);
|
2022-08-29 22:00:12 +00:00
|
|
|
}
|
2022-06-23 07:25:56 +00:00
|
|
|
}
|