diff --git a/apps/dokploy/components/dashboard/docker/terminal/docker-terminal-modal.tsx b/apps/dokploy/components/dashboard/docker/terminal/docker-terminal-modal.tsx index 876d6838..f0f8ca6a 100644 --- a/apps/dokploy/components/dashboard/docker/terminal/docker-terminal-modal.tsx +++ b/apps/dokploy/components/dashboard/docker/terminal/docker-terminal-modal.tsx @@ -1,56 +1,94 @@ +import { Button } from "@/components/ui/button"; import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, } from "@/components/ui/dialog"; import { DropdownMenuItem } from "@/components/ui/dropdown-menu"; import dynamic from "next/dynamic"; +import { useState } from "react"; const Terminal = dynamic( - () => import("./docker-terminal").then((e) => e.DockerTerminal), - { - ssr: false, - }, + () => import("./docker-terminal").then((e) => e.DockerTerminal), + { + ssr: false, + } ); interface Props { - containerId: string; - serverId?: string; - children?: React.ReactNode; + containerId: string; + serverId?: string; + children?: React.ReactNode; } export const DockerTerminalModal = ({ - children, - containerId, - serverId, + children, + containerId, + serverId, }: Props) => { - return ( - - - e.preventDefault()} - > - {children} - - - - - Docker Terminal - - Easy way to access to docker container - - + const [mainDialogOpen, setMainDialogOpen] = useState(false); + const [confirmDialogOpen, setConfirmDialogOpen] = useState(false); - - - - ); + const handleMainDialogOpenChange = (open: boolean) => { + if (!open) { + setConfirmDialogOpen(true); + } else { + setMainDialogOpen(true); + } + }; + + const handleConfirm = () => { + setConfirmDialogOpen(false); + setMainDialogOpen(false); + }; + + const handleCancel = () => { + setConfirmDialogOpen(false); + }; + return ( + + + e.preventDefault()} + > + {children} + + + + + Docker Terminal + + Easy way to access to docker container + + + + + + + + Are you sure you want to close the terminal? + + By clicking the confirm button, the terminal will be closed. + + + + + + + + + + + ); }; diff --git a/apps/dokploy/components/dashboard/settings/web-server/docker-terminal-modal.tsx b/apps/dokploy/components/dashboard/settings/web-server/docker-terminal-modal.tsx index f38ecf12..ba3253a4 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/docker-terminal-modal.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/docker-terminal-modal.tsx @@ -1,20 +1,22 @@ +import { Button } from "@/components/ui/button"; import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, } from "@/components/ui/dialog"; import { Label } from "@/components/ui/label"; import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectTrigger, - SelectValue, + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, } from "@/components/ui/select"; import { api } from "@/utils/api"; import { Loader2 } from "lucide-react"; @@ -23,80 +25,118 @@ import type React from "react"; import { useEffect, useState } from "react"; const Terminal = dynamic( - () => - import("@/components/dashboard/docker/terminal/docker-terminal").then( - (e) => e.DockerTerminal, - ), - { - ssr: false, - }, + () => + import("@/components/dashboard/docker/terminal/docker-terminal").then( + (e) => e.DockerTerminal + ), + { + ssr: false, + } ); interface Props { - appName: string; - children?: React.ReactNode; - serverId?: string; + appName: string; + children?: React.ReactNode; + serverId?: string; } export const DockerTerminalModal = ({ children, appName, serverId }: Props) => { - const { data, isLoading } = api.docker.getContainersByAppNameMatch.useQuery( - { - appName, - serverId, - }, - { - enabled: !!appName, - }, - ); - const [containerId, setContainerId] = useState(); + const { data, isLoading } = api.docker.getContainersByAppNameMatch.useQuery( + { + appName, + serverId, + }, + { + enabled: !!appName, + } + ); + const [containerId, setContainerId] = useState(); + const [mainDialogOpen, setMainDialogOpen] = useState(false); + const [confirmDialogOpen, setConfirmDialogOpen] = useState(false); - useEffect(() => { - if (data && data?.length > 0) { - setContainerId(data[0]?.containerId); - } - }, [data]); - return ( - - {children} - - - Docker Terminal - - Easy way to access to docker container - - - - - - - - ); + const handleMainDialogOpenChange = (open: boolean) => { + if (!open) { + setConfirmDialogOpen(true); + } else { + setMainDialogOpen(true); + } + }; + + const handleConfirm = () => { + setConfirmDialogOpen(false); + setMainDialogOpen(false); + }; + + const handleCancel = () => { + setConfirmDialogOpen(false); + }; + + useEffect(() => { + if (data && data?.length > 0) { + setContainerId(data[0]?.containerId); + } + }, [data]); + + return ( + + {children} + + + Docker Terminal + + Easy way to access to docker container + + + + + + + + + + Are you sure you want to close the terminal? + + + By clicking the confirm button, the terminal will be closed. + + + + + + + + + + + ); };