import React, { useState } from 'react'; import { Package, Paperclip } from '../../../icons'; import EmptyState from '../../EmptyState/EmptyState'; import ArtifactDrawer from '../../ArtifactDrawer'; import { Section } from '../ui'; import type { ArtifactLog } from '../types'; interface Props { artifacts: ArtifactLog[]; open: boolean; onToggle: () => void; } interface DrawerSelection { decky: string; storedAs: string; fields: Record; } /** CAPTURED ARTIFACTS collapsible — file-drop log with inline * preview button per row. The drawer's open/close state lives * here; the artifact list itself is read from the data hook. */ export const ArtifactsPanel: React.FC = ({ artifacts, open, onToggle }) => { const [selected, setSelected] = useState(null); return ( <>
CAPTURED ARTIFACTS ({artifacts.length})} open={open} onToggle={onToggle} > {artifacts.length > 0 ? (
{artifacts.map((row) => { let fields: Record = {}; try { fields = JSON.parse(row.fields || '{}'); } catch { // malformed SD params — preview unavailable } const storedAs = fields.stored_as ? String(fields.stored_as) : null; const sha = fields.sha256 ? String(fields.sha256) : ''; return ( ); })}
TIMESTAMP DECKY FILENAME SIZE SHA-256
{new Date(row.timestamp).toLocaleString()} {row.decky} {(fields.orig_path as string | undefined) ?? storedAs ?? '—'} {fields.size ? `${fields.size} B` : '—'} {sha ? `${sha.slice(0, 12)}…` : '—'} {storedAs && ( )}
) : ( )}
{selected && ( setSelected(null)} /> )} ); };