From 940b9967b847e946727609a300bbe1b9e1a931ab Mon Sep 17 00:00:00 2001 From: HarikrishnanD Date: Tue, 2 Sep 2025 19:17:46 +0530 Subject: [PATCH 1/5] feat(ui): add default "Dokploy" option to server selection dropdown - Add "Dokploy" as default option in server selection dropdowns - Hide dropdown when only one server is available (servers.length <= 1) - Show dropdown only when multiple servers exist (servers.length > 1) - Update placeholder text from "Select a Server" to "Dokploy" - Fix issue where users couldn't switch back to default server - Update form submission logic to handle "dokploy" default value - Apply changes to all deployment components (application, compose, template, database, certificate, AI) Resolves #1852 --- .../dashboard/project/add-application.tsx | 18 +++- .../dashboard/project/add-compose.tsx | 18 +++- .../dashboard/project/add-database.tsx | 28 ++++-- .../dashboard/project/add-template.tsx | 17 +++- .../dashboard/project/ai/step-one.tsx | 29 ++++-- .../settings/certificates/add-certificate.tsx | 93 +++++++++++-------- 6 files changed, 131 insertions(+), 72 deletions(-) diff --git a/apps/dokploy/components/dashboard/project/add-application.tsx b/apps/dokploy/components/dashboard/project/add-application.tsx index 137f75a51..7d53b3095 100644 --- a/apps/dokploy/components/dashboard/project/add-application.tsx +++ b/apps/dokploy/components/dashboard/project/add-application.tsx @@ -95,7 +95,7 @@ export const AddApplication = ({ projectId, projectName }: Props) => { appName: data.appName, description: data.description, projectId, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, }) .then(async () => { toast.success("Service Created"); @@ -157,7 +157,7 @@ export const AddApplication = ({ projectId, projectName }: Props) => { )} /> - {hasServers && ( + {hasServers && servers.length > 1 && ( { diff --git a/apps/dokploy/components/dashboard/project/add-compose.tsx b/apps/dokploy/components/dashboard/project/add-compose.tsx index c32e55c16..7249d2745 100644 --- a/apps/dokploy/components/dashboard/project/add-compose.tsx +++ b/apps/dokploy/components/dashboard/project/add-compose.tsx @@ -101,7 +101,7 @@ export const AddCompose = ({ projectId, projectName }: Props) => { projectId, composeType: data.composeType, appName: data.appName, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, }) .then(async () => { toast.success("Compose Created"); @@ -165,7 +165,7 @@ export const AddCompose = ({ projectId, projectName }: Props) => { )} /> - {hasServers && ( + {hasServers && servers.length > 1 && ( { diff --git a/apps/dokploy/components/dashboard/project/add-database.tsx b/apps/dokploy/components/dashboard/project/add-database.tsx index 104413908..e7a72afe1 100644 --- a/apps/dokploy/components/dashboard/project/add-database.tsx +++ b/apps/dokploy/components/dashboard/project/add-database.tsx @@ -220,7 +220,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { appName: data.appName, dockerImage: defaultDockerImage, projectId, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, description: data.description, }; @@ -232,7 +232,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, }); } else if (data.type === "mongo") { promise = mongoMutation.mutateAsync({ @@ -240,14 +240,14 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databasePassword: data.databasePassword, databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, replicaSets: data.replicaSets, }); } else if (data.type === "redis") { promise = redisMutation.mutateAsync({ ...commonParams, databasePassword: data.databasePassword, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, projectId, }); } else if (data.type === "mariadb") { @@ -258,7 +258,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databaseName: data.databaseName || "mariadb", databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, }); } else if (data.type === "mysql") { promise = mysqlMutation.mutateAsync({ @@ -268,7 +268,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], databaseRootPassword: data.databaseRootPassword, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, }); } @@ -398,7 +398,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { )} /> - {hasServers && ( + {hasServers && servers.length > 1 && ( { Select a Server { - const server = servers?.find((s) => s.serverId === value); - if (server) { + if (value === "dokploy") { setTemplateInfo({ ...templateInfo, - server: server, + server: undefined, }); + } else { + const server = servers?.find((s) => s.serverId === value); + if (server) { + setTemplateInfo({ + ...templateInfo, + server: server, + }); + } } }} > - + + + + Dokploy + + Default + + + {servers?.map((server) => ( {server.name} ))} - Servers ({servers?.length}) + Servers ({servers?.length + 1}) diff --git a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx index ab19f6185..57e3115ac 100644 --- a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx +++ b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx @@ -65,6 +65,7 @@ export const AddCertificate = () => { const { mutateAsync, isError, error, isLoading } = api.certificates.create.useMutation(); const { data: servers } = api.server.withSSHKey.useQuery(); + const hasServers = servers && servers.length > 0; const form = useForm({ defaultValues: { @@ -85,7 +86,7 @@ export const AddCertificate = () => { certificateData: data.certificateData, privateKey: data.privateKey, autoRenew: data.autoRenew, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, organizationId: "", }) .then(async () => { @@ -174,52 +175,62 @@ export const AddCertificate = () => { )} /> - ( - - - - - - Select a Server {!isCloud && "(Optional)"} - - - - - + {hasServers && servers.length > 1 && ( + ( + + + + + + Select a Server {!isCloud && "(Optional)"} + + + + + - + + + + + + - {server.name} + Dokploy - {server.ipAddress} + Default - ))} - Servers ({servers?.length}) - - - - - - )} - /> + {servers?.map((server) => ( + + + {server.name} + + {server.ipAddress} + + + + ))} + Servers ({servers?.length + 1}) + + + + + + )} + /> + )} From 4a3a7fa47bf65d8cec5c7a689540b95c521ddfd4 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 02:43:53 +0000 Subject: [PATCH 2/5] [autofix.ci] apply automated fixes --- .../dokploy/components/dashboard/project/add-application.tsx | 4 +++- apps/dokploy/components/dashboard/project/add-compose.tsx | 4 +++- apps/dokploy/components/dashboard/project/add-template.tsx | 5 ++++- .../dashboard/settings/certificates/add-certificate.tsx | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/dokploy/components/dashboard/project/add-application.tsx b/apps/dokploy/components/dashboard/project/add-application.tsx index 7d53b3095..7c5c1a69c 100644 --- a/apps/dokploy/components/dashboard/project/add-application.tsx +++ b/apps/dokploy/components/dashboard/project/add-application.tsx @@ -214,7 +214,9 @@ export const AddApplication = ({ projectId, projectName }: Props) => { ))} - Servers ({servers?.length + 1}) + + Servers ({servers?.length + 1}) + diff --git a/apps/dokploy/components/dashboard/project/add-compose.tsx b/apps/dokploy/components/dashboard/project/add-compose.tsx index 7249d2745..7c1dbfd47 100644 --- a/apps/dokploy/components/dashboard/project/add-compose.tsx +++ b/apps/dokploy/components/dashboard/project/add-compose.tsx @@ -222,7 +222,9 @@ export const AddCompose = ({ projectId, projectName }: Props) => { ))} - Servers ({servers?.length + 1}) + + Servers ({servers?.length + 1}) + diff --git a/apps/dokploy/components/dashboard/project/add-template.tsx b/apps/dokploy/components/dashboard/project/add-template.tsx index 66466bfc7..56ff6705f 100644 --- a/apps/dokploy/components/dashboard/project/add-template.tsx +++ b/apps/dokploy/components/dashboard/project/add-template.tsx @@ -500,7 +500,10 @@ export const AddTemplate = ({ projectId, baseUrl }: Props) => { onClick={async () => { const promise = mutateAsync({ projectId, - serverId: serverId === "dokploy" ? undefined : serverId, + serverId: + serverId === "dokploy" + ? undefined + : serverId, id: template.id, baseUrl: customBaseUrl, }); diff --git a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx index 57e3115ac..95405d9d6 100644 --- a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx +++ b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx @@ -222,7 +222,9 @@ export const AddCertificate = () => { ))} - Servers ({servers?.length + 1}) + + Servers ({servers?.length + 1}) + From 52e21dab4e184e0cf866829f045243cc1ba8dd16 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Wed, 3 Sep 2025 20:45:47 -0600 Subject: [PATCH 3/5] refactor(ui): simplify server selection logic across components - Remove redundant server count check in server selection dropdowns across multiple components (AddApplication, AddCompose, AddDatabase, AddTemplate, StepOne, AddCertificate) to streamline UI behavior. --- .../components/dashboard/project/add-application.tsx | 2 +- .../components/dashboard/project/add-compose.tsx | 2 +- .../components/dashboard/project/add-database.tsx | 12 ++++++------ .../components/dashboard/project/add-template.tsx | 2 +- .../components/dashboard/project/ai/step-one.tsx | 2 +- .../settings/certificates/add-certificate.tsx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/dokploy/components/dashboard/project/add-application.tsx b/apps/dokploy/components/dashboard/project/add-application.tsx index 7c5c1a69c..1a83cdb64 100644 --- a/apps/dokploy/components/dashboard/project/add-application.tsx +++ b/apps/dokploy/components/dashboard/project/add-application.tsx @@ -157,7 +157,7 @@ export const AddApplication = ({ projectId, projectName }: Props) => { )} /> - {hasServers && servers.length > 1 && ( + {hasServers && ( { )} /> - {hasServers && servers.length > 1 && ( + {hasServers && ( { databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId === "dokploy" ? undefined : data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, }); } else if (data.type === "mongo") { promise = mongoMutation.mutateAsync({ @@ -240,14 +240,14 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databasePassword: data.databasePassword, databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId === "dokploy" ? undefined : data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, replicaSets: data.replicaSets, }); } else if (data.type === "redis") { promise = redisMutation.mutateAsync({ ...commonParams, databasePassword: data.databasePassword, - serverId: data.serverId === "dokploy" ? undefined : data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, projectId, }); } else if (data.type === "mariadb") { @@ -258,7 +258,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databaseName: data.databaseName || "mariadb", databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId === "dokploy" ? undefined : data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, }); } else if (data.type === "mysql") { promise = mysqlMutation.mutateAsync({ @@ -268,7 +268,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], databaseRootPassword: data.databaseRootPassword, - serverId: data.serverId === "dokploy" ? undefined : data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, }); } @@ -398,7 +398,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => { )} /> - {hasServers && servers.length > 1 && ( + {hasServers && ( { project. - {hasServers && servers.length > 1 && ( + {hasServers && (
diff --git a/apps/dokploy/components/dashboard/project/ai/step-one.tsx b/apps/dokploy/components/dashboard/project/ai/step-one.tsx index e81c5623c..2099a8505 100644 --- a/apps/dokploy/components/dashboard/project/ai/step-one.tsx +++ b/apps/dokploy/components/dashboard/project/ai/step-one.tsx @@ -48,7 +48,7 @@ export const StepOne = ({ setTemplateInfo, templateInfo }: any) => { />
- {hasServers && servers.length > 1 && ( + {hasServers && (
diff --git a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx index 938e719b2..6f7ef6821 100644 --- a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx +++ b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx @@ -198,10 +198,14 @@ export const AddCertificate = () => {