import { GitlabIcon } from "@/components/icons/data-tools-icons"; import { AlertBlock } from "@/components/shared/alert-block"; import { Button } from "@/components/ui/button"; import { CardContent } from "@/components/ui/card"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { api } from "@/utils/api"; import { useUrl } from "@/utils/hooks/use-url"; import { zodResolver } from "@hookform/resolvers/zod"; import { ExternalLink } from "lucide-react"; import Link from "next/link"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; const Schema = z.object({ name: z.string().min(1, { message: "Name is required", }), gitlabUrl: z.string().min(1, { message: "GitLab URL is required", }), applicationId: z.string().min(1, { message: "Application ID is required", }), applicationSecret: z.string().min(1, { message: "Application Secret is required", }), redirectUri: z.string().min(1, { message: "Redirect URI is required", }), groupName: z.string().optional(), }); type Schema = z.infer; export const AddGitlabProvider = () => { const utils = api.useUtils(); const [isOpen, setIsOpen] = useState(false); const url = useUrl(); const { data: auth } = api.user.get.useQuery(); const { mutateAsync, error, isError } = api.gitlab.create.useMutation(); const webhookUrl = `${url}/api/providers/gitlab/callback`; const form = useForm({ defaultValues: { applicationId: "", applicationSecret: "", groupName: "", redirectUri: webhookUrl, name: "", gitlabUrl: "https://gitlab.com", }, resolver: zodResolver(Schema), }); const gitlabUrl = form.watch("gitlabUrl"); useEffect(() => { form.reset({ applicationId: "", applicationSecret: "", groupName: "", redirectUri: webhookUrl, name: "", gitlabUrl: "https://gitlab.com", }); }, [form, isOpen]); const onSubmit = async (data: Schema) => { await mutateAsync({ applicationId: data.applicationId || "", secret: data.applicationSecret || "", groupName: data.groupName || "", authId: auth?.id || "", name: data.name || "", redirectUri: data.redirectUri || "", gitlabUrl: data.gitlabUrl || "https://gitlab.com", }) .then(async () => { await utils.gitProvider.getAll.invalidate(); toast.success("GitLab created successfully"); setIsOpen(false); }) .catch(() => { toast.error("Error configuring GitLab"); }); }; return ( GitLab Provider {isError && {error?.message}}

To integrate your GitLab account, you need to create a new application in your GitLab settings. Follow these steps:

  1. Go to your GitLab profile settings{" "}
  2. Navigate to Applications
  3. Create a new application with the following details:
    • Name: Dokploy
    • Redirect URI:{" "} {webhookUrl}{" "}
    • Scopes: api, read_user, read_repository
  4. After creating, you'll receive an Application ID and Secret, copy them and paste them below.
( Name )} /> ( Gitlab URL )} /> ( Redirect URI )} /> ( Application ID )} /> ( Application Secret )} /> ( Group Name (Optional, Comma-Separated List) )} />
); };