From 46f1af3bb30797030237ee856f16c598d8a45a18 Mon Sep 17 00:00:00 2001 From: HarikrishnanD Date: Thu, 4 Sep 2025 13:54:19 +0530 Subject: [PATCH] feat(ui): add conditional server dropdown with Dokploy default option - Add IS_CLOUD flag support for server selection dropdown - Show "Dokploy" as default option in self-hosted environments - Hide dropdown when no remote servers exist - Add conditional placeholder text and server count display - Handle "dokploy" value in form submission (converts to undefined) - Apply changes to all relevant components: add-application, add-compose, add-template, add-database, add-certificate, and AI step-one Resolves #1852 --- .../dashboard/project/add-application.tsx | 28 +++++++++++------- .../dashboard/project/add-compose.tsx | 28 +++++++++++------- .../dashboard/project/add-database.tsx | 29 ++++++++++++------- .../dashboard/project/add-template.tsx | 28 +++++++++++------- .../dashboard/project/ai/step-one.tsx | 29 ++++++++++++------- .../settings/certificates/add-certificate.tsx | 28 +++++++++++------- 6 files changed, 104 insertions(+), 66 deletions(-) diff --git a/apps/dokploy/components/dashboard/project/add-application.tsx b/apps/dokploy/components/dashboard/project/add-application.tsx index 1a83cdb64..5f4d9c8e5 100644 --- a/apps/dokploy/components/dashboard/project/add-application.tsx +++ b/apps/dokploy/components/dashboard/project/add-application.tsx @@ -76,6 +76,10 @@ export const AddApplication = ({ projectId, projectName }: Props) => { const { data: servers } = api.server.withSSHKey.useQuery(); const hasServers = servers && servers.length > 0; + // Show dropdown logic based on cloud environment + // Cloud: show only if there are remote servers (no Dokploy option) + // Self-hosted: show only if there are remote servers (Dokploy is default, hide if no remote servers) + const shouldShowServerDropdown = hasServers; const { mutateAsync, isLoading, error, isError } = api.application.create.useMutation(); @@ -157,7 +161,7 @@ export const AddApplication = ({ projectId, projectName }: Props) => { )} /> - {hasServers && ( + {shouldShowServerDropdown && ( { - + - - - Dokploy - - Default + {!isCloud && ( + + + Dokploy + + Default + - - + + )} {servers?.map((server) => ( { ))} - Servers ({servers?.length + 1}) + Servers ({servers?.length + (!isCloud ? 1 : 0)}) diff --git a/apps/dokploy/components/dashboard/project/add-database.tsx b/apps/dokploy/components/dashboard/project/add-database.tsx index 07af43312..8c8ec9650 100644 --- a/apps/dokploy/components/dashboard/project/add-database.tsx +++ b/apps/dokploy/components/dashboard/project/add-database.tsx @@ -178,6 +178,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { const utils = api.useUtils(); const [visible, setVisible] = useState(false); const slug = slugify(projectName); + const { data: isCloud } = api.settings.isCloud.useQuery(); const { data: servers } = api.server.withSSHKey.useQuery(); const postgresMutation = api.postgres.create.useMutation(); const mongoMutation = api.mongo.create.useMutation(); @@ -186,6 +187,10 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { const mysqlMutation = api.mysql.create.useMutation(); const hasServers = servers && servers.length > 0; + // Show dropdown logic based on cloud environment + // Cloud: show only if there are remote servers (no Dokploy option) + // Self-hosted: show only if there are remote servers (Dokploy is default, hide if no remote servers) + const shouldShowServerDropdown = hasServers; const form = useForm({ defaultValues: { @@ -398,7 +403,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { )} /> - {hasServers && ( + {shouldShowServerDropdown && ( { Select a Server { if (value === "dokploy") { setTemplateInfo({ @@ -73,24 +78,26 @@ export const StepOne = ({ setTemplateInfo, templateInfo }: any) => { }} > - + - - - Dokploy - - Default + {!isCloud && ( + + + Dokploy + + Default + - - + + )} {servers?.map((server) => ( {server.name} ))} - Servers ({servers?.length + 1}) + Servers ({servers?.length + (!isCloud ? 1 : 0)}) diff --git a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx index 75b903874..938e719b2 100644 --- a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx +++ b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx @@ -66,6 +66,10 @@ export const AddCertificate = () => { api.certificates.create.useMutation(); const { data: servers } = api.server.withSSHKey.useQuery(); const hasServers = servers && servers.length > 0; + // Show dropdown logic based on cloud environment + // Cloud: show only if there are remote servers (no Dokploy option) + // Self-hosted: show only if there are remote servers (Dokploy is default, hide if no remote servers) + const shouldShowServerDropdown = hasServers; const form = useForm({ defaultValues: { @@ -175,7 +179,7 @@ export const AddCertificate = () => { )} /> - {hasServers && ( + {shouldShowServerDropdown && ( {