Download frontend/src/components/ExportBackupButton.tsx from Smart-Slate/Systematic-tool-review: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/ExportBackupButton.tsx
- Command line
-
hf download hf://spaces/Smart-Slate/Systematic-tool-review/frontend/src/components/ExportBackupButton.tsx
-
curl -L -o ExportBackupButton.tsx https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/ExportBackupButton.tsx
1.45 kB
| /** | |
| * File : frontend/src/components/ExportBackupButton.tsx (new) | |
| * Purpose : one button that saves a project's backup file. | |
| * Consumers: App.tsx (project detail view). | |
| * Read-only: it never changes any project data. | |
| * Styles : existing classes from index.css only (secondary-btn, locked-note, form-error). | |
| */ | |
| import { useState } from "react"; | |
| import { BackupApiError, downloadBackup } from "../api/backup"; | |
| interface Props { | |
| protocolId: string; | |
| } | |
| export function ExportBackupButton({ protocolId }: Props) { | |
| const [busy, setBusy] = useState(false); | |
| const [error, setError] = useState<string | null>(null); | |
| const [done, setDone] = useState(false); | |
| async function handleClick() { | |
| setBusy(true); | |
| setError(null); | |
| setDone(false); | |
| try { | |
| await downloadBackup(protocolId); | |
| setDone(true); | |
| } catch (err) { | |
| setError(err instanceof BackupApiError ? err.message : "Backup failed. Please try again."); | |
| } finally { | |
| setBusy(false); | |
| } | |
| } | |
| return ( | |
| <div style={{ marginBottom: 14 }}> | |
| <button type="button" className="secondary-btn" onClick={handleClick} disabled={busy}> | |
| {busy ? "Preparing backup…" : "Export project backup"} | |
| </button> | |
| {done && <div className="locked-note" role="status">Backup saved to your downloads.</div>} | |
| {error && <div className="form-error" role="alert" style={{ whiteSpace: "pre-line" }}>{error}</div>} | |
| </div> | |
| ); | |
| } | |