import { Copy, FileSymlink, Folder, FolderOpen, Monitor, Pencil, Server } from 'lucide-react'; import React from 'react'; import { useI18n } from '../../application/i18n/I18nProvider'; import { sanitizeHost } from '../../domain/host'; import type { Host } from '../../types'; import { ContextMenuContent, ContextMenuItem } from '../ui/context-menu'; export interface HostTreeHostContextMenuHandlers { onConnect: (host: Host) => void; onRenameHost?: (host: Host) => void; onDuplicateHost: (host: Host) => void; onCopyCredentials: (host: Host) => void; onDeleteHost: (host: Host) => void; } export const HostTreeHostContextMenuContent: React.FC< HostTreeHostContextMenuHandlers & { host: Host } > = ({ host, onConnect, onRenameHost, onDuplicateHost, onCopyCredentials, onDeleteHost, }) => { const { t } = useI18n(); const safeHost = sanitizeHost(host); return ( onConnect(safeHost)}> {t('vault.hosts.connect')} {onRenameHost && ( onRenameHost(host)}> {t('common.rename')} )} onDuplicateHost(host)}> {t('action.duplicate')} onCopyCredentials(host)}> {t('vault.hosts.copyCredentials')} onDeleteHost(host)} className="text-destructive focus:text-destructive" > {t('action.delete')} ); }; export interface HostTreeGroupContextMenuHandlers { onNewGroup: (parentPath?: string) => void; onRenameGroup: (groupPath: string) => void; onDeleteGroup: (groupPath: string) => void; onUnmanageGroup?: (groupPath: string) => void; } export const HostTreeGroupContextMenuContent: React.FC< HostTreeGroupContextMenuHandlers & { groupPath: string; isManaged: boolean } > = ({ groupPath, isManaged, onNewGroup, onRenameGroup, onDeleteGroup, onUnmanageGroup, }) => { const { t } = useI18n(); return ( onNewGroup(groupPath)}> {t('vault.hosts.newGroup')} onRenameGroup(groupPath)}> {t('vault.groups.rename')} onDeleteGroup(groupPath)} className="text-destructive focus:text-destructive" > {t('vault.groups.delete')} {isManaged && onUnmanageGroup && ( onUnmanageGroup(groupPath)}> {t('vault.managedSource.unmanage')} )} ); };