mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-21 13:55:33 +02:00
* feat: update dependencies and enhance UI components in Dokploy - Updated various package versions in pnpm-lock.yaml to improve compatibility and performance, including React and Tailwind CSS. - Modified components.json to change the styling to "radix-nova" and added new properties for icon library and menu color. - Refactored multiple components to use updated class names for better styling consistency and responsiveness. - Removed unused Radix UI components from package.json to streamline dependencies. - Adjusted layout and styling in several dashboard components for improved user experience and visual appeal. - Enhanced tooltip and form item components for better accessibility and usability. * refactor: enhance UI components in HandleCertificate and SidebarLogo - Updated the HandleCertificate component to improve dialog content height and textarea styling for better usability. - Adjusted the SidebarLogo component layout to enhance alignment and spacing, ensuring a more consistent appearance across the sidebar. - Implemented responsive design adjustments to textarea elements, preventing overflow and improving user experience. * refactor: improve UI consistency and styling across dashboard components - Updated Card components in ShowDeployments, ShowSchedules, and ShowVolumeBackups to remove unnecessary border styles for a cleaner look. - Enhanced TabsList components in ShowProviderForm and ShowProviderFormCompose by adding a variant for improved visual distinction. - Adjusted spacing in AdvancedEnvironmentSelector for better layout and readability. - Removed redundant border classes in Service component for a more streamlined design. * [autofix.ci] apply automated fixes * chore: update package dependencies and refactor email rendering - Upgraded React and React DOM to version 19.2.7 across multiple packages for improved performance and compatibility. - Updated TSX to version 4.22.4 in various package.json files. - Refactored email rendering from `renderAsync` to `render` in notification utilities and email templates for consistency. - Adjusted Tailwind configuration usage in email templates to utilize a centralized configuration file. These changes enhance the overall stability and maintainability of the codebase. * refactor: update badge variants across dashboard components - Changed badge variant from "outline-solid" to "outline" in multiple components including columns, show-domains, and various deployment tables for consistency in styling. - Updated button variants in billing and project templates to align with the new badge styling. - Enhanced input components to support password generation and error messaging, improving user experience. These changes streamline the UI and ensure a cohesive design across the application. * refactor: clean up calendar component imports and structure - Removed redundant imports of icons from lucide-react and streamlined the import statements for better readability. - Adjusted the placement of type imports to enhance code organization. These changes improve the maintainability and clarity of the calendar component. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
292 lines
8.6 KiB
TypeScript
292 lines
8.6 KiB
TypeScript
import type { IUpdateData } from "@dokploy/server/index";
|
|
import {
|
|
Bug,
|
|
Download,
|
|
Info,
|
|
RefreshCcw,
|
|
Server,
|
|
Sparkles,
|
|
Stars,
|
|
} from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useState } from "react";
|
|
import { toast } from "sonner";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/components/ui/dialog";
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from "@/components/ui/tooltip";
|
|
import { api } from "@/utils/api";
|
|
import { ToggleAutoCheckUpdates } from "./toggle-auto-check-updates";
|
|
import { UpdateWebServer } from "./update-webserver";
|
|
|
|
interface Props {
|
|
updateData?: IUpdateData;
|
|
children?: React.ReactNode;
|
|
isOpen?: boolean;
|
|
onOpenChange?: (open: boolean) => void;
|
|
}
|
|
|
|
export const UpdateServer = ({
|
|
updateData,
|
|
children,
|
|
isOpen: isOpenProp,
|
|
onOpenChange: onOpenChangeProp,
|
|
}: Props) => {
|
|
const [hasCheckedUpdate, setHasCheckedUpdate] = useState(!!updateData);
|
|
const [isUpdateAvailable, setIsUpdateAvailable] = useState(
|
|
!!updateData?.updateAvailable,
|
|
);
|
|
const { mutateAsync: getUpdateData, isPending } =
|
|
api.settings.getUpdateData.useMutation();
|
|
const { data: dokployVersion } = api.settings.getDokployVersion.useQuery();
|
|
const { data: releaseTag } = api.settings.getReleaseTag.useQuery();
|
|
const [latestVersion, setLatestVersion] = useState(
|
|
updateData?.latestVersion ?? "",
|
|
);
|
|
const [isOpenInternal, setIsOpenInternal] = useState(false);
|
|
|
|
const handleCheckUpdates = async () => {
|
|
try {
|
|
const updateData = await getUpdateData();
|
|
const versionToUpdate = updateData.latestVersion || "";
|
|
setHasCheckedUpdate(true);
|
|
setIsUpdateAvailable(updateData.updateAvailable);
|
|
setLatestVersion(versionToUpdate);
|
|
|
|
if (updateData.updateAvailable) {
|
|
toast.success(versionToUpdate, {
|
|
description: "New version available!",
|
|
});
|
|
} else {
|
|
toast.info("No updates available");
|
|
}
|
|
} catch (error) {
|
|
console.error("Error checking for updates:", error);
|
|
setHasCheckedUpdate(true);
|
|
setIsUpdateAvailable(false);
|
|
toast.error(
|
|
"An error occurred while checking for updates, please try again.",
|
|
);
|
|
}
|
|
};
|
|
|
|
const isOpen = isOpenInternal || isOpenProp;
|
|
const onOpenChange = (open: boolean) => {
|
|
setIsOpenInternal(open);
|
|
onOpenChangeProp?.(open);
|
|
};
|
|
|
|
return (
|
|
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
|
<DialogTrigger asChild>
|
|
{children ? (
|
|
children
|
|
) : (
|
|
<TooltipProvider delayDuration={0}>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant={updateData ? "outline" : "secondary"}
|
|
size="sm"
|
|
onClick={() => onOpenChange?.(true)}
|
|
>
|
|
<Download className="h-4 w-4 shrink-0" />
|
|
{updateData ? (
|
|
<span className="font-medium truncate group-data-[collapsible=icon]:hidden">
|
|
Update Available
|
|
</span>
|
|
) : (
|
|
<span className="font-medium truncate group-data-[collapsible=icon]:hidden">
|
|
Check for updates
|
|
</span>
|
|
)}
|
|
{updateData && (
|
|
<span className="absolute right-2 flex h-2 w-2 group-data-[collapsible=icon]:hidden">
|
|
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75" />
|
|
<span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500" />
|
|
</span>
|
|
)}
|
|
</Button>
|
|
</TooltipTrigger>
|
|
{updateData && (
|
|
<TooltipContent side="right" sideOffset={10}>
|
|
<p>Update Available</p>
|
|
</TooltipContent>
|
|
)}
|
|
</Tooltip>
|
|
</TooltipProvider>
|
|
)}
|
|
</DialogTrigger>
|
|
<DialogContent className="max-w-lg">
|
|
<div className="flex items-center justify-between mb-8">
|
|
<DialogTitle className="text-2xl font-semibold">
|
|
Web Server Update
|
|
</DialogTitle>
|
|
{dokployVersion && (
|
|
<div className="flex items-center gap-1.5 rounded-full px-3 py-1 mr-2 bg-muted">
|
|
<Server className="h-4 w-4 text-muted-foreground" />
|
|
<span className="text-sm text-muted-foreground">
|
|
{dokployVersion}{" "}
|
|
{(releaseTag === "canary" || releaseTag === "feature") &&
|
|
`(${releaseTag})`}
|
|
</span>
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* Initial state */}
|
|
{!hasCheckedUpdate && (
|
|
<div className="mb-8">
|
|
<p className="text text-muted-foreground">
|
|
Check for new releases and update Dokploy.
|
|
<br />
|
|
<br />
|
|
We recommend checking for updates regularly to ensure you have the
|
|
latest features and security improvements.
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
{/* Update available state */}
|
|
{isUpdateAvailable && latestVersion && (
|
|
<div className="mb-8">
|
|
<div className="inline-flex items-center gap-2 rounded-lg px-3 py-2 border border-emerald-900 bg-emerald-900 dark:bg-emerald-900/40 mb-4 w-full">
|
|
<div className="flex items-center gap-1.5">
|
|
<Download className="h-4 w-4 text-emerald-400" />
|
|
<span className="text font-medium text-emerald-400 ">
|
|
New version available:
|
|
</span>
|
|
</div>
|
|
<span className="text font-semibold text-emerald-300">
|
|
{latestVersion}
|
|
</span>
|
|
</div>
|
|
|
|
<div className="space-y-4 text-muted-foreground">
|
|
<p className="text">
|
|
A new version of the server software is available. Consider
|
|
updating if you:
|
|
</p>
|
|
<ul className="space-y-3">
|
|
<li className="flex items-start gap-2">
|
|
<Stars className="h-5 w-5 mt-0.5 text-[#5B9DFF]" />
|
|
<span className="text">
|
|
Want to access the latest features and improvements
|
|
</span>
|
|
</li>
|
|
<li className="flex items-start gap-2">
|
|
<Bug className="h-5 w-5 mt-0.5 text-[#5B9DFF]" />
|
|
<span className="text">
|
|
Are experiencing issues that may be resolved in the new
|
|
version
|
|
</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* Up to date state */}
|
|
{hasCheckedUpdate && !isUpdateAvailable && !isPending && (
|
|
<div className="mb-8">
|
|
<div className="flex flex-col items-center gap-6 mb-6">
|
|
<div className="rounded-full p-4 bg-emerald-400/40">
|
|
<Sparkles className="h-8 w-8 text-emerald-400" />
|
|
</div>
|
|
<div className="text-center space-y-2">
|
|
<h3 className="text-lg font-medium">
|
|
You are using the latest version
|
|
</h3>
|
|
<p className="text text-muted-foreground">
|
|
Your server is up to date with all the latest features and
|
|
security improvements.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{hasCheckedUpdate && isPending && (
|
|
<div className="mb-8">
|
|
<div className="flex flex-col items-center gap-6 mb-6">
|
|
<div className="rounded-full p-4 bg-[#5B9DFF]/40 text-foreground">
|
|
<RefreshCcw className="h-8 w-8 animate-spin" />
|
|
</div>
|
|
<div className="text-center space-y-2">
|
|
<h3 className="text-lg font-medium">Checking for updates...</h3>
|
|
<p className="text text-muted-foreground">
|
|
Please wait while we pull the latest version information from
|
|
Docker Hub.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{isUpdateAvailable && (
|
|
<div className="rounded-lg bg-[#16254D] p-4 mb-8">
|
|
<div className="flex gap-2">
|
|
<Info className="h-5 w-5 shrink-0 text-[#5B9DFF]" />
|
|
<div className="text-[#5B9DFF]">
|
|
We recommend reviewing the{" "}
|
|
<Link
|
|
href="https://github.com/Dokploy/dokploy/releases"
|
|
target="_blank"
|
|
className="text-white underline hover:text-zinc-200"
|
|
>
|
|
release notes
|
|
</Link>{" "}
|
|
for any breaking changes before updating.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
<div className="flex items-center justify-between pt-2">
|
|
<ToggleAutoCheckUpdates disabled={isPending} />
|
|
</div>
|
|
|
|
<div className="space-y-4 flex items-center justify-end mt-4 ">
|
|
<div className="flex items-center gap-2">
|
|
<Button variant="outline" onClick={() => onOpenChange?.(false)}>
|
|
Cancel
|
|
</Button>
|
|
{isUpdateAvailable ? (
|
|
<UpdateWebServer />
|
|
) : (
|
|
<Button
|
|
variant="secondary"
|
|
onClick={handleCheckUpdates}
|
|
disabled={isPending}
|
|
>
|
|
{isPending ? (
|
|
<>
|
|
<RefreshCcw className="h-4 w-4 animate-spin" />
|
|
Checking for updates
|
|
</>
|
|
) : (
|
|
<>
|
|
<RefreshCcw className="h-4 w-4" />
|
|
Check for updates
|
|
</>
|
|
)}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|
|
|
|
export default UpdateServer;
|