import { FolderTree, Server } from 'lucide-react'; import React from 'react'; import { DistroAvatar } from '../DistroAvatar'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { hostDisplayTitle } from '@/domain/hostDisplay.ts'; import { cn } from '@/lib/utils'; import type { Host } from '@/domain/models'; export interface SnippetTargetsSectionProps { t: (key: string, params?: Record) => string; targetHosts: Host[]; onEditTargets: () => void; targetGroups?: string[]; onEditGroups?: () => void; hint?: string; variant?: 'card' | 'embedded'; targetsAllHosts?: boolean; onTargetsAllHostsChange?: (checked: boolean) => void; } const actionButtonClass = (embedded: boolean) => cn( 'shrink-0 rounded-md transition-colors', embedded ? 'h-6 px-2 text-[11px]' : 'h-6 px-2 text-xs', ); const TargetsBody: React.FC<{ t: SnippetTargetsSectionProps['t']; targetHosts: Host[]; onEditTargets: () => void; targetGroups?: string[]; onEditGroups?: () => void; hint?: string; embedded?: boolean; targetsAllHosts?: boolean; onTargetsAllHostsChange?: (checked: boolean) => void; }> = ({ t, targetHosts, onEditTargets, targetGroups = [], onEditGroups, hint, embedded = false, targetsAllHosts = false, onTargetsAllHostsChange, }) => ( <>

{t('snippets.targets.title')}

{!targetsAllHosts ? ( <> {onEditGroups ? ( ) : null} ) : null} {onTargetsAllHostsChange ? ( ) : null}
{hint && !targetsAllHosts ? (

{hint}

) : null} {targetsAllHosts ? (

{t('snippets.targets.allHostsActive')}

) : targetHosts.length === 0 && targetGroups.length === 0 ? ( embedded ? null : ( ) ) : (
{targetGroups.map((groupPath) => (
{groupPath}
))} {targetHosts.map((host) => ( embedded ? (
{hostDisplayTitle(host)}
) : (
{hostDisplayTitle(host)}
) ))}
)} ); export const SnippetTargetsSection: React.FC = ({ t, targetHosts, onEditTargets, targetGroups, onEditGroups, hint, variant = 'card', targetsAllHosts, onTargetsAllHostsChange, }) => { const body = ( ); if (variant === 'embedded') { return
{body}
; } return ( {body} ); };