import React from 'react'; import * as Ariakit from '@ariakit/react'; import { ChevronRight } from 'lucide-react'; import { PinIcon, MCPIcon } from '~/components/svg'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; interface MCPSubMenuProps { isMCPPinned: boolean; setIsMCPPinned: (value: boolean) => void; mcpValues?: string[]; mcpServerNames: string[]; handleMCPToggle: (serverName: string) => void; placeholder?: string; } const MCPSubMenu = ({ mcpValues, isMCPPinned, mcpServerNames, setIsMCPPinned, handleMCPToggle, placeholder, ...props }: MCPSubMenuProps) => { const localize = useLocalize(); const menuStore = Ariakit.useMenuStore({ focusLoop: true, showTimeout: 100, placement: 'right', }); return ( ) => { e.stopPropagation(); menuStore.toggle(); }} className="flex w-full cursor-pointer items-center justify-between rounded-lg p-2 hover:bg-surface-hover" /> } >
{placeholder || localize('com_ui_mcp_servers')}
{mcpServerNames.map((serverName) => ( { event.preventDefault(); handleMCPToggle(serverName); }} className={cn( 'flex items-center gap-2 rounded-lg px-2 py-1.5 text-text-primary hover:cursor-pointer', 'scroll-m-1 outline-none transition-colors', 'hover:bg-black/[0.075] dark:hover:bg-white/10', 'data-[active-item]:bg-black/[0.075] dark:data-[active-item]:bg-white/10', 'w-full min-w-0 text-sm', )} > {serverName} ))}
); }; export default React.memo(MCPSubMenu);