diff --git a/frontend/src/components/existing/ExistingTestsView.tsx b/frontend/src/components/existing/ExistingTestsView.tsx index 3ea9735..48bcfec 100644 --- a/frontend/src/components/existing/ExistingTestsView.tsx +++ b/frontend/src/components/existing/ExistingTestsView.tsx @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' import { useTaskLogs } from '../../hooks/useTaskLogs' -import { Play, RefreshCw, Terminal, Zap, Layers, Cloud, FolderOpen, FileCode, ArrowRight, Monitor, Search } from 'lucide-react' +import { Play, RefreshCw, Terminal, Zap, Layers, Cloud, FolderOpen, FileCode, ArrowRight, Monitor, Search, GitBranch, ChevronDown } from 'lucide-react' import { DCLOUD_NAV_ITEMS, DCLOUD_MODULE_INFO } from '../layout/navConfig' interface TestFunc { name: string; readable: string; doc: string } @@ -32,9 +32,27 @@ export default function ExistingTestsView() { const [roboForm, setRoboForm] = useState({ product: 'robogo', env: 'PROD', scope: 'all', run_count: 1, account: '', password: '' }) const [feUrl, setFeUrl] = useState('') const [feBranch, setFeBranch] = useState('main') - const [feApiKey, setFeApiKey] = useState('') + const [feBranchSuggestions, setFeBranchSuggestions] = useState<{name:string;commit:string}[]>([]) + const [feShowBranchPicker, setFeShowBranchPicker] = useState(false) + const [feScanningBranches, setFeScanningBranches] = useState(false) const [feTaskId, setFeTaskId] = useState(null) const { logs: feLogs, running: feRunning, connect: feConnect } = useTaskLogs() + + const detectFeBranches = async (repoUrl: string) => { + if (!repoUrl || !repoUrl.includes('://')) return + setFeScanningBranches(true) + setFeBranchSuggestions([]) + try { + const res = await fetch('/api/repos/branches?url=' + encodeURIComponent(repoUrl)) + const data = await res.json() + if (data.branches && data.branches.length > 0) { + setFeBranchSuggestions(data.branches) + const selected = data.latest && data.latest !== data.default ? data.latest : data.default + setFeBranch(selected || 'main') + } + } catch {} + setFeScanningBranches(false) + } const [taskId, setTaskId] = useState(null) const { logs, running, connect } = useTaskLogs() @@ -297,29 +315,48 @@ export default function ExistingTestsView() { setFeUrl(e.target.value)} + onChange={e => { setFeUrl(e.target.value); setFeShowBranchPicker(false) }} + onBlur={() => { if (feUrl.includes('://')) detectFeBranches(feUrl) }} className="flex-1 px-3 py-2 rounded-lg text-sm bg-[rgb(var(--color-page))] border border-[rgb(var(--color-border))] text-[rgb(var(--color-text-primary))] outline-none" /> - setFeBranch(e.target.value)} - className="w-28 px-3 py-2 rounded-lg text-sm bg-[rgb(var(--color-page))] border border-[rgb(var(--color-border))] text-[rgb(var(--color-text-primary))] outline-none" - /> - setFeApiKey(e.target.value)} - className="w-48 px-3 py-2 rounded-lg text-sm bg-[rgb(var(--color-page))] border border-[rgb(var(--color-border))] text-[rgb(var(--color-text-primary))] outline-none" - /> +
+
{ if (feUrl.includes('://')) detectFeBranches(feUrl); setFeShowBranchPicker(!feShowBranchPicker) }}> + + {feScanningBranches ? ( + 扫描中... + ) : ( + {feBranch} + )} + +
+ {feShowBranchPicker && ( +
+ {feScanningBranches ? ( +
+ + 正在扫描远程分支... +
+ ) : ( + feBranchSuggestions.map(b => ( + + )) + )} +
+ )} +