| 1 | /** |
| 2 | * ConfigManagerEntry - 配置管理入口组件 |
| 3 | */ |
| 4 | 'use client' |
| 5 | |
| 6 | import type { SidebarCommonProps } from '../../types' |
| 7 | import { SlidersHorizontal } from 'lucide-react' |
| 8 | import { useTransClient } from '@/app/i18n/client' |
| 9 | import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' |
| 10 | import { useConfigManagerDialogStore } from '@/store/configManagerDialog' |
| 11 | import { cn } from '@/utils/className' |
| 12 | |
| 13 | export function ConfigManagerEntry({ collapsed }: SidebarCommonProps) { |
| 14 | const { t } = useTransClient('common') |
| 15 | const openDialog = useConfigManagerDialogStore(state => state.openDialog) |
| 16 | |
| 17 | const content = ( |
| 18 | <button |
| 19 | type="button" |
| 20 | onClick={() => openDialog('sidebar')} |
| 21 | data-testid="sidebar-config-manager" |
| 22 | className={cn( |
| 23 | 'flex flex-1 cursor-pointer items-center rounded-lg text-muted-foreground transition-colors hover:bg-brand-cyan/10 hover:text-brand-cyan', |
| 24 | collapsed ? 'h-9 w-9 justify-center' : 'justify-between px-3 py-2', |
| 25 | )} |
| 26 | > |
| 27 | <div className="flex items-center gap-2"> |
| 28 | <SlidersHorizontal size={18} className="text-brand-cyan" /> |
| 29 | {!collapsed && <span className="text-sm">{t('configManagement')}</span>} |
| 30 | </div> |
| 31 | </button> |
| 32 | ) |
| 33 | |
| 34 | if (!collapsed) |
| 35 | return content |
| 36 | |
| 37 | return ( |
| 38 | <TooltipProvider> |
| 39 | <Tooltip> |
| 40 | <TooltipTrigger asChild>{content}</TooltipTrigger> |
| 41 | <TooltipContent side="right"> |
| 42 | <p>{t('configManagement')}</p> |
| 43 | </TooltipContent> |
| 44 | </Tooltip> |
| 45 | </TooltipProvider> |
| 46 | ) |
| 47 | } |
| 48 |