1
This commit is contained in:
parent
0fe5f766c8
commit
967c79a618
@ -279,66 +279,35 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>代码仓库组</FormLabel>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<FormControl>
|
||||
<Button
|
||||
variant="outline"
|
||||
role="combobox"
|
||||
disabled={!form.watch('gitInstanceId')}
|
||||
className={cn(
|
||||
"w-full justify-between",
|
||||
!field.value && "text-muted-foreground"
|
||||
)}
|
||||
>
|
||||
{field.value
|
||||
? repositoryGroups.find(
|
||||
(group) => group.id === field.value
|
||||
)?.name
|
||||
: "请选择代码仓库组"}
|
||||
</Button>
|
||||
</FormControl>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[--radix-popover-trigger-width] p-0" side="bottom" align="start">
|
||||
<Command className="w-full">
|
||||
<CommandInput
|
||||
placeholder="搜索代码仓库组..."
|
||||
className="h-9"
|
||||
<Select
|
||||
disabled={!form.watch('gitInstanceId')}
|
||||
onValueChange={(value) => {
|
||||
form.setValue("repositoryGroupId", Number(value));
|
||||
}}
|
||||
value={field.value?.toString()}
|
||||
>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue
|
||||
placeholder={!form.watch('gitInstanceId')
|
||||
? "请先选择Git实例"
|
||||
: "请选择代码仓库组"
|
||||
}
|
||||
/>
|
||||
<CommandEmpty>未找到代码仓库组</CommandEmpty>
|
||||
<ScrollArea className="h-[200px] overflow-auto">
|
||||
<CommandGroup className="overflow-hidden">
|
||||
{repositoryGroups.map((group) => (
|
||||
<CommandItem
|
||||
key={group.id}
|
||||
value={group.name}
|
||||
onSelect={() => {
|
||||
form.setValue("repositoryGroupId", group.id);
|
||||
// 关闭 Popover
|
||||
const popoverTrigger = document.querySelector('[role="combobox"]');
|
||||
if (popoverTrigger) {
|
||||
(popoverTrigger as HTMLElement).click();
|
||||
}
|
||||
}}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Check
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4",
|
||||
group.id === field.value
|
||||
? "opacity-100"
|
||||
: "opacity-0"
|
||||
)}
|
||||
/>
|
||||
{group.name}
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</ScrollArea>
|
||||
</Command>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<FormMessage/>
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{repositoryGroups.map((group) => (
|
||||
<SelectItem
|
||||
key={group.id}
|
||||
value={group.id.toString()}
|
||||
>
|
||||
{group.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user