import { useState, useEffect } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { ScrollArea } from '@/components/ui/scroll-area'; import { GitBranch, GitCompare, Settings, GitPullRequest, } from 'lucide-react'; import { BranchManager } from './BranchManager'; import { CompareView } from './CompareView'; import { DiffViewer } from './DiffViewer'; import { PullRequestForm } from './PullRequestForm'; import { useGitStatus } from '@/hooks/useGitStatus'; import { useGit } from '@/hooks/useGit'; import { useFSPaths } from '@/hooks/useFSPaths'; interface GitManagementDialogProps{ projectId: string; children?: React.ReactNode; open?: boolean; onOpenChange?: (open: boolean) => void; defaultTab?: string; } export function GitManagementDialog({ projectId, children, open, onOpenChange, defaultTab = 'branches', }: GitManagementDialogProps) { const [activeTab, setActiveTab] = useState(defaultTab); const [remoteUrl, setRemoteUrl] = useState(null); const { git } = useGit(); const { projectsPath } = useFSPaths(); const projectPath = `${projectsPath}/${projectId}`; const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId); useEffect(() => { const loadRemoteUrl = async () => { try { const url = await git.getRemoteURL(projectPath, 'origin'); setRemoteUrl(url); } catch { setRemoteUrl(null); } }; if (open) { loadRemoteUrl(); } }, [open, git, projectPath]); const handleBranchChange = () => { // Refetch git status when branches change refetchGitStatus(); }; return ( <> {children && {children}} {/* Fixed Header */} Git Management {/* Tabs Container - takes remaining space */}
{/* Fixed Tab List */}
Branches Changes Compare {remoteUrl && ( Pull Request )}
{/* Scrollable Tab Content */}
{remoteUrl && (
)}
); }