diff --git a/apps/dokploy/components/dashboard/settings/web-server/update-webserver.tsx b/apps/dokploy/components/dashboard/settings/web-server/update-webserver.tsx index 47d38310e..9b3c89f65 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/update-webserver.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/update-webserver.tsx @@ -13,22 +13,49 @@ import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; import { toast } from "sonner"; -export const UpdateWebServer = () => { +interface Props { + isNavbar?: boolean; +} + +export const UpdateWebServer = ({ isNavbar }: Props) => { const { mutateAsync: updateServer, isLoading } = api.settings.updateServer.useMutation(); + + const buttonLabel = isNavbar ? "Update available" : "Update server"; + + const handleConfirm = async () => { + try { + await updateServer(); + toast.success( + "The server has been updated. The page will be reloaded to reflect the changes...", + ); + setTimeout(() => { + // Allow seeing the toast before reloading + window.location.reload(); + }, 2000); + } catch (error) { + console.error("Error updating server:", error); + toast.error( + "An error occurred while updating the server, please try again.", + ); + } + }; + return ( @@ -36,19 +63,12 @@ export const UpdateWebServer = () => { Are you absolutely sure? This action cannot be undone. This will update the web server to the - new version. + new version. The page will be reloaded once the update is finished. Cancel - { - await updateServer(); - toast.success("Please reload the browser to see the changes"); - }} - > - Confirm - + Confirm