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.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
refactor(security): move all security tab tables onto DataTable
Juan Denis249546720aa5
diff --git a/frontend/src/components/security/Fail2banTab.jsx b/frontend/src/components/security/Fail2banTab.jsxindex df05b61c..56f8b85f 100644--- a/frontend/src/components/security/Fail2banTab.jsx+++ b/frontend/src/components/security/Fail2banTab.jsx@@ -7,7 +7,9 @@ import Modal from '../Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';-import { Pill } from '@/components/ds';+import { ColumnsMenu, DataTable, DataTableFooter, Pill, SortMenu } from '@/components/ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';const Fail2banTab = () => {@@ -21,6 +23,10 @@ const Fail2banTab = () => {const [banJail, setBanJail] = useState('sshd');const [confirmDialog, setConfirmDialog] = useState(null);const toast = useToast();+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-fail2ban-bans-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-fail2ban-bans-cols' });useEffect(() => {loadData();@@ -110,6 +116,37 @@ const Fail2banTab = () => {return <div className="loading-sm">Loading Fail2ban status...</div>;}+ // Cell markup/classNames identical to the hand-rolled table they replace.+ const banColumns = [+ {+ key: 'ip',+ header: 'IP Address',+ sortable: true,+ hideable: false,+ sortValue: (ban) => ban.ip || '',+ cellClassName: 'sk-cell-mono sec-ip--red',+ render: (ban) => ban.ip,+ },+ {+ key: 'jail',+ header: 'Jail',+ sortable: true,+ sortValue: (ban) => ban.jail || '',+ render: (ban) => <span className="sk-tag">{ban.jail}</span>,+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ render: (ban) => (+ <Button variant="secondary" size="sm" onClick={() => handleUnban(ban.ip, ban.jail)}>+ Unban+ </Button>+ ),+ },+ ];+return (<div className="fail2ban-tab">{!status?.installed ? (@@ -199,34 +236,36 @@ const Fail2banTab = () => {<div className="card sec-flush"><div className="card-header"><h3>Banned IPs {bans.length > 0 && <span className="sec-count">· {bans.length}</span>}</h3>+ <div className="sec-tableactions">+ <SortMenu columns={banColumns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={banColumns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ />+ </div></div>{bans.length === 0 ? (<div className="card-body"><p className="text-muted">No IPs are currently banned.</p></div>) : (- <table className="sk-dtable">- <thead>- <tr>- <th>IP Address</th>- <th>Jail</th>- <th>Actions</th>- </tr>- </thead>- <tbody>- {bans.map((ban, index) => (- <tr key={index}>- <td className="sk-cell-mono sec-ip--red">{ban.ip}</td>- <td><span className="sk-tag">{ban.jail}</span></td>- <td>- <Button variant="secondary" size="sm" onClick={() => handleUnban(ban.ip, ban.jail)}>- Unban- </Button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={banColumns}+ data={bans}+ keyField={(ban) => `${ban.ip}-${ban.jail}`}+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ footer={(+ <DataTableFooter+ shown={bans.length}+ total={bans.length}+ noun="banned IP"+ />+ )}+ />)}</div></>diff --git a/frontend/src/components/security/FirewallTab.jsx b/frontend/src/components/security/FirewallTab.jsxindex 94c60348..9bae1692 100644--- a/frontend/src/components/security/FirewallTab.jsx+++ b/frontend/src/components/security/FirewallTab.jsx@@ -7,7 +7,9 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Switch } from '@/components/ui/switch';-import { Pill, SegControl } from '@/components/ds';+import { ColumnsMenu, DataTable, DataTableFooter, Pill, SegControl, SortMenu } from '@/components/ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { Shield } from 'lucide-react';import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';@@ -34,6 +36,10 @@ const FirewallTab = () => {const [guard, setGuard] = useState(null);const [guardLoading, setGuardLoading] = useState(false);const toast = useToast();+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-firewall-rules-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-firewall-rules-cols' });const commonPorts = [{ port: 22, name: 'SSH', protocol: 'tcp' },@@ -252,6 +258,57 @@ const FirewallTab = () => {const isActive = status?.any_active;const activeFirewall = status?.active_firewall;+ // Cell markup/classNames are identical to the hand-rolled table they+ // replace, so _security.scss keeps applying (.sec-state, .sec-rich-rule…).+ const ruleColumns = [+ {+ key: 'type',+ header: 'Type',+ sortable: true,+ sortValue: (rule) => rule.type || '',+ render: (rule) => (+ <span className={`sec-state sec-state--${RULE_TYPE_TONES[rule.type] || 'gray'}`}>+ {rule.type}+ </span>+ ),+ },+ {+ key: 'target',+ header: 'Target',+ sortable: true,+ sortValue: (rule) => rule.service || rule.port || rule.rule || '',+ cellClassName: 'sk-cell-mono',+ render: (rule) => (+ <>+ {rule.type === 'service' && rule.service}+ {rule.type === 'port' && rule.port}+ {rule.type === 'rich' && <span className="sec-rich-rule">{rule.rule}</span>}+ </>+ ),+ },+ {+ key: 'protocol',+ header: 'Protocol',+ sortable: true,+ sortValue: (rule) => rule.protocol || '',+ cellClassName: 'sk-cell-mono sec-proto',+ render: (rule) => rule.protocol || '-',+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ render: (rule) => (+ rule.type === 'port' && (+ <Button variant="destructive" size="sm" onClick={() => handleRemovePort(rule.port, rule.protocol)}>+ Remove+ </Button>+ )+ ),+ },+ ];+if (loading) {return <div className="loading-sm">Loading firewall status...</div>;}@@ -360,47 +417,37 @@ const FirewallTab = () => {<div className="card sec-flush"><div className="card-header"><h3>Firewall Rules</h3>- <Button variant="default" size="sm" onClick={() => setShowPortModal(true)}>Add Rule</Button>+ <div className="sec-tableactions">+ <SortMenu columns={ruleColumns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={ruleColumns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ />+ <Button variant="default" size="sm" onClick={() => setShowPortModal(true)}>Add Rule</Button>+ </div></div>{rules.length === 0 ? (<div className="card-body"><p className="text-muted">No rules configured</p></div>) : (- <table className="sk-dtable">- <thead>- <tr>- <th>Type</th>- <th>Target</th>- <th>Protocol</th>- <th>Actions</th>- </tr>- </thead>- <tbody>- {rules.map((rule, index) => (- <tr key={index}>- <td>- <span className={`sec-state sec-state--${RULE_TYPE_TONES[rule.type] || 'gray'}`}>- {rule.type}- </span>- </td>- <td className="sk-cell-mono">- {rule.type === 'service' && rule.service}- {rule.type === 'port' && rule.port}- {rule.type === 'rich' && <span className="sec-rich-rule">{rule.rule}</span>}- </td>- <td className="sk-cell-mono sec-proto">{rule.protocol || '-'}</td>- <td>- {rule.type === 'port' && (- <Button variant="destructive" size="sm" onClick={() => handleRemovePort(rule.port, rule.protocol)}>- Remove- </Button>- )}- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={ruleColumns}+ data={rules}+ keyField={(rule) => `${rule.type}-${rule.service || rule.port || rule.rule}-${rule.protocol || ''}`}+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ footer={(+ <DataTableFooter+ shown={rules.length}+ total={rules.length}+ noun="rule"+ />+ )}+ />)}</div>)}diff --git a/frontend/src/components/security/IPListsTab.jsx b/frontend/src/components/security/IPListsTab.jsxindex 21997240..da488fd0 100644--- a/frontend/src/components/security/IPListsTab.jsx+++ b/frontend/src/components/security/IPListsTab.jsx@@ -6,6 +6,9 @@ import Modal from '../Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';+import { ColumnsMenu, DataTable, DataTableFooter, SortMenu } from '@/components/ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';const IPListsTab = () => {const [lists, setLists] = useState({ allowlist: [], blocklist: [] });@@ -16,6 +19,11 @@ const IPListsTab = () => {const [actionLoading, setActionLoading] = useState(false);const [confirmDialog, setConfirmDialog] = useState(null);const toast = useToast();+ // Each list is its own table with its own persisted sort/columns state.+ const allowSorts = useTableSort({ storageKey: 'serverkit-table-ip-allowlist-sort' });+ const allowCols = useColumnVisibility({ storageKey: 'serverkit-table-ip-allowlist-cols' });+ const blockSorts = useTableSort({ storageKey: 'serverkit-table-ip-blocklist-sort' });+ const blockCols = useColumnVisibility({ storageKey: 'serverkit-table-ip-blocklist-cols' });useEffect(() => {loadLists();@@ -73,48 +81,92 @@ const IPListsTab = () => {});};- const renderList = (title, listType, items, tone) => (+ // Cell markup/classNames identical to the hand-rolled table they replace.+ const renderList = (title, listType, items, tone, sortState, colState) => {+ const columns = [+ {+ key: 'ip',+ header: 'IP / CIDR',+ sortable: true,+ hideable: false,+ sortValue: (item) => item.ip || '',+ cellClassName: `sk-cell-mono sec-ip--${tone}`,+ render: (item) => item.ip,+ },+ {+ key: 'comment',+ header: 'Comment',+ sortable: true,+ sortValue: (item) => item.comment || '',+ render: (item) => item.comment || <span className="sec-dash">—</span>,+ },+ {+ key: 'added',+ header: 'Added',+ sortable: true,+ sortValue: (item) => {+ const t = new Date(item.added_at).getTime();+ return Number.isNaN(t) ? null : t;+ },+ cellClassName: 'sk-cell-mono sec-faint',+ render: (item) => new Date(item.added_at).toLocaleDateString(),+ },+ {+ key: 'actions',+ header: '',+ sortable: false,+ hideable: false,+ cellClassName: 'sec-rowend',+ render: (item) => (+ <Button variant="destructive" size="sm" onClick={() => handleRemove(item.ip, listType)}>+ Remove+ </Button>+ ),+ },+ ];+ return (<div className="card sec-flush"><div className="card-header"><h3 className={`sec-listtitle sec-listtitle--${tone}`}>{title} <span className="sec-count">· {items.length}</span></h3>- <Button variant="default" size="sm" onClick={() => setShowAddModal(listType)}>- Add IP- </Button>+ <div className="sec-tableactions">+ <SortMenu columns={columns} sorts={sortState.sorts} onChange={sortState.setSorts} />+ <ColumnsMenu+ columns={columns}+ hiddenKeys={colState.hiddenKeys}+ onToggle={colState.toggleColumn}+ onShowAll={colState.showAllColumns}+ />+ <Button variant="default" size="sm" onClick={() => setShowAddModal(listType)}>+ Add IP+ </Button>+ </div></div>{items.length === 0 ? (<div className="card-body"><p className="text-muted">No IPs in {listType}.</p></div>) : (- <table className="sk-dtable">- <thead>- <tr>- <th>IP / CIDR</th>- <th>Comment</th>- <th>Added</th>- <th></th>- </tr>- </thead>- <tbody>- {items.map((item, index) => (- <tr key={index}>- <td className={`sk-cell-mono sec-ip--${tone}`}>{item.ip}</td>- <td>{item.comment || <span className="sec-dash">—</span>}</td>- <td className="sk-cell-mono sec-faint">{new Date(item.added_at).toLocaleDateString()}</td>- <td className="sec-rowend">- <Button variant="destructive" size="sm" onClick={() => handleRemove(item.ip, listType)}>- Remove- </Button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={columns}+ data={items}+ keyField={(item) => item.ip}+ sorts={sortState.sorts}+ onSortsChange={sortState.setSorts}+ hiddenKeys={colState.hiddenKeys}+ footer={(+ <DataTableFooter+ shown={items.length}+ total={items.length}+ noun="entry"+ />+ )}+ />)}</div>- );+ );+ };if (loading) {return <div className="loading-sm">Loading IP lists...</div>;@@ -123,8 +175,8 @@ const IPListsTab = () => {return (<div className="ip-lists-tab"><div className="ip-lists-grid">- {renderList('Allowlist', 'allowlist', lists.allowlist, 'green')}- {renderList('Blocklist', 'blocklist', lists.blocklist, 'red')}+ {renderList('Allowlist', 'allowlist', lists.allowlist, 'green', allowSorts, allowCols)}+ {renderList('Blocklist', 'blocklist', lists.blocklist, 'red', blockSorts, blockCols)}</div><Modal open={!!showAddModal} onClose={() => setShowAddModal(null)} title={`Add to ${showAddModal || ''}`}>diff --git a/frontend/src/components/security/IntegrityTab.jsx b/frontend/src/components/security/IntegrityTab.jsxindex 9bc9aa48..34f50dc3 100644--- a/frontend/src/components/security/IntegrityTab.jsx+++ b/frontend/src/components/security/IntegrityTab.jsx@@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from 'react';import api from '../../services/api';import { Button } from '@/components/ui/button';import { Switch } from '@/components/ui/switch';+import { DataTable, DataTableFooter } from '@/components/ds';// Scoped file-integrity monitoring: baseline-and-diff over the paths// ServerKit manages (nginx configs, serverkit-owned systemd units, and@@ -116,42 +117,55 @@ const IntegrityTab = () => {})),];const shown = rows.slice(0, 200);+ // Cell markup/classNames identical to the hand-rolled table they+ // replace. The old "… and N more" truncation row is now the standard+ // DataTableFooter count ("Shown 200 of N changes").+ const columns = [+ {+ key: 'change',+ header: 'Change',+ sortable: true,+ sortValue: (row) => row.kind,+ render: (row) => <span className={`sec-state sec-state--${row.tone}`}>{row.kind}</span>,+ },+ {+ key: 'path',+ header: 'Path',+ sortable: true,+ sortValue: (row) => row.path,+ cellClassName: 'sk-cell-mono sec-path',+ render: (row) => row.path,+ },+ {+ key: 'what',+ header: 'What changed',+ render: (row) => (+ row.what ? (+ <span className="sec-what">+ {row.what.map((w) => (+ <span key={w} className="sec-state sec-state--gray">{w}</span>+ ))}+ </span>+ ) : (+ <span className="sec-dash">—</span>+ )+ ),+ },+ ];return (- <table className="sk-dtable">- <thead>- <tr>- <th>Change</th>- <th>Path</th>- <th>What changed</th>- </tr>- </thead>- <tbody>- {shown.map((row, i) => (- <tr key={i}>- <td><span className={`sec-state sec-state--${row.tone}`}>{row.kind}</span></td>- <td className="sk-cell-mono sec-path">{row.path}</td>- <td>- {row.what ? (- <span className="sec-what">- {row.what.map((w) => (- <span key={w} className="sec-state sec-state--gray">{w}</span>- ))}- </span>- ) : (- <span className="sec-dash">—</span>- )}- </td>- </tr>- ))}- {rows.length > shown.length && (- <tr>- <td colSpan={3} className="sk-cell-mono sec-faint">- … and {rows.length - shown.length} more- </td>- </tr>- )}- </tbody>- </table>+ <DataTable+ columns={columns}+ data={shown}+ keyField={(row) => `${row.kind}:${row.path}`}+ storageKey="serverkit-table-integrity-changes"+ footer={(+ <DataTableFooter+ shown={shown.length}+ total={rows.length}+ noun="change"+ />+ )}+ />);}diff --git a/frontend/src/components/security/QuarantineTab.jsx b/frontend/src/components/security/QuarantineTab.jsxindex 335e561e..cb03763b 100644--- a/frontend/src/components/security/QuarantineTab.jsx+++ b/frontend/src/components/security/QuarantineTab.jsx@@ -1,12 +1,19 @@import { useState, useEffect } from 'react';import api from '../../services/api';import { Button } from '@/components/ui/button';+import { ColumnsMenu, DataTable, DataTableFooter, SortMenu } from '@/components/ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { formatBytes } from '@/utils/formatBytes';const QuarantineTab = () => {const [files, setFiles] = useState([]);const [loading, setLoading] = useState(true);const [message, setMessage] = useState(null);+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-quarantine-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-quarantine-cols' });useEffect(() => {loadFiles();@@ -48,6 +55,76 @@ const QuarantineTab = () => {}}+ // Cell markup/classNames identical to the hand-rolled table they replace.+ const columns = [+ {+ key: 'filename',+ header: 'Filename',+ sortable: true,+ hideable: false,+ sortValue: (file) => file.name || '',+ cellClassName: 'sk-cell-mono sec-path sec-path--red',+ render: (file) => file.name,+ },+ {+ key: 'original',+ header: 'Original Location',+ sortable: true,+ sortValue: (file) => file.original_path || '',+ cellClassName: 'sk-cell-mono sec-path sec-faint',+ render: (file) => (+ <span title={file.original_path || ''}>+ {file.original_path || '—'}+ </span>+ ),+ },+ {+ key: 'size',+ header: 'Size',+ sortable: true,+ sortValue: (file) => (file.size == null ? null : Number(file.size)),+ cellClassName: 'sk-cell-mono',+ render: (file) => formatBytes(file.size, { defaultValue: '0 B' }),+ },+ {+ key: 'quarantined',+ header: 'Quarantined',+ sortable: true,+ sortValue: (file) => {+ const t = new Date(file.quarantined_at).getTime();+ return Number.isNaN(t) ? null : t;+ },+ cellClassName: 'sk-cell-mono sec-faint',+ render: (file) => new Date(file.quarantined_at).toLocaleString(),+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ render: (file) => (+ <div className="quarantine-actions">+ <Button+ variant="outline"+ size="sm"+ onClick={() => handleRestore(file)}+ disabled={!file.original_path}+ title={file.original_path ? 'Restore to original location' : 'Original location unknown'}+ >+ Restore+ </Button>+ <Button+ variant="destructive"+ size="sm"+ onClick={() => handleDelete(file.name)}+ >+ Delete+ </Button>+ </div>+ ),+ },+ ];+return (<div className="quarantine-tab">{message && (@@ -59,7 +136,16 @@ const QuarantineTab = () => {<div className="card sec-flush"><div className="card-header"><h3>Quarantined Files {!loading && files.length > 0 && <span className="sec-count">· {files.length}</span>}</h3>- <Button variant="outline" size="sm" onClick={loadFiles}>Refresh</Button>+ <div className="sec-tableactions">+ <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={columns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ />+ <Button variant="outline" size="sm" onClick={loadFiles}>Refresh</Button>+ </div></div>{loading ? (<div className="card-body">@@ -77,49 +163,21 @@ const QuarantineTab = () => {</div></div>) : (- <table className="sk-dtable">- <thead>- <tr>- <th>Filename</th>- <th>Original Location</th>- <th>Size</th>- <th>Quarantined</th>- <th>Actions</th>- </tr>- </thead>- <tbody>- {files.map((file, index) => (- <tr key={index}>- <td className="sk-cell-mono sec-path sec-path--red">{file.name}</td>- <td className="sk-cell-mono sec-path sec-faint" title={file.original_path || ''}>- {file.original_path || '—'}- </td>- <td className="sk-cell-mono">{formatBytes(file.size, { defaultValue: '0 B' })}</td>- <td className="sk-cell-mono sec-faint">{new Date(file.quarantined_at).toLocaleString()}</td>- <td>- <div className="quarantine-actions">- <Button- variant="outline"- size="sm"- onClick={() => handleRestore(file)}- disabled={!file.original_path}- title={file.original_path ? 'Restore to original location' : 'Original location unknown'}- >- Restore- </Button>- <Button- variant="destructive"- size="sm"- onClick={() => handleDelete(file.name)}- >- Delete- </Button>- </div>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={columns}+ data={files}+ keyField="name"+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ footer={(+ <DataTableFooter+ shown={files.length}+ total={files.length}+ noun="file"+ />+ )}+ />)}</div></div>diff --git a/frontend/src/components/security/SSHKeysTab.jsx b/frontend/src/components/security/SSHKeysTab.jsxindex 9105430d..67ff0cef 100644--- a/frontend/src/components/security/SSHKeysTab.jsx+++ b/frontend/src/components/security/SSHKeysTab.jsx@@ -6,6 +6,9 @@ import Modal from '../Modal';import { Button } from '@/components/ui/button';import { Textarea } from '@/components/ui/textarea';import { Label } from '@/components/ui/label';+import { ColumnsMenu, DataTable, DataTableFooter, SortMenu } from '@/components/ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';const SSHKeysTab = () => {const [keys, setKeys] = useState([]);@@ -15,6 +18,10 @@ const SSHKeysTab = () => {const [actionLoading, setActionLoading] = useState(false);const [confirmDialog, setConfirmDialog] = useState(null);const toast = useToast();+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-ssh-keys-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-ssh-keys-cols' });useEffect(() => {loadKeys();@@ -68,12 +75,57 @@ const SSHKeysTab = () => {});};+ // Cell markup/classNames identical to the hand-rolled table they replace.+ const columns = [+ {+ key: 'type',+ header: 'Type',+ sortable: true,+ sortValue: (key) => key.type || '',+ render: (key) => <span className="sk-tag">{key.type}</span>,+ },+ {+ key: 'fingerprint',+ header: 'Fingerprint',+ sortable: true,+ hideable: false,+ sortValue: (key) => key.fingerprint || '',+ cellClassName: 'sk-cell-mono sec-fp',+ render: (key) => key.fingerprint,+ },+ {+ key: 'comment',+ header: 'Comment',+ sortable: true,+ sortValue: (key) => key.comment || '',+ render: (key) => key.comment || <span className="sec-dash">—</span>,+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ render: (key) => (+ <Button variant="destructive" size="sm" onClick={() => handleRemoveKey(key.id, key.comment)}>+ Remove+ </Button>+ ),+ },+ ];+return (<div className="ssh-keys-tab"><div className="card sec-flush"><div className="card-header"><h3>SSH Authorized Keys {!loading && keys.length > 0 && <span className="sec-count">· {keys.length}</span>}</h3><div className="card-actions">+ <SortMenu columns={columns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={columns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ /><Button variant="default" size="sm" onClick={() => setShowAddModal(true)}>Add Key</Button>@@ -96,30 +148,21 @@ const SSHKeysTab = () => {</div></div>) : (- <table className="sk-dtable">- <thead>- <tr>- <th>Type</th>- <th>Fingerprint</th>- <th>Comment</th>- <th>Actions</th>- </tr>- </thead>- <tbody>- {keys.map((key) => (- <tr key={key.id}>- <td><span className="sk-tag">{key.type}</span></td>- <td className="sk-cell-mono sec-fp">{key.fingerprint}</td>- <td>{key.comment || <span className="sec-dash">—</span>}</td>- <td>- <Button variant="destructive" size="sm" onClick={() => handleRemoveKey(key.id, key.comment)}>- Remove- </Button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={columns}+ data={keys}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ footer={(+ <DataTableFooter+ shown={keys.length}+ total={keys.length}+ noun="key"+ />+ )}+ />)}</div>diff --git a/frontend/src/components/security/ScannerTab.jsx b/frontend/src/components/security/ScannerTab.jsxindex f869e5f2..25494e9e 100644--- a/frontend/src/components/security/ScannerTab.jsx+++ b/frontend/src/components/security/ScannerTab.jsx@@ -2,7 +2,9 @@ import { useState, useEffect, useRef } from 'react';import api from '../../services/api';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';-import { Pill } from '@/components/ds';+import { ColumnsMenu, DataTable, DataTableFooter, Pill, SortMenu } from '@/components/ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { Zap, Radar, FolderSearch, Download, Box, ShieldAlert, FileCode2, Trash2 } from 'lucide-react';const SEVERITY_TONE = {@@ -29,6 +31,11 @@ const ScannerTab = () => {// Findings (YARA + ClamAV) from the last completed job/scanconst [findings, setFindings] = useState([]);const [quarantining, setQuarantining] = useState(null);+ // Per-table sort + column visibility (persisted, mirrored by header menus)+ const findingsSorts = useTableSort({ storageKey: 'serverkit-table-scanner-findings-sort' });+ const findingsCols = useColumnVisibility({ storageKey: 'serverkit-table-scanner-findings-cols' });+ const historySorts = useTableSort({ storageKey: 'serverkit-table-scanner-history-sort' });+ const historyCols = useColumnVisibility({ storageKey: 'serverkit-table-scanner-history-cols' });// YARA rules managerconst [rules, setRules] = useState(null);@@ -228,6 +235,115 @@ const ScannerTab = () => {const isScanning = scanStatus.status === 'running';const jobRunning = scanJob && ['pending', 'running'].includes(scanJob.status);+ // Cell markup/classNames identical to the hand-rolled tables they replace.+ const findingColumns = [+ {+ key: 'rule',+ header: 'Rule',+ sortable: true,+ hideable: false,+ sortValue: (f) => f.rule || '',+ cellClassName: 'sk-cell-mono',+ render: (f) => <span title={f.description}>{f.rule}</span>,+ },+ {+ key: 'severity',+ header: 'Severity',+ sortable: true,+ sortValue: (f) => f.severity || '',+ render: (f) => (+ <span className={`sec-state sec-state--${SEVERITY_TONE[f.severity] || 'gray'}`}>+ {f.severity}+ </span>+ ),+ },+ {+ key: 'file',+ header: 'File',+ sortable: true,+ sortValue: (f) => f.file || '',+ cellClassName: 'sk-cell-mono sec-path sec-path--red',+ render: (f) => <span title={f.file}>{f.file}</span>,+ },+ {+ key: 'match',+ header: 'Match',+ cellClassName: 'sk-cell-mono scan-snippet',+ render: (f) => f.matched || '—',+ },+ {+ key: 'source',+ header: 'Source',+ sortable: true,+ sortValue: (f) => f.source || '',+ render: (f) => <span className="sec-state sec-state--gray">{f.source}</span>,+ },+ {+ key: 'actions',+ header: '',+ sortable: false,+ hideable: false,+ cellClassName: 'sec-rowend',+ render: (f) => (+ <Button+ variant="destructive"+ size="sm"+ onClick={() => handleQuarantine(f)}+ disabled={quarantining === f.file}+ >+ {quarantining === f.file ? 'Moving…' : 'Quarantine'}+ </Button>+ ),+ },+ ];++ const historyColumns = [+ {+ key: 'date',+ header: 'Date',+ sortable: true,+ hideable: false,+ sortValue: (scan) => {+ const t = new Date(scan.started_at).getTime();+ return Number.isNaN(t) ? null : t;+ },+ cellClassName: 'sk-cell-mono sec-faint',+ render: (scan) => new Date(scan.started_at).toLocaleString(),+ },+ {+ key: 'directory',+ header: 'Directory',+ sortable: true,+ sortValue: (scan) => scan.directory || '',+ cellClassName: 'sk-cell-mono sec-path',+ render: (scan) => scan.directory,+ },+ {+ key: 'status',+ header: 'Status',+ sortable: true,+ sortValue: (scan) => scan.status || '',+ render: (scan) => (+ <Pill kind={scan.status === 'completed' ? 'green' : scan.status === 'error' ? 'red' : 'amber'}>+ {scan.status}+ </Pill>+ ),+ },+ {+ key: 'threats',+ header: 'Threats',+ sortable: true,+ sortValue: (scan) => scan.infected_files?.length ?? 0,+ render: (scan) => (+ scan.infected_files?.length > 0 ? (+ <span className="sec-state sec-state--red">{scan.infected_files.length} found</span>+ ) : (+ <span className="sec-state sec-state--green">clean</span>+ )+ ),+ },+ ];+return (<div className="scanner-tab">{message && (@@ -426,52 +542,48 @@ const ScannerTab = () => {<ShieldAlert size={13} />Findings <span className="sec-count">· {findings.length}</span></h3>- <Button variant="outline" size="sm" onClick={() => setFindings([])}>Dismiss</Button>+ <div className="sec-tableactions">+ <SortMenu columns={findingColumns} sorts={findingsSorts.sorts} onChange={findingsSorts.setSorts} />+ <ColumnsMenu+ columns={findingColumns}+ hiddenKeys={findingsCols.hiddenKeys}+ onToggle={findingsCols.toggleColumn}+ onShowAll={findingsCols.showAllColumns}+ />+ <Button variant="outline" size="sm" onClick={() => setFindings([])}>Dismiss</Button>+ </div></div>- <table className="sk-dtable">- <thead>- <tr>- <th>Rule</th>- <th>Severity</th>- <th>File</th>- <th>Match</th>- <th>Source</th>- <th></th>- </tr>- </thead>- <tbody>- {findings.map((f, index) => (- <tr key={`${f.file}-${f.rule}-${index}`}>- <td className="sk-cell-mono" title={f.description}>{f.rule}</td>- <td>- <span className={`sec-state sec-state--${SEVERITY_TONE[f.severity] || 'gray'}`}>- {f.severity}- </span>- </td>- <td className="sk-cell-mono sec-path sec-path--red" title={f.file}>{f.file}</td>- <td className="sk-cell-mono scan-snippet">{f.matched || '—'}</td>- <td><span className="sec-state sec-state--gray">{f.source}</span></td>- <td className="sec-rowend">- <Button- variant="destructive"- size="sm"- onClick={() => handleQuarantine(f)}- disabled={quarantining === f.file}- >- {quarantining === f.file ? 'Moving…' : 'Quarantine'}- </Button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={findingColumns}+ data={findings}+ keyField={(f) => `${f.file}-${f.rule}-${f.source}`}+ sorts={findingsSorts.sorts}+ onSortsChange={findingsSorts.setSorts}+ hiddenKeys={findingsCols.hiddenKeys}+ footer={(+ <DataTableFooter+ shown={findings.length}+ total={findings.length}+ noun="finding"+ />+ )}+ /></div>)}<div className="card sec-flush"><div className="card-header"><h3>Scan History</h3>- <Button variant="outline" size="sm" onClick={loadHistory}>Refresh</Button>+ <div className="sec-tableactions">+ <SortMenu columns={historyColumns} sorts={historySorts.sorts} onChange={historySorts.setSorts} />+ <ColumnsMenu+ columns={historyColumns}+ hiddenKeys={historyCols.hiddenKeys}+ onToggle={historyCols.toggleColumn}+ onShowAll={historyCols.showAllColumns}+ />+ <Button variant="outline" size="sm" onClick={loadHistory}>Refresh</Button>+ </div></div>{history.length === 0 ? (<div className="card-body">@@ -484,36 +596,21 @@ const ScannerTab = () => {</div></div>) : (- <table className="sk-dtable">- <thead>- <tr>- <th>Date</th>- <th>Directory</th>- <th>Status</th>- <th>Threats</th>- </tr>- </thead>- <tbody>- {history.map((scan, index) => (- <tr key={index}>- <td className="sk-cell-mono sec-faint">{new Date(scan.started_at).toLocaleString()}</td>- <td className="sk-cell-mono sec-path">{scan.directory}</td>- <td>- <Pill kind={scan.status === 'completed' ? 'green' : scan.status === 'error' ? 'red' : 'amber'}>- {scan.status}- </Pill>- </td>- <td>- {scan.infected_files?.length > 0 ? (- <span className="sec-state sec-state--red">{scan.infected_files.length} found</span>- ) : (- <span className="sec-state sec-state--green">clean</span>- )}- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={historyColumns}+ data={history}+ keyField={(scan) => `${scan.started_at}-${scan.directory}`}+ sorts={historySorts.sorts}+ onSortsChange={historySorts.setSorts}+ hiddenKeys={historyCols.hiddenKeys}+ footer={(+ <DataTableFooter+ shown={history.length}+ total={history.length}+ noun="scan"+ />+ )}+ />)}</div></div>diff --git a/frontend/src/styles/pages/_security.scss b/frontend/src/styles/pages/_security.scssindex 335e0c29..2881cfb7 100644--- a/frontend/src/styles/pages/_security.scss+++ b/frontend/src/styles/pages/_security.scss@@ -58,6 +58,15 @@gap: $space-2;}+ // Right-end cluster in a table card header (sort/columns menus + actions).+ // Same layout as .card-actions but outside the legacy `card*` namespace the+ // ESLint no-restricted-syntax rule flags on new markup.+ .sec-tableactions {+ display: flex;+ align-items: center;+ gap: $space-2;+ }+// ── shared page atoms ───────────────────────────────────// Count suffix inside an eyebrow heading ("Banned IPs · 4").sec-count {