()
| 4 | export default function LocalEvidenceCommand({ command, label = 'Copy local command' }: { command: string; label?: string }) { |
| 5 | const [result, setResult] = useState<{ command: string; message: string }>(); |
| 6 | const copy = async () => { |
| 7 | try { |
| 8 | if (!navigator.clipboard?.writeText) throw new Error('Clipboard unavailable. Select the command below and copy it manually.'); |
| 9 | await navigator.clipboard.writeText(command); |
| 10 | setResult({ command, message: 'Command copied locally. Nothing was executed or sent.' }); |
| 11 | } catch (error) { |
| 12 | setResult({ command, message: error instanceof Error ? error.message : 'Could not copy. Select the command and copy it manually.' }); |
| 13 | } |
| 14 | }; |
| 15 | return <div className="local-evidence-command"> |
| 16 | <button type="button" disabled={!command} onClick={() => { void copy(); }}>{label}</button> |
| 17 | <code tabIndex={0}>{command}</code> |
no outgoing calls
no test coverage detected