From a7bbe1e00021b706cadaac49de1f037e0f9e487c Mon Sep 17 00:00:00 2001 From: ecwu Date: Mon, 6 Jan 2025 00:29:21 +0800 Subject: [PATCH] refactor: enhance ToolsDropdownList with Popover and Command components for improved usability --- src/components/ListAPI.tsx | 160 ++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 82 deletions(-) diff --git a/src/components/ListAPI.tsx b/src/components/ListAPI.tsx index 90efd11..f9259a8 100644 --- a/src/components/ListAPI.tsx +++ b/src/components/ListAPI.tsx @@ -16,6 +16,22 @@ import { NavigationMenu, NavigationMenuList, } from "@/components/ui/navigation-menu"; +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, +} from "@/components/ui/command"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { BrushIcon } from "lucide-react"; + +import { useToast } from "@/hooks/use-toast"; interface APITemplateDropdownProps { label: string; @@ -133,85 +149,71 @@ function APIsDropdownList({ function ToolsDropdownList() { const ctx = useContext(AppContext); if (!ctx) return
error
; + const { toast } = useToast(); + const [open, setOpen] = React.useState(false); const { chatStore, setChatStore } = ctx; return ( - - - {Tr(`Tools`)} - - - - - + + ))} + + + + + + ); } @@ -219,7 +221,8 @@ const APIListMenu: React.FC = () => { const ctx = useContext(AppContext); if (!ctx) return
error
; return ( -
+
+ {ctx.templateTools.length > 0 && } {ctx.templateAPIs.length > 0 && ( @@ -260,13 +263,6 @@ const APIListMenu: React.FC = () => { )} - {ctx.templateTools.length > 0 && ( - - - - - - )}
); };