import { Crosshair } from 'lucide-react' import { useTranslation } from 'react-i18next' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' import type { LogEntry } from '@/api/logs' import { HighlightedLogLine } from './HighlightedLogLine' export type LogContext = { row: LogEntry; before: LogEntry[]; after: LogEntry[] } function ContextRow({ row, current, terms }: { row: LogEntry; current?: boolean; terms: string[] }) { const { t } = useTranslation('logs') const match = row.message.match(/^\d{4}-\d\d-\d\dT\S+\s+(stdout|stderr)\s+[FP]\s+([\s\S]*)$/) return
{current && {t('context.current')}} {match && {match[1]}} {row.level && {row.level}}
} export function LogContextDialog({ context, terms, onClose }: { context: LogContext | null; terms: string[]; onClose: () => void }) { const { t } = useTranslation('logs') return { if (!open) onClose() }}> {t('context.title')} {context?.row.labels.filename ? t('context.sameFile') : t('context.sameStream')} ยท {t('context.meta')} {context &&
{['namespace', 'app', 'pod'].filter(key => context.row.labels[key]).map(key => {key}={context.row.labels[key]})} {context.row.labels.filename && {t('context.file', { name: context.row.labels.filename.split('/').slice(-2).join('/') })}}
}
{context &&

{t('context.beforeTitle', { count: context.before.length })}

{context.before.length ?
{context.before.map((row, index) => )}
:

{t('context.beforeEmpty')}

}

{t('context.afterTitle', { count: context.after.length })}

{context.after.length ?
{context.after.map((row, index) => )}
:

{t('context.afterEmpty')}

}
}
}