mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 19:18:45 +00:00
3ca5afd49f
* 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>
169 lines
3.7 KiB
TypeScript
169 lines
3.7 KiB
TypeScript
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
|
|
import { FileTerminal } from "lucide-react";
|
|
import { useEffect, useState } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
import { toast } from "sonner";
|
|
import { z } from "zod";
|
|
import { AlertBlock } from "@/components/shared/alert-block";
|
|
import { CodeEditor } from "@/components/shared/code-editor";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/components/ui/dialog";
|
|
import {
|
|
Form,
|
|
FormControl,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from "@/components/ui/form";
|
|
import { api } from "@/utils/api";
|
|
|
|
interface Props {
|
|
serverId: string;
|
|
}
|
|
|
|
const schema = z.object({
|
|
command: z.string().min(1, {
|
|
message: "Command is required",
|
|
}),
|
|
});
|
|
|
|
type Schema = z.infer<typeof schema>;
|
|
|
|
export const EditScript = ({ serverId }: Props) => {
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
const { data: server } = api.server.one.useQuery(
|
|
{
|
|
serverId,
|
|
},
|
|
{
|
|
enabled: !!serverId,
|
|
},
|
|
);
|
|
|
|
const { mutateAsync, isPending } = api.server.update.useMutation();
|
|
|
|
const { data: defaultCommand } = api.server.getDefaultCommand.useQuery(
|
|
{
|
|
serverId,
|
|
},
|
|
{
|
|
enabled: !!serverId,
|
|
},
|
|
);
|
|
|
|
const form = useForm<Schema>({
|
|
defaultValues: {
|
|
command: "",
|
|
},
|
|
resolver: zodResolver(schema),
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (server) {
|
|
form.reset({
|
|
command: server.command || defaultCommand,
|
|
});
|
|
}
|
|
}, [server, defaultCommand]);
|
|
|
|
const onSubmit = async (formData: Schema) => {
|
|
if (server) {
|
|
await mutateAsync({
|
|
...server,
|
|
command: formData.command || "",
|
|
serverId,
|
|
})
|
|
.then((_data) => {
|
|
toast.success("Script modified successfully");
|
|
})
|
|
.catch(() => {
|
|
toast.error("Error modifying the script");
|
|
});
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
|
<DialogTrigger asChild>
|
|
<Button variant="outline">
|
|
Modify Script
|
|
<FileTerminal className="size-4 text-muted-foreground" />
|
|
</Button>
|
|
</DialogTrigger>
|
|
<DialogContent className="sm:max-w-5xl overflow-x-hidden">
|
|
<DialogHeader>
|
|
<DialogTitle>Modify Script</DialogTitle>
|
|
<DialogDescription>
|
|
Modify the script which install everything necessary to deploy
|
|
applications on your server,
|
|
</DialogDescription>
|
|
|
|
<AlertBlock type="warning">
|
|
We recommend not modifying this script unless you know what you are
|
|
doing.
|
|
</AlertBlock>
|
|
</DialogHeader>
|
|
<div className="grid gap-4">
|
|
<Form {...form}>
|
|
<form
|
|
onSubmit={form.handleSubmit(onSubmit)}
|
|
id="hook-form-delete-application"
|
|
className="grid w-full gap-4"
|
|
>
|
|
<FormField
|
|
control={form.control}
|
|
name="command"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormLabel>Command</FormLabel>
|
|
<FormControl className="max-h-[75vh] max-w-240 overflow-y-scroll overflow-x-hidden">
|
|
<CodeEditor
|
|
language="shell"
|
|
wrapperClassName="font-mono"
|
|
{...field}
|
|
placeholder={`
|
|
set -e
|
|
echo "Hello world"
|
|
`}
|
|
/>
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
</form>
|
|
</Form>
|
|
</div>
|
|
<DialogFooter className="flex justify-between w-full">
|
|
<Button
|
|
variant="secondary"
|
|
onClick={() => {
|
|
form.reset({
|
|
command: defaultCommand || "",
|
|
});
|
|
}}
|
|
>
|
|
Reset
|
|
</Button>
|
|
<Button
|
|
isLoading={isPending}
|
|
form="hook-form-delete-application"
|
|
type="submit"
|
|
>
|
|
Save
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|