import * as Dialog from '@radix-ui/react-dialog'; import { useState } from 'react'; import { motion } from 'framer-motion'; import { toast } from 'react-toastify'; import { classNames } from '~/utils/classNames'; import { useGitLabConnection } from '~/lib/hooks'; interface GitLabAuthDialogProps { isOpen: boolean; onClose: () => void; } export function GitLabAuthDialog({ isOpen, onClose }: GitLabAuthDialogProps) { const { isConnecting, error, connect } = useGitLabConnection(); const [token, setToken] = useState(''); const [gitlabUrl, setGitlabUrl] = useState('https://gitlab.com'); const handleConnect = async (event: React.FormEvent) => { event.preventDefault(); if (!token.trim()) { toast.error('Please enter your GitLab access token'); return; } try { await connect(token, gitlabUrl); toast.success('Successfully connected to GitLab!'); setToken(''); onClose(); } catch (error) { // Error handling is done in the hook console.error('GitLab connect failed:', error); } }; return ( !open && onClose()}>
Connect to GitLab

GitLab Connection

Connect your GitLab account to deploy your projects

setGitlabUrl(e.target.value)} disabled={isConnecting} placeholder="https://gitlab.com" className={classNames( 'w-full px-3 py-2 rounded-lg text-sm', 'bg-bolt-elements-background-depth-2 dark:bg-bolt-elements-background-depth-3', 'border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor-dark', 'text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary-dark', 'placeholder-bolt-elements-textTertiary dark:placeholder-bolt-elements-textTertiary-dark', 'focus:outline-none focus:ring-2 focus:ring-orange-500', 'disabled:opacity-50 disabled:cursor-not-allowed', )} />
setToken(e.target.value)} disabled={isConnecting} placeholder="Enter your GitLab access token" className={classNames( 'w-full px-3 py-2 rounded-lg text-sm', 'bg-bolt-elements-background-depth-2 dark:bg-bolt-elements-background-depth-3', 'border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor-dark', 'text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary-dark', 'placeholder-bolt-elements-textTertiary dark:placeholder-bolt-elements-textTertiary-dark', 'focus:outline-none focus:ring-2 focus:ring-orange-500', 'disabled:opacity-50 disabled:cursor-not-allowed', )} required />
Get your token
Required scopes: api, read_repository
{error && (

{error}

)}
Cancel {isConnecting ? ( <>
Connecting... ) : ( <>
Connect to GitLab )}
); }