mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 23:02:12 +00:00
fix: Fix exposing explicit search button in gh branch dropdown (#435)
* fix: Fix exposing explicit search button in gh branch dropdown * cr
This commit is contained in:
parent
b128e4ae45
commit
0953468b5c
1 changed files with 25 additions and 19 deletions
|
|
@ -20,6 +20,7 @@ import { GitBranch, Shield } from "lucide-react";
|
||||||
import { TargetRepository } from "@open-swe/shared/open-swe/types";
|
import { TargetRepository } from "@open-swe/shared/open-swe/types";
|
||||||
import { Branch } from "@/utils/github";
|
import { Branch } from "@/utils/github";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { defaultFilter } from "cmdk";
|
||||||
|
|
||||||
interface BranchSelectorProps {
|
interface BranchSelectorProps {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
|
@ -123,6 +124,14 @@ export function BranchSelector({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Whether or not to allow explicitly searching for a branch, even when there are results.
|
||||||
|
const allowExplicitSearchReqWithResults = !!(
|
||||||
|
searchQuery.trim() &&
|
||||||
|
branches.some(
|
||||||
|
(branch) => defaultFilter(branch.name, searchQuery.trim()) > 0,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (!selectedRepository) {
|
if (!selectedRepository) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -300,25 +309,22 @@ export function BranchSelector({
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
{/* Show this search button if there is a search query, and there are some results. this is for
|
{/* Show this search button if there is a search query, and there are some results. this is for
|
||||||
cases when some results do show, just not the exact result the user is looking for */}
|
cases when some results do show, just not the exact result the user is looking for */}
|
||||||
{searchQuery.trim() &&
|
{allowExplicitSearchReqWithResults && (
|
||||||
branches.some((branch) =>
|
<div className="px-2 py-1">
|
||||||
branch.name.toLowerCase().includes(searchQuery.toLowerCase()),
|
<Button
|
||||||
) && (
|
variant="outline"
|
||||||
<div className="px-2 py-1">
|
size="sm"
|
||||||
<Button
|
onClick={handleSearchForBranch}
|
||||||
variant="outline"
|
disabled={isSearching}
|
||||||
size="sm"
|
className="w-full text-xs"
|
||||||
onClick={handleSearchForBranch}
|
>
|
||||||
disabled={isSearching}
|
{isSearching
|
||||||
className="w-full text-xs"
|
? "Searching..."
|
||||||
>
|
: `Search for "${searchQuery.trim()}"`}
|
||||||
{isSearching
|
</Button>
|
||||||
? "Searching..."
|
</div>
|
||||||
: `Search for "${searchQuery.trim()}"`}
|
)}
|
||||||
</Button>
|
{branchesHasMore && !allowExplicitSearchReqWithResults && (
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{branchesHasMore && (
|
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
<CommandItem
|
<CommandItem
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue