Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

refactor(backups): move snapshot/schedule/history tables onto DataTable

Juan Denis3d026208f4e5
diff --git a/frontend/src/components/backups/BackupHistoryList.jsx b/frontend/src/components/backups/BackupHistoryList.jsx
index 8f17b1c2..50f6337f 100644
--- a/frontend/src/components/backups/BackupHistoryList.jsx
+++ b/frontend/src/components/backups/BackupHistoryList.jsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { Pill } from '@/components/ds';
+import { Pill, DataTable, DataTableFooter } from '@/components/ds';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState';
import {
@@ -128,6 +128,80 @@ export default function BackupHistoryList({
}) {
const hasDrills = drills && drills.length > 0;
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace (.sk-cell-name, .backup-history-list__*,
+ // .sk-cell-mono). The row click opens the detail drawer; the actions cell
+ // stops propagation so its buttons never trigger it.
+ const columns = [
+ {
+ key: 'backup',
+ header: 'Backup',
+ sortable: true,
+ hideable: false,
+ sortValue: (run) => run.metadata?.backup_name || `Backup #${run.id}`,
+ render: (run) => (
+ <div className="sk-cell-name">
+ <span className="backup-history-list__ico"><Archive size={14} /></span>
+ <span>{run.metadata?.backup_name || `Backup #${run.id}`}</span>
+ <Pill kind={run.kind === 'full' ? 'violet' : 'gray'} dot={false}>{run.kind}</Pill>
+ </div>
+ ),
+ },
+ {
+ key: 'date',
+ header: 'Date',
+ sortable: true,
+ sortValue: (run) => (run.started_at ? new Date(run.started_at).getTime() : null),
+ cellClassName: 'backup-history-list__when',
+ render: (run) => formatWhen(run.started_at),
+ },
+ {
+ key: 'size',
+ header: 'Size',
+ sortable: true,
+ sortValue: (run) => run.size_total || 0,
+ cellClassName: 'sk-cell-mono',
+ render: (run) => humanSize(run.size_total),
+ },
+ {
+ key: 'cost',
+ header: 'Cost',
+ sortable: true,
+ sortValue: (run) => Number(run.cost_total || 0),
+ cellClassName: 'sk-cell-mono',
+ render: (run) => formatMoney(run.cost_total),
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ sortValue: (run) => run.status || '',
+ render: (run) => <Pill kind={statusKind(run.status)}>{run.status}</Pill>,
+ },
+ {
+ key: 'storage',
+ header: 'Storage',
+ sortable: true,
+ sortValue: (run) => storageLabel(run),
+ render: (run) => storageIcon(run),
+ },
+ {
+ key: 'actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ render: (run) => (
+ <div className="backup-history-list__actions" onClick={(e) => e.stopPropagation()}>
+ <Button size="icon" variant="outline" title="Restore" disabled={run.status !== 'success'} onClick={() => onRestore(run)}><RotateCcw size={14} /></Button>
+ {run.remote_key && (
+ <Button size="icon" variant="outline" title="Verify remote copy" onClick={() => onVerify(run)}><ShieldCheck size={14} /></Button>
+ )}
+ <Button size="icon" variant="destructive" title="Delete" onClick={() => onDelete(run)}><Trash2 size={14} /></Button>
+ </div>
+ ),
+ },
+ ];
+
if (loading && (!runs || runs.length === 0)) {
return <EmptyState icon={Archive} title="Loading backups…" loading />;
}
@@ -150,50 +224,22 @@ export default function BackupHistoryList({
return (
<>
<RestoreDrills drills={drills} />
- <table className="sk-dtable backup-history-list">
- <thead>
- <tr>
- <th>Backup</th>
- <th>Date</th>
- <th>Size</th>
- <th>Cost</th>
- <th>Status</th>
- <th>Storage</th>
- <th aria-label="Actions" />
- </tr>
- </thead>
- <tbody>
- {runs.map((run) => (
- <tr
- key={run.id}
- className={`backup-history-list__row ${onRowClick ? 'is-clickable' : ''}`}
- onClick={onRowClick ? () => onRowClick(run) : undefined}
- >
- <td>
- <div className="sk-cell-name">
- <span className="backup-history-list__ico"><Archive size={14} /></span>
- <span>{run.metadata?.backup_name || `Backup #${run.id}`}</span>
- <Pill kind={run.kind === 'full' ? 'violet' : 'gray'} dot={false}>{run.kind}</Pill>
- </div>
- </td>
- <td className="backup-history-list__when">{formatWhen(run.started_at)}</td>
- <td className="sk-cell-mono">{humanSize(run.size_total)}</td>
- <td className="sk-cell-mono">{formatMoney(run.cost_total)}</td>
- <td><Pill kind={statusKind(run.status)}>{run.status}</Pill></td>
- <td>{storageIcon(run)}</td>
- <td>
- <div className="backup-history-list__actions" onClick={(e) => e.stopPropagation()}>
- <Button size="icon" variant="outline" title="Restore" disabled={run.status !== 'success'} onClick={() => onRestore(run)}><RotateCcw size={14} /></Button>
- {run.remote_key && (
- <Button size="icon" variant="outline" title="Verify remote copy" onClick={() => onVerify(run)}><ShieldCheck size={14} /></Button>
- )}
- <Button size="icon" variant="destructive" title="Delete" onClick={() => onDelete(run)}><Trash2 size={14} /></Button>
- </div>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <DataTable
+ columns={columns}
+ data={runs}
+ keyField="id"
+ storageKey="serverkit-table-backup-history"
+ onRowClick={onRowClick}
+ rowClassName="backup-history-list__row"
+ tableClassName="backup-history-list"
+ footer={(
+ <DataTableFooter
+ shown={runs.length}
+ total={runs.length}
+ noun="backup"
+ />
+ )}
+ />
</>
);
}
diff --git a/frontend/src/components/backups/BackupsOverview.jsx b/frontend/src/components/backups/BackupsOverview.jsx
index ab201541..f672e8cf 100644
--- a/frontend/src/components/backups/BackupsOverview.jsx
+++ b/frontend/src/components/backups/BackupsOverview.jsx
@@ -5,7 +5,7 @@ import {
} from 'lucide-react';
import api from '../../services/api';
import { formatBytes } from '@/utils/formatBytes';
-import { KpiBand, MetricCard, Pill } from '@/components/ds';
+import { KpiBand, MetricCard, Pill, DataTable, DataTableFooter } from '@/components/ds';
import EmptyState from '../EmptyState';
// Daily activity cells: one column per week, one row per weekday. Half a year
@@ -94,6 +94,51 @@ function nextFire(schedule) {
return null;
}
+// DataTable columns for the "Latest snapshots" digest. The hand-rolled table
+// had no thead; the shared primitive always renders one, so the cells keep
+// their exact markup (.sk-cell-name, .bk-ico, .sk-cell-sub) and the columns
+// gain the standard sk-dtable headers.
+const LATEST_COLUMNS = [
+ {
+ key: 'name',
+ header: 'Snapshot',
+ sortable: true,
+ hideable: false,
+ sortValue: (e) => e.name || '',
+ render: (e) => {
+ const Icon = KIND_ICON[e.kind] || Archive;
+ return (
+ <div className="sk-cell-name">
+ <span className="bk-ico"><Icon size={14} /></span>
+ <span>
+ <div>{e.name}</div>
+ <div className="sk-cell-sub">{e.sub} · {relativeTime(e.at)}</div>
+ </span>
+ </div>
+ );
+ },
+ },
+ {
+ key: 'size',
+ header: 'Size',
+ sortable: true,
+ sortValue: (e) => e.size || 0,
+ cellClassName: 'sk-cell-mono',
+ render: (e) => formatBytes(e.size, { defaultValue: '—' }),
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ sortValue: (e) => e.status || '',
+ render: (e) => (
+ <Pill kind={e.status === 'complete' ? 'green' : e.status === 'running' ? 'cyan' : 'red'}>
+ {e.status}
+ </Pill>
+ ),
+ },
+];
+
// The Backups overview, ported from the design mock: what is protected, how
// reliably it has been running, where the bytes live, and what happened lately.
// The archive table lives on its own Snapshots section — this page answers
@@ -423,32 +468,20 @@ export default function BackupsOverview({
description="Run a backup or enable a schedule to start building an archive."
/>
) : (
- <table className="sk-dtable bk-latest">
- <tbody>
- {latest.map((e) => {
- const Icon = KIND_ICON[e.kind] || Archive;
- return (
- <tr key={e.id}>
- <td>
- <div className="sk-cell-name">
- <span className="bk-ico"><Icon size={14} /></span>
- <span>
- <div>{e.name}</div>
- <div className="sk-cell-sub">{e.sub} · {relativeTime(e.at)}</div>
- </span>
- </div>
- </td>
- <td className="sk-cell-mono">{formatBytes(e.size, { defaultValue: '—' })}</td>
- <td>
- <Pill kind={e.status === 'complete' ? 'green' : e.status === 'running' ? 'cyan' : 'red'}>
- {e.status}
- </Pill>
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
+ <DataTable
+ columns={LATEST_COLUMNS}
+ data={latest}
+ keyField="id"
+ storageKey="serverkit-table-backup-latest"
+ tableClassName="bk-latest"
+ footer={(
+ <DataTableFooter
+ shown={latest.length}
+ total={events.length}
+ noun="snapshot"
+ />
+ )}
+ />
)}
</section>
</div>
diff --git a/frontend/src/components/backups/SchedulesTable.jsx b/frontend/src/components/backups/SchedulesTable.jsx
index d51c33b6..c33a6550 100644
--- a/frontend/src/components/backups/SchedulesTable.jsx
+++ b/frontend/src/components/backups/SchedulesTable.jsx
@@ -1,5 +1,6 @@
import { Archive, Database, Globe, HardDrive, Package, Play, ShieldCheck, Trash2 } from 'lucide-react';
import { Switch } from '@/components/ui/switch';
+import { DataTable, DataTableFooter } from '@/components/ds';
const KIND_ICON = {
application: Package,
@@ -72,103 +73,158 @@ function frequencyLabel(schedule) {
export default function SchedulesTable({
schedules, retentionDays, remoteLabel, onToggle, onRemove, onRun,
}) {
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace, so _backups.scss keeps applying
+ // (.bk-name, .bk-ret, .bk-lastrun, .bk-paused, .bk-col-on, .bk-actions).
+ const columns = [
+ {
+ key: 'policy',
+ header: 'Policy',
+ sortable: true,
+ hideable: false,
+ sortValue: (s) => s.name || '',
+ render: (schedule) => {
+ const Icon = KIND_ICON[schedule.backup_type] || Archive;
+ return (
+ <div className="sk-cell-name bk-name">
+ <span className={`bk-ico bk-ico--${schedule.backup_type}`}>
+ <Icon size={15} />
+ </span>
+ <span>
+ <div>{schedule.name}</div>
+ <div className="sk-cell-sub">
+ {[schedule.target, schedule.backup_type,
+ schedule.upload_remote ? 'off-box copy' : null]
+ .filter(Boolean).join(' · ')}
+ </div>
+ </span>
+ </div>
+ );
+ },
+ },
+ {
+ key: 'frequency',
+ header: 'Frequency',
+ sortable: true,
+ sortValue: (s) => frequencyLabel(s),
+ cellClassName: 'sk-cell-mono',
+ render: (schedule) => frequencyLabel(schedule),
+ },
+ {
+ // Same retentionDays on every row — sorting it would be noise.
+ key: 'retention',
+ header: 'Retention',
+ render: () => (
+ <span className="bk-ret">
+ <span>{retentionDays} d</span>
+ </span>
+ ),
+ },
+ {
+ key: 'destination',
+ header: 'Destination',
+ sortable: true,
+ sortValue: (s) => (s.upload_remote ? remoteLabel : 'Local disk'),
+ cellClassName: 'sk-cell-mono',
+ render: (schedule) => (schedule.upload_remote ? remoteLabel : 'Local disk'),
+ },
+ {
+ key: 'lastRun',
+ header: 'Last run',
+ sortable: true,
+ sortValue: (s) => (s.last_run ? new Date(s.last_run).getTime() : null),
+ render: (schedule) => {
+ const failed = schedule.last_status === 'failed';
+ return failed ? (
+ <span className="bk-lastrun is-failed">
+ <i />{agoLabel(schedule.last_run)}
+ </span>
+ ) : (
+ <span className="bk-lastrun">{agoLabel(schedule.last_run)}</span>
+ );
+ },
+ },
+ {
+ key: 'next',
+ header: 'Next',
+ sortable: true,
+ sortValue: (s) => {
+ const next = s.enabled ? nextFire(s) : null;
+ return next ? next.getTime() : null;
+ },
+ cellClassName: 'sk-cell-mono',
+ render: (schedule) => {
+ const next = schedule.enabled ? nextFire(schedule) : null;
+ return schedule.enabled
+ ? (next ? untilLabel(next) : '—')
+ : <span className="bk-paused">paused</span>;
+ },
+ },
+ {
+ key: 'on',
+ header: 'On',
+ sortable: true,
+ sortValue: (s) => (s.enabled ? 1 : 0),
+ className: 'bk-col-on',
+ cellClassName: 'bk-col-on',
+ render: (schedule) => (
+ <Switch
+ checked={Boolean(schedule.enabled)}
+ onCheckedChange={() => onToggle(schedule)}
+ aria-label={`${schedule.enabled ? 'Disable' : 'Enable'} ${schedule.name}`}
+ />
+ ),
+ },
+ {
+ key: 'actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ render: (schedule) => (
+ <div className="bk-actions">
+ {onRun && (
+ <button
+ type="button"
+ className="bk-iconbtn"
+ onClick={() => onRun(schedule)}
+ title="Run this policy now"
+ aria-label={`Run ${schedule.name} now`}
+ >
+ <Play size={15} />
+ </button>
+ )}
+ <button
+ type="button"
+ className="bk-iconbtn bk-iconbtn--danger"
+ onClick={() => onRemove(schedule.id)}
+ title="Delete this policy"
+ aria-label={`Delete ${schedule.name}`}
+ >
+ <Trash2 size={15} />
+ </button>
+ </div>
+ ),
+ },
+ ];
+
return (
<>
<div className="bk-card">
- <table className="sk-dtable bk-table bk-table--schedules">
- <thead>
- <tr>
- <th>Policy</th>
- <th>Frequency</th>
- <th>Retention</th>
- <th>Destination</th>
- <th>Last run</th>
- <th>Next</th>
- <th className="bk-col-on">On</th>
- <th aria-label="Actions" />
- </tr>
- </thead>
- <tbody>
- {schedules.map((schedule) => {
- const Icon = KIND_ICON[schedule.backup_type] || Archive;
- const next = schedule.enabled ? nextFire(schedule) : null;
- const failed = schedule.last_status === 'failed';
- return (
- <tr key={schedule.id} className={schedule.enabled ? undefined : 'is-off'}>
- <td>
- <div className="sk-cell-name bk-name">
- <span className={`bk-ico bk-ico--${schedule.backup_type}`}>
- <Icon size={15} />
- </span>
- <span>
- <div>{schedule.name}</div>
- <div className="sk-cell-sub">
- {[schedule.target, schedule.backup_type,
- schedule.upload_remote ? 'off-box copy' : null]
- .filter(Boolean).join(' · ')}
- </div>
- </span>
- </div>
- </td>
- <td className="sk-cell-mono">{frequencyLabel(schedule)}</td>
- <td>
- <span className="bk-ret">
- <span>{retentionDays} d</span>
- </span>
- </td>
- <td className="sk-cell-mono">
- {schedule.upload_remote ? remoteLabel : 'Local disk'}
- </td>
- <td>
- {failed ? (
- <span className="bk-lastrun is-failed">
- <i />{agoLabel(schedule.last_run)}
- </span>
- ) : (
- <span className="bk-lastrun">{agoLabel(schedule.last_run)}</span>
- )}
- </td>
- <td className="sk-cell-mono">
- {schedule.enabled
- ? (next ? untilLabel(next) : '—')
- : <span className="bk-paused">paused</span>}
- </td>
- <td className="bk-col-on">
- <Switch
- checked={Boolean(schedule.enabled)}
- onCheckedChange={() => onToggle(schedule)}
- aria-label={`${schedule.enabled ? 'Disable' : 'Enable'} ${schedule.name}`}
- />
- </td>
- <td>
- <div className="bk-actions">
- {onRun && (
- <button
- type="button"
- className="bk-iconbtn"
- onClick={() => onRun(schedule)}
- title="Run this policy now"
- aria-label={`Run ${schedule.name} now`}
- >
- <Play size={15} />
- </button>
- )}
- <button
- type="button"
- className="bk-iconbtn bk-iconbtn--danger"
- onClick={() => onRemove(schedule.id)}
- title="Delete this policy"
- aria-label={`Delete ${schedule.name}`}
- >
- <Trash2 size={15} />
- </button>
- </div>
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
+ <DataTable
+ columns={columns}
+ data={schedules}
+ keyField="id"
+ storageKey="serverkit-table-backup-schedules"
+ rowClassName={(schedule) => (schedule.enabled ? undefined : 'is-off')}
+ tableClassName="bk-table bk-table--schedules"
+ footer={(
+ <DataTableFooter
+ shown={schedules.length}
+ total={schedules.length}
+ noun="schedule"
+ />
+ )}
+ />
</div>
<p className="bk-hint bk-hint--foot">
<ShieldCheck size={13} />
diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsx
index 96b83238..cdb37ef3 100644
--- a/frontend/src/pages/Backups.jsx
+++ b/frontend/src/pages/Backups.jsx
@@ -11,11 +11,15 @@ import { FormField, FormRow } from '../components/FormField';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
-import { Pill, SearchField, SegControl } from '@/components/ds';
+import {
+ Pill, SearchField, SegControl, DataTable, SortMenu, ColumnsMenu, SortChipBar, DataTableFooter,
+} from '@/components/ds';
import BackupsOverview from '../components/backups/BackupsOverview';
import SchedulesTable from '../components/backups/SchedulesTable';
import StorageDestinations from '../components/backups/StorageDestinations';
import { useTopbarActions } from '@/hooks/useTopbarActions';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
// `backups` is kept as an alias so old /backups/backups links still resolve to
// the archive, which now answers to `snapshots`.
@@ -40,6 +44,10 @@ const Backups = () => {
const activeTab = TAB_ALIASES[rawTab] || rawTab;
const [filterType, setFilterType] = useState('all');
const [search, setSearch] = useState('');
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-backups-sort' });
+ const {
+ hiddenKeys, toggleColumn, showAllColumns,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-backups-cols' });
// Modal states
const [showBackupModal, setShowBackupModal] = useState(false);
@@ -396,6 +404,121 @@ const Backups = () => {
}
};
+ // DataTable columns for the snapshot archive. Cell markup and classNames
+ // are identical to the hand-rolled table they replace, so _backups.scss
+ // keeps applying (.bk-name, .bk-ico, .bk-when, .bk-actions).
+ const snapshotColumns = [
+ {
+ key: 'name',
+ header: 'Name',
+ sortable: true,
+ hideable: false,
+ sortValue: (b) => b.name || b.app_name || '',
+ render: (backup) => (
+ <div className="sk-cell-name bk-name">
+ <span className={`bk-ico bk-ico--${backup.type}`}>
+ {getBackupIcon(backup.type)}
+ </span>
+ <span title={backup.name || backup.app_name}>
+ {backup.name || backup.app_name}
+ </span>
+ </div>
+ ),
+ },
+ {
+ key: 'type',
+ header: 'Type',
+ sortable: true,
+ sortValue: (b) => b.type || '',
+ render: (backup) => <span className="sk-tag">{backup.type}</span>,
+ },
+ {
+ key: 'site',
+ header: 'Site/Service',
+ sortable: true,
+ sortValue: (b) => b.app_name || b.name?.split('_')[0] || null,
+ render: (backup) => backup.app_name || backup.name?.split('_')[0] || '—',
+ },
+ {
+ key: 'size',
+ header: 'Size',
+ sortable: true,
+ sortValue: (b) => b.size || 0,
+ cellClassName: 'sk-cell-mono',
+ render: (backup) => formatBytes(backup.size, { defaultValue: '0 B' }),
+ },
+ {
+ key: 'storage',
+ header: 'Storage',
+ sortable: true,
+ sortValue: (b) => b.remote_status || 'local',
+ render: (backup) => getRemoteStatusPill(backup.remote_status),
+ },
+ {
+ key: 'created',
+ header: 'Created',
+ sortable: true,
+ sortValue: (b) => (b.timestamp ? new Date(b.timestamp).getTime() : null),
+ cellClassName: 'bk-when',
+ render: (backup) => formatTimestamp(backup.timestamp),
+ },
+ {
+ key: 'cost',
+ header: 'Cost',
+ sortable: true,
+ sortValue: (b) => ((b.size || 0) / (1024 ** 3)) * (costSummary?.cost_rates?.local || 0),
+ cellClassName: 'sk-cell-mono',
+ render: (backup) => formatMoney(((backup.size || 0) / (1024 ** 3)) * (costSummary?.cost_rates?.local || 0)),
+ },
+ {
+ key: 'actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ render: (backup) => (
+ <div className="bk-actions">
+ {backup.type !== 'files' && (
+ <button
+ type="button"
+ className="bk-iconbtn"
+ onClick={() => {
+ setSelectedBackup(backup);
+ setShowRestoreModal(true);
+ }}
+ title="Restore this snapshot"
+ aria-label={`Restore ${backup.name}`}
+ >
+ <History size={15} />
+ </button>
+ )}
+ {storageConfig?.provider !== 'local' && backup.remote_status !== 'synced' && (
+ <button
+ type="button"
+ className="bk-iconbtn"
+ onClick={() => handleUploadToRemote(backup)}
+ disabled={uploadingBackup === backup.path}
+ title="Copy to remote storage"
+ aria-label={`Upload ${backup.name} to remote storage`}
+ >
+ {uploadingBackup === backup.path
+ ? <RefreshCw size={15} className="spinning" />
+ : <Upload size={15} />}
+ </button>
+ )}
+ <button
+ type="button"
+ className="bk-iconbtn bk-iconbtn--danger"
+ onClick={() => handleDeleteBackup(backup.path)}
+ title="Delete this snapshot"
+ aria-label={`Delete ${backup.name}`}
+ >
+ <Trash2 size={15} />
+ </button>
+ </div>
+ ),
+ },
+ ];
+
// Search narrows first so the segment counts always describe what a click
// on that segment would actually show.
const searchedBackups = (() => {
@@ -484,11 +607,21 @@ const Backups = () => {
{ value: 'files', label: 'Files', count: searchedBackups.filter(b => b.type === 'files').length },
]}
/>
- <Button size="sm" variant="outline" onClick={loadData}>
- <RefreshCw size={14} />
- Refresh
- </Button>
+ <div className="bk-listhead__right">
+ <SortMenu columns={snapshotColumns} sorts={sorts} onChange={setSorts} />
+ <ColumnsMenu
+ columns={snapshotColumns}
+ hiddenKeys={hiddenKeys}
+ onToggle={toggleColumn}
+ onShowAll={showAllColumns}
+ />
+ <Button size="sm" variant="outline" onClick={loadData}>
+ <RefreshCw size={14} />
+ Refresh
+ </Button>
+ </div>
</div>
+ <SortChipBar columns={snapshotColumns} sorts={sorts} onChange={setSorts} />
{backups.length === 0 ? (
<EmptyState
icon={FileArchive}
@@ -504,85 +637,22 @@ const Backups = () => {
</div>
) : (
<div className="bk-card">
- <table className="sk-dtable bk-table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Type</th>
- <th>Site/Service</th>
- <th>Size</th>
- <th>Storage</th>
- <th>Created</th>
- <th>Cost</th>
- <th aria-label="Actions" />
- </tr>
- </thead>
- <tbody>
- {filteredBackups.map((backup, index) => (
- <tr key={index}>
- <td>
- <div className="sk-cell-name bk-name">
- <span className={`bk-ico bk-ico--${backup.type}`}>
- {getBackupIcon(backup.type)}
- </span>
- <span title={backup.name || backup.app_name}>
- {backup.name || backup.app_name}
- </span>
- </div>
- </td>
- <td>
- <span className="sk-tag">{backup.type}</span>
- </td>
- <td>{backup.app_name || backup.name?.split('_')[0] || '—'}</td>
- <td className="sk-cell-mono">{formatBytes(backup.size, { defaultValue: '0 B' })}</td>
- <td>{getRemoteStatusPill(backup.remote_status)}</td>
- <td className="bk-when">{formatTimestamp(backup.timestamp)}</td>
- <td className="sk-cell-mono">{formatMoney(((backup.size || 0) / (1024 ** 3)) * (costSummary?.cost_rates?.local || 0))}</td>
- <td>
- <div className="bk-actions">
- {backup.type !== 'files' && (
- <button
- type="button"
- className="bk-iconbtn"
- onClick={() => {
- setSelectedBackup(backup);
- setShowRestoreModal(true);
- }}
- title="Restore this snapshot"
- aria-label={`Restore ${backup.name}`}
- >
- <History size={15} />
- </button>
- )}
- {storageConfig?.provider !== 'local' && backup.remote_status !== 'synced' && (
- <button
- type="button"
- className="bk-iconbtn"
- onClick={() => handleUploadToRemote(backup)}
- disabled={uploadingBackup === backup.path}
- title="Copy to remote storage"
- aria-label={`Upload ${backup.name} to remote storage`}
- >
- {uploadingBackup === backup.path
- ? <RefreshCw size={15} className="spinning" />
- : <Upload size={15} />}
- </button>
- )}
- <button
- type="button"
- className="bk-iconbtn bk-iconbtn--danger"
- onClick={() => handleDeleteBackup(backup.path)}
- title="Delete this snapshot"
- aria-label={`Delete ${backup.name}`}
- >
- <Trash2 size={15} />
- </button>
- </div>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <DataTable
+ columns={snapshotColumns}
+ data={filteredBackups}
+ keyField="path"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ hiddenKeys={hiddenKeys}
+ tableClassName="bk-table"
+ footer={(
+ <DataTableFooter
+ shown={filteredBackups.length}
+ total={backups.length}
+ noun="snapshot"
+ />
+ )}
+ />
</div>
)}
</>
diff --git a/frontend/src/styles/pages/_backups.scss b/frontend/src/styles/pages/_backups.scss
index fd2738f3..4af8ab91 100644
--- a/frontend/src/styles/pages/_backups.scss
+++ b/frontend/src/styles/pages/_backups.scss
@@ -534,6 +534,12 @@
align-items: center;
gap: $space-3;
margin-bottom: $space-3;
+
+ &__right {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ }
}
.bk-empty {