mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-23 14:55:28 +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>
313 lines
8.1 KiB
TypeScript
313 lines
8.1 KiB
TypeScript
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
|
|
import { Dices } from "lucide-react";
|
|
import { useEffect, useState } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
import { toast } from "sonner";
|
|
import type z from "zod";
|
|
import { AlertBlock } from "@/components/shared/alert-block";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/components/ui/dialog";
|
|
import {
|
|
Form,
|
|
FormControl,
|
|
FormDescription,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from "@/components/ui/form";
|
|
import { Input, NumberInput } from "@/components/ui/input";
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/ui/select";
|
|
import { Switch } from "@/components/ui/switch";
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from "@/components/ui/tooltip";
|
|
import { domain } from "@/server/db/validations/domain";
|
|
import { api } from "@/utils/api";
|
|
|
|
type Domain = z.infer<typeof domain>;
|
|
|
|
interface Props {
|
|
previewDeploymentId: string;
|
|
domainId?: string;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export const AddPreviewDomain = ({
|
|
previewDeploymentId,
|
|
domainId = "",
|
|
children,
|
|
}: Props) => {
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
const utils = api.useUtils();
|
|
const { data, refetch } = api.domain.one.useQuery(
|
|
{
|
|
domainId,
|
|
},
|
|
{
|
|
enabled: !!domainId,
|
|
},
|
|
);
|
|
|
|
const { data: previewDeployment } = api.previewDeployment.one.useQuery(
|
|
{
|
|
previewDeploymentId,
|
|
},
|
|
{
|
|
enabled: !!previewDeploymentId,
|
|
},
|
|
);
|
|
|
|
const { mutateAsync, isError, error, isPending } = domainId
|
|
? api.domain.update.useMutation()
|
|
: api.domain.create.useMutation();
|
|
|
|
const { mutateAsync: generateDomain, isPending: isLoadingGenerate } =
|
|
api.domain.generateDomain.useMutation();
|
|
|
|
const form = useForm<Domain>({
|
|
resolver: zodResolver(domain),
|
|
});
|
|
|
|
const host = form.watch("host");
|
|
const isTraefikMeDomain = host?.includes("sslip.io") || false;
|
|
|
|
useEffect(() => {
|
|
if (data) {
|
|
form.reset({
|
|
...data,
|
|
/* Convert null to undefined */
|
|
path: data?.path || undefined,
|
|
port: data?.port || undefined,
|
|
customCertResolver: data?.customCertResolver || undefined,
|
|
});
|
|
}
|
|
|
|
if (!domainId) {
|
|
form.reset({});
|
|
}
|
|
}, [form, form.reset, data, isPending]);
|
|
|
|
const dictionary = {
|
|
success: domainId ? "Domain Updated" : "Domain Created",
|
|
error: domainId ? "Error updating the domain" : "Error creating the domain",
|
|
submit: domainId ? "Update" : "Create",
|
|
dialogDescription: domainId
|
|
? "In this section you can edit a domain"
|
|
: "In this section you can add domains",
|
|
};
|
|
|
|
const onSubmit = async (data: Domain) => {
|
|
await mutateAsync({
|
|
domainId,
|
|
previewDeploymentId,
|
|
...data,
|
|
})
|
|
.then(async () => {
|
|
toast.success(dictionary.success);
|
|
await utils.previewDeployment.all.invalidate({
|
|
applicationId: previewDeployment?.applicationId,
|
|
});
|
|
|
|
if (domainId) {
|
|
refetch();
|
|
}
|
|
setIsOpen(false);
|
|
})
|
|
.catch(() => {
|
|
toast.error(dictionary.error);
|
|
});
|
|
};
|
|
return (
|
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
|
<DialogTrigger className="" asChild>
|
|
{children}
|
|
</DialogTrigger>
|
|
<DialogContent className="sm:max-w-2xl">
|
|
<DialogHeader>
|
|
<DialogTitle>Domain</DialogTitle>
|
|
<DialogDescription>{dictionary.dialogDescription}</DialogDescription>
|
|
</DialogHeader>
|
|
{isError && <AlertBlock type="error">{error?.message}</AlertBlock>}
|
|
|
|
<Form {...form}>
|
|
<form
|
|
id="hook-form"
|
|
onSubmit={form.handleSubmit(onSubmit)}
|
|
className="grid w-full gap-8 "
|
|
>
|
|
<div className="flex flex-col gap-4">
|
|
<div className="flex flex-col gap-2">
|
|
<FormField
|
|
control={form.control}
|
|
name="host"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
{isTraefikMeDomain && (
|
|
<AlertBlock type="info">
|
|
<strong>Note:</strong> sslip.io is a public HTTP
|
|
service and does not support SSL/HTTPS. HTTPS and
|
|
certificate options will not have any effect.
|
|
</AlertBlock>
|
|
)}
|
|
<FormLabel>Host</FormLabel>
|
|
<div className="flex gap-2">
|
|
<FormControl>
|
|
<Input placeholder="api.dokploy.com" {...field} />
|
|
</FormControl>
|
|
<TooltipProvider delayDuration={0}>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant="secondary"
|
|
type="button"
|
|
isLoading={isLoadingGenerate}
|
|
onClick={() => {
|
|
generateDomain({
|
|
appName: previewDeployment?.appName || "",
|
|
serverId:
|
|
previewDeployment?.application
|
|
?.serverId || "",
|
|
})
|
|
.then((domain) => {
|
|
field.onChange(domain);
|
|
})
|
|
.catch((err) => {
|
|
toast.error(err.message);
|
|
});
|
|
}}
|
|
>
|
|
<Dices className="size-4 text-muted-foreground" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent
|
|
side="left"
|
|
sideOffset={5}
|
|
className="max-w-40"
|
|
>
|
|
<p>Generate sslip.io domain</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</TooltipProvider>
|
|
</div>
|
|
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="path"
|
|
render={({ field }) => {
|
|
return (
|
|
<FormItem>
|
|
<FormLabel>Path</FormLabel>
|
|
<FormControl>
|
|
<Input placeholder={"/"} {...field} />
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
);
|
|
}}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="port"
|
|
render={({ field }) => {
|
|
return (
|
|
<FormItem>
|
|
<FormLabel>Container Port</FormLabel>
|
|
<FormControl>
|
|
<NumberInput placeholder={"3000"} {...field} />
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
);
|
|
}}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="https"
|
|
render={({ field }) => (
|
|
<FormItem className="flex flex-row items-center justify-between p-3 mt-4 border rounded-lg shadow-xs">
|
|
<div className="space-y-0.5">
|
|
<FormLabel>HTTPS</FormLabel>
|
|
<FormDescription>
|
|
Automatically provision SSL Certificate.
|
|
</FormDescription>
|
|
<FormMessage />
|
|
</div>
|
|
<FormControl>
|
|
<Switch
|
|
checked={field.value}
|
|
onCheckedChange={field.onChange}
|
|
/>
|
|
</FormControl>
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
{form.getValues().https && (
|
|
<FormField
|
|
control={form.control}
|
|
name="certificateType"
|
|
render={({ field }) => (
|
|
<FormItem className="col-span-2">
|
|
<FormLabel>Certificate Provider</FormLabel>
|
|
<Select
|
|
onValueChange={field.onChange}
|
|
defaultValue={field.value || ""}
|
|
>
|
|
<FormControl>
|
|
<SelectTrigger>
|
|
<SelectValue placeholder="Select a certificate provider" />
|
|
</SelectTrigger>
|
|
</FormControl>
|
|
|
|
<SelectContent>
|
|
<SelectItem value="none">None</SelectItem>
|
|
<SelectItem value={"letsencrypt"}>
|
|
Let's Encrypt
|
|
</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<DialogFooter>
|
|
<Button isLoading={isPending} form="hook-form" type="submit">
|
|
{dictionary.submit}
|
|
</Button>
|
|
</DialogFooter>
|
|
</Form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|