diff --git a/apps/dokploy/__test__/drop/drop.test.test.ts b/apps/dokploy/__test__/drop/drop.test.test.ts index 74c80365..7dc9e560 100644 --- a/apps/dokploy/__test__/drop/drop.test.test.ts +++ b/apps/dokploy/__test__/drop/drop.test.test.ts @@ -27,6 +27,11 @@ if (typeof window === "undefined") { const baseApp: ApplicationNested = { applicationId: "", herokuVersion: "", + giteaBranch: "", + giteaBuildPath: "", + giteaId: "", + giteaOwner: "", + giteaRepository: "", cleanCache: false, watchPaths: [], applicationStatus: "done", diff --git a/apps/dokploy/__test__/traefik/traefik.test.ts b/apps/dokploy/__test__/traefik/traefik.test.ts index 74b0e265..d8a14ab4 100644 --- a/apps/dokploy/__test__/traefik/traefik.test.ts +++ b/apps/dokploy/__test__/traefik/traefik.test.ts @@ -7,6 +7,11 @@ import { expect, test } from "vitest"; const baseApp: ApplicationNested = { applicationId: "", herokuVersion: "", + giteaRepository: "", + giteaOwner: "", + giteaBranch: "", + giteaBuildPath: "", + giteaId: "", cleanCache: false, applicationStatus: "done", appName: "", diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-gitea-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-gitea-provider.tsx index 1dd2abfe..c3fcede1 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-gitea-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-gitea-provider.tsx @@ -67,7 +67,6 @@ const GiteaProviderSchema = z.object({ .object({ repo: z.string().min(1, "Repo is required"), owner: z.string().min(1, "Owner is required"), - id: z.number().nullable().optional(), }) .required(), branch: z.string().min(1, "Branch is required"), @@ -94,7 +93,6 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => { repository: { owner: "", repo: "", - id: null, }, giteaId: "", branch: "", @@ -127,7 +125,6 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => { { owner: repository?.owner, repositoryName: repository?.repo, - id: repository?.id ?? 0, // Use nullish coalescing to provide 0 as a fallback giteaId: giteaId, }, { @@ -142,7 +139,6 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => { repository: { repo: data.giteaRepository || "", owner: data.giteaOwner || "", - id: data.giteaProjectId || null, // Handle null case explicitly }, buildPath: data.giteaBuildPath || "/", giteaId: data.giteaId || "", @@ -159,7 +155,6 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => { giteaBuildPath: data.buildPath, giteaId: data.giteaId, applicationId, - giteaProjectId: data.repository.id || null, // Handle null case explicitly watchPaths: data.watchPaths, }) .then(async () => { @@ -192,7 +187,6 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => { form.setValue("repository", { owner: "", repo: "", - id: null, }); form.setValue("branch", ""); }} @@ -277,7 +271,6 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => { form.setValue("repository", { owner: repo.owner.username as string, repo: repo.name, - id: repo.id, }); form.setValue("branch", ""); }} diff --git a/apps/dokploy/components/dashboard/compose/general/generic/save-gitea-provider-compose.tsx b/apps/dokploy/components/dashboard/compose/general/generic/save-gitea-provider-compose.tsx index 49c95c27..201f9da2 100644 --- a/apps/dokploy/components/dashboard/compose/general/generic/save-gitea-provider-compose.tsx +++ b/apps/dokploy/components/dashboard/compose/general/generic/save-gitea-provider-compose.tsx @@ -39,7 +39,7 @@ import { } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import { api } from "@/utils/api"; -import type { Branch, Repository } from "@/utils/gitea-utils"; +import type { Repository } from "@/utils/gitea-utils"; import { zodResolver } from "@hookform/resolvers/zod"; import { CheckIcon, ChevronsUpDown, Plus, X } from "lucide-react"; import Link from "next/link"; @@ -54,7 +54,6 @@ const GiteaProviderSchema = z.object({ .object({ repo: z.string().min(1, "Repo is required"), owner: z.string().min(1, "Owner is required"), - id: z.number().nullable(), }) .required(), branch: z.string().min(1, "Branch is required"), @@ -80,7 +79,6 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => { repository: { owner: "", repo: "", - id: null, }, giteaId: "", branch: "", @@ -116,11 +114,10 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => { data: branches, fetchStatus, status, - } = api.gitea.getGiteaBranches.useQuery( + } = api.gitea.getGiteaBranches.useQuery( { owner: repository?.owner, repositoryName: repository?.repo, - id: repository?.id || 0, giteaId: giteaId, }, { @@ -130,55 +127,18 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => { useEffect(() => { if (data) { - console.log("Setting form data from API:", data); - - // Only reset form on initial load, not after user interactions - if (!form.formState.isDirty && !form.formState.dirtyFields.giteaId) { - console.log("Initial form reset from API data"); - form.reset({ - branch: data.giteaBranch || "", - repository: { - repo: data.giteaRepository || "", - owner: data.giteaOwner || "", - id: null, - }, - composePath: data.composePath || "./docker-compose.yml", - giteaId: data.giteaId || "", - watchPaths: data.watchPaths || [], - }); - } else { - console.log( - "Skipping form reset because form has been modified by user", - ); - } + form.reset({ + branch: data.giteaBranch || "", + repository: { + repo: data.giteaRepository || "", + owner: data.giteaOwner || "", + }, + composePath: data.composePath || "./docker-compose.yml", + giteaId: data.giteaId || "", + watchPaths: data.watchPaths || [], + }); } - }, [data]); - - // Add this separate effect to update repository ID if needed - useEffect(() => { - const values = form.getValues(); - // If we have a repository selected but no ID, try to find it - if ( - values.repository.owner && - values.repository.repo && - !values.repository.id && - repositories?.length - ) { - const matchingRepo = repositories.find( - (repo) => - repo.name === values.repository.repo && - repo.owner.username === values.repository.owner, - ); - - if (matchingRepo) { - console.log("Found matching repository ID:", matchingRepo.id); - form.setValue("repository", { - ...values.repository, - id: matchingRepo.id, - }); - } - } - }, [repositories]); + }, [form.reset, data, form]); const onSubmit = async (data: GiteaProvider) => { await mutateAsync({ @@ -219,18 +179,12 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => { Gitea Account