feat: Add comprehensive Git management UI (Phase 1 Critical Features)

Implement advanced Git client features with clean, beautiful UI:

NEW COMPONENTS:
- BranchManager: Create, switch, delete branches with visual interface
- DiffViewer: Side-by-side and unified diff views with syntax highlighting
- CompareView: Compare branches/commits with stats and file diffs
- MergeDialog: Merge branches with preview and conflict detection
- PullRequestDialog: Create PRs on GitHub/GitLab with full workflow
- GitManagementDialog: Main container with tabbed interface

FEATURES:
✨ Branch Management
  - Visual branch list (local and remote)
  - Create branches with validation
  - Switch/delete with confirmation
  - Current branch indicator

✨ Visual Diff Viewer
  - Side-by-side diff view
  - Unified diff view
  - Syntax highlighting (TypeScript, JavaScript, CSS, JSON, Markdown)
  - File tree navigation
  - Copy hunks to clipboard
  - Status badges (added/modified/deleted)

✨ Branch Comparison
  - Compare any two branches
  - Commits ahead/behind statistics
  - Files changed overview
  - Full diff view integration
  - Commit metadata display

✨ Merge Operations
  - Merge preview before execution
  - Fast-forward detection
  - Commit list preview
  - File change preview
  - Automatic rebuild after merge
  - Conflict detection

✨ Pull Request Creation
  - GitHub integration
  - GitLab integration
  - Auto platform detection
  - Target branch selection
  - Markdown description support
  - Credential validation
  - Direct link to created PR

INTEGRATIONS:
- Added prismjs for syntax highlighting
- Extended GitDialog with "Advanced" button
- Integrated with existing Git status monitoring
- Connected to credential management system

DOCUMENTATION:
- Comprehensive feature guide (GIT_FEATURES_GUIDE.md)
- Usage examples and workflows
- Troubleshooting section
- API documentation for AI assistants

DEPENDENCIES:
- prismjs@^1.30.0 (syntax highlighting)
- @types/prismjs@^1.26.5 (TypeScript types)

This completes Phase 1 (Critical Features) from the Git Client Project Plan.
All features tested and working with beautiful, clean UI design.
This commit is contained in:
shakespeare.diy committed 2025-10-14 14:35:02 -05:00
1 parent 7bb7939a4a
commit dad4ce0aa4
12 files changed
+3140 -18

No files matched your search

+174
View File
@@ -0,0 +1,174 @@
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@/components/ui/dialog';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import {
GitBranch,
GitCompare,
GitMerge,
GitPullRequest,
Settings,
History,
} from 'lucide-react';
import { BranchManager } from './BranchManager';
import { CompareView } from './CompareView';
import { MergeDialog } from './MergeDialog';
import { PullRequestDialog } from './PullRequestDialog';
import { DiffViewer } from './DiffViewer';
import { useGitStatus } from '@/hooks/useGitStatus';
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 [isMergeDialogOpen, setIsMergeDialogOpen] = useState(false);
const [isPRDialogOpen, setIsPRDialogOpen] = useState(false);
const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId);
const handleBranchChange = () => {
// Refetch git status when branches change
refetchGitStatus();
};
const handleMergeComplete = () => {
setIsMergeDialogOpen(false);
refetchGitStatus();
};
// Get remote URL for PR creation
const remoteUrl = gitStatus?.remotes.find(r => r.name === 'origin')?.url;
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
{children && <DialogTrigger asChild>{children}</DialogTrigger>}
<DialogContent className="max-w-6xl max-h-[90vh] p-0">
<DialogHeader className="px-6 pt-6 pb-4">
<DialogTitle className="flex items-center gap-2">
<GitBranch className="h-5 w-5" />
Git Management
</DialogTitle>
</DialogHeader>
<Tabs value={activeTab} onValueChange={setActiveTab} className="flex-1">
<div className="border-b px-6">
<TabsList className="h-auto p-0 bg-transparent">
<TabsTrigger
value="branches"
className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none"
>
<GitBranch className="h-4 w-4" />
Branches
</TabsTrigger>
<TabsTrigger
value="changes"
className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none"
>
<Settings className="h-4 w-4" />
Changes
</TabsTrigger>
<TabsTrigger
value="compare"
className="gap-2 data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none"
>
<GitCompare className="h-4 w-4" />
Compare
</TabsTrigger>
</TabsList>
</div>
{/* Branches Tab */}
<TabsContent value="branches" className="mt-0 p-6">
<div className="space-y-6">
<div className="flex items-center gap-2">
{gitStatus?.currentBranch && (
<>
<Button
variant="outline"
size="sm"
className="gap-2"
onClick={() => setIsMergeDialogOpen(true)}
>
<GitMerge className="h-4 w-4" />
Merge
</Button>
{remoteUrl && (
<Button
variant="outline"
size="sm"
className="gap-2"
onClick={() => setIsPRDialogOpen(true)}
>
<GitPullRequest className="h-4 w-4" />
Pull Request
</Button>
)}
</>
)}
</div>
<BranchManager
projectId={projectId}
currentBranch={gitStatus?.currentBranch || null}
onBranchChange={handleBranchChange}
/>
</div>
</TabsContent>
{/* Changes Tab */}
<TabsContent value="changes" className="mt-0 h-[600px]">
<DiffViewer
projectId={projectId}
compareFrom="HEAD"
/>
</TabsContent>
{/* Compare Tab */}
<TabsContent value="compare" className="mt-0 p-6">
<CompareView projectId={projectId} />
</TabsContent>
</Tabs>
</DialogContent>
</Dialog>
{/* Merge Dialog */}
<MergeDialog
projectId={projectId}
currentBranch={gitStatus?.currentBranch || null}
open={isMergeDialogOpen}
onOpenChange={setIsMergeDialogOpen}
onMergeComplete={handleMergeComplete}
/>
{/* Pull Request Dialog */}
{remoteUrl && (
<PullRequestDialog
projectId={projectId}
currentBranch={gitStatus?.currentBranch || null}
remoteUrl={remoteUrl}
open={isPRDialogOpen}
onOpenChange={setIsPRDialogOpen}
/>
)}
</>
);
}