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(cron,backups,incidents): ListToolbar + shared EmptyState

Juan Denis897f9a876439
diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsx
index cdb37ef3..6cb2fcf1 100644
--- a/frontend/src/pages/Backups.jsx
+++ b/frontend/src/pages/Backups.jsx
@@ -13,6 +13,7 @@ import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import {
Pill, SearchField, SegControl, DataTable, SortMenu, ColumnsMenu, SortChipBar, DataTableFooter,
+ ListToolbar,
} from '@/components/ds';
import BackupsOverview from '../components/backups/BackupsOverview';
import SchedulesTable from '../components/backups/SchedulesTable';
@@ -596,31 +597,35 @@ const Backups = () => {
<>
{/* Search lives in the top bar with every other list page;
the segments carry the counts. */}
- <div className="bk-listhead">
- <SegControl
- value={filterType}
- onChange={setFilterType}
- options={[
- { value: 'all', label: 'All', count: searchedBackups.length },
- { value: 'application', label: 'Applications', count: searchedBackups.filter(b => b.type === 'application').length },
- { value: 'database', label: 'Databases', count: searchedBackups.filter(b => b.type === 'database').length },
- { value: 'files', label: 'Files', count: searchedBackups.filter(b => b.type === 'files').length },
- ]}
- />
- <div className="bk-listhead__right">
- <SortMenu columns={snapshotColumns} sorts={sorts} onChange={setSorts} />
- <ColumnsMenu
- columns={snapshotColumns}
- hiddenKeys={hiddenKeys}
- onToggle={toggleColumn}
- onShowAll={showAllColumns}
+ <ListToolbar
+ filters={(
+ <SegControl
+ value={filterType}
+ onChange={setFilterType}
+ options={[
+ { value: 'all', label: 'All', count: searchedBackups.length },
+ { value: 'application', label: 'Applications', count: searchedBackups.filter(b => b.type === 'application').length },
+ { value: 'database', label: 'Databases', count: searchedBackups.filter(b => b.type === 'database').length },
+ { 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>
- </div>
+ )}
+ tools={(
+ <>
+ <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>
+ </>
+ )}
+ />
<SortChipBar columns={snapshotColumns} sorts={sorts} onChange={setSorts} />
{backups.length === 0 ? (
<EmptyState
@@ -630,11 +635,12 @@ const Backups = () => {
action={<Button onClick={() => setShowBackupModal(true)}>Create Backup</Button>}
/>
) : filteredBackups.length === 0 ? (
- <div className="bk-empty">
- {search.trim()
+ <EmptyState
+ icon={FileArchive}
+ title={search.trim()
? `No snapshots match “${search.trim()}”.`
: 'No snapshots match the current filter.'}
- </div>
+ />
) : (
<div className="bk-card">
<DataTable
diff --git a/frontend/src/pages/CronJobs.jsx b/frontend/src/pages/CronJobs.jsx
index 441e2af2..d74b6dda 100644
--- a/frontend/src/pages/CronJobs.jsx
+++ b/frontend/src/pages/CronJobs.jsx
@@ -12,7 +12,7 @@ import { Button } from '@/components/ui/button';
import { Switch } from '@/components/ui/switch';
import {
Pill, SegControl, SearchField, DataTable, Drawer,
- SortMenu, ColumnsMenu, DataTableFooter, ViewMenu,
+ SortMenu, ColumnsMenu, DataTableFooter, ViewMenu, ListToolbar,
} from '@/components/ds';
import { useTableSort } from '@/hooks/useTableSort';
import { useColumnVisibility } from '@/hooks/useColumnVisibility';
@@ -415,24 +415,28 @@ const CronJobs = () => {
<div className="cron-body">
{/* No KPI strip: every number it carried is already on the
segment you'd click to act on it (mirrors /domains). */}
- <div className="cron-listhead">
- <h2 className="cron-listhead__title">All jobs</h2>
- <div className="cron-listhead__right">
- {serviceNote && <span className="cron-servicenote">{serviceNote}</span>}
- <span className="cron-listhead__count">
+ <ListToolbar
+ title="All jobs"
+ filters={<SegControl value={filter} onChange={setFilter} options={filterOptions} />}
+ count={(
+ <>
+ {serviceNote && <span className="cron-servicenote">{serviceNote}</span>}
{shown.length} of {jobs.length} jobs
- </span>
- <SegControl value={filter} onChange={setFilter} options={filterOptions} />
- <ViewMenu views={tableViews} />
- <SortMenu columns={jobColumns} sorts={sorts} onChange={setSorts} />
- <ColumnsMenu
- columns={jobColumns}
- hiddenKeys={hiddenKeys}
- onToggle={toggleColumn}
- onShowAll={showAllColumns}
- />
- </div>
- </div>
+ </>
+ )}
+ tools={(
+ <>
+ <ViewMenu views={tableViews} />
+ <SortMenu columns={jobColumns} sorts={sorts} onChange={setSorts} />
+ <ColumnsMenu
+ columns={jobColumns}
+ hiddenKeys={hiddenKeys}
+ onToggle={toggleColumn}
+ onShowAll={showAllColumns}
+ />
+ </>
+ )}
+ />
{shown.length === 0 ? (
<div className="cron-empty">
@@ -820,7 +824,7 @@ function CronFormDrawer({ open, job, onClose, onSaved }) {
title={job ? 'Edit cron job' : 'New cron job'}
subtitle={job ? job.name : 'Schedule a command on this server'}
icon={<Clock size={18} />}
- width={600}
+ width={640}
className="cron-form-drawer"
>
<form className="cron-form" onSubmit={submit}>
diff --git a/frontend/src/pages/Incidents.jsx b/frontend/src/pages/Incidents.jsx
index e931fea6..da1f8272 100644
--- a/frontend/src/pages/Incidents.jsx
+++ b/frontend/src/pages/Incidents.jsx
@@ -15,7 +15,7 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import EmptyState from '../components/EmptyState';
import FleetAlertsPanel from '../components/monitoring/FleetAlertsPanel';
-import { Drawer, KpiBand, MetricCard, Pill, SegControl } from '@/components/ds';
+import { Drawer, KpiBand, ListToolbar, MetricCard, Pill, SegControl } from '@/components/ds';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { useTopbarActions } from '@/hooks/useTopbarActions';
@@ -220,12 +220,10 @@ export default function Incidents() {
/>
</KpiBand>
- <div className="incidents-listhead">
- <SegControl value={filter} onChange={setFilter} options={FILTERS} />
- <span className="incidents-listhead__meta">
- {shown.length} shown · monitor outages and host threshold alerts
- </span>
- </div>
+ <ListToolbar
+ filters={<SegControl value={filter} onChange={setFilter} options={FILTERS} />}
+ count={<>{shown.length} shown · monitor outages and host threshold alerts</>}
+ />
{shown.length === 0 ? (
<EmptyState
diff --git a/frontend/src/pages/MonitorDetail.jsx b/frontend/src/pages/MonitorDetail.jsx
index a7b380f6..255aab53 100644
--- a/frontend/src/pages/MonitorDetail.jsx
+++ b/frontend/src/pages/MonitorDetail.jsx
@@ -463,9 +463,10 @@ export default function MonitorDetail() {
hiddenKeys={hiddenKeys}
rowClassName={(c) => (c.status === 'up' ? undefined : 'is-bad')}
emptyState={(
- <div className="mon-empty">
- <p>No checks in this window yet.</p>
- </div>
+ <EmptyState
+ icon={Activity}
+ title="No checks in this window yet."
+ />
)}
columns={checkColumns}
footer={<DataTableFooter shown={rows.length} total={rows.length} noun="check" />}
diff --git a/frontend/src/styles/pages/_backups.scss b/frontend/src/styles/pages/_backups.scss
index 4af8ab91..b0b87340 100644
--- a/frontend/src/styles/pages/_backups.scss
+++ b/frontend/src/styles/pages/_backups.scss
@@ -528,36 +528,6 @@
}
}
-.bk-listhead {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: $space-3;
- margin-bottom: $space-3;
-
- &__right {
- display: flex;
- align-items: center;
- gap: $space-3;
- }
-}
-
-.bk-empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: $space-3;
- padding: $space-12 $space-6;
- text-align: center;
- color: $text-tertiary;
- background: $bg-card;
- border: 1px dashed $border-subtle;
- border-radius: $radius-lg;
-
- svg { color: $text-tertiary; opacity: 0.7; }
-}
-
// ---------- Backups / schedules table ----------
.bk-table {
width: 100%;
diff --git a/frontend/src/styles/pages/_cron.scss b/frontend/src/styles/pages/_cron.scss
index 69b330b8..cffd0108 100644
--- a/frontend/src/styles/pages/_cron.scss
+++ b/frontend/src/styles/pages/_cron.scss
@@ -4,45 +4,6 @@
.cron-page {
- // ── list head ───────────────────────────────────────────
- // No KPI strip and no in-body search box: the segmented filter carries the
- // counts and search lives in the top bar, matching /domains. The section
- // title anchors the left, everything that qualifies the list sits right.
- .cron-listhead {
- display: flex;
- align-items: center;
- gap: $space-4;
- margin-bottom: $space-3;
-
- &__title {
- margin: 0;
- font-size: 14px;
- font-weight: $font-weight-semibold;
- letter-spacing: -0.01em;
- color: var(--text);
- }
-
- &__right {
- display: flex;
- align-items: center;
- gap: $space-3;
- margin-left: auto;
- }
-
- &__count {
- font-family: var(--mono);
- font-size: 11.5px;
- color: var(--text-faint);
- white-space: nowrap;
- }
-
- @media (max-width: $breakpoint-md) {
- flex-wrap: wrap;
-
- &__right { width: 100%; margin-left: 0; }
- }
- }
-
.cron-servicenote {
font-family: var(--mono);
font-size: 11px;
diff --git a/frontend/src/styles/pages/_monitors.scss b/frontend/src/styles/pages/_monitors.scss
index c4dc2359..e090ee0c 100644
--- a/frontend/src/styles/pages/_monitors.scss
+++ b/frontend/src/styles/pages/_monitors.scss
@@ -86,12 +86,6 @@
}
}
- .mon-empty {
- padding: 26px 18px;
- font-size: 13px;
- color: var(--text-faint);
- }
-
// Check result code chip (200 / down / ok).
.mon-code {
display: inline-flex;
@@ -385,21 +379,6 @@
// ── incidents ───────────────────────────────────────────────
.incidents-page {
- .incidents-listhead {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 16px;
- flex-wrap: wrap;
- margin: 18px 0 14px;
- }
-
- .incidents-listhead__meta {
- font-family: var(--mono);
- font-size: 11px;
- color: var(--text-faint);
- }
-
.incidents-list {
background: var(--bg-card, var(--surface-1));
border: 1px solid var(--border-soft);