diff --git a/__test__/traefik/traefik.test.ts b/__test__/traefik/traefik.test.ts index f10eefb33..ce35611f3 100644 --- a/__test__/traefik/traefik.test.ts +++ b/__test__/traefik/traefik.test.ts @@ -19,7 +19,7 @@ const baseApp: ApplicationNested = { createdAt: "", customGitBranch: "", customGitBuildPath: "", - customGitSSHKey: "", + customGitSSHKeyId: null, customGitUrl: "", description: "", dockerfile: null, diff --git a/components/dashboard/application/general/generic/save-git-provider.tsx b/components/dashboard/application/general/generic/save-git-provider.tsx index 28828e7cd..58fd1973a 100644 --- a/components/dashboard/application/general/generic/save-git-provider.tsx +++ b/components/dashboard/application/general/generic/save-git-provider.tsx @@ -1,13 +1,4 @@ import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; import { Form, FormControl, @@ -17,11 +8,20 @@ import { FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; -import { Textarea } from "@/components/ui/textarea"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; -import copy from "copy-to-clipboard"; -import { CopyIcon, LockIcon } from "lucide-react"; +import { KeyRoundIcon, LockIcon } from "lucide-react"; +import { useRouter } from "next/router"; + import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; @@ -33,6 +33,7 @@ const GitProviderSchema = z.object({ }), branch: z.string().min(1, "Branch required"), buildPath: z.string().min(1, "Build Path required"), + sshKey: z.string().optional(), }); type GitProvider = z.infer; @@ -43,19 +44,18 @@ interface Props { export const SaveGitProvider = ({ applicationId }: Props) => { const { data, refetch } = api.application.one.useQuery({ applicationId }); + const { data: sshKeys } = api.sshKey.all.useQuery(); + const router = useRouter(); const { mutateAsync, isLoading } = api.application.saveGitProdiver.useMutation(); - const { mutateAsync: generateSSHKey, isLoading: isGeneratingSSHKey } = - api.application.generateSSHKey.useMutation(); - const { mutateAsync: removeSSHKey, isLoading: isRemovingSSHKey } = - api.application.removeSSHKey.useMutation(); const form = useForm({ defaultValues: { branch: "", buildPath: "/", repositoryURL: "", + sshKey: undefined, }, resolver: zodResolver(GitProviderSchema), }); @@ -63,6 +63,7 @@ export const SaveGitProvider = ({ applicationId }: Props) => { useEffect(() => { if (data) { form.reset({ + sshKey: data.customGitSSHKeyId || undefined, branch: data.customGitBranch || "", buildPath: data.customGitBuildPath || "/", repositoryURL: data.customGitUrl || "", @@ -75,6 +76,7 @@ export const SaveGitProvider = ({ applicationId }: Props) => { customGitBranch: values.branch, customGitBuildPath: values.buildPath, customGitUrl: values.repositoryURL, + customGitSSHKeyId: values.sshKey === "none" ? null : values.sshKey, applicationId, }) .then(async () => { @@ -92,160 +94,103 @@ export const SaveGitProvider = ({ applicationId }: Props) => { onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-4" > -
-
- ( - - - Repository URL -
- - - ? - - - - Private Repository - - If your repository is private is necessary to - generate SSH Keys to add to your git provider. - - -
-
-