Новая обработка обновлений в соответствии с новым протоколом предоставляемым SDU серверами
This commit is contained in:
@@ -1,44 +1,50 @@
|
||||
import { Button, MantineRadius } from "@mantine/core";
|
||||
import { IconRefresh } from "@tabler/icons-react";
|
||||
import { AnimatedRoundedProgress } from "../AnimatedRoundedProgress/AnimatedRoundedProgress";
|
||||
import { UpdateStatus, useUpdater } from "@/app/hooks/useUpdater";
|
||||
import { useUpdater } from "@/app/providers/UpdateProvider/useUpdater";
|
||||
import { UpdateStatus } from "@/app/providers/UpdateProvider/UpdateProvider";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface UpdateAlertProps {
|
||||
radius?: MantineRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Компонент для отображения кнопки обновлений если оно доступно, и прогресса загрузки если обновление уже скачивается
|
||||
*/
|
||||
export function UpdateAlert(props : UpdateAlertProps) {
|
||||
const radius = props.radius || 0;
|
||||
const {
|
||||
appUpdateUrl,
|
||||
kernelUpdateUrl,
|
||||
downloadProgress,
|
||||
updateStatus,
|
||||
kernelOutdatedForNextAppUpdates,
|
||||
downloadLastApplicationUpdate,
|
||||
restartAppForUpdateApply,
|
||||
checkForUpdates
|
||||
} = useUpdater();
|
||||
|
||||
useEffect(() => {
|
||||
checkForUpdates();
|
||||
}, []);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{updateStatus == UpdateStatus.IDLE && <>
|
||||
{kernelOutdatedForNextAppUpdates && <>
|
||||
<Button h={45} leftSection={
|
||||
<IconRefresh size={15}/>
|
||||
} onClick={() => {
|
||||
window.shell.openExternal(kernelUpdateUrl);
|
||||
}} fullWidth variant={'gradient'} gradient={{ from: 'red', to: 'orange', deg: 233 }} radius={radius}>
|
||||
Kernel update required
|
||||
</Button>
|
||||
</>}
|
||||
{!kernelOutdatedForNextAppUpdates && appUpdateUrl != "" && <>
|
||||
<Button h={45} onClick={downloadLastApplicationUpdate} leftSection={
|
||||
<IconRefresh size={15}/>
|
||||
} fullWidth variant={'gradient'} gradient={{ from: 'blue', to: 'green', deg: 233 }} radius={radius}>
|
||||
New version available
|
||||
</Button>
|
||||
</>}
|
||||
{updateStatus == UpdateStatus.KERNEL_UPDATE_NEED && <>
|
||||
<Button h={45} leftSection={
|
||||
<IconRefresh size={15}/>
|
||||
} onClick={() => {
|
||||
window.shell.openExternal(kernelUpdateUrl);
|
||||
}} fullWidth variant={'gradient'} gradient={{ from: 'red', to: 'orange', deg: 233 }} radius={radius}>
|
||||
Kernel update required
|
||||
</Button>
|
||||
</>}
|
||||
{updateStatus == UpdateStatus.APP_UPDATE_AVAILABLE && <>
|
||||
<Button h={45} onClick={downloadLastApplicationUpdate} leftSection={
|
||||
<IconRefresh size={15}/>
|
||||
} fullWidth variant={'gradient'} gradient={{ from: 'blue', to: 'green', deg: 233 }} radius={radius}>
|
||||
New version available
|
||||
</Button>
|
||||
</>}
|
||||
{updateStatus == UpdateStatus.DOWNLOADING && <>
|
||||
<Button h={45} leftSection={
|
||||
|
||||
Reference in New Issue
Block a user