diff --git a/apps/dokploy/components/dashboard/project/advanced-environment-selector.tsx b/apps/dokploy/components/dashboard/project/advanced-environment-selector.tsx index 5246df5dd..915b2159d 100644 --- a/apps/dokploy/components/dashboard/project/advanced-environment-selector.tsx +++ b/apps/dokploy/components/dashboard/project/advanced-environment-selector.tsx @@ -22,17 +22,13 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { toast } from "sonner"; -import { ChevronDownIcon, PlusIcon, PencilIcon, TrashIcon } from "lucide-react"; +import { ChevronDownIcon, PlusIcon, PencilIcon, TrashIcon, CopyIcon } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { AlertBlock } from "@/components/shared/alert-block"; +import { findEnvironmentById } from "@dokploy/server"; -interface Environment { - environmentId: string; - name: string; - description?: string | null; - createdAt: string; -} +type Environment = Awaited>; interface AdvancedEnvironmentSelectorProps { projectId: string; environments: Environment[]; @@ -59,7 +55,16 @@ export const AdvancedEnvironmentSelector = ({ enabled: !!currentEnvironmentId, }); - const haveServices = environment && (environment?.mariadb?.length > 0 || environment?.mongo?.length > 0 || environment?.mysql?.length > 0 || environment?.postgres?.length > 0 || environment?.redis?.length > 0 || environment?.applications?.length > 0 || environment?.compose?.length > 0); + + const haveServices = selectedEnvironment && ( + (selectedEnvironment?.mariadb?.length || 0) > 0 || + (selectedEnvironment?.mongo?.length || 0) > 0 || + (selectedEnvironment?.mysql?.length || 0) > 0 || + (selectedEnvironment?.postgres?.length || 0) > 0 || + (selectedEnvironment?.redis?.length || 0) > 0 || + (selectedEnvironment?.applications?.length || 0) > 0 || + (selectedEnvironment?.compose?.length || 0) > 0 + ); const createEnvironment = api.environment.create.useMutation(); const updateEnvironment = api.environment.update.useMutation(); const deleteEnvironment = api.environment.remove.useMutation(); @@ -221,6 +226,17 @@ export const AdvancedEnvironmentSelector = ({ > + {/* */}