Use generic branchselector in PR dialog (#680)
This commit is contained in:
@@ -10,17 +10,12 @@ import { Label } from '@radix-ui/react-label';
|
||||
import { Textarea } from '@/components/ui/textarea.tsx';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import BranchSelector from '@/components/tasks/BranchSelector';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { attemptsApi } from '@/lib/api.ts';
|
||||
|
||||
import {
|
||||
GitBranch,
|
||||
GitHubServiceError,
|
||||
TaskAttempt,
|
||||
TaskWithAttemptStatus,
|
||||
@@ -37,9 +32,7 @@ const CreatePrDialog = NiceModal.create(() => {
|
||||
const [prBaseBranch, setPrBaseBranch] = useState('');
|
||||
const [creatingPR, setCreatingPR] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [branches, setBranches] = useState<
|
||||
Array<{ name: string; is_current: boolean; is_remote: boolean }>
|
||||
>([]);
|
||||
const [branches, setBranches] = useState<GitBranch[]>([]);
|
||||
const [branchesLoading, setBranchesLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -161,29 +154,17 @@ const CreatePrDialog = NiceModal.create(() => {
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="pr-base">Base Branch</Label>
|
||||
<Select
|
||||
value={prBaseBranch}
|
||||
onValueChange={setPrBaseBranch}
|
||||
disabled={branchesLoading}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue
|
||||
placeholder={
|
||||
branchesLoading
|
||||
? 'Loading branches...'
|
||||
: 'Select base branch'
|
||||
}
|
||||
/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{branches.map((branch) => (
|
||||
<SelectItem key={branch.name} value={branch.name}>
|
||||
{branch.name}
|
||||
{branch.is_current && ' (current)'}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<BranchSelector
|
||||
branches={branches}
|
||||
selectedBranch={prBaseBranch}
|
||||
onBranchSelect={setPrBaseBranch}
|
||||
placeholder={
|
||||
branchesLoading ? 'Loading branches...' : 'Select base branch'
|
||||
}
|
||||
className={
|
||||
branchesLoading ? 'opacity-50 cursor-not-allowed' : ''
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{error && (
|
||||
<div className="text-sm text-destructive bg-red-50 p-2 rounded">
|
||||
|
||||
Reference in New Issue
Block a user