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(serverdetail): move server-detail tab tables onto DataTable
Juan Denis65703c165db0
diff --git a/frontend/src/components/serverdetail/CloudflaredTab.jsx b/frontend/src/components/serverdetail/CloudflaredTab.jsxindex 1dd72d29..b7344f7c 100644--- a/frontend/src/components/serverdetail/CloudflaredTab.jsx+++ b/frontend/src/components/serverdetail/CloudflaredTab.jsx@@ -4,7 +4,9 @@ import { useToast } from '../../contexts/ToastContext';import { useConfirm } from '../../hooks/useConfirm';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';-import { Pill } from '../ds';+import { ColumnsMenu, DataTable, DataTableFooter, Pill, SortMenu } from '../ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import EmptyState from '../EmptyState';import { Cloud } from 'lucide-react';import {@@ -50,6 +52,11 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {// Login flow: { channel, authUrl, status: 'starting'|'awaiting'|'done'|'error', error, certPath }const [login, setLogin] = useState(null);+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-sd-cloudflared-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-sd-cloudflared-cols' });+const loadStatus = useCallback(async () => {try {const s = await api.getRemoteCloudflaredStatus(serverId);@@ -222,6 +229,59 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {const notInstalled = status?.available === false;const notAuthed = status?.available && status?.authenticated === false;+ // Tunnels table columns. Cell markup and classNames are identical to the+ // hand-rolled table they replace so the .cron-tab__* / .data-table SCSS+ // keeps applying.+ const tunnelColumns = [+ {+ key: 'name',+ header: 'Name',+ sortable: true,+ hideable: false,+ sortValue: (t) => t.name || '',+ render: (t) => <span className="cron-tab__name">{t.name}</span>,+ },+ {+ key: 'id',+ header: 'ID',+ cellClassName: 'mono',+ render: (t) => `${(t.id || '').substring(0, 8)}…`,+ },+ {+ key: 'connections',+ header: 'Connections',+ sortable: true,+ sortValue: (t) => t.connections?.length ?? 0,+ render: (t) => t.connections?.length || 0,+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ className: 'actions-cell',+ cellClassName: 'actions-cell',+ render: (t) => (+ <>+ <Button+ size="sm"+ variant="outline"+ onClick={() => { setRouteTunnel(t); setShowRouteModal(true); }}+ >+ Route subdomain+ </Button>+ <button type="button"+ className="btn-icon danger"+ onClick={() => handleDelete(t)}+ title="Delete"+ >+ <TrashIcon />+ </button>+ </>+ ),+ },+ ];+return (<div className="cloudflared-tab"><div className="cron-tab__header">@@ -240,6 +300,13 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {<Button onClick={() => setShowCreateModal(true)} disabled={notInstalled || notAuthed}>Create Tunnel</Button>+ <SortMenu columns={tunnelColumns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={tunnelColumns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ /></div></div>@@ -281,41 +348,22 @@ const CloudflaredTab = ({ serverId, serverStatus }) => {description="No tunnels on this server. Use Create Tunnel to make one."/>) : (- <table className="data-table">- <thead>- <tr>- <th>Name</th>- <th>ID</th>- <th>Connections</th>- <th className="actions-cell">Actions</th>- </tr>- </thead>- <tbody>- {tunnels.map(t => (- <tr key={t.id || t.name}>- <td><span className="cron-tab__name">{t.name}</span></td>- <td className="mono">{(t.id || '').substring(0, 8)}…</td>- <td>{t.connections?.length || 0}</td>- <td className="actions-cell">- <Button- size="sm"- variant="outline"- onClick={() => { setRouteTunnel(t); setShowRouteModal(true); }}- >- Route subdomain- </Button>- <button type="button"- className="btn-icon danger"- onClick={() => handleDelete(t)}- title="Delete"- >- <TrashIcon />- </button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={tunnelColumns}+ data={tunnels}+ keyField={(t) => t.id || t.name}+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ tableClassName="data-table"+ footer={(+ <DataTableFooter+ shown={tunnels.length}+ total={tunnels.length}+ noun="tunnel"+ />+ )}+ />))}diff --git a/frontend/src/components/serverdetail/CronTab.jsx b/frontend/src/components/serverdetail/CronTab.jsxindex 541ae2ab..6b7af24b 100644--- a/frontend/src/components/serverdetail/CronTab.jsx+++ b/frontend/src/components/serverdetail/CronTab.jsx@@ -5,7 +5,9 @@ import { useConfirm } from '../../hooks/useConfirm';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Textarea } from '@/components/ui/textarea';-import { Pill } from '../ds';+import { ColumnsMenu, DataTable, DataTableFooter, Pill, SortMenu } from '../ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import EmptyState from '../EmptyState';import { Clock3 } from 'lucide-react';import {@@ -47,6 +49,10 @@ const CronTab = ({ serverId, serverStatus }) => {schedule: '0 * * * *',command: '',});+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-sd-cron-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-sd-cron-cols' });const loadJobs = useCallback(async () => {try {@@ -150,6 +156,76 @@ const CronTab = ({ serverId, serverStatus }) => {return <EmptyState loading title="Loading cron jobs" />;}+ // Jobs table columns. Cell markup and classNames are identical to the+ // hand-rolled table they replace so the .cron-tab / .data-table SCSS+ // keeps applying (.cron-tab__name, .cron-tab__command, .mono).+ const cronColumns = [+ {+ key: 'schedule',+ header: 'Schedule',+ sortable: true,+ hideable: false,+ sortValue: (job) => job.schedule || '',+ render: (job) => (+ <>+ <span className="mono" title={job.schedule}>{job.schedule}</span>+ {job.description && job.description !== job.schedule && (+ <div className="cron-tab__description">{job.description}</div>+ )}+ </>+ ),+ },+ {+ key: 'command',+ header: 'Command',+ sortable: true,+ sortValue: (job) => job.command || '',+ render: (job) => (+ <>+ {job.name && <div className="cron-tab__name">{job.name}</div>}+ <code className="cron-tab__command">{job.command}</code>+ </>+ ),+ },+ {+ key: 'status',+ header: 'Status',+ sortable: true,+ sortValue: (job) => (job.enabled ? 'enabled' : 'disabled'),+ render: (job) => (+ <Pill kind={job.enabled ? 'green' : 'gray'}>+ {job.enabled ? 'enabled' : 'disabled'}+ </Pill>+ ),+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ className: 'actions-cell',+ cellClassName: 'actions-cell',+ render: (job) => (+ <>+ <button type="button"+ className="btn-icon"+ onClick={() => handleToggle(job)}+ title={job.enabled ? 'Disable' : 'Enable'}+ >+ {job.enabled ? <StopIcon /> : <PlayIcon />}+ </button>+ <button type="button"+ className="btn-icon danger"+ onClick={() => handleRemove(job)}+ title="Remove"+ >+ <TrashIcon />+ </button>+ </>+ ),+ },+ ];+return (<div className="cron-tab"><div className="cron-tab__header">@@ -168,6 +244,13 @@ const CronTab = ({ serverId, serverStatus }) => {<Button onClick={() => setShowAddModal(true)} disabled={status?.available === false}>Add Job</Button>+ <SortMenu columns={cronColumns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={cronColumns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ /></div></div>@@ -182,53 +265,23 @@ const CronTab = ({ serverId, serverStatus }) => {description="No scheduled jobs on this server. Use Add Job to schedule one."/>) : (- <table className="data-table">- <thead>- <tr>- <th>Schedule</th>- <th>Command</th>- <th>Status</th>- <th className="actions-cell">Actions</th>- </tr>- </thead>- <tbody>- {jobs.map(job => (- <tr key={job.id} className={!job.enabled ? 'row-disabled' : ''}>- <td>- <span className="mono" title={job.schedule}>{job.schedule}</span>- {job.description && job.description !== job.schedule && (- <div className="cron-tab__description">{job.description}</div>- )}- </td>- <td>- {job.name && <div className="cron-tab__name">{job.name}</div>}- <code className="cron-tab__command">{job.command}</code>- </td>- <td>- <Pill kind={job.enabled ? 'green' : 'gray'}>- {job.enabled ? 'enabled' : 'disabled'}- </Pill>- </td>- <td className="actions-cell">- <button type="button"- className="btn-icon"- onClick={() => handleToggle(job)}- title={job.enabled ? 'Disable' : 'Enable'}- >- {job.enabled ? <StopIcon /> : <PlayIcon />}- </button>- <button type="button"- className="btn-icon danger"- onClick={() => handleRemove(job)}- title="Remove"- >- <TrashIcon />- </button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={cronColumns}+ data={jobs}+ keyField="id"+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ rowClassName={(job) => (!job.enabled ? 'row-disabled' : '')}+ tableClassName="data-table"+ footer={(+ <DataTableFooter+ shown={jobs.length}+ total={jobs.length}+ noun="job"+ />+ )}+ />)}<Dialogdiff --git a/frontend/src/components/serverdetail/ServerDockerTab.jsx b/frontend/src/components/serverdetail/ServerDockerTab.jsxindex 5254fa39..38dcc84b 100644--- a/frontend/src/components/serverdetail/ServerDockerTab.jsx+++ b/frontend/src/components/serverdetail/ServerDockerTab.jsx@@ -3,7 +3,7 @@ import api from '../../services/api';import { useToast } from '../../contexts/ToastContext';import { useConfirm } from '../../hooks/useConfirm';import { Button } from '@/components/ui/button';-import { Pill } from '../ds';+import { DataTable, DataTableFooter, Pill } from '../ds';import EmptyState from '../EmptyState';import { Boxes, Container } from 'lucide-react';import {@@ -44,6 +44,55 @@ const formatPorts = (ports) => {return parts.join(', ');};+// docker prints image sizes as strings ("25.5MB", "1.2GB") — parse to bytes+// so the Size column sorts numerically instead of lexicographically.+const SIZE_UNITS = { b: 1, kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12 };+const parseDockerSize = (size) => {+ const match = /^([\d.]+)\s*(b|kb|mb|gb|tb)$/i.exec(size || '');+ if (!match) return null;+ return parseFloat(match[1]) * (SIZE_UNITS[match[2].toLowerCase()] || 1);+};++// Images table columns. Cell markup and classNames are identical to the+// hand-rolled table they replace so the .data-table SCSS keeps applying.+const IMAGE_COLUMNS = [+ {+ key: 'repository',+ header: 'Repository',+ sortable: true,+ hideable: false,+ sortValue: (image) => image.repository || '<none>',+ render: (image) => image.repository || '<none>',+ },+ {+ key: 'tag',+ header: 'Tag',+ sortable: true,+ sortValue: (image) => image.tag || '<none>',+ render: (image) => image.tag || '<none>',+ },+ {+ key: 'id',+ header: 'Image ID',+ cellClassName: 'mono',+ render: (image) => image.id?.substring(0, 12),+ },+ {+ key: 'size',+ header: 'Size',+ sortable: true,+ sortValue: (image) => parseDockerSize(image.size),+ render: (image) => image.size,+ },+ {+ key: 'created',+ header: 'Created',+ sortable: true,+ sortValue: (image) => image.created || null,+ render: (image) => image.created,+ },+];+const ServerDockerTab = ({ serverId, serverStatus, server }) => {const [containers, setContainers] = useState([]);const [images, setImages] = useState([]);@@ -141,6 +190,101 @@ const ServerDockerTab = ({ serverId, serverStatus, server }) => {return <EmptyState loading title="Loading Docker data" />;}+ // Containers table columns. Cell markup and classNames are identical to+ // the hand-rolled table they replace so the .data-table SCSS (and the+ // .server-detail-page dense-table overrides) keeps applying.+ const containerColumns = [+ {+ key: 'name',+ header: 'Name',+ sortable: true,+ hideable: false,+ sortValue: (container) => container.name || '',+ render: (container) => (+ <>+ <span className="container-name">{container.name}</span>+ <span className="container-id">{container.id?.substring(0, 12)}</span>+ </>+ ),+ },+ {+ key: 'image',+ header: 'Image',+ sortable: true,+ sortValue: (container) => container.image || '',+ render: (container) => container.image,+ },+ {+ key: 'status',+ header: 'Status',+ sortable: true,+ sortValue: (container) => container.state || '',+ render: (container) => {+ const isRunning = container.state === 'running';+ return (+ <Pill kind={isRunning ? 'green' : container.state === 'paused' || container.state === 'restarting' ? 'amber' : 'gray'}>+ {container.state}+ </Pill>+ );+ },+ },+ {+ key: 'ports',+ header: 'Ports',+ sortable: true,+ sortValue: (container) => {+ const text = formatPorts(container.ports);+ return text === '-' ? null : text;+ },+ render: (container) => formatPorts(container.ports),+ },+ {+ key: 'actions',+ header: 'Actions',+ sortable: false,+ hideable: false,+ cellClassName: 'actions-cell',+ render: (container) => {+ const isRunning = container.state === 'running';+ return isRunning ? (+ <>+ <button type="button"+ className="btn-icon"+ onClick={() => handleContainerAction(container.id, 'restart')}+ title="Restart"+ >+ <RefreshIcon />+ </button>+ <button type="button"+ className="btn-icon danger"+ onClick={() => handleContainerAction(container.id, 'stop')}+ title="Stop"+ >+ <StopIcon />+ </button>+ </>+ ) : (+ <>+ <button type="button"+ className="btn-icon success"+ onClick={() => handleContainerAction(container.id, 'start')}+ title="Start"+ >+ <PlayIcon />+ </button>+ <button type="button"+ className="btn-icon danger"+ onClick={() => handleContainerAction(container.id, 'remove')}+ title="Remove"+ >+ <TrashIcon />+ </button>+ </>+ );+ },+ },+ ];+return (<div className="docker-tab">{loadError && (@@ -169,74 +313,20 @@ const ServerDockerTab = ({ serverId, serverStatus, server }) => {{containers.length === 0 ? (<EmptyState icon={Container} title="No containers" description="No containers are running on this server." />) : (- <table className="data-table">- <thead>- <tr>- <th>Name</th>- <th>Image</th>- <th>Status</th>- <th>Ports</th>- <th>Actions</th>- </tr>- </thead>- <tbody>- {containers.map(container => {- const isRunning = container.state === 'running';- return (- <tr key={container.id}>- <td>- <span className="container-name">{container.name}</span>- <span className="container-id">{container.id?.substring(0, 12)}</span>- </td>- <td>{container.image}</td>- <td>- <Pill kind={isRunning ? 'green' : container.state === 'paused' || container.state === 'restarting' ? 'amber' : 'gray'}>- {container.state}- </Pill>- </td>- <td>{formatPorts(container.ports)}</td>- <td className="actions-cell">- {isRunning ? (- <>- <button type="button"- className="btn-icon"- onClick={() => handleContainerAction(container.id, 'restart')}- title="Restart"- >- <RefreshIcon />- </button>- <button type="button"- className="btn-icon danger"- onClick={() => handleContainerAction(container.id, 'stop')}- title="Stop"- >- <StopIcon />- </button>- </>- ) : (- <>- <button type="button"- className="btn-icon success"- onClick={() => handleContainerAction(container.id, 'start')}- title="Start"- >- <PlayIcon />- </button>- <button type="button"- className="btn-icon danger"- onClick={() => handleContainerAction(container.id, 'remove')}- title="Remove"- >- <TrashIcon />- </button>- </>- )}- </td>- </tr>- );- })}- </tbody>- </table>+ <DataTable+ columns={containerColumns}+ data={containers}+ keyField="id"+ storageKey="serverkit-table-sd-docker-containers"+ tableClassName="data-table"+ footer={(+ <DataTableFooter+ shown={containers.length}+ total={containers.length}+ noun="container"+ />+ )}+ />)}</div>)}@@ -246,28 +336,20 @@ const ServerDockerTab = ({ serverId, serverStatus, server }) => {{images.length === 0 ? (<EmptyState icon={Boxes} title="No images" description="No Docker images are present on this server." />) : (- <table className="data-table">- <thead>- <tr>- <th>Repository</th>- <th>Tag</th>- <th>Image ID</th>- <th>Size</th>- <th>Created</th>- </tr>- </thead>- <tbody>- {images.map(image => (- <tr key={image.id}>- <td>{image.repository || '<none>'}</td>- <td>{image.tag || '<none>'}</td>- <td className="mono">{image.id?.substring(0, 12)}</td>- <td>{image.size}</td>- <td>{image.created}</td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={IMAGE_COLUMNS}+ data={images}+ keyField="id"+ storageKey="serverkit-table-sd-docker-images"+ tableClassName="data-table"+ footer={(+ <DataTableFooter+ shown={images.length}+ total={images.length}+ noun="image"+ />+ )}+ />)}</div>)}diff --git a/frontend/src/components/serverdetail/ServicesTab.jsx b/frontend/src/components/serverdetail/ServicesTab.jsxindex 15f5b030..3bbfcb7e 100644--- a/frontend/src/components/serverdetail/ServicesTab.jsx+++ b/frontend/src/components/serverdetail/ServicesTab.jsx@@ -3,7 +3,9 @@ import api from '../../services/api';import { useToast } from '../../contexts/ToastContext';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';-import { Pill } from '../ds';+import { Pill, ColumnsMenu, DataTable, DataTableFooter, SortMenu } from '../ds';+import { useTableSort } from '@/hooks/useTableSort';+import { useColumnVisibility } from '@/hooks/useColumnVisibility';import Modal from '../Modal';const STATE_FILTERS = [@@ -34,6 +36,10 @@ const ServicesTab = ({ serverId, serverStatus }) => {const [search, setSearch] = useState('');const [busyUnit, setBusyUnit] = useState(null);const [logsFor, setLogsFor] = useState(null); // { unit, entries, raw }+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-sd-services-sort' });+ const {+ hiddenKeys, toggleColumn, showAllColumns,+ } = useColumnVisibility({ storageKey: 'serverkit-table-sd-services-cols' });const loadUnits = useCallback(async () => {setLoading(true);@@ -105,6 +111,70 @@ const ServicesTab = ({ serverId, serverStatus }) => {);}+ // Units table columns. Cell markup and classNames are identical to the+ // hand-rolled table they replace so the .server-services__* SCSS keeps+ // applying (.server-services__desc, .server-services__row-actions, .mono).+ const unitColumns = [+ {+ key: 'unit',+ header: 'Unit',+ sortable: true,+ hideable: false,+ sortValue: (u) => u.unit || '',+ cellClassName: 'mono',+ render: (u) => u.unit,+ },+ {+ key: 'state',+ header: 'State',+ sortable: true,+ sortValue: (u) => u.active || u.sub || 'unknown',+ render: (u) => (+ <Pill kind={STATE_PILL[u.active] || STATE_PILL[u.sub] || 'gray'}>+ {u.active || u.sub || 'unknown'}+ </Pill>+ ),+ },+ {+ key: 'description',+ header: 'Description',+ sortable: true,+ sortValue: (u) => u.description || '',+ cellClassName: 'server-services__desc',+ render: (u) => u.description,+ },+ {+ key: 'actions',+ header: '',+ sortable: false,+ hideable: false,+ cellClassName: 'server-services__row-actions',+ render: (u) => (+ <>+ <Button+ size="sm" variant="outline"+ disabled={busyUnit === u.unit}+ onClick={() => control(u.unit, 'start')}+ >Start</Button>+ <Button+ size="sm" variant="outline"+ disabled={busyUnit === u.unit}+ onClick={() => control(u.unit, 'stop')}+ >Stop</Button>+ <Button+ size="sm" variant="outline"+ disabled={busyUnit === u.unit}+ onClick={() => control(u.unit, 'restart')}+ >Restart</Button>+ <Button+ size="sm" variant="outline"+ onClick={() => viewLogs(u.unit)}+ >Logs</Button>+ </>+ ),+ },+ ];+return (<div className="server-services"><div className="server-services__toolbar">@@ -135,6 +205,13 @@ const ServicesTab = ({ serverId, serverStatus }) => {>Reload daemon</Button>+ <SortMenu columns={unitColumns} sorts={sorts} onChange={setSorts} />+ <ColumnsMenu+ columns={unitColumns}+ hiddenKeys={hiddenKeys}+ onToggle={toggleColumn}+ onShowAll={showAllColumns}+ /></div></div>@@ -143,50 +220,22 @@ const ServicesTab = ({ serverId, serverStatus }) => {) : filtered.length === 0 ? (<p className="text-muted-foreground">No matching units.</p>) : (- <table className="server-services__table">- <thead>- <tr>- <th>Unit</th>- <th>State</th>- <th>Description</th>- <th aria-label="actions" />- </tr>- </thead>- <tbody>- {filtered.map((u) => (- <tr key={u.unit}>- <td className="mono">{u.unit}</td>- <td>- <Pill kind={STATE_PILL[u.active] || STATE_PILL[u.sub] || 'gray'}>- {u.active || u.sub || 'unknown'}- </Pill>- </td>- <td className="server-services__desc">{u.description}</td>- <td className="server-services__row-actions">- <Button- size="sm" variant="outline"- disabled={busyUnit === u.unit}- onClick={() => control(u.unit, 'start')}- >Start</Button>- <Button- size="sm" variant="outline"- disabled={busyUnit === u.unit}- onClick={() => control(u.unit, 'stop')}- >Stop</Button>- <Button- size="sm" variant="outline"- disabled={busyUnit === u.unit}- onClick={() => control(u.unit, 'restart')}- >Restart</Button>- <Button- size="sm" variant="outline"- onClick={() => viewLogs(u.unit)}- >Logs</Button>- </td>- </tr>- ))}- </tbody>- </table>+ <DataTable+ columns={unitColumns}+ data={filtered}+ keyField="unit"+ sorts={sorts}+ onSortsChange={setSorts}+ hiddenKeys={hiddenKeys}+ tableClassName="server-services__table"+ footer={(+ <DataTableFooter+ shown={filtered.length}+ total={units.length}+ noun="unit"+ />+ )}+ />)}<Modaldiff --git a/frontend/src/components/serverdetail/SurveyTab.jsx b/frontend/src/components/serverdetail/SurveyTab.jsxindex 1356884b..a5ab726e 100644--- a/frontend/src/components/serverdetail/SurveyTab.jsx+++ b/frontend/src/components/serverdetail/SurveyTab.jsx@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';import api from '../../services/api';import { useToast } from '../../contexts/ToastContext';import { Button } from '@/components/ui/button';-import { Pill } from '../ds';+import { DataTable, DataTableFooter, Pill } from '../ds';import EmptyState from '../EmptyState';import {FileSearch,@@ -394,41 +394,75 @@ function ServiceGrid({ services }) {}// Read-only web-server vhosts, with a "managed by" column that flags sites owned-// by another control panel.+// by another control panel. Cell markup and classNames are identical to the+// hand-rolled table this replaces so the .survey-tab__table SCSS keeps applying.+const SITE_COLUMNS = [+ {+ key: 'domain',+ header: 'Domain',+ sortable: true,+ hideable: false,+ sortValue: (s) => s.domain || '',+ cellClassName: 'survey-tab__mono',+ render: (s) => s.domain,+ },+ {+ key: 'stack',+ header: 'Stack',+ sortable: true,+ sortValue: (s) => s.stack || '',+ render: (s) => s.stack,+ },+ {+ key: 'docRoot',+ header: 'Doc root',+ sortable: true,+ sortValue: (s) => s.doc_root || null,+ cellClassName: 'survey-tab__mono',+ render: (s) => s.doc_root || '—',+ },+ {+ key: 'upstream',+ header: 'Upstream',+ sortable: true,+ sortValue: (s) => s.upstream || null,+ cellClassName: 'survey-tab__mono',+ render: (s) => s.upstream || '—',+ },+ {+ key: 'managedBy',+ header: 'Managed by',+ sortable: true,+ sortValue: (s) => s.managed_by || '',+ render: (s) => (+ s.managed_by === 'other-panel'+ ? <Pill kind="amber">other panel</Pill>+ : <Pill kind="gray">{s.managed_by}</Pill>+ ),+ },+];+function SitesTable({ sites }) {const list = sites || [];if (!list.length) {return <p className="survey-tab__muted">No web-server vhosts detected.</p>;}return (- <div className="survey-tab__table-wrap">- <table className="survey-tab__table">- <thead>- <tr>- <th>Domain</th>- <th>Stack</th>- <th>Doc root</th>- <th>Upstream</th>- <th>Managed by</th>- </tr>- </thead>- <tbody>- {list.map((s, i) => (- <tr key={s.domain || i}>- <td className="survey-tab__mono">{s.domain}</td>- <td>{s.stack}</td>- <td className="survey-tab__mono">{s.doc_root || '—'}</td>- <td className="survey-tab__mono">{s.upstream || '—'}</td>- <td>- {s.managed_by === 'other-panel'- ? <Pill kind="amber">other panel</Pill>- : <Pill kind="gray">{s.managed_by}</Pill>}- </td>- </tr>- ))}- </tbody>- </table>- </div>+ <DataTable+ columns={SITE_COLUMNS}+ data={list}+ keyField={(s) => s.domain || `${s.stack}|${s.doc_root}|${s.upstream}`}+ storageKey="serverkit-table-sd-survey-sites"+ className="survey-tab__table-wrap"+ tableClassName="survey-tab__table"+ footer={(+ <DataTableFooter+ shown={list.length}+ total={list.length}+ noun="site"+ />+ )}+ />);}