mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: show auto check update toggle
This commit is contained in:
@@ -14,13 +14,14 @@ import Link from "next/link";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { UpdateWebServer } from "./update-webserver";
|
import { UpdateWebServer } from "./update-webserver";
|
||||||
|
import { ToggleAutoCheckUpdates } from "./toggle-auto-check-updates";
|
||||||
|
|
||||||
export const UpdateServer = () => {
|
export const UpdateServer = () => {
|
||||||
const [isUpdateAvailable, setIsUpdateAvailable] = useState<null | boolean>(
|
const [isUpdateAvailable, setIsUpdateAvailable] = useState<null | boolean>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const { mutateAsync: checkAndUpdateImage, isLoading } =
|
const { mutateAsync: checkServerUpdates, isLoading } =
|
||||||
api.settings.checkAndUpdateImage.useMutation();
|
api.settings.checkServerUpdates.useMutation();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -61,6 +62,7 @@ export const UpdateServer = () => {
|
|||||||
</AlertBlock>
|
</AlertBlock>
|
||||||
|
|
||||||
<div className="w-full flex flex-col gap-4">
|
<div className="w-full flex flex-col gap-4">
|
||||||
|
<ToggleAutoCheckUpdates />
|
||||||
{isUpdateAvailable === false && (
|
{isUpdateAvailable === false && (
|
||||||
<div className="flex flex-col items-center gap-3">
|
<div className="flex flex-col items-center gap-3">
|
||||||
<RefreshCcw className="size-6 self-center text-muted-foreground" />
|
<RefreshCcw className="size-6 self-center text-muted-foreground" />
|
||||||
@@ -75,7 +77,7 @@ export const UpdateServer = () => {
|
|||||||
<Button
|
<Button
|
||||||
className="w-full"
|
className="w-full"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await checkAndUpdateImage()
|
await checkServerUpdates()
|
||||||
.then(async (updateAvailable) => {
|
.then(async (updateAvailable) => {
|
||||||
setIsUpdateAvailable(updateAvailable);
|
setIsUpdateAvailable(updateAvailable);
|
||||||
toast.info(
|
toast.info(
|
||||||
@@ -84,7 +86,8 @@ export const UpdateServer = () => {
|
|||||||
: "No updates available",
|
: "No updates available",
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
|
console.error("Error checking for updates:", error);
|
||||||
setIsUpdateAvailable(false);
|
setIsUpdateAvailable(false);
|
||||||
toast.error(
|
toast.error(
|
||||||
"An error occurred while checking for updates, please try again.",
|
"An error occurred while checking for updates, please try again.",
|
||||||
|
|||||||
Reference in New Issue
Block a user