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(queues,docker,misc): move remaining tables onto DataTable

Juan Denisfa6b9f3e2644
diff --git a/frontend/src/components/EnvironmentVariables.jsx b/frontend/src/components/EnvironmentVariables.jsx
index 1cea1c51..7ce164e3 100644
--- a/frontend/src/components/EnvironmentVariables.jsx
+++ b/frontend/src/components/EnvironmentVariables.jsx
@@ -10,6 +10,7 @@ import { Badge } from '@/components/ui/badge';
import { Label } from '@/components/ui/label';
import Modal from './Modal';
import EmptyState from './EmptyState';
+import { DataTable, DataTableFooter } from '@/components/ds';
const EnvironmentVariables = ({ appId }) => {
const toast = useToast();
@@ -584,28 +585,48 @@ const EnvironmentVariables = ({ appId }) => {
{history.length === 0 ? (
<p className="hint">No changes recorded yet.</p>
) : (
- <table className="table">
- <thead>
- <tr>
- <th>Key</th>
- <th>Action</th>
- <th>Changed At</th>
- </tr>
- </thead>
- <tbody>
- {history.map((h, idx) => (
- <tr key={idx}>
- <td className="mono">{h.key}</td>
- <td>
- <Badge variant={h.action === 'created' ? 'success' : h.action === 'deleted' ? 'destructive' : 'warning'}>
- {h.action}
- </Badge>
- </td>
- <td>{new Date(h.changed_at).toLocaleString()}</td>
- </tr>
- ))}
- </tbody>
- </table>
+ <DataTable
+ columns={[
+ {
+ key: 'key',
+ header: 'Key',
+ sortable: true,
+ hideable: false,
+ sortValue: (h) => h.key || '',
+ cellClassName: 'mono',
+ render: (h) => h.key,
+ },
+ {
+ key: 'action',
+ header: 'Action',
+ sortable: true,
+ sortValue: (h) => h.action || '',
+ render: (h) => (
+ <Badge variant={h.action === 'created' ? 'success' : h.action === 'deleted' ? 'destructive' : 'warning'}>
+ {h.action}
+ </Badge>
+ ),
+ },
+ {
+ key: 'changed_at',
+ header: 'Changed At',
+ sortable: true,
+ sortValue: (h) => new Date(h.changed_at).getTime(),
+ render: (h) => new Date(h.changed_at).toLocaleString(),
+ },
+ ]}
+ data={history.map((h, idx) => ({ ...h, __idx: idx }))}
+ keyField="__idx"
+ storageKey="serverkit-table-env-history"
+ tableClassName="table"
+ footer={(
+ <DataTableFooter
+ shown={history.length}
+ total={history.length}
+ noun="change"
+ />
+ )}
+ />
)}
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowHistoryModal(false)}>
diff --git a/frontend/src/components/ProcessTable.jsx b/frontend/src/components/ProcessTable.jsx
index 711a9069..bfbc02e9 100644
--- a/frontend/src/components/ProcessTable.jsx
+++ b/frontend/src/components/ProcessTable.jsx
@@ -1,6 +1,7 @@
import { X, AlertTriangle } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
+import { DataTable, DataTableFooter } from '@/components/ds';
export function UsageCell({ percent = 0, variant = 'cpu' }) {
const clamped = Math.min(Number(percent) || 0, 100);
@@ -21,76 +22,119 @@ export function ProcessTable({
formatMemory = defaultFormatMemory,
getStatusVariant = defaultGetStatusVariant,
}) {
- return (
- <div className="processes-table-wrapper">
- <table
- className="table processes-table"
- spellCheck={false}
- data-gramm="false"
- data-gramm_editor="false"
- data-enable-grammarly="false"
- >
- <thead>
- <tr>
- <th>PID</th>
- <th>Name</th>
- <th>User</th>
- <th>CPU %</th>
- <th>Memory %</th>
- <th>Memory</th>
- <th>Status</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tbody>
- {processes.map(p => (
- <tr
- key={p.pid}
- className={selectedPid === p.pid ? 'selected' : ''}
- onClick={() => onSelect?.(p)}
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace, so _terminal.scss keeps applying
+ // (.processes-table, .mono, .process-name, .usage-cell, .action-buttons).
+ // No menus: this component has no toolbar row of its own, and the SCSS
+ // pins column widths by nth-child, so columns stay visible.
+ const columns = [
+ {
+ key: 'pid',
+ header: 'PID',
+ sortable: true,
+ sortValue: (p) => p.pid,
+ cellClassName: 'mono',
+ render: (p) => p.pid,
+ },
+ {
+ key: 'name',
+ header: 'Name',
+ sortable: true,
+ hideable: false,
+ sortValue: (p) => p.name || '',
+ render: (p) => <div className="process-name"><span>{p.name}</span></div>,
+ },
+ {
+ key: 'user',
+ header: 'User',
+ sortable: true,
+ sortValue: (p) => p.user || '',
+ render: (p) => p.user,
+ },
+ {
+ key: 'cpu',
+ header: 'CPU %',
+ sortable: true,
+ sortValue: (p) => Number(p.cpu_percent) || 0,
+ render: (p) => <UsageCell percent={p.cpu_percent} variant="cpu" />,
+ },
+ {
+ key: 'memoryPercent',
+ header: 'Memory %',
+ sortable: true,
+ sortValue: (p) => Number(p.memory_percent) || 0,
+ render: (p) => <UsageCell percent={p.memory_percent} variant="memory" />,
+ },
+ {
+ key: 'memory',
+ header: 'Memory',
+ sortable: true,
+ sortValue: (p) => p.memory_info?.rss ?? null,
+ render: (p) => formatMemory(p.memory_info?.rss),
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ sortValue: (p) => p.status || '',
+ render: (p) => (
+ <Badge variant={getStatusVariant(p.status)}>{p.status}</Badge>
+ ),
+ },
+ {
+ key: '__actions',
+ header: 'Actions',
+ sortable: false,
+ hideable: false,
+ render: (p) => (
+ <div className="action-buttons">
+ {onKill && (
+ <Button
+ variant="outline"
+ size="icon"
+ className="process-action-button"
+ onClick={(e) => { e.stopPropagation(); onKill(p); }}
+ title="Kill"
+ aria-label={`Kill ${p.name}`}
>
- <td className="mono">{p.pid}</td>
- <td><div className="process-name"><span>{p.name}</span></div></td>
- <td>{p.user}</td>
- <td><UsageCell percent={p.cpu_percent} variant="cpu" /></td>
- <td><UsageCell percent={p.memory_percent} variant="memory" /></td>
- <td>{formatMemory(p.memory_info?.rss)}</td>
- <td>
- <Badge variant={getStatusVariant(p.status)}>{p.status}</Badge>
- </td>
- <td>
- <div className="action-buttons">
- {onKill && (
- <Button
- variant="outline"
- size="icon"
- className="process-action-button"
- onClick={(e) => { e.stopPropagation(); onKill(p); }}
- title="Kill"
- aria-label={`Kill ${p.name}`}
- >
- <X size={12} />
- </Button>
- )}
- {onForceKill && (
- <Button
- variant="destructive"
- size="icon"
- className="process-action-button"
- onClick={(e) => { e.stopPropagation(); onForceKill(p); }}
- title="Force Kill"
- aria-label={`Force kill ${p.name}`}
- >
- <AlertTriangle size={12} />
- </Button>
- )}
- </div>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <X size={12} />
+ </Button>
+ )}
+ {onForceKill && (
+ <Button
+ variant="destructive"
+ size="icon"
+ className="process-action-button"
+ onClick={(e) => { e.stopPropagation(); onForceKill(p); }}
+ title="Force Kill"
+ aria-label={`Force kill ${p.name}`}
+ >
+ <AlertTriangle size={12} />
+ </Button>
+ )}
+ </div>
+ ),
+ },
+ ];
+
+ return (
+ <DataTable
+ columns={columns}
+ data={processes}
+ keyField="pid"
+ storageKey="serverkit-table-processes"
+ onRowClick={(p) => onSelect?.(p)}
+ rowClassName={(p) => (selectedPid === p.pid ? 'selected' : '')}
+ className="processes-table-wrapper"
+ tableClassName="table processes-table"
+ footer={(
+ <DataTableFooter
+ shown={processes.length}
+ total={processes.length}
+ noun="process"
+ />
+ )}
+ />
);
}
diff --git a/frontend/src/components/docker/ContainersTab.jsx b/frontend/src/components/docker/ContainersTab.jsx
index 7e6961ea..f09dd593 100644
--- a/frontend/src/components/docker/ContainersTab.jsx
+++ b/frontend/src/components/docker/ContainersTab.jsx
@@ -6,14 +6,16 @@ import LogToolbar from '../log-viewer/LogToolbar';
import LogContent from '../log-viewer/LogContent';
import EmptyState from '../EmptyState';
import Modal from '@/components/Modal';
-import { Drawer } from '@/components/ds';
+import { Drawer, DataTable, DataTableFooter, SortMenu, ColumnsMenu } from '@/components/ds';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import {
Box, Search, X, RefreshCw, Trash2, Play, Square, RotateCw,
Terminal as TerminalLucide, FileText, Activity, Clock3, Copy,
- Database, Gauge, Package, Server as ServerIcon, ArrowUpDown, Lock,
+ Database, Gauge, Package, Server as ServerIcon, Lock,
} from 'lucide-react';
import {
useServer,
@@ -65,8 +67,15 @@ const ContainersTab = ({ onStatsChange }) => {
const [execContainer, setExecContainer] = useState(null);
const [searchTerm, setSearchTerm] = useState('');
const [statusFilter, setStatusFilter] = useState('all');
- const [sortKey, setSortKey] = useState('status');
- const [sortDirection, setSortDirection] = useState('asc');
+ // Native DataTable header sorting (the old <select> + direction button is
+ // gone). Default keeps the previous behavior: running containers first.
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: [{ key: 'status', direction: 'asc' }],
+ storageKey: 'serverkit-table-docker-containers-sort',
+ });
+ const {
+ hiddenKeys, toggleColumn, showAllColumns,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-docker-containers-cols' });
const statsRequestSeq = useRef(0);
useEffect(() => {
@@ -241,7 +250,7 @@ const ContainersTab = ({ onStatsChange }) => {
const filteredContainers = useMemo(() => {
const search = searchTerm.toLowerCase();
- const filtered = containers.filter(c => {
+ return containers.filter(c => {
if (statusFilter === 'running' && !isContainerRunning(c)) return false;
if (statusFilter === 'stopped' && isContainerRunning(c)) return false;
if (!search) return true;
@@ -249,43 +258,165 @@ const ContainersTab = ({ onStatsChange }) => {
getContainerId(c).toLowerCase().includes(search) ||
getContainerImage(c).toLowerCase().includes(search);
});
-
- const direction = sortDirection === 'asc' ? 1 : -1;
- const statusRank = (container) => isContainerRunning(container) ? 0 : 1;
- const createdTime = (container) => {
- const raw = container.created || container.CreatedAt || '';
- const parsed = Date.parse(raw);
- return Number.isNaN(parsed) ? 0 : parsed;
- };
-
- return [...filtered].sort((a, b) => {
- const statsA = parseStats(containerStats[getContainerId(a)]);
- const statsB = parseStats(containerStats[getContainerId(b)]);
- let result = 0;
-
- if (sortKey === 'status') {
- result = statusRank(a) - statusRank(b) ||
- getContainerStatus(a).localeCompare(getContainerStatus(b));
- } else if (sortKey === 'name') {
- result = getContainerName(a).localeCompare(getContainerName(b));
- } else if (sortKey === 'image') {
- result = getContainerImage(a).localeCompare(getContainerImage(b));
- } else if (sortKey === 'cpu') {
- result = statsA.cpu - statsB.cpu;
- } else if (sortKey === 'memory') {
- result = statsA.memory - statsB.memory;
- } else if (sortKey === 'created') {
- result = createdTime(a) - createdTime(b);
- }
-
- return result * direction;
- });
- }, [containers, statusFilter, searchTerm, sortKey, sortDirection, containerStats]);
+ }, [containers, statusFilter, searchTerm]);
const selectedStats = selectedContainer
? parseStats(containerStats[getContainerId(selectedContainer)])
: { cpu: 0, memory: 0, available: false };
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace, so _docker.scss keeps applying
+ // (.dx-manager-table, .dx-name-stack, .dx-status-pill, .dx-row-actions...).
+ const columns = [
+ {
+ key: 'name',
+ header: 'Name',
+ sortable: true,
+ hideable: false,
+ sortValue: (container) => getContainerName(container),
+ render: (container) => {
+ const isRunning = isContainerRunning(container);
+ return (
+ <div className="dx-name-stack">
+ <span className="dx-name-line">
+ {/* hue-hashed per-container identity dot (demo .dot-ico);
+ dims when stopped — status itself lives in the Status pill */}
+ <span
+ className={`dx-status-dot ${isRunning ? 'running' : 'stopped'}`}
+ style={{
+ background: `hsl(${containerHue(getContainerName(container))} 60% 60%)`,
+ boxShadow: isRunning
+ ? `0 0 6px hsl(${containerHue(getContainerName(container))} 60% 60% / 0.55)`
+ : 'none',
+ opacity: isRunning ? 1 : 0.4,
+ }}
+ />
+ <span title={getContainerName(container)}>{getContainerName(container)}</span>
+ </span>
+ <span className="dx-muted-line mono">{shortId(getContainerId(container))}</span>
+ </div>
+ );
+ },
+ },
+ {
+ key: 'image',
+ header: 'Image',
+ sortable: true,
+ sortValue: (container) => getContainerImage(container),
+ render: (container) => (
+ <span className="dx-code-pill" title={getContainerImage(container)}>
+ {getContainerImage(container)}
+ </span>
+ ),
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ // Running first on asc, matching the old default sort.
+ sortValue: (container) => (isContainerRunning(container) ? 0 : 1),
+ render: (container) => (
+ <>
+ <span className={`dx-status-pill ${isContainerRunning(container) ? 'running' : 'stopped'}`}>
+ {getContainerStatusLabel(container)}
+ </span>
+ <span className="dx-muted-line">{getContainerStatus(container)}</span>
+ </>
+ ),
+ },
+ {
+ key: 'ports',
+ header: 'Ports',
+ sortable: false,
+ render: (container) => {
+ const ports = formatPorts(container.ports);
+ return (
+ <div className="dx-port-list">
+ {ports.slice(0, 2).map((port, i) => (
+ <span key={i} className={`dx-port-pill ${port === '-' ? 'is-empty' : ''}`}>{port}</span>
+ ))}
+ {ports.length > 2 && <span className="dx-port-more">+{ports.length - 2}</span>}
+ </div>
+ );
+ },
+ },
+ {
+ key: 'resources',
+ header: 'Resources',
+ sortable: true,
+ // CPU% is the headline number; containers without stats sort last.
+ sortValue: (container) => {
+ const stats = parseStats(containerStats[getContainerId(container)]);
+ return stats.available ? stats.cpu : null;
+ },
+ render: (container) => (
+ <ContainerResourceBars
+ stats={parseStats(containerStats[getContainerId(container)])}
+ muted={!isContainerRunning(container)}
+ />
+ ),
+ },
+ {
+ key: 'created',
+ header: 'Created',
+ sortable: true,
+ sortValue: (container) => {
+ const parsed = Date.parse(container.created || container.CreatedAt || '');
+ return Number.isNaN(parsed) ? null : parsed;
+ },
+ render: (container) => (
+ <span className="dx-muted-line">{container.created || container.CreatedAt || '-'}</span>
+ ),
+ },
+ {
+ key: '__actions',
+ header: 'Actions',
+ sortable: false,
+ hideable: false,
+ className: 'text-right',
+ render: (container) => {
+ const containerId = getContainerId(container);
+ const isRunning = isContainerRunning(container);
+ const isProtected = isProtectedContainer(container);
+ return (
+ <div className="dx-row-actions" onClick={(e) => e.stopPropagation()}>
+ <button type="button" className="dx-row-action" onClick={() => setLogsContainer(container)} title="Logs">
+ <FileText size={13} />
+ </button>
+ {isRunning && !isRemote && (
+ <button type="button" className="dx-row-action" onClick={() => setExecContainer(container)} title="Exec">
+ <TerminalLucide size={13} />
+ </button>
+ )}
+ {isProtected ? (
+ <span className="dx-row-protected" title="ServerKit system container — managed by the panel, lifecycle controls are disabled">
+ <Lock size={11} /> System
+ </span>
+ ) : isRunning ? (
+ <>
+ <button type="button" className="dx-row-action" onClick={() => handleAction(containerId, 'restart')} title="Restart">
+ <RotateCw size={13} />
+ </button>
+ <button type="button" className="dx-row-action is-danger" onClick={() => handleAction(containerId, 'stop')} title="Stop">
+ <Square size={13} />
+ </button>
+ </>
+ ) : (
+ <>
+ <button type="button" className="dx-row-action is-success" onClick={() => handleAction(containerId, 'start')} title="Start">
+ <Play size={13} />
+ </button>
+ <button type="button" className="dx-row-action is-danger" onClick={() => handleAction(containerId, 'remove')} title="Remove">
+ <Trash2 size={13} />
+ </button>
+ </>
+ )}
+ </div>
+ );
+ },
+ },
+ ];
+
if (loading) {
return (
<div className="dx-tab-pane">
@@ -315,24 +446,13 @@ const ContainersTab = ({ onStatsChange }) => {
))}
</div>
<div className="dx-tab-toolbar-right">
- <div className="dx-sort-control">
- <span>Sort</span>
- <select value={sortKey} onChange={(e) => setSortKey(e.target.value)}>
- <option value="status">Status</option>
- <option value="name">Name</option>
- <option value="image">Image</option>
- <option value="cpu">CPU</option>
- <option value="memory">RAM</option>
- <option value="created">Created</option>
- </select>
- <button type="button"
- className="lv-icon-btn"
- onClick={() => setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc')}
- title={`Sort ${sortDirection === 'asc' ? 'ascending' : 'descending'}`}
- >
- <ArrowUpDown size={13} />
- </button>
- </div>
+ <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />
+ <ColumnsMenu
+ columns={columns}
+ hiddenKeys={hiddenKeys}
+ onToggle={toggleColumn}
+ onShowAll={showAllColumns}
+ />
<label className="dx-toggle">
<input
type="checkbox"
@@ -379,117 +499,27 @@ const ContainersTab = ({ onStatsChange }) => {
) : (
<div className="dx-manager-layout">
<section className="dx-resource-list">
- <div className="dx-table-wrap">
- <table className="dx-manager-table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Image</th>
- <th>Status</th>
- <th>Ports</th>
- <th>Resources</th>
- <th>Created</th>
- <th className="text-right">Actions</th>
- </tr>
- </thead>
- <tbody>
- {filteredContainers.map(container => {
- const containerId = getContainerId(container);
- const stats = parseStats(containerStats[containerId]);
- const isRunning = isContainerRunning(container);
- const isProtected = isProtectedContainer(container);
- const ports = formatPorts(container.ports);
- const isSelected = getContainerId(selectedContainer) === containerId;
- return (
- <tr
- key={containerId}
- className={`${isRunning ? 'is-running' : 'is-stopped'} ${isSelected ? 'is-selected' : ''}`}
- onClick={() => setSelectedContainer(container)}
- >
- <td>
- <div className="dx-name-stack">
- <span className="dx-name-line">
- {/* hue-hashed per-container identity dot (demo .dot-ico);
- dims when stopped — status itself lives in the Status pill */}
- <span
- className={`dx-status-dot ${isRunning ? 'running' : 'stopped'}`}
- style={{
- background: `hsl(${containerHue(getContainerName(container))} 60% 60%)`,
- boxShadow: isRunning
- ? `0 0 6px hsl(${containerHue(getContainerName(container))} 60% 60% / 0.55)`
- : 'none',
- opacity: isRunning ? 1 : 0.4,
- }}
- />
- <span title={getContainerName(container)}>{getContainerName(container)}</span>
- </span>
- <span className="dx-muted-line mono">{shortId(containerId)}</span>
- </div>
- </td>
- <td>
- <span className="dx-code-pill" title={getContainerImage(container)}>
- {getContainerImage(container)}
- </span>
- </td>
- <td>
- <span className={`dx-status-pill ${isRunning ? 'running' : 'stopped'}`}>
- {getContainerStatusLabel(container)}
- </span>
- <span className="dx-muted-line">{getContainerStatus(container)}</span>
- </td>
- <td>
- <div className="dx-port-list">
- {ports.slice(0, 2).map((port, i) => (
- <span key={i} className={`dx-port-pill ${port === '-' ? 'is-empty' : ''}`}>{port}</span>
- ))}
- {ports.length > 2 && <span className="dx-port-more">+{ports.length - 2}</span>}
- </div>
- </td>
- <td>
- <ContainerResourceBars stats={stats} muted={!isRunning} />
- </td>
- <td>
- <span className="dx-muted-line">{container.created || container.CreatedAt || '-'}</span>
- </td>
- <td className="dx-row-actions" onClick={(e) => e.stopPropagation()}>
- <button type="button" className="dx-row-action" onClick={() => setLogsContainer(container)} title="Logs">
- <FileText size={13} />
- </button>
- {isRunning && !isRemote && (
- <button type="button" className="dx-row-action" onClick={() => setExecContainer(container)} title="Exec">
- <TerminalLucide size={13} />
- </button>
- )}
- {isProtected ? (
- <span className="dx-row-protected" title="ServerKit system container — managed by the panel, lifecycle controls are disabled">
- <Lock size={11} /> System
- </span>
- ) : isRunning ? (
- <>
- <button type="button" className="dx-row-action" onClick={() => handleAction(containerId, 'restart')} title="Restart">
- <RotateCw size={13} />
- </button>
- <button type="button" className="dx-row-action is-danger" onClick={() => handleAction(containerId, 'stop')} title="Stop">
- <Square size={13} />
- </button>
- </>
- ) : (
- <>
- <button type="button" className="dx-row-action is-success" onClick={() => handleAction(containerId, 'start')} title="Start">
- <Play size={13} />
- </button>
- <button type="button" className="dx-row-action is-danger" onClick={() => handleAction(containerId, 'remove')} title="Remove">
- <Trash2 size={13} />
- </button>
- </>
- )}
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
- </div>
+ <DataTable
+ columns={columns}
+ data={filteredContainers}
+ keyField={(container) => getContainerId(container)}
+ sorts={sorts}
+ onSortsChange={setSorts}
+ hiddenKeys={hiddenKeys}
+ onRowClick={(container) => setSelectedContainer(container)}
+ rowClassName={(container) => (
+ `${isContainerRunning(container) ? 'is-running' : 'is-stopped'} ${getContainerId(selectedContainer) === getContainerId(container) ? 'is-selected' : ''}`
+ )}
+ className="dx-table-wrap"
+ tableClassName="dx-manager-table"
+ footer={(
+ <DataTableFooter
+ shown={filteredContainers.length}
+ total={containers.length}
+ noun="container"
+ />
+ )}
+ />
</section>
</div>
)}
diff --git a/frontend/src/pages/DeliveryLog.jsx b/frontend/src/pages/DeliveryLog.jsx
index cc2d3b7b..4099d7a1 100644
--- a/frontend/src/pages/DeliveryLog.jsx
+++ b/frontend/src/pages/DeliveryLog.jsx
@@ -1,7 +1,7 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { Send, RefreshCw, Inbox } from 'lucide-react';
import api from '../services/api';
-import { MetricCard, KpiBand, FilterDrawer, FilterButton } from '@/components/ds';
+import { MetricCard, KpiBand, FilterDrawer, FilterButton, DataTable, DataTableFooter } from '@/components/ds';
import PageLayout from '../layouts/PageLayout';
import { Button } from '@/components/ui/button';
import { useAuth } from '../contexts/AuthContext';
@@ -66,6 +66,74 @@ export default function DeliveryLog() {
const byStatus = stats?.by_status || {};
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace, so _notification-center.scss keeps
+ // applying (.sk-dlog__table, .sk-dlog__status, .sk-dlog__target, ...).
+ // Runs uncontrolled (storageKey only): the page's own controls live in the
+ // shared topbar + FilterDrawer, not in an in-page toolbar row.
+ const columns = [
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ sortValue: (d) => d.status || '',
+ render: (d) => <span className={`sk-dlog__status is-${d.status}`}>{d.status}</span>,
+ },
+ {
+ key: 'channel',
+ header: 'Channel',
+ sortable: true,
+ sortValue: (d) => d.channel || '',
+ render: (d) => d.channel,
+ },
+ {
+ key: 'target',
+ header: 'To',
+ sortable: true,
+ sortValue: (d) => d.target || null,
+ cellClassName: 'sk-dlog__target',
+ render: (d) => d.target || '—',
+ },
+ {
+ key: 'notification',
+ header: 'Notification',
+ sortable: true,
+ sortValue: (d) => d.title || d.event_key || '',
+ render: (d) => (
+ <>
+ <div className="sk-dlog__title">{d.title || d.event_key}</div>
+ {d.error && <div className="sk-dlog__error" title={d.error}>{d.error}</div>}
+ </>
+ ),
+ },
+ {
+ key: 'tries',
+ header: 'Tries',
+ sortable: true,
+ sortValue: (d) => d.attempts ?? 0,
+ render: (d) => d.attempts,
+ },
+ {
+ key: 'when',
+ header: 'When',
+ sortable: true,
+ sortValue: (d) => (d.created_at ? new Date(d.created_at).getTime() : null),
+ cellClassName: 'sk-dlog__when',
+ render: (d) => timeAgo(d.created_at),
+ },
+ {
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ render: (d) => (
+ (d.status === 'failed' || d.status === 'skipped') && d.channel !== 'inapp' && (
+ <Button variant="ghost" size="sm" onClick={() => onRetry(d.id)}>Retry</Button>
+ )
+ ),
+ },
+ ];
+
return (
<PageLayout
icon={<Send size={18} />}
@@ -102,41 +170,21 @@ export default function DeliveryLog() {
<p>No deliveries match these filters.</p>
</div>
) : (
- <div className="sk-dlog__table-wrap">
- <table className="sk-dlog__table">
- <thead>
- <tr>
- <th>Status</th>
- <th>Channel</th>
- <th>To</th>
- <th>Notification</th>
- <th>Tries</th>
- <th>When</th>
- <th aria-label="Actions" />
- </tr>
- </thead>
- <tbody>
- {deliveries.map((d) => (
- <tr key={d.id}>
- <td><span className={`sk-dlog__status is-${d.status}`}>{d.status}</span></td>
- <td>{d.channel}</td>
- <td className="sk-dlog__target">{d.target || '—'}</td>
- <td>
- <div className="sk-dlog__title">{d.title || d.event_key}</div>
- {d.error && <div className="sk-dlog__error" title={d.error}>{d.error}</div>}
- </td>
- <td>{d.attempts}</td>
- <td className="sk-dlog__when">{timeAgo(d.created_at)}</td>
- <td>
- {(d.status === 'failed' || d.status === 'skipped') && d.channel !== 'inapp' && (
- <Button variant="ghost" size="sm" onClick={() => onRetry(d.id)}>Retry</Button>
- )}
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <DataTable
+ columns={columns}
+ data={deliveries}
+ keyField="id"
+ storageKey="serverkit-table-delivery-log"
+ className="sk-dlog__table-wrap"
+ tableClassName="sk-dlog__table"
+ footer={(
+ <DataTableFooter
+ shown={deliveries.length}
+ total={deliveries.length}
+ noun="delivery"
+ />
+ )}
+ />
)}
</div>
diff --git a/frontend/src/pages/QueueDetail.jsx b/frontend/src/pages/QueueDetail.jsx
index e1f8a1e3..3a6fc5cd 100644
--- a/frontend/src/pages/QueueDetail.jsx
+++ b/frontend/src/pages/QueueDetail.jsx
@@ -18,7 +18,11 @@ import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
-import { MetricCard, Pill } from '@/components/ds';
+import {
+ ColumnsMenu, DataTable, DataTableFooter, MetricCard, Pill, SortChipBar, SortMenu,
+} from '@/components/ds';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
const STATUS_KINDS = {
pending: 'blue',
@@ -54,6 +58,10 @@ const QueueDetail = () => {
const [selectedMessage, setSelectedMessage] = useState(null);
const [showSend, setShowSend] = useState(false);
const [sendForm, setSendForm] = useState({ payload: '{}', priority: 0, delay_ms: 0 });
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-queue-messages-sort' });
+ const {
+ hiddenKeys, toggleColumn, showAllColumns,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-queue-messages-cols' });
const pollRef = useRef(null);
@@ -156,6 +164,60 @@ const QueueDetail = () => {
}
};
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace, so _queue-operations.scss keeps applying
+ // (.queue-table, .col-actions, .queue-payload-preview, .queue-actions).
+ const columns = [
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ // Lifecycle order, not alphabet.
+ sortValue: (msg) => STATUS_ORDER.indexOf(msg.status),
+ render: (msg) => <Pill kind={STATUS_KINDS[msg.status] || 'gray'}>{msg.status}</Pill>,
+ },
+ {
+ key: 'payload',
+ header: 'Payload',
+ sortable: false,
+ render: (msg) => <code className="queue-payload-preview">{JSON.stringify(msg.payload).slice(0, 80)}</code>,
+ },
+ {
+ key: 'attempts',
+ header: 'Attempts',
+ sortable: true,
+ sortValue: (msg) => msg.attempts,
+ render: (msg) => <>{msg.attempts} / {msg.max_attempts}</>,
+ },
+ {
+ key: 'created',
+ header: 'Created',
+ sortable: true,
+ sortValue: (msg) => new Date(msg.created_at).getTime(),
+ render: (msg) => new Date(msg.created_at).toLocaleString(),
+ },
+ ...(!viewOnly ? [{
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ className: 'col-actions',
+ cellClassName: 'col-actions',
+ render: (msg) => (
+ <div className="queue-actions" onClick={e => e.stopPropagation()}>
+ {(msg.status === 'failed' || msg.status === 'dead_letter') && (
+ <Button variant="ghost" size="sm" onClick={() => handleRequeue(msg)} title="Requeue">
+ <RefreshCw size={14} />
+ </Button>
+ )}
+ <Button variant="ghost" size="sm" onClick={() => handleDelete(msg)} title="Delete message">
+ <Trash2 size={14} />
+ </Button>
+ </div>
+ ),
+ }] : []),
+ ];
+
if (loading) {
return (
<div className="queue-page queue-page--loading">
@@ -212,20 +274,33 @@ const QueueDetail = () => {
<div className={`queue-detail-body ${selectedMessage ? 'has-panel' : ''}`}>
<div className="queue-detail-main">
<div className="queue-messages-toolbar">
- <select
- className="queue-select"
- value={statusFilter}
- onChange={(e) => setStatusFilter(e.target.value)}
- >
- <option value="all">All statuses</option>
- {STATUS_ORDER.map(s => <option key={s} value={s}>{STATUS_LABELS[s]}</option>)}
- </select>
- <span className="queue-results-summary">
- <strong>{messages.length}</strong>
- <span>{messages.length === 1 ? 'message' : 'messages'}</span>
- </span>
+ <div className="queue-messages-selects">
+ <select
+ className="queue-select"
+ value={statusFilter}
+ onChange={(e) => setStatusFilter(e.target.value)}
+ >
+ <option value="all">All statuses</option>
+ {STATUS_ORDER.map(s => <option key={s} value={s}>{STATUS_LABELS[s]}</option>)}
+ </select>
+ </div>
+ <div className="queue-messages-actions">
+ <span className="queue-results-summary">
+ <strong>{messages.length}</strong>
+ <span>{messages.length === 1 ? 'message' : 'messages'}</span>
+ </span>
+ <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />
+ <ColumnsMenu
+ columns={columns}
+ hiddenKeys={hiddenKeys}
+ onToggle={toggleColumn}
+ onShowAll={showAllColumns}
+ />
+ </div>
</div>
+ <SortChipBar columns={columns} sorts={sorts} onChange={setSorts} />
+
{messages.length === 0 ? (
<EmptyState
icon={Inbox}
@@ -235,47 +310,25 @@ const QueueDetail = () => {
: 'This queue is empty. Send a message to get started.'}
/>
) : (
- <div className="queue-table-wrap">
- <table className="queue-table">
- <thead>
- <tr>
- <th>Status</th>
- <th>Payload</th>
- <th>Attempts</th>
- <th>Created</th>
- {!viewOnly && <th className="col-actions" aria-label="Actions" />}
- </tr>
- </thead>
- <tbody>
- {messages.map(msg => (
- <tr
- key={msg.id}
- className={`is-clickable ${selectedMessage?.id === msg.id ? 'is-selected' : ''}`}
- onClick={() => setSelectedMessage(msg)}
- >
- <td><Pill kind={STATUS_KINDS[msg.status] || 'gray'}>{msg.status}</Pill></td>
- <td><code className="queue-payload-preview">{JSON.stringify(msg.payload).slice(0, 80)}</code></td>
- <td>{msg.attempts} / {msg.max_attempts}</td>
- <td>{new Date(msg.created_at).toLocaleString()}</td>
- {!viewOnly && (
- <td className="col-actions" onClick={e => e.stopPropagation()}>
- <div className="queue-actions">
- {(msg.status === 'failed' || msg.status === 'dead_letter') && (
- <Button variant="ghost" size="sm" onClick={() => handleRequeue(msg)} title="Requeue">
- <RefreshCw size={14} />
- </Button>
- )}
- <Button variant="ghost" size="sm" onClick={() => handleDelete(msg)} title="Delete message">
- <Trash2 size={14} />
- </Button>
- </div>
- </td>
- )}
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <DataTable
+ columns={columns}
+ data={messages}
+ keyField="id"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ hiddenKeys={hiddenKeys}
+ onRowClick={(msg) => setSelectedMessage(msg)}
+ rowClassName={(msg) => (selectedMessage?.id === msg.id ? 'is-selected' : '')}
+ className="queue-table-wrap"
+ tableClassName="queue-table"
+ footer={(
+ <DataTableFooter
+ shown={messages.length}
+ total={messages.length}
+ noun="message"
+ />
+ )}
+ />
)}
</div>
diff --git a/frontend/src/pages/QueueOperations.jsx b/frontend/src/pages/QueueOperations.jsx
index c7f0f9b0..64e6803f 100644
--- a/frontend/src/pages/QueueOperations.jsx
+++ b/frontend/src/pages/QueueOperations.jsx
@@ -22,7 +22,11 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
-import { MetricCard, Pill } from '@/components/ds';
+import {
+ ColumnsMenu, DataTable, DataTableFooter, MetricCard, Pill, SortChipBar, SortMenu,
+} from '@/components/ds';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { formatCompact, formatFull } from '../utils/formatNumber';
const STATUS_KINDS = {
@@ -66,6 +70,10 @@ const QueueOperations = () => {
const [sendTarget, setSendTarget] = useState(null);
const [sendForm, setSendForm] = useState({ payload: '{}', priority: 0, delay_ms: 0 });
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-queue-ops-sort' });
+ const {
+ hiddenKeys, toggleColumn, showAllColumns,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-queue-ops-cols' });
const pollRef = useRef(null);
const navigate = useNavigate();
@@ -260,6 +268,88 @@ const QueueOperations = () => {
: `${STATUS_LABELS[messageFilter]} queues`;
const activeGroupLabel = activeGroup ? activeGroup.name : 'All groups';
+ // DataTable columns. Cell markup and classNames are identical to the
+ // hand-rolled table they replace, so _queue-operations.scss keeps applying
+ // (.queue-table, .queue-row-*, .queue-actions, .col-actions).
+ const columns = [
+ {
+ key: 'name',
+ header: 'Queue',
+ sortable: true,
+ hideable: false,
+ sortValue: (queue) => queue.name || queue.slug || '',
+ render: (queue) => (
+ <div className="queue-row-name">
+ <span className="queue-row-title">{queue.name}</span>
+ <code className="queue-row-sub">/{queue.slug}</code>
+ </div>
+ ),
+ },
+ {
+ key: 'group',
+ header: 'Group',
+ sortable: true,
+ sortValue: (queue) => queue.group_slug || null,
+ render: (queue) => (
+ queue.group_slug && (
+ <span className="queue-row-group">
+ <Folder size={12} /> {queue.group_slug}
+ </span>
+ )
+ ),
+ },
+ {
+ key: 'messages',
+ header: 'Messages',
+ sortable: true,
+ sortValue: (queue) => queue.stats?.total ?? 0,
+ render: (queue) => (
+ <div className="queue-row-counts" onClick={e => e.stopPropagation()}>
+ {STATUS_ORDER.filter(s => (queue.stats?.[s] || 0) > 0).map(status => (
+ <Pill key={status} kind={STATUS_KINDS[status]}>
+ {STATUS_LABELS[status]} {queue.stats[status]}
+ </Pill>
+ ))}
+ {(queue.stats?.total || 0) === 0 && (
+ <span className="muted">Empty</span>
+ )}
+ </div>
+ ),
+ },
+ {
+ key: 'created',
+ header: 'Created',
+ sortable: true,
+ sortValue: (queue) => new Date(queue.created_at).getTime(),
+ render: (queue) => new Date(queue.created_at).toLocaleString(),
+ },
+ {
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ className: 'col-actions',
+ cellClassName: 'col-actions',
+ render: (queue) => (
+ <div className="queue-actions" onClick={e => e.stopPropagation()}>
+ {!systemGroupSlugs.has(queue.group_slug) && (
+ <Button variant="ghost" size="sm" onClick={() => openSendModal(queue)} title="Send message">
+ <Send size={14} />
+ </Button>
+ )}
+ <Button variant="ghost" size="sm" onClick={() => openQueue(queue)} title="View messages">
+ <Inbox size={14} />
+ </Button>
+ {!systemGroupSlugs.has(queue.group_slug) && (
+ <Button variant="ghost" size="sm" onClick={() => handleDeleteQueue(queue)} title="Delete queue">
+ <Trash2 size={14} />
+ </Button>
+ )}
+ </div>
+ ),
+ },
+ ];
+
if (loading) {
return (
<div className="queue-page queue-page--loading">
@@ -392,6 +482,13 @@ const QueueOperations = () => {
<option value="">All groups</option>
{groups.map(g => <option key={g.id} value={g.slug}>{g.name}</option>)}
</select>
+ <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />
+ <ColumnsMenu
+ columns={columns}
+ hiddenKeys={hiddenKeys}
+ onToggle={toggleColumn}
+ onShowAll={showAllColumns}
+ />
</div>
<div className="queue-results-summary">
<strong>{filteredQueues.length}</strong>
@@ -412,6 +509,8 @@ const QueueOperations = () => {
</div>
</div>
+ <SortChipBar columns={columns} sorts={sorts} onChange={setSorts} />
+
{filteredQueues.length === 0 ? (
<EmptyState
icon={Layers}
@@ -434,72 +533,24 @@ const QueueOperations = () => {
)}
/>
) : (
- <div className="queue-table-wrap">
- <table className="queue-table">
- <thead>
- <tr>
- <th>Queue</th>
- <th>Group</th>
- <th>Messages</th>
- <th>Created</th>
- <th className="col-actions" aria-label="Actions" />
- </tr>
- </thead>
- <tbody>
- {filteredQueues.map(queue => (
- <tr
- key={queue.id}
- className="is-clickable"
- onClick={() => openQueue(queue)}
- >
- <td>
- <div className="queue-row-name">
- <span className="queue-row-title">{queue.name}</span>
- <code className="queue-row-sub">/{queue.slug}</code>
- </div>
- </td>
- <td>
- {queue.group_slug && (
- <span className="queue-row-group">
- <Folder size={12} /> {queue.group_slug}
- </span>
- )}
- </td>
- <td onClick={e => e.stopPropagation()}>
- <div className="queue-row-counts">
- {STATUS_ORDER.filter(s => (queue.stats?.[s] || 0) > 0).map(status => (
- <Pill key={status} kind={STATUS_KINDS[status]}>
- {STATUS_LABELS[status]} {queue.stats[status]}
- </Pill>
- ))}
- {(queue.stats?.total || 0) === 0 && (
- <span className="muted">Empty</span>
- )}
- </div>
- </td>
- <td>{new Date(queue.created_at).toLocaleString()}</td>
- <td className="col-actions" onClick={e => e.stopPropagation()}>
- <div className="queue-actions">
- {!systemGroupSlugs.has(queue.group_slug) && (
- <Button variant="ghost" size="sm" onClick={() => openSendModal(queue)} title="Send message">
- <Send size={14} />
- </Button>
- )}
- <Button variant="ghost" size="sm" onClick={() => openQueue(queue)} title="View messages">
- <Inbox size={14} />
- </Button>
- {!systemGroupSlugs.has(queue.group_slug) && (
- <Button variant="ghost" size="sm" onClick={() => handleDeleteQueue(queue)} title="Delete queue">
- <Trash2 size={14} />
- </Button>
- )}
- </div>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <DataTable
+ columns={columns}
+ data={filteredQueues}
+ keyField="id"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ hiddenKeys={hiddenKeys}
+ onRowClick={(queue) => openQueue(queue)}
+ className="queue-table-wrap"
+ tableClassName="queue-table"
+ footer={(
+ <DataTableFooter
+ shown={filteredQueues.length}
+ total={queues.length}
+ noun="queue"
+ />
+ )}
+ />
)}
</main>
</div>
diff --git a/frontend/src/styles/pages/_docker.scss b/frontend/src/styles/pages/_docker.scss
index 4d91614c..be75a8f3 100644
--- a/frontend/src/styles/pages/_docker.scss
+++ b/frontend/src/styles/pages/_docker.scss
@@ -2006,35 +2006,6 @@
margin-left: auto;
}
-.dx-sort-control {
- display: inline-flex;
- align-items: center;
- gap: $space-1;
-
- span {
- color: $text-tertiary;
- font-size: $font-size-xs;
- font-weight: $font-weight-semibold;
- }
-
- select {
- height: 32px;
- min-width: 108px;
- padding: 0 $space-6 0 $space-2;
- border: 1px solid $border-default;
- border-radius: $radius-md;
- background: $bg-elevated;
- color: $text-primary;
- font-size: $font-size-xs;
- outline: none;
-
- &:focus {
- border-color: $accent-primary;
- box-shadow: 0 0 0 2px $accent-glow;
- }
- }
-}
-
.dx-manager-layout {
grid-template-columns: minmax(0, 1fr);
gap: 0;