diff --git a/apps/dokploy/components/dashboard/project/add-application.tsx b/apps/dokploy/components/dashboard/project/add-application.tsx index dd4effb0f..079701eb8 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 = ({ environmentId, 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(); @@ -94,8 +98,8 @@ export const AddApplication = ({ environmentId, projectName }: Props) => { name: data.name, appName: data.appName, description: data.description, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, environmentId, - serverId: data.serverId, }) .then(async () => { toast.success("Service Created"); @@ -157,7 +161,7 @@ export const AddApplication = ({ environmentId, projectName }: Props) => { )} /> - {hasServers && ( + {shouldShowServerDropdown && ( { diff --git a/apps/dokploy/components/dashboard/project/add-compose.tsx b/apps/dokploy/components/dashboard/project/add-compose.tsx index d565b5bfd..a187104ec 100644 --- a/apps/dokploy/components/dashboard/project/add-compose.tsx +++ b/apps/dokploy/components/dashboard/project/add-compose.tsx @@ -82,6 +82,10 @@ export const AddCompose = ({ environmentId, projectName }: Props) => { const { data: environment } = api.environment.one.useQuery({ environmentId }); 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: { @@ -104,7 +108,7 @@ export const AddCompose = ({ environmentId, projectName }: Props) => { environmentId, composeType: data.composeType, appName: data.appName, - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? undefined : data.serverId, }) .then(async () => { toast.success("Compose Created"); @@ -169,7 +173,7 @@ export const AddCompose = ({ environmentId, projectName }: Props) => { )} /> - {hasServers && ( + {shouldShowServerDropdown && ( { diff --git a/apps/dokploy/components/dashboard/project/add-database.tsx b/apps/dokploy/components/dashboard/project/add-database.tsx index c7d114c93..064e93544 100644 --- a/apps/dokploy/components/dashboard/project/add-database.tsx +++ b/apps/dokploy/components/dashboard/project/add-database.tsx @@ -179,6 +179,7 @@ export const AddDatabase = ({ environmentId, 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(); @@ -190,6 +191,10 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { const { data: environment } = api.environment.one.useQuery({ environmentId }); 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: { @@ -223,9 +228,8 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { name: data.name, appName: data.appName, dockerImage: defaultDockerImage, - projectId: environment?.projectId || "", + serverId: data.serverId === "dokploy" ? undefined : data.serverId, environmentId, - serverId: data.serverId, description: data.description, }; @@ -237,7 +241,7 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, }); } else if (data.type === "mongo") { promise = mongoMutation.mutateAsync({ @@ -245,14 +249,14 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { databasePassword: data.databasePassword, databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: 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, + serverId: data.serverId === "dokploy" ? null : data.serverId, }); } else if (data.type === "mariadb") { promise = mariadbMutation.mutateAsync({ @@ -262,7 +266,7 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { databaseName: data.databaseName || "mariadb", databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], - serverId: data.serverId, + serverId: data.serverId === "dokploy" ? null : data.serverId, }); } else if (data.type === "mysql") { promise = mysqlMutation.mutateAsync({ @@ -271,8 +275,8 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { databaseName: data.databaseName || "mysql", databaseUser: data.databaseUser || databasesUserDefaultPlaceholder[data.type], + serverId: data.serverId === "dokploy" ? null : data.serverId, databaseRootPassword: data.databaseRootPassword || "", - serverId: data.serverId, }); } @@ -403,7 +407,7 @@ export const AddDatabase = ({ environmentId, projectName }: Props) => { )} /> - {hasServers && ( + {shouldShowServerDropdown && ( { 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, + }); + } } }} > - + + {!isCloud && ( + + + Dokploy + + Default + + + + )} {servers?.map((server) => ( {server.name} ))} - Servers ({servers?.length}) + + 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 ab19f6185..6f7ef6821 100644 --- a/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx +++ b/apps/dokploy/components/dashboard/settings/certificates/add-certificate.tsx @@ -65,6 +65,11 @@ 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; + // 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: { @@ -85,7 +90,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 +179,70 @@ export const AddCertificate = () => { )} /> - ( - - - - - - Select a Server {!isCloud && "(Optional)"} - - - - - + {shouldShowServerDropdown && ( + ( + + + + + + Select a Server {!isCloud && "(Optional)"} + + + + + - + + + + + + {!isCloud && ( + + + Dokploy + + Default + - - - ))} - Servers ({servers?.length}) - - - - - - )} - /> + + )} + {servers?.map((server) => ( + + + {server.name} + + {server.ipAddress} + + + + ))} + + Servers ({servers?.length + (!isCloud ? 1 : 0)}) + + + + + + + )} + /> + )}