mirror of
https://github.com/andwati/dokploy.git
synced 2026-12-01 07:28:45 +00:00
fix(ui): code formatting and DialogHeader improvements
- Apply consistent code formatting across dialog components - Add bottom padding to DialogHeader for better visual separation - Clean up DialogHeader usage in swarm settings (remove duplicate padding) - Improve schedule dialog layout and add proper description - Fix indentation and formatting inconsistencies Final cleanup of dialog component formatting and spacing.
This commit is contained in:
+1
-1
@@ -271,7 +271,7 @@ export const AddSwarmSettings = ({ applicationId }: Props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="sm:max-w-5xl p-0">
|
<DialogContent className="sm:max-w-5xl p-0">
|
||||||
<DialogHeader className="p-6">
|
<DialogHeader>
|
||||||
<DialogTitle>Swarm Settings</DialogTitle>
|
<DialogTitle>Swarm Settings</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Update certain settings using a json object.
|
Update certain settings using a json object.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
@@ -232,14 +233,17 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => {
|
|||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
className={cn(
|
className={cn(
|
||||||
"overflow-y-auto",
|
|
||||||
scheduleTypeForm === "dokploy-server" || scheduleTypeForm === "server"
|
scheduleTypeForm === "dokploy-server" || scheduleTypeForm === "server"
|
||||||
? "max-h-[95vh] sm:max-w-2xl"
|
? "sm:max-w-2xl"
|
||||||
: " sm:max-w-lg",
|
: "sm:max-w-lg",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{scheduleId ? "Edit" : "Create"} Schedule</DialogTitle>
|
<DialogTitle>{scheduleId ? "Edit" : "Create"} Schedule</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
{scheduleId ? "Manage" : "Create"} a schedule to run a task at a
|
||||||
|
specific time or interval.
|
||||||
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
||||||
@@ -434,82 +438,82 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => {
|
|||||||
|
|
||||||
{(scheduleTypeForm === "application" ||
|
{(scheduleTypeForm === "application" ||
|
||||||
scheduleTypeForm === "compose") && (
|
scheduleTypeForm === "compose") && (
|
||||||
<>
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="shellType"
|
name="shellType"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel className="flex items-center gap-2">
|
<FormLabel className="flex items-center gap-2">
|
||||||
Shell Type
|
Shell Type
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
defaultValue={field.value}
|
defaultValue={field.value}
|
||||||
>
|
>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select shell type" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="bash">Bash</SelectItem>
|
||||||
|
<SelectItem value="sh">Sh</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormDescription>
|
||||||
|
Choose the shell to execute your command
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="command"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel className="flex items-center gap-2">
|
||||||
|
Command
|
||||||
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<Input placeholder="npm run backup" {...field} />
|
||||||
<SelectValue placeholder="Select shell type" />
|
|
||||||
</SelectTrigger>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<FormDescription>
|
||||||
<SelectItem value="bash">Bash</SelectItem>
|
The command to execute in your container
|
||||||
<SelectItem value="sh">Sh</SelectItem>
|
</FormDescription>
|
||||||
</SelectContent>
|
<FormMessage />
|
||||||
</Select>
|
</FormItem>
|
||||||
<FormDescription>
|
)}
|
||||||
Choose the shell to execute your command
|
/>
|
||||||
</FormDescription>
|
</>
|
||||||
<FormMessage />
|
)}
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="command"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel className="flex items-center gap-2">
|
|
||||||
Command
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="npm run backup" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormDescription>
|
|
||||||
The command to execute in your container
|
|
||||||
</FormDescription>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(scheduleTypeForm === "dokploy-server" ||
|
{(scheduleTypeForm === "dokploy-server" ||
|
||||||
scheduleTypeForm === "server") && (
|
scheduleTypeForm === "server") && (
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="script"
|
name="script"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Script</FormLabel>
|
<FormLabel>Script</FormLabel>
|
||||||
<FormControl>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<CodeEditor
|
<FormControl>
|
||||||
language="shell"
|
<CodeEditor
|
||||||
placeholder={`# This is a comment
|
language="shell"
|
||||||
|
placeholder={`# This is a comment
|
||||||
echo "Hello, world!"
|
echo "Hello, world!"
|
||||||
`}
|
`}
|
||||||
className="h-96 font-mono"
|
className="h-96 font-mono"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
|
</FormControl>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormControl>
|
<FormMessage />
|
||||||
<FormMessage />
|
</FormItem>
|
||||||
</FormItem>
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
)}
|
||||||
)}
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
|
import { cn } from "@/lib/utils";
|
||||||
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||||
import { X } from "lucide-react";
|
import { X } from "lucide-react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
const DialogContext = React.createContext<{
|
const DialogContext = React.createContext<{
|
||||||
onOpenChange?: (open: boolean) => void;
|
onOpenChange?: (open: boolean) => void;
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
}>({});
|
}>({});
|
||||||
|
|
||||||
const Dialog = ({ onOpenChange, open, ...props }: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) => (
|
const Dialog = ({
|
||||||
|
onOpenChange,
|
||||||
|
open,
|
||||||
|
...props
|
||||||
|
}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) => (
|
||||||
<DialogContext.Provider value={{ onOpenChange, open }}>
|
<DialogContext.Provider value={{ onOpenChange, open }}>
|
||||||
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange} {...props} modal={false}/>
|
<DialogPrimitive.Root
|
||||||
|
open={open}
|
||||||
|
onOpenChange={onOpenChange}
|
||||||
|
{...props}
|
||||||
|
modal={false}
|
||||||
|
/>
|
||||||
</DialogContext.Provider>
|
</DialogContext.Provider>
|
||||||
);
|
);
|
||||||
Dialog.displayName = DialogPrimitive.Root.displayName;
|
Dialog.displayName = DialogPrimitive.Root.displayName;
|
||||||
@@ -44,18 +53,19 @@ const DialogContent = React.forwardRef<
|
|||||||
const { onOpenChange, open } = React.useContext(DialogContext);
|
const { onOpenChange, open } = React.useContext(DialogContext);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
|
|
||||||
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
const scrollbarWidth =
|
||||||
|
window.innerWidth - document.documentElement.clientWidth;
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
const originalPaddingRight = body.style.paddingRight;
|
const originalPaddingRight = body.style.paddingRight;
|
||||||
const originalOverflow = body.style.overflow;
|
const originalOverflow = body.style.overflow;
|
||||||
|
|
||||||
body.style.overflow = 'hidden';
|
body.style.overflow = "hidden";
|
||||||
if (scrollbarWidth > 0) {
|
if (scrollbarWidth > 0) {
|
||||||
body.style.paddingRight = `${scrollbarWidth}px`;
|
body.style.paddingRight = `${scrollbarWidth}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
body.style.overflow = originalOverflow;
|
body.style.overflow = originalOverflow;
|
||||||
body.style.paddingRight = originalPaddingRight;
|
body.style.paddingRight = originalPaddingRight;
|
||||||
@@ -63,23 +73,26 @@ const DialogContent = React.forwardRef<
|
|||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
// Handle outside interactions properly with Command components
|
// Handle outside interactions properly with Command components
|
||||||
const handleInteractOutside = React.useCallback((e: Event) => {
|
const handleInteractOutside = React.useCallback(
|
||||||
if (onOpenChange) {
|
(_e: Event) => {
|
||||||
onOpenChange(false);
|
if (onOpenChange) {
|
||||||
}
|
onOpenChange(false);
|
||||||
}, [onOpenChange]);
|
}
|
||||||
|
},
|
||||||
|
[onOpenChange],
|
||||||
|
);
|
||||||
|
|
||||||
const hasPaddingOverride = className?.includes("p-0");
|
const hasPaddingOverride = className?.includes("p-0");
|
||||||
|
|
||||||
// Separate DialogFooter from other children for proper layout
|
// Separate DialogFooter from other children for proper layout
|
||||||
const childrenArray = React.Children.toArray(children);
|
const childrenArray = React.Children.toArray(children);
|
||||||
const dialogFooter = childrenArray.find((child) =>
|
const dialogFooter = childrenArray.find(
|
||||||
React.isValidElement(child) && child.type === DialogFooter
|
(child) => React.isValidElement(child) && child.type === DialogFooter,
|
||||||
);
|
);
|
||||||
const otherChildren = childrenArray.filter((child) =>
|
const otherChildren = childrenArray.filter(
|
||||||
!(React.isValidElement(child) && child.type === DialogFooter)
|
(child) => !(React.isValidElement(child) && child.type === DialogFooter),
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
{/* Custom overlay for modal=false - no click handler to avoid Command conflicts */}
|
{/* Custom overlay for modal=false - no click handler to avoid Command conflicts */}
|
||||||
@@ -94,9 +107,11 @@ const DialogContent = React.forwardRef<
|
|||||||
onInteractOutside={(e) => {
|
onInteractOutside={(e) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
// Don't close when clicking inside popovers, dropdowns, or command components
|
// Don't close when clicking inside popovers, dropdowns, or command components
|
||||||
if (target.closest('[data-radix-popper-content-wrapper]') ||
|
if (
|
||||||
target.closest('[cmdk-root]') ||
|
target.closest("[data-radix-popper-content-wrapper]") ||
|
||||||
target.closest('[data-radix-command-root]')) {
|
target.closest("[cmdk-root]") ||
|
||||||
|
target.closest("[data-radix-command-root]")
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -105,23 +120,23 @@ const DialogContent = React.forwardRef<
|
|||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={contentRef}
|
ref={contentRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
"overflow-y-auto overflow-x-hidden flex-1 min-h-0 overscroll-contain",
|
"overflow-y-auto overflow-x-hidden flex-1 min-h-0 overscroll-contain",
|
||||||
!hasPaddingOverride && "p-6"
|
!hasPaddingOverride && "p-6",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{otherChildren}
|
{otherChildren}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* DialogFooter outside scrollable area with proper spacing */}
|
{/* DialogFooter outside scrollable area with proper spacing */}
|
||||||
{dialogFooter && (
|
{dialogFooter && (
|
||||||
<div className="p-6 pt-0 border-t border-border/50">
|
<div className="p-6 pt-0 border-t border-border/50">
|
||||||
{dialogFooter}
|
{dialogFooter}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
<X className="h-4 w-4" />
|
<X className="h-4 w-4" />
|
||||||
<span className="sr-only">Close</span>
|
<span className="sr-only">Close</span>
|
||||||
@@ -138,7 +153,7 @@ const DialogHeader = ({
|
|||||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col space-y-1.5 text-center sm:text-left",
|
"flex flex-col space-y-1.5 text-center sm:text-left pb-4",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -198,4 +213,4 @@ export {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogDescription,
|
DialogDescription,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user