refactor: Move merge and PR UI to Repository dialog

Relocate merge and pull request buttons from Advanced Git Management dialog to the main Repository dialog for better accessibility and workflow.

CHANGES:
- Add "Branch Operations" card to GitDialog
- Display Merge Branch and Pull Request buttons directly in Repository dialog
- Remove duplicate buttons from GitManagementDialog branches tab
- Simplify GitManagementDialog component (removed merge/PR dialog state)

BENEFITS:
- More intuitive workflow: common operations are in the main dialog
- Cleaner separation: Repository dialog = operations, Advanced = exploration
- Faster access to merge/PR features without opening advanced dialog

The Merge and PR dialogs now open from the Repository dialog's "Branch Operations" section, making them easier to discover and use.
This commit is contained in:
shakespeare.diy committed 2025-10-14 14:39:50 -05:00
1 parent dad4ce0aa4
commit a390593841
2 files changed
+24 -66

No files matched your search

+24 -1
View File
@@ -49,6 +49,8 @@ import { cn } from '@/lib/utils';
import { findCredentialsForRepo } from '@/lib/gitCredentials'; import { findCredentialsForRepo } from '@/lib/gitCredentials';
import { nip19 } from 'nostr-tools'; import { nip19 } from 'nostr-tools';
import { GitManagementDialog } from '@/components/git/GitManagementDialog'; import { GitManagementDialog } from '@/components/git/GitManagementDialog';
import { MergeDialog } from '@/components/git/MergeDialog';
import { PullRequestDialog } from '@/components/git/PullRequestDialog';
const GRASP_SERVERS = ["git.shakespeare.diy", "relay.ngit.dev"]; const GRASP_SERVERS = ["git.shakespeare.diy", "relay.ngit.dev"];
@@ -768,8 +770,29 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
</Button> </Button>
</div> </div>
)} )}
</CardContent>
</Card>
)}
{/* Branch Operations */}
{gitStatus?.isGitRepo && gitStatus.currentBranch && (
<Card>
<CardHeader className="pb-3">
<CardTitle className="text-sm">Branch Operations</CardTitle>
</CardHeader>
<CardContent className="flex gap-2">
<MergeDialog
projectId={projectId}
currentBranch={gitStatus.currentBranch}
onMergeComplete={() => refetchGitStatus()}
/>
{gitStatus.remotes.length > 0 && originUrl && (
<PullRequestDialog
projectId={projectId}
currentBranch={gitStatus.currentBranch}
remoteUrl={originUrl}
/>
)}
</CardContent> </CardContent>
</Card> </Card>
)} )}
@@ -1,5 +1,4 @@
import { useState } from 'react'; import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { import {
Dialog, Dialog,
DialogContent, DialogContent,
@@ -11,15 +10,10 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { import {
GitBranch, GitBranch,
GitCompare, GitCompare,
GitMerge,
GitPullRequest,
Settings, Settings,
History,
} from 'lucide-react'; } from 'lucide-react';
import { BranchManager } from './BranchManager'; import { BranchManager } from './BranchManager';
import { CompareView } from './CompareView'; import { CompareView } from './CompareView';
import { MergeDialog } from './MergeDialog';
import { PullRequestDialog } from './PullRequestDialog';
import { DiffViewer } from './DiffViewer'; import { DiffViewer } from './DiffViewer';
import { useGitStatus } from '@/hooks/useGitStatus'; import { useGitStatus } from '@/hooks/useGitStatus';
@@ -39,8 +33,6 @@ export function GitManagementDialog({
defaultTab = 'branches', defaultTab = 'branches',
}: GitManagementDialogProps) { }: GitManagementDialogProps) {
const [activeTab, setActiveTab] = useState(defaultTab); const [activeTab, setActiveTab] = useState(defaultTab);
const [isMergeDialogOpen, setIsMergeDialogOpen] = useState(false);
const [isPRDialogOpen, setIsPRDialogOpen] = useState(false);
const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId); const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId);
@@ -49,14 +41,6 @@ export function GitManagementDialog({
refetchGitStatus(); refetchGitStatus();
}; };
const handleMergeComplete = () => {
setIsMergeDialogOpen(false);
refetchGitStatus();
};
// Get remote URL for PR creation
const remoteUrl = gitStatus?.remotes.find(r => r.name === 'origin')?.url;
return ( return (
<> <>
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
@@ -98,40 +82,11 @@ export function GitManagementDialog({
{/* Branches Tab */} {/* Branches Tab */}
<TabsContent value="branches" className="mt-0 p-6"> <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 <BranchManager
projectId={projectId} projectId={projectId}
currentBranch={gitStatus?.currentBranch || null} currentBranch={gitStatus?.currentBranch || null}
onBranchChange={handleBranchChange} onBranchChange={handleBranchChange}
/> />
</div>
</TabsContent> </TabsContent>
{/* Changes Tab */} {/* Changes Tab */}
@@ -149,26 +104,6 @@ export function GitManagementDialog({
</Tabs> </Tabs>
</DialogContent> </DialogContent>
</Dialog> </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}
/>
)}
</> </>
); );
} }