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.

feat(ui): the last hand-rolled list surfaces join the convention

Juan Denis258b1255322e
diff --git a/frontend/src/components/ProcessTable.jsx b/frontend/src/components/ProcessTable.jsx
index bfbc02e9..20bcbdd5 100644
--- a/frontend/src/components/ProcessTable.jsx
+++ b/frontend/src/components/ProcessTable.jsx
@@ -1,14 +1,89 @@
+import { useCallback, useMemo, useState } from 'react';
import { X, AlertTriangle } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
-import { DataTable, DataTableFooter } from '@/components/ds';
+import { DataTable, DataTableFooter, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
-export function UsageCell({ percent = 0, variant = 'cpu' }) {
+// Built-in saved views. These are the five chips that used to sit in a second
+// toolbar row on Terminal › Processes (All / Running / Sleeping / Stopped /
+// Zombie) — every one of them was a rule over the `status` column wearing a
+// button's clothes. Written as rules they combine with the search and with any
+// column filter, they carry live counts in the picker, and a user can save
+// their own slice next to them.
+//
+// Every rule matches the `status` column's `value`, which is psutil's own
+// lowercase status word — the one the Badge renders.
+const NO_RULES = { match: 'all', rules: [] };
+const STATUS_IS = (id, ...values) => ({
+ match: 'all',
+ rules: [{ id, field: 'status', op: 'any', value: values }],
+});
+
+// Busiest-first is the only ordering that makes a top-N slice meaningful, so
+// every view carries it rather than inheriting whatever was clicked last.
+const BY_CPU = [{ key: 'cpu', direction: 'desc' }];
+
+const PROCESS_VIEWS = [
+ {
+ // The worklist. A stopped or zombie process is the only row here that
+ // is unambiguously wrong — a zombie is holding a PID its parent never
+ // reaped, a stopped one is parked on a signal — so it leads.
+ name: 'Stopped & zombie',
+ state: {
+ sorts: BY_CPU,
+ hiddenKeys: [],
+ columnFilters: STATUS_IS('pv1', 'stopped', 'zombie'),
+ page: { search: '' },
+ },
+ },
+ {
+ name: 'Running',
+ state: {
+ sorts: BY_CPU,
+ hiddenKeys: [],
+ columnFilters: STATUS_IS('pv2', 'running'),
+ page: { search: '' },
+ },
+ },
+ {
+ // Almost everything on a healthy box. Worth its own view because it is
+ // the half you subtract to see what is actually doing work.
+ name: 'Sleeping',
+ state: {
+ sorts: BY_CPU,
+ hiddenKeys: [],
+ columnFilters: STATUS_IS('pv3', 'sleeping', 'idle', 'disk-sleep'),
+ page: { search: '' },
+ },
+ },
+ {
+ name: 'All processes',
+ state: {
+ sorts: BY_CPU,
+ hiddenKeys: [],
+ columnFilters: NO_RULES,
+ page: { search: '' },
+ },
+ },
+];
+
+// psutil reports the owner as `username`; the per-PID detail endpoint and the
+// style-guide fixtures call it `user`. Read both so the column is never blank
+// against a real payload.
+export const procUser = (p) => p.user || p.username || '';
+
+export function UsageCell({ percent = 0, variant = 'cpu', label }) {
const clamped = Math.min(Number(percent) || 0, 100);
return (
<div className="usage-cell">
<div className={`usage-bar ${variant}`} style={{ width: `${clamped}%` }} />
- <span>{clamped.toFixed(1)}%</span>
+ <span>{label ?? `${clamped.toFixed(1)}%`}</span>
</div>
);
}
@@ -19,21 +94,56 @@ export function ProcessTable({
onSelect,
onKill,
onForceKill,
+ onRefresh,
formatMemory = defaultFormatMemory,
getStatusVariant = defaultGetStatusVariant,
+ // Saved views + the one row of chrome are opt-in: the style guide renders
+ // the bare table, a real page passes the key its views are stored under.
+ viewPageKey,
+ // Extra nodes for that SAME chrome row — a host's own data-source controls
+ // (Terminal's top-N and live toggle), never a second toolbar underneath.
+ actions,
+ storageKey = 'serverkit-table-processes',
+ // Controlled sort, same contract as DataTable's. Terminal drives it because
+ // the endpoint returns a top-N slice and the fetch has to be ordered by
+ // whatever the table is ordered by.
+ sorts: controlledSorts,
+ onSortsChange,
}) {
- // 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 [search, setSearch] = useState('');
+ const internalSort = useTableSort({ storageKey: `${storageKey}-sort`, defaultSorts: BY_CPU });
+ const sorts = controlledSorts ?? internalSort.sorts;
+ const setSorts = onSortsChange ?? internalSort.setSorts;
+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({ storageKey: `${storageKey}-cols` });
+
+ const searched = useMemo(() => {
+ const needle = search.trim().toLowerCase();
+ if (!needle) return processes;
+ return processes.filter((p) => (
+ p.name?.toLowerCase().includes(needle)
+ || procUser(p).toLowerCase().includes(needle)
+ || p.command?.toLowerCase().includes(needle)
+ || String(p.pid).includes(needle)
+ ));
+ }, [processes, search]);
+
+ const viewPageState = useMemo(() => ({ search }), [search]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearch(saved.search);
+ }, []);
+
+ // Every column declares BOTH a `value` (what the rules and the exporter
+ // read) and a `render` — none of these cells is a bare row property, and a
+ // derived column without a render draws nothing at all.
const columns = [
{
key: 'pid',
header: 'PID',
sortable: true,
+ type: 'num',
+ value: (p) => p.pid,
sortValue: (p) => p.pid,
- cellClassName: 'mono',
+ cellClassName: 'sk-cell-mono',
render: (p) => p.pid,
},
{
@@ -41,41 +151,61 @@ export function ProcessTable({
header: 'Name',
sortable: true,
hideable: false,
+ // Hundreds of distinct executables on a real host — a fragment you
+ // type, never a list you pick from.
+ type: 'text',
+ value: (p) => p.name || '',
sortValue: (p) => p.name || '',
+ cellClassName: 'sk-cell-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,
+ value: procUser,
+ sortValue: procUser,
+ render: procUser,
},
{
key: 'cpu',
header: 'CPU %',
sortable: true,
+ type: 'num',
+ value: (p) => Number(p.cpu_percent) || 0,
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),
+ type: 'num',
+ value: (p) => Number(p.memory_percent) || 0,
+ sortValue: (p) => Number(p.memory_percent) || 0,
+ // ONE memory column, not the two this table used to declare: the
+ // process LIST endpoint carries `memory_percent` only — `memory_info`
+ // comes back from the per-PID detail call — so the bytes column
+ // rendered a dash on every row of real data. The bar is always the
+ // percentage; the label upgrades to bytes when a row has them.
+ render: (p) => (
+ <UsageCell
+ percent={p.memory_percent}
+ variant="memory"
+ label={p.memory_info?.rss != null ? formatMemory(p.memory_info.rss) : undefined}
+ />
+ ),
},
{
key: 'status',
header: 'Status',
sortable: true,
+ // Declared, not inferred: a box where everything sleeps offers ONE
+ // distinct value, the column would fall back to text, and every view
+ // above would become a no-op typed-fragment match.
+ type: 'enum',
+ enumOrder: ['running', 'sleeping', 'idle', 'disk-sleep', 'stopped', 'zombie'],
+ value: (p) => p.status || '',
sortValue: (p) => p.status || '',
render: (p) => (
<Badge variant={getStatusVariant(p.status)}>{p.status}</Badge>
@@ -117,25 +247,81 @@ export function ProcessTable({
},
];
- return (
+ // `rows` is the SEARCHED list — the column rules are applied inside
+ // DataTable, and the count below comes back through `chrome.shownCount`.
+ const chrome = useTableChrome({
+ columns,
+ rows: searched,
+ viewPageKey,
+ builtinViews: PROCESS_VIEWS,
+ noun: 'processes',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
+
+ const table = (
<DataTable
- columns={columns}
- data={processes}
+ columns={chrome.columns}
+ data={searched}
keyField="pid"
- storageKey="serverkit-table-processes"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ {...chrome.tableProps}
onRowClick={(p) => onSelect?.(p)}
rowClassName={(p) => (selectedPid === p.pid ? 'selected' : '')}
className="processes-table-wrapper"
tableClassName="table processes-table"
+ emptyTitle="No processes match this view."
+ emptyMessage=""
footer={(
<DataTableFooter
- shown={processes.length}
+ shown={chrome.shownCount}
total={processes.length}
noun="process"
+ plural="processes"
/>
)}
/>
);
+
+ if (!viewPageKey) return table;
+
+ return (
+ <>
+ {/* One row of chrome: the view name is the heading, and search, the
+ host's own controls, the filter button and the "⋮" ride it. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="processes"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={search}
+ onSearch={setSearch}
+ placeholder="Filter PID, name, command…"
+ />
+ {actions}
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={onRefresh} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ {table}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
+ </>
+ );
}
export function ProcessDetailsPanel({ process, onClose, formatMemory = defaultFormatMemory }) {
@@ -150,7 +336,7 @@ export function ProcessDetailsPanel({ process, onClose, formatMemory = defaultFo
<div className="details-grid">
<DetailItem label="PID" value={process.pid} mono />
<DetailItem label="Name" value={process.name} />
- <DetailItem label="User" value={process.user} />
+ <DetailItem label="User" value={procUser(process)} />
<DetailItem label="Status" value={process.status} />
<DetailItem label="CPU" value={`${(process.cpu_percent || 0).toFixed(2)}%`} />
<DetailItem label="Memory" value={formatMemory(process.memory_info?.rss)} />
diff --git a/frontend/src/components/SearchFilterBar.jsx b/frontend/src/components/SearchFilterBar.jsx
deleted file mode 100644
index 834c5909..00000000
--- a/frontend/src/components/SearchFilterBar.jsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import { Search, X } from 'lucide-react';
-import { Input } from '@/components/ui/input';
-import { Button } from '@/components/ui/button';
-import { cn } from '@/lib/utils';
-
-/**
- * Reusable search + filter + sort bar for list pages.
- *
- * <SearchFilterBar
- * search={searchTerm}
- * onSearch={setSearchTerm}
- * filters={[
- * { key: 'all', label: 'All' },
- * { key: 'active', label: 'Active' },
- * ]}
- * activeFilter={filter}
- * onFilterChange={setFilter}
- * />
- */
-export function SearchFilterBar({
- search = '',
- onSearch,
- placeholder = 'Search...',
- filters = [],
- activeFilter,
- onFilterChange,
- sortOptions = [],
- sort,
- onSortChange,
- className,
-}) {
- return (
- <div className={cn('sk-search-filter-bar', className)}>
- <div className="sk-search-filter-bar__search">
- <Search size={16} className="sk-search-filter-bar__search-icon" />
- <Input
- type="text"
- value={search}
- onChange={(e) => onSearch?.(e.target.value)}
- placeholder={placeholder}
- className="sk-search-filter-bar__input"
- />
- {search && (
- <Button
- type="button"
- size="icon"
- variant="ghost"
- className="sk-search-filter-bar__clear"
- onClick={() => onSearch?.('')}
- aria-label="Clear search"
- title="Clear search"
- >
- <X size={14} />
- </Button>
- )}
- </div>
-
- {filters.length > 0 && (
- <div className="sk-search-filter-bar__filters" role="group" aria-label="Filters">
- {filters.map((filter) => (
- <button
- key={filter.key}
- type="button"
- className={cn(
- 'sk-search-filter-bar__chip',
- activeFilter === filter.key && 'is-active'
- )}
- onClick={() => onFilterChange?.(filter.key)}
- >
- {filter.label}
- {filter.count != null && (
- <span className="sk-search-filter-bar__count">{filter.count}</span>
- )}
- </button>
- ))}
- </div>
- )}
-
- {sortOptions.length > 0 && (
- <div className="sk-search-filter-bar__sort">
- <select
- value={sort}
- onChange={(e) => onSortChange?.(e.target.value)}
- aria-label="Sort by"
- >
- {sortOptions.map((option) => (
- <option key={option.key} value={option.key}>{option.label}</option>
- ))}
- </select>
- </div>
- )}
- </div>
- );
-}
-
-export default SearchFilterBar;
diff --git a/frontend/src/components/databases/BackupsTab.jsx b/frontend/src/components/databases/BackupsTab.jsx
index f523dd5d..c1ce0744 100644
--- a/frontend/src/components/databases/BackupsTab.jsx
+++ b/frontend/src/components/databases/BackupsTab.jsx
@@ -1,35 +1,87 @@
-import { useEffect, useState } from 'react';
-import { Archive, Trash2, RefreshCw } from 'lucide-react';
+import { useEffect, useState, useMemo, useCallback } from 'react';
+import { Archive, Trash2 } from 'lucide-react';
import api from '../../services/api';
import EmptyState from '../EmptyState';
import { useConfirm } from '../../hooks/useConfirm';
import { formatBytes } from '@/utils/formatBytes';
+import { DataTable, DataTableFooter, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
-const FILTERS = [
- { id: 'all', label: 'All' },
- { id: 'mysql', label: 'MySQL' },
- { id: 'postgresql', label: 'PostgreSQL' },
+// The backend reports the engine as the bare wire name it derived from the
+// filename prefix; these are what the row (and therefore every rule) says.
+const ENGINE_LABEL = { mysql: 'MySQL', postgresql: 'PostgreSQL' };
+
+// Built-in saved views. The All / MySQL / PostgreSQL segmented row this replaces
+// was a column rule on the engine wearing a segmented control — and it re-asked
+// the server for a subset it already had. The list is fetched whole once and
+// sliced here, so the presets combine with a search and with each other's sorts.
+const NO_RULES = { match: 'all', rules: [] };
+const NEWEST_FIRST = [{ key: 'created', direction: 'desc' }];
+const PAGE_CLEAR = { search: '' };
+const ENGINE_IS = (label, id) => ({
+ match: 'all',
+ rules: [{ id, field: 'engine', op: 'any', value: [label] }],
+});
+
+const BACKUP_VIEWS = [
+ {
+ // The landing view: everything, most recent dump first, because the
+ // backup you care about is almost always the last one taken.
+ name: 'All backups',
+ state: { sorts: NEWEST_FIRST, hiddenKeys: [], columnFilters: NO_RULES, page: PAGE_CLEAR },
+ },
+ {
+ name: 'MySQL',
+ state: { sorts: NEWEST_FIRST, hiddenKeys: ['engine'], columnFilters: ENGINE_IS('MySQL', 'bk1'), page: PAGE_CLEAR },
+ },
+ {
+ name: 'PostgreSQL',
+ state: { sorts: NEWEST_FIRST, hiddenKeys: ['engine'], columnFilters: ENGINE_IS('PostgreSQL', 'bk2'), page: PAGE_CLEAR },
+ },
+ {
+ // Disk pressure, which is the other reason anyone opens this tab: the
+ // dumps worth pruning are at the top.
+ name: 'Largest first',
+ state: {
+ sorts: [{ key: 'size', direction: 'desc' }],
+ hiddenKeys: [],
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
];
export default function BackupsTab() {
const { confirm } = useConfirm();
const [backups, setBackups] = useState([]);
const [loading, setLoading] = useState(true);
- const [filter, setFilter] = useState('all');
-
- useEffect(() => { load(); }, [filter]); // eslint-disable-line react-hooks/exhaustive-deps
+ const [search, setSearch] = useState('');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: NEWEST_FIRST,
+ storageKey: 'serverkit-table-db-backups-sort',
+ });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-db-backups-cols' });
- async function load() {
+ const load = useCallback(async () => {
setLoading(true);
try {
- const data = await api.getDatabaseBackups(filter === 'all' ? null : filter);
+ const data = await api.getDatabaseBackups();
setBackups(data.backups || []);
} catch (err) {
console.error('Failed to load backups:', err);
} finally {
setLoading(false);
}
- }
+ }, []);
+
+ useEffect(() => { load(); }, [load]);
async function remove(filename) {
const ok = await confirm({ title: 'Delete backup', message: `Delete backup "${filename}"? This cannot be undone.`, confirmText: 'Delete backup', variant: 'danger' });
@@ -42,60 +94,200 @@ export default function BackupsTab() {
}
}
- return (
- <div className="dbx-backups">
- <div className="dbx-backups-toolbar">
- <div className="dbx-segmented">
- {FILTERS.map((f) => (
- <button key={f.id} type="button" className={filter === f.id ? 'is-active' : ''} onClick={() => setFilter(f.id)}>
- {f.label}
- </button>
- ))}
- </div>
- <div className="dbx-table-toolbar-spacer" />
- <button type="button" className="dbx-icon-btn" onClick={load} disabled={loading} aria-label="Refresh">
- <RefreshCw size={14} className={loading ? 'dbx-spin' : ''} aria-hidden="true" />
+ // Every derived column carries BOTH `value` (what the rules, the pick-lists
+ // and the export read) and `render` (the cell): `engine` and `created` are
+ // not keys on a backup row at all, and `size` is a raw byte count that would
+ // otherwise print as nine digits.
+ const columns = [
+ {
+ key: 'database',
+ header: 'Database',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ value: (b) => b.database || '',
+ cellClassName: 'sk-cell-name',
+ },
+ {
+ key: 'engine',
+ header: 'Engine',
+ sortable: true,
+ // Declared, not inferred: a directory holding two MySQL dumps and
+ // nothing else fails the enum cardinality test, which would turn the
+ // pick-list into a typed fragment and both engine views into no-ops.
+ type: 'enum',
+ enumOrder: ['MySQL', 'PostgreSQL'],
+ value: (b) => ENGINE_LABEL[b.type] || b.type || '',
+ sortValue: (b) => ENGINE_LABEL[b.type] || b.type || '',
+ render: (b) => (
+ <span className={`dbx-engine-tag is-${b.type}`}>{ENGINE_LABEL[b.type] || b.type}</span>
+ ),
+ },
+ {
+ key: 'filename',
+ header: 'File',
+ sortable: true,
+ type: 'text',
+ value: (b) => b.filename || '',
+ cellClassName: 'sk-cell-mono',
+ },
+ {
+ key: 'size',
+ header: 'Size',
+ sortable: true,
+ type: 'num',
+ value: (b) => (typeof b.size === 'number' ? b.size : null),
+ sortValue: (b) => (typeof b.size === 'number' ? b.size : null),
+ cellClassName: 'sk-cell-mono',
+ render: (b) => formatBytes(b.size, { decimals: 2, defaultValue: '0 B' }),
+ },
+ {
+ key: 'created',
+ header: 'Created',
+ sortable: true,
+ // Declared: `sortValue` is epoch ms, and letting that number type the
+ // column would offer "is under 1754…" instead of a date picker.
+ type: 'date',
+ value: (b) => b.created_at || null,
+ sortValue: (b) => {
+ const parsed = Date.parse(b.created_at || '');
+ return Number.isNaN(parsed) ? null : parsed;
+ },
+ cellClassName: 'sk-cell-mono',
+ render: (b) => {
+ const parsed = Date.parse(b.created_at || '');
+ return Number.isNaN(parsed) ? '—' : new Date(parsed).toLocaleString();
+ },
+ },
+ {
+ key: 'actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ className: 'text-right',
+ cellClassName: 'dbx-grid-actions',
+ render: (b) => (
+ <button type="button" className="dbx-icon-btn is-danger" onClick={() => remove(b.filename)} aria-label={`Delete ${b.filename}`}>
+ <Trash2 size={14} aria-hidden="true" />
</button>
+ ),
+ },
+ ];
+
+ const shown = useMemo(() => {
+ const term = search.trim().toLowerCase();
+ if (!term) return backups;
+ return backups.filter((b) => (
+ (b.database || '').toLowerCase().includes(term)
+ || (b.filename || '').toLowerCase().includes(term)
+ ));
+ }, [backups, search]);
+
+ const viewPageState = useMemo(() => ({ search }), [search]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearch(saved.search);
+ }, []);
+
+ // Scoped to this tab. `urlScope` because the Databases route can have a
+ // processes tab and a table's structure open beside this one, and three
+ // chrome instances would otherwise fight over the same ?view=/?sort=.
+ const chrome = useTableChrome({
+ columns,
+ rows: shown,
+ viewPageKey: 'databases-backups',
+ builtinViews: BACKUP_VIEWS,
+ urlScope: 'dbbackups',
+ noun: 'backups',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
+
+ if (loading) {
+ return <EmptyState loading loadingVariant="table" title="Loading backups…" />;
+ }
+
+ // An empty pane still needs a way to re-check. Returning the EmptyState on
+ // its own took the chrome — and with it the only Refresh on this tab — off
+ // the screen exactly when the user most wants to press it, because a backup
+ // that finished a second ago is the reason the list looks empty.
+ if (backups.length === 0) {
+ return (
+ <div className="dbx-backups">
+ <GridViewPicker
+ views={chrome.views}
+ label="backups"
+ onCreate={chrome.createView}
+ actions={<GridToolsMenu {...chrome.toolsProps} onRefresh={load} />}
+ />
+ <EmptyState
+ icon={Archive}
+ title="No backups yet"
+ description="Back up a database from its tree menu and it will appear here."
+ />
</div>
+ );
+ }
- <div className="dbx-backups-body">
- {loading ? (
- <EmptyState loading loadingVariant="table" title="Loading backups…" />
- ) : backups.length === 0 ? (
- <EmptyState icon={Archive} title="No backups yet" description="Back up a database from its tree menu and it will appear here." />
- ) : (
- <table className="dbx-grid dbx-backups-table">
- <thead>
- <tr>
- <th scope="col">Database</th>
- <th scope="col">Engine</th>
- <th scope="col">File</th>
- <th scope="col">Size</th>
- <th scope="col">Created</th>
- <th scope="col" aria-label="Actions" />
- </tr>
- </thead>
- <tbody>
- {backups.map((b) => (
- <tr key={b.filename}>
- <td className="dbx-col-name">{b.database}</td>
- <td>
- <span className={`dbx-engine-tag is-${b.type}`}>{b.type === 'mysql' ? 'MySQL' : 'PostgreSQL'}</span>
- </td>
- <td className="dbx-mono">{b.filename}</td>
- <td className="dbx-mono">{formatBytes(b.size, { decimals: 2, defaultValue: '0 B' })}</td>
- <td className="dbx-mono">{new Date(b.created_at).toLocaleString()}</td>
- <td className="dbx-grid-actions">
- <button type="button" className="dbx-icon-btn is-danger" onClick={() => remove(b.filename)} aria-label={`Delete ${b.filename}`}>
- <Trash2 size={14} aria-hidden="true" />
- </button>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ return (
+ <div className="dbx-backups">
+ {/* One row of chrome. This pane lives inside the explorer's own tab
+ bar, so it stays inline rather than being hoisted; refresh is in
+ the "⋮" with the other table-wide actions. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="backups"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={search}
+ onSearch={setSearch}
+ placeholder="Filter database or file…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={load} />
+ </>
)}
- </div>
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ {/* Only the SEARCH can empty the pane outright. A column rule that
+ matches nothing keeps the table mounted — the header menu that
+ undoes it lives in the header. */}
+ {shown.length === 0 ? (
+ <EmptyState
+ icon={Archive}
+ title="No matching backups"
+ description="No backup matches the current search."
+ />
+ ) : (
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={shown}
+ keyField="filename"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ className="dbx-pane-scroll"
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={backups.length}
+ noun="backup"
+ />
+ )}
+ />
+ )}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
);
}
diff --git a/frontend/src/components/databases/ConsoleTab.jsx b/frontend/src/components/databases/ConsoleTab.jsx
index df397c09..b2e34660 100644
--- a/frontend/src/components/databases/ConsoleTab.jsx
+++ b/frontend/src/components/databases/ConsoleTab.jsx
@@ -207,25 +207,18 @@ export default function ConsoleTab({ conn, tabId, active, isAdmin, initialQuery
<div className="dbx-results">
{(results || loading || error) ? (
- <>
- {results && !error && (
- <div className="dbx-results-head">
- <span className="dbx-results-count">
- <strong>{results.row_count}</strong> row{results.row_count === 1 ? '' : 's'}
- {results.truncated && ` · truncated from ${results.total_rows}`}
- </span>
- <span className="dbx-results-time">{results.execution_time}s</span>
- </div>
- )}
- <ResultsGrid
- columns={results?.columns}
- rows={results?.rows}
- loading={loading}
- error={error}
- emptyTitle="Query ran"
- emptyDescription="No rows returned."
- />
- </>
+ // No count strip above the grid: the status bar at the foot
+ // of the explorer already reports rows, truncation and
+ // execution time for whichever tab is active, and this was
+ // the same three facts a second time.
+ <ResultsGrid
+ columns={results?.columns}
+ rows={results?.rows}
+ loading={loading}
+ error={error}
+ emptyTitle="Query ran"
+ emptyDescription="No rows returned."
+ />
) : (
<div className="dbx-console-hint">
<p>Write SQL above and press <kbd>{MOD_KEY}</kbd> + <kbd>Enter</kbd> to run.</p>
diff --git a/frontend/src/components/databases/ProcessListPanel.jsx b/frontend/src/components/databases/ProcessListPanel.jsx
index d78ed495..3648d360 100644
--- a/frontend/src/components/databases/ProcessListPanel.jsx
+++ b/frontend/src/components/databases/ProcessListPanel.jsx
@@ -1,13 +1,65 @@
-import { useState, useEffect, useCallback, useRef } from 'react';
-import { RefreshCw, Ban, Activity, TimerReset } from 'lucide-react';
+import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
+import { Ban, Activity, TimerReset } from 'lucide-react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
import { useConfirm } from '../../hooks/useConfirm';
import EmptyState from '../EmptyState';
+import { DataTable, DataTableFooter, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
const REFRESH_MS = 5000;
const QUERY_PREVIEW_LEN = 120;
+// What the cells render when the engine reports nothing. Real values, not '':
+// an empty rule value is dropped before it ever filters, so "db is ''" would
+// silently match everything — filtering on the same dash the cell shows keeps
+// the rule and the row telling the same story.
+const NO_DB = '—';
+const IDLE = 'idle';
+
+// A session that has been open for over a minute is either a long query or a
+// connection nobody closed; either way it is the row you came here to find.
+const LONG_RUNNING_S = 60;
+
+// Built-in saved views. Deliberately none about "active vs idle": MySQL reports
+// that in `Command` (Sleep/Query) and PostgreSQL in `state` (idle/active), so a
+// preset phrased in either engine's vocabulary would be a no-op on the other.
+// Time and database mean the same thing on both.
+const NO_RULES = { match: 'all', rules: [] };
+const BY_TIME = [{ key: 'time', direction: 'desc' }];
+const PAGE_CLEAR = { search: '' };
+
+const PROCESS_VIEWS = [
+ {
+ name: 'All sessions',
+ state: { sorts: BY_TIME, hiddenKeys: [], groupBy: null, columnFilters: NO_RULES, page: PAGE_CLEAR },
+ },
+ {
+ name: 'Long running',
+ state: {
+ sorts: BY_TIME,
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'pl1', field: 'time', op: 'gt', value: LONG_RUNNING_S }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // Which database is holding the connections — the question a raw
+ // processlist makes you count by eye.
+ name: 'By database',
+ state: { sorts: BY_TIME, hiddenKeys: [], groupBy: 'db', columnFilters: NO_RULES, page: PAGE_CLEAR },
+ },
+];
+
function formatTime(s) {
if (s == null) return '—';
if (s < 60) return `${s}s`;
@@ -27,7 +79,17 @@ export default function ProcessListPanel({ conn, engine, active, isAdmin }) {
const [loading, setLoading] = useState(false);
const [autoRefresh, setAutoRefresh] = useState(true);
const [killing, setKilling] = useState(null);
+ const [search, setSearch] = useState('');
const inFlight = useRef(false);
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: BY_TIME,
+ storageKey: 'serverkit-table-db-processes-sort',
+ });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-db-processes-cols' });
+ // Not persisted on its own: a grouping worth keeping is a saved view.
+ const [groupBy, setGroupBy] = useState(null);
const isDocker = conn?.dbType === 'docker';
const engineKind = isDocker ? (conn.dockerType || 'mysql') : (engine || conn?.dbType);
@@ -83,34 +145,194 @@ export default function ProcessListPanel({ conn, engine, active, isAdmin }) {
}
}
+ const isPg = engineKind === 'postgresql';
+
+ // `db`, `state`, `time` and `query` all render something the row does not
+ // literally hold — a dash, an engine-dependent field, a formatted duration,
+ // a truncated preview — so each carries `render` as well as `value`.
+ const columns = [
+ {
+ key: 'id',
+ header: 'ID',
+ sortable: true,
+ hideable: false,
+ type: 'num',
+ value: (p) => p.id,
+ sortValue: (p) => p.id,
+ cellClassName: 'sk-cell-mono',
+ },
+ {
+ key: 'user',
+ header: 'User',
+ sortable: true,
+ type: 'enum',
+ value: (p) => p.user || NO_DB,
+ sortValue: (p) => p.user || '',
+ render: (p) => p.user || NO_DB,
+ },
+ {
+ key: 'db',
+ header: 'Database',
+ sortable: true,
+ // Grouping is the whole point of the "By database" view, and
+ // `groupValue` has to be spelled out: the grouper falls back to
+ // row[key], which is null for a session not bound to a database.
+ groupable: true,
+ groupValue: (p) => p.db || NO_DB,
+ value: (p) => p.db || NO_DB,
+ sortValue: (p) => p.db || '',
+ render: (p) => p.db || NO_DB,
+ },
+ {
+ key: 'state',
+ header: isPg ? 'State' : 'Command',
+ sortable: true,
+ // Declared: a server with two sessions fails the enum cardinality
+ // test, and a pick-list is what makes this column useful at all.
+ type: 'enum',
+ value: (p) => (isPg ? (p.state || NO_DB) : (p.command || p.state || NO_DB)),
+ sortValue: (p) => (isPg ? (p.state || '') : (p.command || p.state || '')),
+ render: (p) => (
+ <span className="dbp-state">
+ {isPg ? (p.state || NO_DB) : (p.command || p.state || NO_DB)}
+ </span>
+ ),
+ },
+ {
+ key: 'time',
+ header: 'Time',
+ sortable: true,
+ // Declared as seconds, not as the "3m 12s" the cell shows: the rule
+ // engine has to compare numbers for "Long running" to mean anything.
+ type: 'num',
+ unit: 's',
+ value: (p) => (typeof p.time_s === 'number' ? p.time_s : null),
+ sortValue: (p) => (typeof p.time_s === 'number' ? p.time_s : null),
+ cellClassName: 'sk-cell-mono',
+ render: (p) => formatTime(p.time_s),
+ },
+ {
+ key: 'query',
+ header: 'Query',
+ sortable: false,
+ // High cardinality by definition — you type a fragment of a table
+ // name, you never pick a whole statement off a list.
+ type: 'text',
+ value: (p) => p.query || IDLE,
+ cellClassName: 'dbp-query',
+ render: (p) => (
+ <span title={p.query || ''}>
+ {p.query
+ ? (p.query.length > QUERY_PREVIEW_LEN ? `${p.query.slice(0, QUERY_PREVIEW_LEN)}…` : p.query)
+ : <span className="dbp-idle">{IDLE}</span>}
+ </span>
+ ),
+ },
+ ];
+
+ if (isAdmin) {
+ columns.push({
+ key: 'actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ className: 'text-right',
+ cellClassName: 'dbp-actions',
+ render: (p) => (
+ <button
+ type="button"
+ className="dbx-icon-btn is-danger"
+ onClick={() => killProcess(p)}
+ disabled={killing === p.id}
+ aria-label={`Kill process ${p.id}`}
+ title={isPg ? 'Terminate backend' : 'Kill process'}
+ >
+ <Ban size={14} aria-hidden="true" />
+ </button>
+ ),
+ });
+ }
+
+ const shown = useMemo(() => {
+ const list = rows || [];
+ const term = search.trim().toLowerCase();
+ if (!term) return list;
+ return list.filter((p) => (
+ String(p.id).includes(term)
+ || (p.user || '').toLowerCase().includes(term)
+ || (p.db || '').toLowerCase().includes(term)
+ || (p.query || '').toLowerCase().includes(term)
+ ));
+ }, [rows, search]);
+
+ const viewPageState = useMemo(() => ({ search }), [search]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearch(saved.search);
+ }, []);
+
+ // Scoped to this tab, and namespaced in the URL: the explorer can hold a
+ // processes tab, a backups tab and a table's structure at once, and three
+ // chrome instances would otherwise fight over the same ?view=/?sort=.
+ const chrome = useTableChrome({
+ columns,
+ rows: shown,
+ // Namespaced by ENGINE, because the same column key does not mean the
+ // same thing across them: `state` reads p.command on MySQL ('Sleep',
+ // 'Query') and p.state on PostgreSQL ('idle', 'active'). One shared
+ // namespace let a view saved against MySQL values apply itself to a
+ // PostgreSQL session list and match nothing, which reads as a broken
+ // view rather than an inapplicable one.
+ viewPageKey: `databases-processes-${engine || 'sql'}`,
+ builtinViews: PROCESS_VIEWS,
+ // Scoped by connection: the explorer keeps panes mounted, so two open
+ // process lists would otherwise write the same ?dbproc.view=.
+ urlScope: `dbproc-${conn?.id ?? 'x'}`,
+ noun: 'sessions',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ groupBy,
+ setGroupBy,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
+
return (
<div className="dbp">
- <div className="dbp-toolbar">
- <span className="dbp-count">
- <Activity size={14} aria-hidden="true" />
- {rows ? `${rows.length} process${rows.length === 1 ? '' : 'es'}` : 'Processes'}
- </span>
- <div className="dbp-toolbar-right">
- <label className="dbp-auto">
- <input
- type="checkbox"
- checked={autoRefresh}
- onChange={(e) => setAutoRefresh(e.target.checked)}
+ {/* One row of chrome. Auto-refresh rides it because it changes what
+ the table is showing rather than acting on a row; refresh itself
+ is in the "⋮". No process count here — the footer reports it,
+ under the rows it is counting. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="sessions"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <label className="dbp-auto">
+ <input
+ type="checkbox"
+ checked={autoRefresh}
+ onChange={(e) => setAutoRefresh(e.target.checked)}
+ />
+ <TimerReset size={13} aria-hidden="true" /> Auto-refresh (5s)
+ </label>
+ <SearchField
+ value={search}
+ onSearch={setSearch}
+ placeholder="Filter sessions…"
/>
- <TimerReset size={13} aria-hidden="true" /> Auto-refresh (5s)
- </label>
- <button
- type="button"
- className="dbx-icon-btn"
- onClick={() => load()}
- disabled={loading}
- aria-label="Refresh processes"
- title="Refresh"
- >
- <RefreshCw size={14} className={loading ? 'dbx-spin' : ''} aria-hidden="true" />
- </button>
- </div>
- </div>
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={() => load()} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
{error ? (
<div className="dbp-error" role="alert">{error}</div>
@@ -122,57 +344,39 @@ export default function ProcessListPanel({ conn, engine, active, isAdmin }) {
description="No client sessions are currently connected to this server."
/>
</div>
- ) : (
- <div className="dbp-scroll">
- <table className="dbp-table">
- <thead>
- <tr>
- <th>ID</th>
- <th>User</th>
- <th>Database</th>
- <th>{engineKind === 'postgresql' ? 'State' : 'Command'}</th>
- <th>Time</th>
- <th>Query</th>
- {isAdmin && <th aria-label="Actions" />}
- </tr>
- </thead>
- <tbody>
- {(rows || []).map((p) => (
- <tr key={p.id}>
- <td className="dbp-mono">{p.id}</td>
- <td>{p.user || '—'}</td>
- <td>{p.db || '—'}</td>
- <td>
- <span className="dbp-state">
- {engineKind === 'postgresql' ? (p.state || '—') : (p.command || p.state || '—')}
- </span>
- </td>
- <td className="dbp-mono">{formatTime(p.time_s)}</td>
- <td className="dbp-query" title={p.query || ''}>
- {p.query
- ? (p.query.length > QUERY_PREVIEW_LEN ? `${p.query.slice(0, QUERY_PREVIEW_LEN)}…` : p.query)
- : <span className="dbp-idle">idle</span>}
- </td>
- {isAdmin && (
- <td className="dbp-actions">
- <button
- type="button"
- className="dbx-icon-btn is-danger"
- onClick={() => killProcess(p)}
- disabled={killing === p.id}
- aria-label={`Kill process ${p.id}`}
- title={engineKind === 'postgresql' ? 'Terminate backend' : 'Kill process'}
- >
- <Ban size={14} aria-hidden="true" />
- </button>
- </td>
- )}
- </tr>
- ))}
- </tbody>
- </table>
+ ) : shown.length === 0 && !loading ? (
+ <div className="dbp-empty">
+ <EmptyState
+ icon={Activity}
+ title="No matching sessions"
+ description="No session matches the current search."
+ />
</div>
+ ) : (
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={shown}
+ keyField="id"
+ loading={loading && !rows}
+ sorts={sorts}
+ onSortsChange={setSorts}
+ groupBy={groupBy}
+ onGroupByChange={setGroupBy}
+ className="dbx-pane-scroll"
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={(rows || []).length}
+ // "session", not "process": the footer pluralises by
+ // appending an s, and "processs" is what that gives.
+ noun="session"
+ />
+ )}
+ />
)}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
);
}
diff --git a/frontend/src/components/databases/TableDataTab.jsx b/frontend/src/components/databases/TableDataTab.jsx
index a32d7f88..a8b7205b 100644
--- a/frontend/src/components/databases/TableDataTab.jsx
+++ b/frontend/src/components/databases/TableDataTab.jsx
@@ -1,10 +1,65 @@
-import { useEffect, useState, useCallback } from 'react';
+import { useEffect, useState, useMemo, useCallback } from 'react';
import { ChevronLeft, ChevronRight, RefreshCw, Table2, Columns3, KeyRound, Terminal } from 'lucide-react';
import { runQuery, getStructure, buildBrowseQuery } from './dbAdapter';
import ResultsGrid from './ResultsGrid';
+import { DataTable, DataTableFooter, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
const PAGE_SIZE = 100;
+// What the Key cell renders for a column that carries none. A real value, not
+// '': an empty rule value is dropped before it filters, so "key is ''" would
+// silently match everything.
+const NO_KEY = '—';
+const PRIMARY = 'PRIMARY';
+
+// Built-in saved views over a table's schema. The default sort is EMPTY on
+// purpose — a schema's natural order is its ordinal order, and that is the one
+// listing in which a column's position means something.
+const NO_RULES = { match: 'all', rules: [] };
+const NATURAL_ORDER = [];
+const PAGE_CLEAR = { search: '' };
+
+const STRUCTURE_VIEWS = [
+ {
+ name: 'All columns',
+ state: { sorts: NATURAL_ORDER, hiddenKeys: [], columnFilters: NO_RULES, page: PAGE_CLEAR },
+ },
+ {
+ // Where the NULLs can come from — the question you ask a schema before
+ // writing a query that joins on one of its columns.
+ name: 'Nullable columns',
+ state: {
+ sorts: NATURAL_ORDER,
+ hiddenKeys: [],
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'st1', field: 'nullable', op: 'is', value: true }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // "is none of —" rather than a list of PRI/UNI/MUL, so a key kind this
+ // build has never seen still lands here.
+ name: 'Indexed columns',
+ state: {
+ sorts: NATURAL_ORDER,
+ hiddenKeys: [],
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'st2', field: 'key', op: 'none', value: [NO_KEY] }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+];
+
// Browses one table: a paginated data grid (SELECT * LIMIT/OFFSET under the
// hood) plus a Structure view. `rowsEstimate` comes from the tree's table list
// so we can show a range without a COUNT(*) round-trip.
@@ -17,6 +72,14 @@ export default function TableDataTab({ conn, tabId, table, rowsEstimate, active,
const [structure, setStructure] = useState(null);
const [structureLoading, setStructureLoading] = useState(false);
const [structureUnsupported, setStructureUnsupported] = useState(false);
+ const [search, setSearch] = useState('');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: NATURAL_ORDER,
+ storageKey: 'serverkit-table-db-structure-sort',
+ });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-db-structure-cols' });
const loadData = useCallback(async (pageIdx) => {
setDataLoading(true);
@@ -35,8 +98,9 @@ export default function TableDataTab({ conn, tabId, table, rowsEstimate, active,
useEffect(() => { loadData(page); }, [loadData, page]);
- async function loadStructure() {
- if (structure || structureLoading || structureUnsupported) return;
+ const loadStructure = useCallback(async (force = false) => {
+ if (structureUnsupported || structureLoading) return;
+ if (structure && !force) return;
setStructureLoading(true);
try {
const result = await getStructure(conn, table);
@@ -44,7 +108,7 @@ export default function TableDataTab({ conn, tabId, table, rowsEstimate, active,
else if (result.success) setStructure(result.columns || []);
} catch { /* leave structure empty; the view shows a fallback */ }
finally { setStructureLoading(false); }
- }
+ }, [conn, table, structure, structureLoading, structureUnsupported]);
useEffect(() => {
if (view === 'structure') loadStructure();
@@ -65,6 +129,113 @@ export default function TableDataTab({ conn, tabId, table, rowsEstimate, active,
const hasMore = (data?.row_count || 0) === PAGE_SIZE;
+ // Schema rows. `nullable` is a BOOLEAN and `key`/`default` are absent on
+ // PostgreSQL, so every one of these needs a `render` — React draws a boolean
+ // and an undefined as nothing at all, which is how a converted column ends
+ // up silently blank.
+ const structureColumns = [
+ {
+ key: 'name',
+ header: 'Column',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ value: (col) => col.name || '',
+ cellClassName: 'sk-cell-name',
+ render: (col) => (
+ <>
+ {(col.key === 'PRI' || col.primary_key) && (
+ <KeyRound size={12} className="dbx-pk" aria-label="Primary key" />
+ )}
+ {col.name}
+ </>
+ ),
+ },
+ {
+ key: 'type',
+ header: 'Type',
+ sortable: true,
+ // Declared: a table of ten VARCHARs and two INTs would infer as an
+ // enum on one table and as text on the next, so the control the
+ // column offers would change from table to table.
+ type: 'enum',
+ value: (col) => col.type || '',
+ sortValue: (col) => col.type || '',
+ cellClassName: 'sk-cell-mono',
+ },
+ {
+ key: 'nullable',
+ header: 'Nullable',
+ sortable: true,
+ type: 'bool',
+ value: (col) => !!col.nullable,
+ sortValue: (col) => (col.nullable ? 1 : 0),
+ render: (col) => (col.nullable ? 'YES' : 'NO'),
+ },
+ {
+ key: 'key',
+ header: 'Key',
+ sortable: true,
+ type: 'enum',
+ value: (col) => ((col.key === 'PRI' || col.primary_key) ? PRIMARY : (col.key || NO_KEY)),
+ sortValue: (col) => ((col.key === 'PRI' || col.primary_key) ? PRIMARY : (col.key || '')),
+ cellClassName: 'sk-cell-mono',
+ render: (col) => ((col.key === 'PRI' || col.primary_key) ? PRIMARY : (col.key || NO_KEY)),
+ },
+ {
+ key: 'default',
+ header: 'Default',
+ sortable: true,
+ type: 'text',
+ value: (col) => (col.default == null ? 'NULL' : String(col.default)),
+ cellClassName: 'sk-cell-mono',
+ render: (col) => (
+ <span className={col.default == null ? 'is-null' : undefined}>
+ {col.default == null ? 'NULL' : String(col.default)}
+ </span>
+ ),
+ },
+ ];
+
+ const shownColumns = useMemo(() => {
+ const list = structure || [];
+ const term = search.trim().toLowerCase();
+ if (!term) return list;
+ return list.filter((col) => (
+ (col.name || '').toLowerCase().includes(term)
+ || (col.type || '').toLowerCase().includes(term)
+ ));
+ }, [structure, search]);
+
+ const viewPageState = useMemo(() => ({ search }), [search]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearch(saved.search);
+ }, []);
+
+ // Scoped to the structure view, and namespaced in the URL: several table
+ // tabs plus a processes tab can be open on this route at once, and their
+ // chrome instances would otherwise fight over the same ?view=/?sort=.
+ const chrome = useTableChrome({
+ columns: structureColumns,
+ rows: shownColumns,
+ viewPageKey: 'databases-table-structure',
+ builtinViews: STRUCTURE_VIEWS,
+ // Scoped per TAB, not per component: the explorer keeps every open tab
+ // mounted (a half-typed query has to survive a click on the tree), so
+ // four open tables mean four live chrome instances. A shared scope had
+ // them all writing the same ?dbstruct.view= and reading each other's
+ // back. The saved-view namespace stays shared, which is what you want —
+ // a "structure" view is worth reusing across tables.
+ urlScope: `dbstruct-${tabId}`,
+ noun: 'columns',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
+
return (
<div className="dbx-table-tab">
<div className="dbx-table-toolbar">
@@ -123,15 +294,20 @@ export default function TableDataTab({ conn, tabId, table, rowsEstimate, active,
<button type="button" className="dbx-chip" onClick={() => onOpenConsole?.(`SELECT * FROM ${table} LIMIT 100;`)}>
<Terminal size={14} aria-hidden="true" /> Query
</button>
- <button
- type="button"
- className="dbx-icon-btn"
- onClick={() => (view === 'data' ? loadData(page) : (setStructure(null), loadStructure()))}
- disabled={dataLoading || structureLoading}
- aria-label="Refresh"
- >
- <RefreshCw size={14} className={dataLoading || structureLoading ? 'dbx-spin' : ''} aria-hidden="true" />
- </button>
+ {/* Data only. The structure table's refresh lives in its own
+ "⋮" with the rest of its table-wide actions, so the schema
+ never carries two ways to reload it. */}
+ {view === 'data' && (
+ <button
+ type="button"
+ className="dbx-icon-btn"
+ onClick={() => loadData(page)}
+ disabled={dataLoading}
+ aria-label="Refresh"
+ >
+ <RefreshCw size={14} className={dataLoading ? 'dbx-spin' : ''} aria-hidden="true" />
+ </button>
+ )}
</div>
<div className="dbx-table-body">
@@ -151,40 +327,55 @@ export default function TableDataTab({ conn, tabId, table, rowsEstimate, active,
) : structureLoading ? (
<div className="dbx-structure-fallback">Loading structure…</div>
) : (
- <div className="dbx-grid-scroll">
- <table className="dbx-grid dbx-structure">
- <thead>
- <tr>
- <th scope="col">Column</th>
- <th scope="col">Type</th>
- <th scope="col">Nullable</th>
- <th scope="col">Key</th>
- <th scope="col">Default</th>
- </tr>
- </thead>
- <tbody>
- {(structure || []).map((col) => {
- const isPk = col.key === 'PRI' || col.primary_key;
- return (
- <tr key={col.name}>
- <td className="dbx-col-name">
- {isPk && <KeyRound size={12} className="dbx-pk" aria-label="Primary key" />}
- {col.name}
- </td>
- <td className="dbx-mono">{col.type}</td>
- <td>{col.nullable ? 'YES' : 'NO'}</td>
- <td className="dbx-mono">{isPk ? 'PRIMARY' : (col.key || '—')}</td>
- <td className={col.default == null ? 'is-null dbx-mono' : 'dbx-mono'}>
- {col.default == null ? 'NULL' : String(col.default)}
- </td>
- </tr>
- );
- })}
- {structure && structure.length === 0 && (
- <tr><td colSpan={5} className="dbx-structure-fallback">No columns reported.</td></tr>
- )}
- </tbody>
- </table>
+ <div className="dbx-structure-pane">
+ {/* One row of chrome for the schema table. This tab sits
+ inside the explorer's own tab bar, so it stays inline
+ rather than being hoisted. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="columns"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={search}
+ onSearch={setSearch}
+ placeholder="Filter column or type…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu
+ {...chrome.toolsProps}
+ onRefresh={() => loadStructure(true)}
+ />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={shownColumns}
+ keyField="name"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ className="dbx-pane-scroll"
+ emptyTitle={structure ? 'No matching columns' : 'No columns reported.'}
+ emptyMessage={structure ? 'No column matches the current search.' : ''}
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={(structure || []).length}
+ noun="column"
+ />
+ )}
+ />
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
)}
</div>
diff --git a/frontend/src/components/docker/ComposeTab.jsx b/frontend/src/components/docker/ComposeTab.jsx
index 29e9688a..e1511af5 100644
--- a/frontend/src/components/docker/ComposeTab.jsx
+++ b/frontend/src/components/docker/ComposeTab.jsx
@@ -1,17 +1,84 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo, useCallback } from 'react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
import { useConfirm } from '../../hooks/useConfirm';
import EmptyState from '../EmptyState';
import Modal from '@/components/Modal';
+import { DataTable, DataTableFooter, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
-import { Package, Play, Square, RotateCw, FileText } from 'lucide-react';
+import { Package, Play, Square, RotateCw, FileText, Download } from 'lucide-react';
import {
useServer,
unwrapRemoteData,
normalizeListResponse,
} from './dockerHelpers';
-import { IconAction, DownloadIcon } from './dockerShared';
+
+// `docker compose ls --format json` capitalises its keys; the label-scanning
+// fallback in docker_service builds the same shape by hand. Read through one
+// accessor each so a payload from either path lands in the same column.
+const projectName = (project) => project.Name || project.name || '';
+const projectStatus = (project) => project.Status || project.status || '';
+const projectConfig = (project) => project.ConfigFiles || project.config_files || '';
+
+// Status is a summary string — "running(3)" or "exited(2), running(1)" — so
+// both the label and the count have to be parsed out of it. A project with even
+// one container up counts as Running, which is what the old pill said too.
+const isProjectRunning = (project) => projectStatus(project).includes('running');
+const projectStatusLabel = (project) => (isProjectRunning(project) ? 'Running' : 'Stopped');
+const projectRunningCount = (project) => {
+ const match = projectStatus(project).match(/running\((\d+)\)/);
+ return match ? Number.parseInt(match[1], 10) : 0;
+};
+
+// Built-in views. Up/down is the only axis a compose listing carries, and it is
+// the one the pill already renders — so the two views below are the chip row
+// that used to sit above this table, minus the row.
+const NO_RULES = { match: 'all', rules: [] };
+const PAGE_CLEAR = { search: '' };
+const STATUS_IS = (id, value) => ({
+ match: 'all',
+ rules: [{ id, field: 'status', op: 'any', value: [value] }],
+});
+
+const COMPOSE_VIEWS = [
+ {
+ // What is actually serving traffic, busiest project first.
+ name: 'Running',
+ state: {
+ sorts: [{ key: 'running', direction: 'desc' }],
+ hiddenKeys: [],
+ columnFilters: STATUS_IS('dc1', 'Running'),
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // Projects the CLI still knows about but nothing is up for — either
+ // deliberately parked or something failed to come back after a reboot.
+ name: 'Stopped',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ columnFilters: STATUS_IS('dc2', 'Stopped'),
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // The way back out of either of the above.
+ name: 'All projects',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+];
// Compose Tab
const ComposeTab = ({ onStatsChange }) => {
@@ -22,10 +89,18 @@ const ComposeTab = ({ onStatsChange }) => {
const [loading, setLoading] = useState(true);
const [logsProject, setLogsProject] = useState(null);
const [actionLoading, setActionLoading] = useState({});
+ const [searchTerm, setSearchTerm] = useState('');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: [{ key: 'name', direction: 'asc' }],
+ storageKey: 'serverkit-table-docker-compose-sort',
+ });
+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({
+ storageKey: 'serverkit-table-docker-compose-cols',
+ });
useEffect(() => {
loadProjects();
- }, [serverId]);
+ }, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps
async function loadProjects() {
setLoading(true);
@@ -46,13 +121,14 @@ const ComposeTab = ({ onStatsChange }) => {
}
async function handleAction(project, action) {
- const projectPath = project.ConfigFiles || project.config_files;
+ const projectPath = projectConfig(project);
if (!projectPath) {
toast.error('Project path not found');
return;
}
- setActionLoading(prev => ({ ...prev, [project.Name || project.name]: true }));
+ const name = projectName(project);
+ setActionLoading(prev => ({ ...prev, [name]: true }));
try {
if (action === 'up') {
@@ -65,7 +141,7 @@ const ComposeTab = ({ onStatsChange }) => {
} else if (action === 'down') {
const downConfirmed = await confirmCompose({ title: 'Stop Compose Project', message: 'Stop this compose project? Containers will be removed.' });
if (!downConfirmed) {
- setActionLoading(prev => ({ ...prev, [project.Name || project.name]: false }));
+ setActionLoading(prev => ({ ...prev, [name]: false }));
return;
}
if (isRemote) {
@@ -95,130 +171,245 @@ const ComposeTab = ({ onStatsChange }) => {
console.error(`Failed to ${action} project:`, err);
toast.error(err.message || `Failed to ${action} project`);
} finally {
- setActionLoading(prev => ({ ...prev, [project.Name || project.name]: false }));
+ setActionLoading(prev => ({ ...prev, [name]: false }));
}
}
- function getProjectStatus(project) {
- const status = project.Status || project.status || '';
- if (status.includes('running')) return 'running';
- if (status.includes('exited') || status.includes('stopped')) return 'exited';
- return 'unknown';
- }
+ const filteredProjects = useMemo(() => {
+ const search = searchTerm.toLowerCase();
+ if (!search) return projects;
+ return projects.filter((project) => (
+ projectName(project).toLowerCase().includes(search) ||
+ projectConfig(project).toLowerCase().includes(search)
+ ));
+ }, [projects, searchTerm]);
- function parseRunningCount(status) {
- // Parse status like "running(3)" or "exited(2), running(1)"
- const match = status.match(/running\((\d+)\)/);
- return match ? parseInt(match[1], 10) : 0;
- }
+ // Every derived column carries BOTH `value` (rules, export) and `render`
+ // (the cell). One without the other renders blank — and `running`, an array
+ // of nothing on the row itself, would have thrown outright.
+ const columns = [
+ {
+ key: 'name',
+ header: 'Project',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ value: projectName,
+ sortValue: projectName,
+ render: (project) => (
+ <span className="dx-name-line" title={projectName(project)}>
+ <span>{projectName(project)}</span>
+ </span>
+ ),
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ // Declared: two labels across a handful of rows infer as text, which
+ // would turn both views above into typed-fragment matches. The
+ // pill's own word IS the filterable value.
+ type: 'enum',
+ enumOrder: ['Running', 'Stopped'],
+ width: 170,
+ value: projectStatusLabel,
+ // Running first on asc, matching the old default ordering.
+ sortValue: (project) => (isProjectRunning(project) ? 0 : 1),
+ render: (project) => (
+ <>
+ <span className={`dx-status-pill ${isProjectRunning(project) ? 'running' : 'stopped'}`}>
+ {projectStatusLabel(project)}
+ </span>
+ <span className="dx-muted-line" title={projectStatus(project)}>
+ {projectStatus(project) || 'unknown'}
+ </span>
+ </>
+ ),
+ },
+ {
+ key: 'running',
+ header: 'Up',
+ sortable: true,
+ // Declared with the raw container count behind it, so "up is over 0"
+ // is a numeric rule rather than a string match on "running(3)".
+ type: 'num',
+ width: 90,
+ value: projectRunningCount,
+ sortValue: projectRunningCount,
+ render: (project) => {
+ const count = projectRunningCount(project);
+ if (!count) return <span className="dx-muted-line">-</span>;
+ return <span className="dx-muted-line mono">{count}</span>;
+ },
+ },
+ {
+ key: 'config',
+ header: 'Config File',
+ sortable: true,
+ type: 'text',
+ value: projectConfig,
+ sortValue: projectConfig,
+ render: (project) => (
+ <span className="dx-muted-line mono" title={projectConfig(project)}>
+ {projectConfig(project) || '-'}
+ </span>
+ ),
+ },
+ {
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ width: 132,
+ className: 'text-right',
+ render: (project) => {
+ const busy = !!actionLoading[projectName(project)];
+ const running = isProjectRunning(project);
+ return (
+ <div className="dx-row-actions">
+ <button
+ type="button"
+ className="dx-row-action"
+ onClick={() => setLogsProject(project)}
+ disabled={busy}
+ title="Logs"
+ >
+ <FileText size={13} />
+ </button>
+ {running ? (
+ <>
+ <button
+ type="button"
+ className="dx-row-action"
+ onClick={() => handleAction(project, 'restart')}
+ disabled={busy}
+ title="Restart"
+ >
+ <RotateCw size={13} />
+ </button>
+ <button
+ type="button"
+ className="dx-row-action is-danger"
+ onClick={() => handleAction(project, 'down')}
+ disabled={busy}
+ title="Stop"
+ >
+ <Square size={13} />
+ </button>
+ </>
+ ) : (
+ <button
+ type="button"
+ className="dx-row-action is-success"
+ onClick={() => handleAction(project, 'up')}
+ disabled={busy}
+ title="Start"
+ >
+ <Play size={13} />
+ </button>
+ )}
+ <button
+ type="button"
+ className="dx-row-action"
+ onClick={() => handleAction(project, 'pull')}
+ disabled={busy}
+ title="Pull images"
+ >
+ <Download size={13} />
+ </button>
+ </div>
+ );
+ },
+ },
+ ];
+
+ const viewPageState = useMemo(() => ({ search: searchTerm }), [searchTerm]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearchTerm(saved.search);
+ }, []);
+
+ // Chrome INLINE in the picker's `actions` — the Docker page owns the top bar
+ // above this panel. `urlScope` because that one route renders five of these
+ // tables, and the link params (`view`, `sort`, `hide`, `f`…) are global
+ // names: unscoped, the compose sort would arrive as the containers sort.
+ const chrome = useTableChrome({
+ columns,
+ rows: filteredProjects,
+ viewPageKey: 'docker-compose',
+ urlScope: 'compose',
+ builtinViews: COMPOSE_VIEWS,
+ noun: 'projects',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
if (loading) {
- return <div className="docker-loading">Loading compose projects...</div>;
+ return (
+ <div className="dx-tab-pane">
+ <div className="docker-loading">Loading compose projects...</div>
+ </div>
+ );
}
return (
- <div>
- <div className="docker-table-header">
- <div className="docker-table-info">
- {projects.length} project{projects.length !== 1 ? 's' : ''} found
- </div>
- <Button variant="outline" size="sm" onClick={loadProjects}>
- Refresh
- </Button>
- </div>
+ <div className="dx-tab-pane dx-list-pane">
+ <GridViewPicker
+ views={chrome.views}
+ label="projects"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={searchTerm}
+ onSearch={setSearchTerm}
+ placeholder="Filter project or config path…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ {/* Refresh is not repeated as its own icon: it rides the
+ "⋮" with the other table-wide actions. */}
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadProjects} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
- {projects.length === 0 ? (
+ {filteredProjects.length === 0 ? (
<EmptyState
icon={Package}
- title="No Compose projects"
- description="No Docker Compose projects are running on this server."
- action={<code>docker compose up -d</code>}
+ title={projects.length === 0 ? 'No Compose projects' : 'No matching projects'}
+ description={projects.length === 0
+ ? 'No Docker Compose projects are running on this server.'
+ : 'No projects match the current search.'}
+ action={projects.length === 0 ? <code>docker compose up -d</code> : null}
/>
) : (
- <table className="docker-table">
- <thead>
- <tr>
- <th>Project</th>
- <th>Status</th>
- <th>Config File</th>
- <th className="text-right">Actions</th>
- </tr>
- </thead>
- <tbody>
- {projects.map(project => {
- const name = project.Name || project.name;
- const status = project.Status || project.status || 'unknown';
- const configFiles = project.ConfigFiles || project.config_files || '';
- const isRunning = getProjectStatus(project) === 'running';
- const runningCount = parseRunningCount(status);
- const isLoading = actionLoading[name];
-
- return (
- <tr key={name}>
- <td>
- <span className="docker-container-name">{name}</span>
- </td>
- <td>
- <span className={`docker-status-pill ${isRunning ? 'running' : 'exited'}`}>
- <span className="docker-status-dot" />
- {isRunning ? `Running (${runningCount})` : 'Stopped'}
- </span>
- <div className="docker-status-detail">{status}</div>
- </td>
- <td>
- <span className="docker-container-id truncate inline-block" style={{ maxWidth: '300px' }}>
- {configFiles}
- </span>
- </td>
- <td className="docker-actions-cell">
- <IconAction
- title="Logs"
- onClick={() => setLogsProject(project)}
- disabled={isLoading}
- >
- <FileText size={14} />
- </IconAction>
- {isRunning ? (
- <>
- <IconAction
- title="Restart"
- onClick={() => handleAction(project, 'restart')}
- disabled={isLoading}
- >
- <RotateCw size={14} />
- </IconAction>
- <IconAction
- title="Stop"
- onClick={() => handleAction(project, 'down')}
- disabled={isLoading}
- color="#EF4444"
- >
- <Square size={14} />
- </IconAction>
- </>
- ) : (
- <IconAction
- title="Start"
- onClick={() => handleAction(project, 'up')}
- disabled={isLoading}
- color="#10B981"
- >
- <Play size={14} />
- </IconAction>
- )}
- <IconAction
- title="Pull Images"
- onClick={() => handleAction(project, 'pull')}
- disabled={isLoading}
- >
- <DownloadIcon />
- </IconAction>
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
+ <section className="dx-resource-list">
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={filteredProjects}
+ keyField={(project) => projectName(project)}
+ sorts={sorts}
+ onSortsChange={setSorts}
+ className="dx-table-wrap"
+ tableClassName="dx-manager-table dx-plain-table"
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={projects.length}
+ noun="project"
+ />
+ )}
+ />
+ </section>
)}
{logsProject && (
@@ -227,6 +418,8 @@ const ComposeTab = ({ onStatsChange }) => {
onClose={() => setLogsProject(null)}
/>
)}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
);
};
@@ -240,13 +433,13 @@ const ComposeLogsModal = ({ project, onClose }) => {
const [selectedService, setSelectedService] = useState('');
const [services, setServices] = useState([]);
- const projectName = project.Name || project.name;
- const projectPath = project.ConfigFiles || project.config_files || '';
+ const name = projectName(project);
+ const projectPath = projectConfig(project);
useEffect(() => {
loadServices();
loadLogs();
- }, [project, tail, selectedService]);
+ }, [project, tail, selectedService]); // eslint-disable-line react-hooks/exhaustive-deps
async function loadServices() {
try {
@@ -291,7 +484,7 @@ const ComposeLogsModal = ({ project, onClose }) => {
}
return (
- <Modal open onClose={onClose} title={`Logs: ${projectName}`} size="lg">
+ <Modal open onClose={onClose} title={`Logs: ${name}`} size="lg">
<div className="modal-body">
<div className="logs-controls flex flex-wrap items-center gap-2 mb-2">
<label>Service:</label>
diff --git a/frontend/src/components/docker/ImagesTab.jsx b/frontend/src/components/docker/ImagesTab.jsx
index 02ef6d22..70b350af 100644
--- a/frontend/src/components/docker/ImagesTab.jsx
+++ b/frontend/src/components/docker/ImagesTab.jsx
@@ -1,17 +1,25 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo, useCallback } from 'react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
import { useConfirm } from '../../hooks/useConfirm';
import EmptyState from '../EmptyState';
import Modal from '@/components/Modal';
+import { DataTable, DataTableFooter, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
-import { Layers } from 'lucide-react';
+import { Layers, Trash2 } from 'lucide-react';
+import { formatBytes } from '@/utils/formatBytes';
+import { formatRelativeTime } from '@/utils/time';
import {
useServer,
normalizeListResponse,
} from './dockerHelpers';
-import { IconAction, TrashIcon } from './dockerShared';
export const PullImageButton = () => {
const [showModal, setShowModal] = useState(false);
@@ -25,6 +33,128 @@ export const PullImageButton = () => {
);
};
+// The two transports describe the same image differently: `docker images`
+// hands back repository/tag as separate strings, the agent hands back
+// `repo_tags: ["nginx:latest"]` and nothing else. Every accessor below reads
+// both, because a column that silently blanks on remote hosts is worse than no
+// column at all.
+const imageId = (image) => String(image.id || image.ID || '').replace(/^sha256:/, '');
+
+const imageRef = (image) => {
+ if (image.repository || image.tag) {
+ return { repository: image.repository || '<none>', tag: image.tag || '<none>' };
+ }
+ const first = Array.isArray(image.repo_tags) ? image.repo_tags[0] : null;
+ if (!first) return { repository: '<none>', tag: '<none>' };
+ // A registry port ("registry:5000/app") puts a colon in the REPOSITORY
+ // half, so the last colon is only the tag separator when no '/' follows it.
+ const colon = first.lastIndexOf(':');
+ if (colon > 0 && !first.slice(colon).includes('/')) {
+ return { repository: first.slice(0, colon), tag: first.slice(colon + 1) };
+ }
+ return { repository: first, tag: '<none>' };
+};
+
+// Docker's CLI prints sizes in SI units ("142MB" = 142 * 10^6); the agent sends
+// a byte count. Parsed to MEGABYTES rather than bytes because this number is
+// also what the filter drawer and the chips show — "size is over 500 MB" is a
+// question you can ask, "is over 500000000" is not. The cell still renders
+// through the app's canonical formatter, so one host's images read the same way
+// as another's.
+const SIZE_MULTIPLIERS = {
+ b: 1, kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12,
+ kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3, tib: 1024 ** 4,
+};
+
+const imageSizeBytes = (image) => {
+ const raw = image.size ?? image.Size;
+ if (typeof raw === 'number') return Number.isFinite(raw) ? raw : null;
+ if (typeof raw !== 'string') return null;
+ const match = raw.trim().match(/^([\d.]+)\s*([a-z]+)?$/i);
+ if (!match) return null;
+ const amount = Number.parseFloat(match[1]);
+ if (!Number.isFinite(amount)) return null;
+ return amount * (SIZE_MULTIPLIERS[(match[2] || 'b').toLowerCase()] ?? 1);
+};
+
+// The number a filter rule compares against MUST be the number the cell shows,
+// or "Size is over 400 MB" matches a row whose own cell reads "392.9 MB". The
+// cell renders through the app-wide formatBytes, which is base-1024 with MB/GB
+// labels, so the rule value is mebibytes too — not docker's base-1000 MB.
+const imageSizeMb = (image) => {
+ const bytes = imageSizeBytes(image);
+ return bytes == null ? null : bytes / (1024 * 1024);
+};
+
+const imageCreatedMs = (image) => {
+ const raw = image.created ?? image.CreatedAt ?? image.Created;
+ // The agent sends epoch SECONDS, the CLI "2026-08-12 09:12:33 -0400 EDT".
+ if (typeof raw === 'number') return raw > 1e11 ? raw : raw * 1000;
+ const parsed = Date.parse(raw || '');
+ return Number.isNaN(parsed) ? null : parsed;
+};
+
+// Built-in views. Dangling is the one axis this payload really has: docker
+// reports an untagged layer as repository `<none>`, on both transports, so the
+// rule below is reading a fact rather than a guess. There is deliberately no
+// "unused" view — the image list carries no reference count, and inventing one
+// from the container list would be a different question answered quietly.
+const NO_RULES = { match: 'all', rules: [] };
+const PAGE_CLEAR = { search: '' };
+
+const IMAGE_VIEWS = [
+ {
+ // What Prune would take, biggest first: an untagged layer left behind
+ // by a rebuild is pure reclaimable disk.
+ name: 'Dangling',
+ state: {
+ sorts: [{ key: 'size', direction: 'desc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'di1', field: 'repository', op: 'is', value: '<none>' }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // The disk question. No rules — the whole library, ordered by what it
+ // costs you.
+ name: 'Largest first',
+ state: {
+ sorts: [{ key: 'size', direction: 'desc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // Every tag of a repository together, which is how you notice you are
+ // still holding four versions of the same base image.
+ name: 'By repository',
+ state: {
+ sorts: [{ key: 'created', direction: 'desc' }],
+ hiddenKeys: [],
+ groupBy: 'repository',
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // The way back out of any of the above.
+ name: 'Newest first',
+ state: {
+ sorts: [{ key: 'created', direction: 'desc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+];
+
// Images Tab
const ImagesTab = ({ onStatsChange }) => {
const toast = useToast();
@@ -33,10 +163,18 @@ const ImagesTab = ({ onStatsChange }) => {
const [images, setImages] = useState([]);
const [loading, setLoading] = useState(true);
const [searchTerm, setSearchTerm] = useState('');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: [{ key: 'repository', direction: 'asc' }],
+ storageKey: 'serverkit-table-docker-images-sort',
+ });
+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({
+ storageKey: 'serverkit-table-docker-images-cols',
+ });
+ const [groupBy, setGroupBy] = useState(null);
useEffect(() => {
loadImages();
- }, [serverId]);
+ }, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps
async function loadImages() {
setLoading(true);
@@ -56,15 +194,16 @@ const ImagesTab = ({ onStatsChange }) => {
}
}
- async function handleRemove(imageId) {
+ async function handleRemove(image) {
const confirmed = await confirmImage({ title: 'Remove Image', message: 'Remove this image?' });
if (!confirmed) return;
try {
+ const id = image.id || image.ID;
if (isRemote) {
- await api.removeRemoteImage(serverId, imageId, true);
+ await api.removeRemoteImage(serverId, id, true);
} else {
- await api.removeImage(imageId, true);
+ await api.removeImage(id, true);
}
toast.success('Image removed successfully');
loadImages();
@@ -75,73 +214,210 @@ const ImagesTab = ({ onStatsChange }) => {
}
}
- const filteredImages = images.filter(img => {
- if (!searchTerm) return true;
+ const filteredImages = useMemo(() => {
const search = searchTerm.toLowerCase();
- return img.repository?.toLowerCase().includes(search) ||
- img.tag?.toLowerCase().includes(search) ||
- img.id?.toLowerCase().includes(search);
+ if (!search) return images;
+ return images.filter((image) => {
+ const { repository, tag } = imageRef(image);
+ return repository.toLowerCase().includes(search) ||
+ tag.toLowerCase().includes(search) ||
+ imageId(image).toLowerCase().includes(search);
+ });
+ }, [images, searchTerm]);
+
+ // Two accessors per derived column on purpose: `value` is what the column
+ // menu, the filter rules and the export read, `render` is the cell. A
+ // derived column with only one of them renders blank (see ds/DataTable).
+ const columns = [
+ {
+ key: 'repository',
+ header: 'Repository',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ // Grouping is the whole point of the "By repository" view, and
+ // `groupValue` has to be spelled out too: the grouper falls back to
+ // row[key], which the agent's payload does not have.
+ groupable: true,
+ value: (image) => imageRef(image).repository,
+ groupValue: (image) => imageRef(image).repository,
+ sortValue: (image) => imageRef(image).repository,
+ render: (image) => (
+ <div className="dx-name-stack">
+ <span className="dx-name-line">
+ <span title={imageRef(image).repository}>{imageRef(image).repository}</span>
+ </span>
+ <span className="dx-muted-line mono">{imageId(image).substring(0, 12) || '-'}</span>
+ </div>
+ ),
+ },
+ {
+ key: 'tag',
+ header: 'Tag',
+ sortable: true,
+ // Declared: a host whose tags all read "8.0"/"20" would infer `num`
+ // and offer "is under 20" instead of a text match.
+ type: 'text',
+ value: (image) => imageRef(image).tag,
+ sortValue: (image) => imageRef(image).tag,
+ render: (image) => <span className="dx-code-pill">{imageRef(image).tag}</span>,
+ },
+ {
+ key: 'size',
+ header: 'Size',
+ sortable: true,
+ type: 'num',
+ unit: ' MB',
+ width: 110,
+ value: imageSizeMb,
+ sortValue: imageSizeMb,
+ render: (image) => (
+ <span className="dx-muted-line mono">{formatBytes(imageSizeBytes(image))}</span>
+ ),
+ },
+ {
+ key: 'created',
+ header: 'Created',
+ sortable: true,
+ // Declared: `sortValue` is epoch ms, and letting that number type the
+ // column would offer "is under 1754…" instead of a date picker.
+ type: 'date',
+ width: 120,
+ value: (image) => {
+ const ms = imageCreatedMs(image);
+ return ms == null ? null : new Date(ms).toISOString();
+ },
+ sortValue: imageCreatedMs,
+ render: (image) => {
+ const ms = imageCreatedMs(image);
+ if (ms == null) return <span className="dx-muted-line">-</span>;
+ const iso = new Date(ms).toISOString();
+ return (
+ <span className="dx-muted-line" title={new Date(ms).toLocaleString()}>
+ {formatRelativeTime(iso)}
+ </span>
+ );
+ },
+ },
+ {
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ width: 72,
+ className: 'text-right',
+ render: (image) => (
+ <div className="dx-row-actions">
+ <button
+ type="button"
+ className="dx-row-action is-danger"
+ onClick={() => handleRemove(image)}
+ title="Remove image"
+ >
+ <Trash2 size={13} />
+ </button>
+ </div>
+ ),
+ },
+ ];
+
+ // The page-private half of a saved view: the search box is the one piece of
+ // state the envelope's common keys cannot describe.
+ const viewPageState = useMemo(() => ({ search: searchTerm }), [searchTerm]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearchTerm(saved.search);
+ }, []);
+
+ // Chrome stays INLINE in the picker's `actions`: the Docker page owns the
+ // top bar above this panel, and hoisting from here would hijack it for
+ // whichever resource tab happened to be open. `urlScope` because that one
+ // route renders five of these tables — unscoped, the images view name would
+ // arrive in the volumes table's ?view=.
+ const chrome = useTableChrome({
+ columns,
+ rows: filteredImages,
+ viewPageKey: 'docker-images',
+ urlScope: 'images',
+ builtinViews: IMAGE_VIEWS,
+ noun: 'images',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ groupBy,
+ setGroupBy,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
});
if (loading) {
- return <div className="docker-loading">Loading images...</div>;
+ return (
+ <div className="dx-tab-pane">
+ <div className="docker-loading">Loading images...</div>
+ </div>
+ );
}
return (
- <div>
- <div className="docker-table-header">
- <div />
- <Input
- type="text"
- className="docker-search"
- placeholder="Search images..."
- value={searchTerm}
- onChange={(e) => setSearchTerm(e.target.value)}
- />
- </div>
+ <div className="dx-tab-pane dx-list-pane">
+ <GridViewPicker
+ views={chrome.views}
+ label="images"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={searchTerm}
+ onSearch={setSearchTerm}
+ placeholder="Filter repository, tag, or ID…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadImages} />
+ </>
+ )}
+ />
+ <GridChips {...chrome.chipProps} />
+
+ {/* Only the SEARCH can empty the pane outright. A column rule that
+ matches nothing keeps the table mounted — the header menu that
+ undoes it lives in the header. */}
{filteredImages.length === 0 ? (
<EmptyState
icon={Layers}
- title="No images"
- description="Pull an image to see it here."
+ title={images.length === 0 ? 'No images' : 'No matching images'}
+ description={images.length === 0
+ ? 'Pull an image to see it here.'
+ : 'No images match the current search.'}
/>
) : (
- <table className="docker-table">
- <thead>
- <tr>
- <th>Repository</th>
- <th>Tag</th>
- <th>Image ID</th>
- <th>Size</th>
- <th>Created</th>
- <th className="text-right">Actions</th>
- </tr>
- </thead>
- <tbody>
- {filteredImages.map(image => (
- <tr key={image.id}>
- <td>
- <span className="docker-container-name">{image.repository || '<none>'}</span>
- </td>
- <td>
- <span className="docker-image-tag">{image.tag || '<none>'}</span>
- </td>
- <td>
- <span className="docker-container-id">{image.id?.substring(0, 12)}</span>
- </td>
- <td>{image.size}</td>
- <td>{image.created}</td>
- <td className="docker-actions-cell">
- <IconAction title="Delete" onClick={() => handleRemove(image.id)} color="#EF4444">
- <TrashIcon />
- </IconAction>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <section className="dx-resource-list">
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={filteredImages}
+ keyField={(image) => imageId(image)}
+ sorts={sorts}
+ onSortsChange={setSorts}
+ groupBy={groupBy}
+ onGroupByChange={setGroupBy}
+ className="dx-table-wrap"
+ tableClassName="dx-manager-table dx-plain-table"
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={images.length}
+ noun="image"
+ />
+ )}
+ />
+ </section>
)}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
);
};
diff --git a/frontend/src/components/docker/NetworksTab.jsx b/frontend/src/components/docker/NetworksTab.jsx
index 0ccec1f5..6b0223ab 100644
--- a/frontend/src/components/docker/NetworksTab.jsx
+++ b/frontend/src/components/docker/NetworksTab.jsx
@@ -1,17 +1,24 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo, useCallback } from 'react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
import { useConfirm } from '../../hooks/useConfirm';
import EmptyState from '../EmptyState';
import Modal from '@/components/Modal';
+import { DataTable, DataTableFooter, Pill, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
-import { Network as NetworkIcon } from 'lucide-react';
+import { Network as NetworkIcon, Trash2, Lock } from 'lucide-react';
import {
useServer,
normalizeListResponse,
+ shortId,
} from './dockerHelpers';
-import { IconAction, TrashIcon } from './dockerShared';
export const CreateNetworkButton = () => {
const [showModal, setShowModal] = useState(false);
@@ -30,6 +37,62 @@ export const CreateNetworkButton = () => {
);
};
+const networkName = (network) => network.name || network.Name || '';
+const networkId = (network) => network.id || network.ID || '';
+
+// bridge/host/none ship with the daemon and cannot be removed. That was already
+// encoded here as a hidden delete button; promoting it to a column is what
+// turns "why can't I delete this one" into something the table says out loud —
+// and gives the view below a rule to stand on.
+const BUILTIN_NETWORKS = ['bridge', 'host', 'none'];
+const networkKind = (network) => (
+ BUILTIN_NETWORKS.includes(networkName(network)) ? 'Built-in' : 'User-defined'
+);
+
+const NO_RULES = { match: 'all', rules: [] };
+const PAGE_CLEAR = { search: '' };
+
+const NETWORK_VIEWS = [
+ {
+ // Everything someone on this host created — the only rows with an
+ // action, and the ones a stale compose project leaves behind.
+ name: 'User-defined',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'dn1', field: 'kind', op: 'any', value: ['User-defined'] }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // No rules, bucketed by driver: bridge networks are per-host, overlay
+ // ones span the swarm, and mixing them in one list hides that.
+ name: 'By driver',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ groupBy: 'driver',
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // The way back out of either of the above.
+ name: 'All networks',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+];
+
// Networks Tab
const NetworksTab = ({ onStatsChange }) => {
const toast = useToast();
@@ -37,10 +100,19 @@ const NetworksTab = ({ onStatsChange }) => {
const { confirm: confirmNetwork } = useConfirm();
const [networks, setNetworks] = useState([]);
const [loading, setLoading] = useState(true);
+ const [searchTerm, setSearchTerm] = useState('');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: [{ key: 'name', direction: 'asc' }],
+ storageKey: 'serverkit-table-docker-networks-sort',
+ });
+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({
+ storageKey: 'serverkit-table-docker-networks-cols',
+ });
+ const [groupBy, setGroupBy] = useState(null);
useEffect(() => {
loadNetworks();
- }, [serverId]);
+ }, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps
async function loadNetworks() {
setLoading(true);
@@ -60,15 +132,15 @@ const NetworksTab = ({ onStatsChange }) => {
}
}
- async function handleRemove(networkId) {
+ async function handleRemove(network) {
const confirmed = await confirmNetwork({ title: 'Remove Network', message: 'Remove this network?' });
if (!confirmed) return;
try {
if (isRemote) {
- await api.removeRemoteNetwork(serverId, networkId);
+ await api.removeRemoteNetwork(serverId, networkId(network));
} else {
- await api.removeNetwork(networkId);
+ await api.removeNetwork(networkId(network));
}
toast.success('Network removed successfully');
loadNetworks();
@@ -79,54 +151,198 @@ const NetworksTab = ({ onStatsChange }) => {
}
}
- const systemNetworks = ['bridge', 'host', 'none'];
+ const filteredNetworks = useMemo(() => {
+ const search = searchTerm.toLowerCase();
+ if (!search) return networks;
+ return networks.filter((network) => (
+ networkName(network).toLowerCase().includes(search) ||
+ networkId(network).toLowerCase().includes(search)
+ ));
+ }, [networks, searchTerm]);
+
+ // Every derived column carries BOTH `value` (rules, grouping, export) and
+ // `render` (the cell). One without the other renders blank.
+ const columns = [
+ {
+ key: 'name',
+ header: 'Name',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ value: networkName,
+ sortValue: networkName,
+ render: (network) => (
+ <div className="dx-name-stack">
+ <span className="dx-name-line">
+ <span title={networkName(network)}>{networkName(network)}</span>
+ </span>
+ <span className="dx-muted-line mono">{shortId(networkId(network))}</span>
+ </div>
+ ),
+ },
+ {
+ key: 'kind',
+ header: 'Kind',
+ sortable: true,
+ // Declared: three built-ins plus one custom network is a two-value
+ // column that infers as text, which would turn the view above into a
+ // typed fragment rather than a pick-list.
+ type: 'enum',
+ enumOrder: ['User-defined', 'Built-in'],
+ width: 130,
+ value: networkKind,
+ sortValue: networkKind,
+ render: (network) => (
+ <Pill kind={networkKind(network) === 'Built-in' ? 'gray' : 'cyan'} dot={false}>
+ {networkKind(network)}
+ </Pill>
+ ),
+ },
+ {
+ key: 'driver',
+ header: 'Driver',
+ sortable: true,
+ type: 'enum',
+ groupable: true,
+ width: 130,
+ value: (network) => network.driver || network.Driver || '-',
+ groupValue: (network) => network.driver || network.Driver || '-',
+ sortValue: (network) => network.driver || network.Driver || '-',
+ render: (network) => (
+ <span className="dx-code-pill">{network.driver || network.Driver || '-'}</span>
+ ),
+ },
+ {
+ key: 'scope',
+ header: 'Scope',
+ sortable: true,
+ type: 'enum',
+ width: 110,
+ value: (network) => network.scope || network.Scope || '-',
+ sortValue: (network) => network.scope || network.Scope || '-',
+ render: (network) => (
+ <span className="dx-muted-line">{network.scope || network.Scope || '-'}</span>
+ ),
+ },
+ {
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ width: 110,
+ className: 'text-right',
+ render: (network) => (
+ <div className="dx-row-actions">
+ {networkKind(network) === 'Built-in' ? (
+ <span className="dx-row-protected" title="Ships with the Docker daemon — it cannot be removed">
+ <Lock size={11} /> System
+ </span>
+ ) : (
+ <button
+ type="button"
+ className="dx-row-action is-danger"
+ onClick={() => handleRemove(network)}
+ title="Remove network"
+ >
+ <Trash2 size={13} />
+ </button>
+ )}
+ </div>
+ ),
+ },
+ ];
+
+ const viewPageState = useMemo(() => ({ search: searchTerm }), [searchTerm]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearchTerm(saved.search);
+ }, []);
+
+ // Chrome INLINE in the picker's `actions` — the Docker page owns the top bar
+ // above this panel. `urlScope` because that one route renders five of these
+ // tables, and the link params (`view`, `sort`, `hide`, `f`…) are global
+ // names: unscoped, the networks view would arrive as the images view.
+ const chrome = useTableChrome({
+ columns,
+ rows: filteredNetworks,
+ viewPageKey: 'docker-networks',
+ urlScope: 'networks',
+ builtinViews: NETWORK_VIEWS,
+ noun: 'networks',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ groupBy,
+ setGroupBy,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
if (loading) {
- return <div className="docker-loading">Loading networks...</div>;
+ return (
+ <div className="dx-tab-pane">
+ <div className="docker-loading">Loading networks...</div>
+ </div>
+ );
}
return (
- <div>
- {networks.length === 0 ? (
+ <div className="dx-tab-pane dx-list-pane">
+ <GridViewPicker
+ views={chrome.views}
+ label="networks"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={searchTerm}
+ onSearch={setSearchTerm}
+ placeholder="Filter name or ID…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadNetworks} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ {filteredNetworks.length === 0 ? (
<EmptyState
icon={NetworkIcon}
- title="No networks"
- description="Create a network to connect containers."
+ title={networks.length === 0 ? 'No networks' : 'No matching networks'}
+ description={networks.length === 0
+ ? 'Create a network to connect containers.'
+ : 'No networks match the current search.'}
/>
) : (
- <table className="docker-table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Network ID</th>
- <th>Driver</th>
- <th>Scope</th>
- <th className="text-right">Actions</th>
- </tr>
- </thead>
- <tbody>
- {networks.map(network => (
- <tr key={network.id}>
- <td>
- <span className="docker-container-name">{network.name}</span>
- </td>
- <td>
- <span className="docker-container-id">{network.id?.substring(0, 12)}</span>
- </td>
- <td>{network.driver}</td>
- <td>{network.scope}</td>
- <td className="docker-actions-cell">
- {!systemNetworks.includes(network.name) && (
- <IconAction title="Delete" onClick={() => handleRemove(network.id)} color="#EF4444">
- <TrashIcon />
- </IconAction>
- )}
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <section className="dx-resource-list">
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={filteredNetworks}
+ keyField={(network) => networkId(network) || networkName(network)}
+ sorts={sorts}
+ onSortsChange={setSorts}
+ groupBy={groupBy}
+ onGroupByChange={setGroupBy}
+ className="dx-table-wrap"
+ tableClassName="dx-manager-table dx-plain-table"
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={networks.length}
+ noun="network"
+ />
+ )}
+ />
+ </section>
)}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
);
};
diff --git a/frontend/src/components/docker/VolumesTab.jsx b/frontend/src/components/docker/VolumesTab.jsx
index 2e00b884..7f1f7802 100644
--- a/frontend/src/components/docker/VolumesTab.jsx
+++ b/frontend/src/components/docker/VolumesTab.jsx
@@ -1,17 +1,23 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo, useCallback } from 'react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
import { useConfirm } from '../../hooks/useConfirm';
import EmptyState from '../EmptyState';
import Modal from '@/components/Modal';
+import { DataTable, DataTableFooter, Pill, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
-import { HardDrive } from 'lucide-react';
+import { HardDrive, Trash2 } from 'lucide-react';
import {
useServer,
normalizeListResponse,
} from './dockerHelpers';
-import { IconAction, TrashIcon } from './dockerShared';
export const CreateVolumeButton = () => {
const [showModal, setShowModal] = useState(false);
@@ -30,6 +36,67 @@ export const CreateVolumeButton = () => {
);
};
+const volumeName = (volume) => volume.name || volume.Name || '';
+
+// Docker names an implicitly-created volume with a 64-character hex digest;
+// anything else was named by a human or a compose file. That split is the only
+// stable axis this payload actually carries, and it is the useful one: a wall
+// of hex is what a rebuilt stack leaves behind.
+//
+// There is deliberately no "Unused" view. `docker volume ls` reports no
+// reference count and neither does the agent (name · driver · mountpoint, plus
+// scope/created_at remotely), so a view by that name would be guessing.
+const ANONYMOUS_NAME = /^[0-9a-f]{64}$/;
+const volumeKind = (volume) => (ANONYMOUS_NAME.test(volumeName(volume)) ? 'Anonymous' : 'Named');
+
+const NO_RULES = { match: 'all', rules: [] };
+const PAGE_CLEAR = { search: '' };
+
+const VOLUME_VIEWS = [
+ {
+ // The cleanup worklist: volumes nobody chose a name for, which is
+ // usually nobody remembering what is in them either.
+ name: 'Anonymous',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'dv1', field: 'kind', op: 'any', value: ['Anonymous'] }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // The other half — the ones a compose file or an operator declared, and
+ // the ones you have to be careful with.
+ name: 'Named',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'dv2', field: 'kind', op: 'any', value: ['Named'] }],
+ },
+ page: PAGE_CLEAR,
+ },
+ },
+ {
+ // No rules: everything, bucketed by storage driver. On most hosts that
+ // is one group — which is itself the answer when it is not.
+ name: 'By driver',
+ state: {
+ sorts: [{ key: 'name', direction: 'asc' }],
+ hiddenKeys: [],
+ groupBy: 'driver',
+ columnFilters: NO_RULES,
+ page: PAGE_CLEAR,
+ },
+ },
+];
+
// Volumes Tab
const VolumesTab = ({ onStatsChange }) => {
const toast = useToast();
@@ -37,10 +104,19 @@ const VolumesTab = ({ onStatsChange }) => {
const { confirm: confirmVolume } = useConfirm();
const [volumes, setVolumes] = useState([]);
const [loading, setLoading] = useState(true);
+ const [searchTerm, setSearchTerm] = useState('');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: [{ key: 'name', direction: 'asc' }],
+ storageKey: 'serverkit-table-docker-volumes-sort',
+ });
+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({
+ storageKey: 'serverkit-table-docker-volumes-cols',
+ });
+ const [groupBy, setGroupBy] = useState(null);
useEffect(() => {
loadVolumes();
- }, [serverId]);
+ }, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps
async function loadVolumes() {
setLoading(true);
@@ -60,15 +136,15 @@ const VolumesTab = ({ onStatsChange }) => {
}
}
- async function handleRemove(volumeName) {
+ async function handleRemove(volume) {
const confirmed = await confirmVolume({ title: 'Remove Volume', message: 'Remove this volume? All data will be lost.' });
if (!confirmed) return;
try {
if (isRemote) {
- await api.removeRemoteVolume(serverId, volumeName, true);
+ await api.removeRemoteVolume(serverId, volumeName(volume), true);
} else {
- await api.removeVolume(volumeName, true);
+ await api.removeVolume(volumeName(volume), true);
}
toast.success('Volume removed successfully');
loadVolumes();
@@ -79,50 +155,190 @@ const VolumesTab = ({ onStatsChange }) => {
}
}
+ const filteredVolumes = useMemo(() => {
+ const search = searchTerm.toLowerCase();
+ if (!search) return volumes;
+ return volumes.filter((volume) => (
+ volumeName(volume).toLowerCase().includes(search) ||
+ String(volume.mountpoint || volume.Mountpoint || '').toLowerCase().includes(search)
+ ));
+ }, [volumes, searchTerm]);
+
+ // Every derived column carries BOTH `value` (rules, grouping, export) and
+ // `render` (the cell). One without the other renders blank.
+ const columns = [
+ {
+ key: 'name',
+ header: 'Name',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ value: volumeName,
+ sortValue: volumeName,
+ render: (volume) => (
+ <span className="dx-name-line" title={volumeName(volume)}>
+ <span>{volumeName(volume)}</span>
+ </span>
+ ),
+ },
+ {
+ key: 'kind',
+ header: 'Kind',
+ sortable: true,
+ // Declared: a host with only named volumes has a single distinct
+ // value, which infers as text and turns the view above into a
+ // typed-fragment match instead of a pick-list.
+ type: 'enum',
+ enumOrder: ['Anonymous', 'Named'],
+ width: 110,
+ value: volumeKind,
+ sortValue: volumeKind,
+ render: (volume) => (
+ <Pill kind={volumeKind(volume) === 'Anonymous' ? 'amber' : 'gray'} dot={false}>
+ {volumeKind(volume)}
+ </Pill>
+ ),
+ },
+ {
+ key: 'driver',
+ header: 'Driver',
+ sortable: true,
+ type: 'enum',
+ groupable: true,
+ width: 120,
+ value: (volume) => volume.driver || volume.Driver || '-',
+ groupValue: (volume) => volume.driver || volume.Driver || '-',
+ sortValue: (volume) => volume.driver || volume.Driver || '-',
+ render: (volume) => (
+ <span className="dx-muted-line">{volume.driver || volume.Driver || '-'}</span>
+ ),
+ },
+ {
+ key: 'mountpoint',
+ header: 'Mountpoint',
+ sortable: true,
+ type: 'text',
+ value: (volume) => volume.mountpoint || volume.Mountpoint || '',
+ sortValue: (volume) => volume.mountpoint || volume.Mountpoint || '',
+ render: (volume) => (
+ <span className="dx-muted-line mono" title={volume.mountpoint || volume.Mountpoint || ''}>
+ {volume.mountpoint || volume.Mountpoint || '-'}
+ </span>
+ ),
+ },
+ {
+ key: '__actions',
+ header: '',
+ sortable: false,
+ hideable: false,
+ width: 72,
+ className: 'text-right',
+ render: (volume) => (
+ <div className="dx-row-actions">
+ <button
+ type="button"
+ className="dx-row-action is-danger"
+ onClick={() => handleRemove(volume)}
+ title="Remove volume"
+ >
+ <Trash2 size={13} />
+ </button>
+ </div>
+ ),
+ },
+ ];
+
+ const viewPageState = useMemo(() => ({ search: searchTerm }), [searchTerm]);
+ const applyViewPageState = useCallback((saved) => {
+ if (saved.search !== undefined) setSearchTerm(saved.search);
+ }, []);
+
+ // Chrome INLINE in the picker's `actions` — the Docker page owns the top bar
+ // above this panel. `urlScope` because that one route renders five of these
+ // tables, and the link params (`view`, `sort`, `hide`, `f`…) are global
+ // names: unscoped, the volumes sort would arrive as the images sort.
+ const chrome = useTableChrome({
+ columns,
+ rows: filteredVolumes,
+ viewPageKey: 'docker-volumes',
+ urlScope: 'volumes',
+ builtinViews: VOLUME_VIEWS,
+ noun: 'volumes',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ groupBy,
+ setGroupBy,
+ pageState: viewPageState,
+ applyPage: applyViewPageState,
+ });
+
if (loading) {
- return <div className="docker-loading">Loading volumes...</div>;
+ return (
+ <div className="dx-tab-pane">
+ <div className="docker-loading">Loading volumes...</div>
+ </div>
+ );
}
return (
- <div>
- {volumes.length === 0 ? (
+ <div className="dx-tab-pane dx-list-pane">
+ <GridViewPicker
+ views={chrome.views}
+ label="volumes"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <SearchField
+ value={searchTerm}
+ onSearch={setSearchTerm}
+ placeholder="Filter name or mountpoint…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadVolumes} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ {filteredVolumes.length === 0 ? (
<EmptyState
icon={HardDrive}
- title="No volumes"
- description="Create a volume for persistent data storage."
+ title={volumes.length === 0 ? 'No volumes' : 'No matching volumes'}
+ description={volumes.length === 0
+ ? 'Create a volume for persistent data storage.'
+ : 'No volumes match the current search.'}
/>
) : (
- <table className="docker-table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Driver</th>
- <th>Mountpoint</th>
- <th className="text-right">Actions</th>
- </tr>
- </thead>
- <tbody>
- {volumes.map(volume => (
- <tr key={volume.name}>
- <td>
- <span className="docker-container-name">{volume.name}</span>
- </td>
- <td>{volume.driver}</td>
- <td>
- <span className="docker-container-id truncate inline-block" style={{ maxWidth: '300px' }}>
- {volume.mountpoint || '-'}
- </span>
- </td>
- <td className="docker-actions-cell">
- <IconAction title="Delete" onClick={() => handleRemove(volume.name)} color="#EF4444">
- <TrashIcon />
- </IconAction>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <section className="dx-resource-list">
+ <DataTable
+ {...chrome.tableProps}
+ columns={chrome.columns}
+ data={filteredVolumes}
+ keyField={(volume) => volumeName(volume)}
+ sorts={sorts}
+ onSortsChange={setSorts}
+ groupBy={groupBy}
+ onGroupByChange={setGroupBy}
+ className="dx-table-wrap"
+ tableClassName="dx-manager-table dx-plain-table"
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={volumes.length}
+ noun="volume"
+ />
+ )}
+ />
+ </section>
)}
+
+ <GridFilterDrawer {...chrome.drawerProps} />
</div>
);
};
diff --git a/frontend/src/components/docker/dockerShared.jsx b/frontend/src/components/docker/dockerShared.jsx
index 36541d1d..24a6b16b 100644
--- a/frontend/src/components/docker/dockerShared.jsx
+++ b/frontend/src/components/docker/dockerShared.jsx
@@ -1,21 +1,6 @@
-import { Trash2 } from 'lucide-react';
-
-// Icon Action button used by remaining (legacy) tabs (Images, Networks, Volumes).
-// Containers tab now renders cards with full action buttons inline.
-export const IconAction = ({ title, onClick, color, children, disabled }) => (
- <button type="button"
- className="docker-icon-action"
- title={title}
- onClick={onClick}
- disabled={disabled}
- style={color ? { color } : {}}
- >
- {children}
- </button>
-);
-
-export const TrashIcon = () => <Trash2 size={14} />;
-
+// Every Docker tab now renders its rows through <DataTable>, whose action cells
+// are plain .dx-row-action buttons around a lucide icon — so the IconAction /
+// TrashIcon / DownloadIcon wrappers the hand-rolled tables shared are gone.
export const ContainerResourceBars = ({ stats, muted = false }) => (
<div className={`dx-mini-resources ${muted || !stats.available ? 'is-muted' : ''}`}>
<div className="dx-mini-resource">
@@ -34,12 +19,3 @@ export const ContainerResourceBars = ({ stats, muted = false }) => (
</div>
</div>
);
-
-// Download Icon for Compose Pull
-export const DownloadIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
- <polyline points="7 10 12 15 17 10"/>
- <line x1="12" y1="15" x2="12" y2="3"/>
- </svg>
-);
diff --git a/frontend/src/components/ds/DataTableFooter.jsx b/frontend/src/components/ds/DataTableFooter.jsx
index efff6f61..225ceef8 100644
--- a/frontend/src/components/ds/DataTableFooter.jsx
+++ b/frontend/src/components/ds/DataTableFooter.jsx
@@ -22,6 +22,9 @@ export function DataTableFooter({
shown,
total,
noun = 'row',
+ // Explicit plural for the nouns a naive +"s" mangles — "5 processs",
+ // "3 policys". Omit it wherever +"s" is already right.
+ plural,
// client-side page-size segment (omit to hide)
pageSize,
pageSizeOptions = [25, 50, 100],
@@ -36,9 +39,10 @@ export function DataTableFooter({
onPageChange,
className,
}) {
+ const many = plural || `${noun}s`;
const label = total == null || total === shown
- ? `${shown} ${noun}${shown === 1 ? '' : 's'}`
- : `Shown ${shown} of ${total} ${noun}s`;
+ ? `${shown} ${shown === 1 ? noun : many}`
+ : `Shown ${shown} of ${total} ${many}`;
const paged = page != null && totalPages != null && onPageChange;
diff --git a/frontend/src/components/layouts/ResourceListPage.jsx b/frontend/src/components/layouts/ResourceListPage.jsx
index dc172be0..ff6b4e91 100644
--- a/frontend/src/components/layouts/ResourceListPage.jsx
+++ b/frontend/src/components/layouts/ResourceListPage.jsx
@@ -18,6 +18,14 @@ import { useTopbarChrome } from '@/hooks/useTopbarActions';
// they own data + columns + handlers and pass them in. Markup mirrors the
// established `.wp-list` design so existing SCSS applies unchanged.
//
+// DEPRECATED props, kept working, zero core render sites: `filters` /
+// `activeFilter` / `onFilterChange` (the status segment row) and `renderCard` /
+// `viewStorageKey` (the list/cards switch). Both are a second way to decide what
+// the table shows that the saved view cannot capture, so core expresses them as
+// `columnFilters` rules instead. They stay because this component is exported
+// from plugins/sdk — its props ARE the contract — and go on the next SDK major.
+// Do not reach for them in core; see the per-prop notes below.
+//
// <ResourceListPage
// className="services-page"
// loading={loading}
diff --git a/frontend/src/components/serverdetail/ServicesTab.jsx b/frontend/src/components/serverdetail/ServicesTab.jsx
index c26bf2f7..169a3620 100644
--- a/frontend/src/components/serverdetail/ServicesTab.jsx
+++ b/frontend/src/components/serverdetail/ServicesTab.jsx
@@ -1,15 +1,17 @@
-import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
+import { useConfirm } from '@/hooks/useConfirm';
import { Button } from '@/components/ui/button';
-import { Pill, DataTable, DataTableFooter, ListToolbar, SearchField } from '../ds';
+import { Pill, Drawer, DataTable, DataTableFooter, ListToolbar, SearchField } from '../ds';
import {
useTableChrome, GridViewPicker, GridChips, GridFilterButton,
GridToolsMenu, GridFilterDrawer,
} from '@/components/ds/grid';
import { useTableSort } from '@/hooks/useTableSort';
import { useColumnVisibility } from '@/hooks/useColumnVisibility';
-import Modal from '../Modal';
+import LogToolbar from '../log-viewer/LogToolbar';
+import LogContent from '../log-viewer/LogContent';
// Built-in saved views. These are the four buttons that used to sit in the
// toolbar (All / Active / Failed / Inactive) — they narrowed the AGENT query
@@ -90,17 +92,53 @@ const STATE_PILL = {
stopped: 'gray',
};
-const ServicesTab = ({ serverId, serverStatus }) => {
+// The panel host and an agent answer the same question in different
+// vocabularies: `/processes/services` probes a fixed list of well-known daemons
+// and reports running/stopped, the agent runs `systemctl list-units --all` and
+// reports systemd's own ACTIVE word. Normalising the local answer INTO the unit
+// shape — rather than teaching the table, the columns and the views two shapes —
+// is what lets one component serve both hosts.
+const localServiceToUnit = (s) => ({
+ unit: s.name,
+ active: s.status === 'running' ? 'active' : 'inactive',
+ sub: s.status || '',
+ pid: s.pid ?? null,
+});
+
+// `serverId` absent means the panel host itself (Terminal › Services); a server
+// id means a paired agent (Server Detail › Services).
+const ServicesTab = ({ serverId = null, serverStatus = 'online' }) => {
const toast = useToast();
+ const { confirm } = useConfirm();
+ const isLocal = !serverId;
const [units, setUnits] = useState([]);
const [loading, setLoading] = useState(true);
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' });
+
+ // Local and remote units are the same table but not the same list, so their
+ // saved views and column prefs are namespaced apart. Server Detail keeps the
+ // keys it already persists under.
+ const viewPageKey = isLocal ? 'terminal-services' : 'serverdetail-services';
+ const storageKey = isLocal ? 'serverkit-table-terminal-services' : 'serverkit-table-sd-services';
+ const { sorts, setSorts } = useTableSort({ storageKey: `${storageKey}-sort` });
const {
hiddenKeys, setHiddenKeys,
- } = useColumnVisibility({ storageKey: 'serverkit-table-sd-services-cols' });
+ } = useColumnVisibility({ storageKey: `${storageKey}-cols` });
+
+ // Log drawer state. The unit under inspection plus the viewer preferences
+ // the shared LogToolbar drives.
+ const [logsFor, setLogsFor] = useState(null);
+ const [logText, setLogText] = useState('');
+ const [logsLoading, setLogsLoading] = useState(false);
+ const [logSearch, setLogSearch] = useState('');
+ const [appliedLogSearch, setAppliedLogSearch] = useState('');
+ const [logLineCount, setLogLineCount] = useState(200);
+ const [logShowLineNumbers, setLogShowLineNumbers] = useState(true);
+ const [logWrap, setLogWrap] = useState(true);
+ const [logAutoRefresh, setLogAutoRefresh] = useState(false);
+ const logContentRef = useRef(null);
+ const logIntervalRef = useRef(null);
// One unfiltered fetch. The state buckets are column rules now, so asking
// the agent for a subset would only hide rows from the rules — and from the
@@ -108,29 +146,45 @@ const ServicesTab = ({ serverId, serverStatus }) => {
const loadUnits = useCallback(async () => {
setLoading(true);
try {
- const data = await api.getRemoteServices(serverId);
- setUnits(data?.units || []);
+ if (isLocal) {
+ const data = await api.getServicesStatus();
+ setUnits((data?.services || []).map(localServiceToUnit));
+ } else {
+ const data = await api.getRemoteServices(serverId);
+ setUnits(data?.units || []);
+ }
} catch (err) {
toast.error(err.message || 'Failed to load services');
} finally {
setLoading(false);
}
- }, [serverId, toast]);
+ }, [isLocal, serverId, toast]);
useEffect(() => {
- if (serverStatus !== 'online') {
+ if (!isLocal && serverStatus !== 'online') {
setLoading(false);
return;
}
loadUnits();
- }, [serverStatus, loadUnits]);
+ }, [isLocal, serverStatus, loadUnits]);
const filtered = useMemo(() => {
if (!search.trim()) return units;
const needle = search.trim().toLowerCase();
- return units.filter((u) => u.unit?.toLowerCase().includes(needle));
+ return units.filter((u) => (
+ u.unit?.toLowerCase().includes(needle)
+ || u.description?.toLowerCase().includes(needle)
+ ));
}, [units, search]);
+ // The row the log drawer is describing, read back from the CURRENT list: a
+ // start/stop from inside the drawer reloads the units, and a snapshot taken
+ // when it opened would keep showing the state you just changed.
+ const logsUnit = useMemo(
+ () => (logsFor ? units.find((u) => u.unit === logsFor.unit) || logsFor : null),
+ [units, logsFor],
+ );
+
// The page's own half of a saved view. Everything else — sorts, hidden
// columns, rules — is captured identically on every list page.
const viewPageState = useMemo(() => ({ search }), [search]);
@@ -139,9 +193,21 @@ const ServicesTab = ({ serverId, serverStatus }) => {
}, []);
async function control(unit, action) {
+ // Stopping or restarting a unit takes something down; starting one
+ // cannot, so only the first two ask.
+ if (action !== 'start') {
+ const ok = await confirm({
+ title: action === 'stop' ? 'Stop service' : 'Restart service',
+ message: `${action === 'stop' ? 'Stop' : 'Restart'} ${unit}?`,
+ variant: 'warning',
+ confirmText: action === 'stop' ? 'Stop' : 'Restart',
+ });
+ if (!ok) return;
+ }
setBusyUnit(unit);
try {
- await api.controlRemoteService(serverId, unit, action);
+ if (isLocal) await api.controlService(unit, action);
+ else await api.controlRemoteService(serverId, unit, action);
toast.success(`${unit}: ${action} ok`);
// Refresh state — only the affected row needs a reload but
// re-fetching the list is simpler and keeps the filter consistent.
@@ -153,13 +219,48 @@ const ServicesTab = ({ serverId, serverStatus }) => {
}
}
- async function viewLogs(unit) {
+ // `lines` is passed explicitly by the line-count control: the state setter
+ // has not landed when the refetch fires, so reading logLineCount there
+ // would re-fetch the count the user just moved away from.
+ const loadLogs = useCallback(async (unit, { spinner = true, lines } = {}) => {
+ const count = lines ?? logLineCount;
+ if (spinner) setLogsLoading(true);
try {
- const data = await api.getRemoteServiceLogs(serverId, unit, 200);
- setLogsFor({ unit, entries: data?.entries || [] });
+ if (isLocal) {
+ const data = await api.getJournalLogs(unit, count);
+ setLogText(data?.lines?.join('\n') || '');
+ } else {
+ const data = await api.getRemoteServiceLogs(serverId, unit, count);
+ setLogText((data?.entries || [])
+ .map((e) => (e.priority ? `[${e.priority}] ` : '') + (e.message || ''))
+ .join('\n'));
+ }
} catch (err) {
- toast.error(err.message || 'Failed to load logs');
+ setLogText(`Error: ${err.message}`);
+ } finally {
+ setLogsLoading(false);
}
+ }, [isLocal, serverId, logLineCount]);
+
+ useEffect(() => {
+ if (logAutoRefresh && logsFor) {
+ logIntervalRef.current = setInterval(() => loadLogs(logsFor.unit, { spinner: false }), 3000);
+ }
+ return () => { if (logIntervalRef.current) clearInterval(logIntervalRef.current); };
+ }, [logAutoRefresh, logsFor, loadLogs]);
+
+ function openLogs(unit) {
+ setLogsFor({ unit });
+ setLogSearch('');
+ setAppliedLogSearch('');
+ setLogText('');
+ loadLogs(unit);
+ }
+
+ function closeLogs() {
+ setLogsFor(null);
+ setLogAutoRefresh(false);
+ setLogText('');
}
async function reloadDaemon() {
@@ -174,10 +275,25 @@ const ServicesTab = ({ serverId, serverStatus }) => {
}
}
+ function downloadLogs() {
+ if (!logText || !logsFor) return;
+ const url = URL.createObjectURL(new Blob([logText], { type: 'text/plain' }));
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `${logsFor.unit}-${Date.now()}.log`;
+ a.click();
+ URL.revokeObjectURL(url);
+ }
+
// 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).
//
+ // The two hosts do not answer with the same fields: an agent unit carries a
+ // description and no PID, the panel host's daemon probe carries a PID and no
+ // description. Declaring only the column the payload actually fills is what
+ // keeps this from being a column of blanks on one host or the other.
+ //
// Declared above the offline guard: the chrome below is a hook, so it
// cannot sit behind an early return.
const unitColumns = [
@@ -215,7 +331,16 @@ const ServicesTab = ({ serverId, serverStatus }) => {
</Pill>
),
},
- {
+ ...(isLocal ? [{
+ key: 'pid',
+ header: 'PID',
+ sortable: true,
+ type: 'num',
+ value: (u) => u.pid ?? null,
+ sortValue: (u) => u.pid ?? null,
+ cellClassName: 'mono',
+ render: (u) => u.pid ?? '—',
+ }] : [{
key: 'description',
header: 'Description',
sortable: true,
@@ -224,7 +349,7 @@ const ServicesTab = ({ serverId, serverStatus }) => {
sortValue: (u) => u.description || '',
cellClassName: 'server-services__desc',
render: (u) => u.description,
- },
+ }]),
{
key: 'actions',
header: '',
@@ -250,7 +375,7 @@ const ServicesTab = ({ serverId, serverStatus }) => {
>Restart</Button>
<Button
size="sm" variant="outline"
- onClick={() => viewLogs(u.unit)}
+ onClick={() => openLogs(u.unit)}
>Logs</Button>
</>
),
@@ -265,7 +390,7 @@ const ServicesTab = ({ serverId, serverStatus }) => {
const chrome = useTableChrome({
columns: unitColumns,
rows: filtered,
- viewPageKey: 'serverdetail-services',
+ viewPageKey,
builtinViews: SERVICE_VIEWS,
noun: 'units',
sorts,
@@ -276,7 +401,7 @@ const ServicesTab = ({ serverId, serverStatus }) => {
applyPage: applyViewPageState,
});
- if (serverStatus !== 'online') {
+ if (!isLocal && serverStatus !== 'online') {
return (
<div className="empty-state">
<p>Server is offline. Reconnect to manage services.</p>
@@ -309,19 +434,24 @@ const ServicesTab = ({ serverId, serverStatus }) => {
</>
)}
/>
- <ListToolbar
- tools={(
- <div className="server-services__actions">
- <Button
- variant="outline"
- onClick={reloadDaemon}
- disabled={busyUnit === '__daemon__'}
- >
- Reload daemon
- </Button>
- </div>
- )}
- />
+ {/* daemon-reload is an agent verb; the panel host has no endpoint
+ for it, so local gets no toolbar row at all rather than an
+ empty one. */}
+ {!isLocal && (
+ <ListToolbar
+ tools={(
+ <div className="server-services__actions">
+ <Button
+ variant="outline"
+ onClick={reloadDaemon}
+ disabled={busyUnit === '__daemon__'}
+ >
+ Reload daemon
+ </Button>
+ </div>
+ )}
+ />
+ )}
<GridChips {...chrome.chipProps} />
@@ -352,24 +482,94 @@ const ServicesTab = ({ serverId, serverStatus }) => {
<GridFilterDrawer {...chrome.drawerProps} />
- <Modal
+ {/* The shared log viewer, not a <pre> in a modal: the same search,
+ line numbers, wrap, live tail and download the Log Files tab
+ offers, so a unit's journal is not a lesser surface. */}
+ <Drawer
open={!!logsFor}
- onClose={() => setLogsFor(null)}
- title={logsFor ? `Logs — ${logsFor.unit}` : ''}
- size="xl"
+ onOpenChange={(open) => { if (!open) closeLogs(); }}
+ title={logsUnit?.unit || ''}
+ subtitle={logsUnit ? (logsUnit.description || `journalctl -u ${logsUnit.unit}`) : ''}
+ width={620}
+ flush
>
- {logsFor && (
- <pre className="server-services__logs">
- {logsFor.entries.length === 0
- ? '(no entries)'
- : logsFor.entries.map((e, i) => (
- <div key={i}>
- [{e.priority || '-'}] {e.message}
+ {logsUnit && (
+ <>
+ <div className="preview-drawer-meta">
+ <div className="meta-item">
+ <span className="meta-label">State</span>
+ <span className="meta-value">
+ {logsUnit.active || logsUnit.sub || 'unknown'}
+ </span>
+ </div>
+ {logsUnit.pid != null && (
+ <div className="meta-item">
+ <span className="meta-label">PID</span>
+ <span className="meta-value mono">{logsUnit.pid}</span>
</div>
- ))}
- </pre>
+ )}
+ </div>
+
+ <div className="preview-drawer-actions">
+ <button type="button"
+ className="drawer-action-btn"
+ onClick={() => control(logsFor.unit, 'start')}
+ disabled={busyUnit === logsFor.unit}
+ >Start</button>
+ <button type="button"
+ className="drawer-action-btn"
+ onClick={() => control(logsFor.unit, 'stop')}
+ disabled={busyUnit === logsFor.unit}
+ >Stop</button>
+ <button type="button"
+ className="drawer-action-btn"
+ onClick={() => control(logsFor.unit, 'restart')}
+ disabled={busyUnit === logsFor.unit}
+ >Restart</button>
+ </div>
+
+ <LogToolbar
+ searchPattern={logSearch}
+ onSearchChange={setLogSearch}
+ onSearchSubmit={() => setAppliedLogSearch(logSearch)}
+ onSearchClear={() => { setLogSearch(''); setAppliedLogSearch(''); }}
+ lineCount={logLineCount}
+ onLineCountChange={(n) => { setLogLineCount(n); loadLogs(logsFor.unit, { lines: n }); }}
+ autoRefresh={logAutoRefresh}
+ onAutoRefreshToggle={() => setLogAutoRefresh(!logAutoRefresh)}
+ showLineNumbers={logShowLineNumbers}
+ onToggleLineNumbers={() => setLogShowLineNumbers(!logShowLineNumbers)}
+ wrapLines={logWrap}
+ onToggleWrap={() => setLogWrap(!logWrap)}
+ isFullscreen={false}
+ onToggleFullscreen={() => {}}
+ onRefresh={() => loadLogs(logsFor.unit)}
+ onDownload={downloadLogs}
+ onClear={() => toast.error('Journal logs cannot be truncated from the panel.')}
+ onScrollToBottom={() => {
+ if (logContentRef.current) {
+ logContentRef.current.scrollTop = logContentRef.current.scrollHeight;
+ }
+ }}
+ canAct={!logsLoading}
+ />
+
+ <div className="preview-drawer-body">
+ <LogContent
+ ref={logContentRef}
+ live={logAutoRefresh}
+ scrollKey={logsFor.unit}
+ content={logText}
+ loading={logsLoading}
+ emptyMessage="No log output."
+ showLineNumbers={logShowLineNumbers}
+ wrapLines={logWrap}
+ searchPattern={appliedLogSearch}
+ />
+ </div>
+ </>
)}
- </Modal>
+ </Drawer>
</div>
);
};
diff --git a/frontend/src/components/shared/EnvironmentVariablesPanel.jsx b/frontend/src/components/shared/EnvironmentVariablesPanel.jsx
index 603d1e9b..d6adfbe6 100644
--- a/frontend/src/components/shared/EnvironmentVariablesPanel.jsx
+++ b/frontend/src/components/shared/EnvironmentVariablesPanel.jsx
@@ -10,6 +10,13 @@ import { useToast } from '../../contexts/ToastContext';
* truth); this surface is the read-side facade meant to be embedded on a
* resource's detail page.
*
+ * Deliberately NOT converged onto components/EnvironmentVariables.jsx (the
+ * app's own env-var editor) or SharedVariableGroups (the group editor). Those
+ * two own a stored row — it has an id, you create/edit/delete it, and a saved
+ * view over it means something. A row here is a computed merge result: no id,
+ * no owner, nothing to act on, and it exists only to answer "where did this
+ * value come from and does it actually win". Same word, three data shapes.
+ *
* Provenance: when the hierarchical resolver is available, each variable shows
* which scope it won at (workspace < project < environment < direct attachment).
* For applications we also cross-check the app's LOCAL env vars: shared groups
diff --git a/frontend/src/components/workspaces/WorkspaceMembersTab.jsx b/frontend/src/components/workspaces/WorkspaceMembersTab.jsx
index 4d489dd5..a5793707 100644
--- a/frontend/src/components/workspaces/WorkspaceMembersTab.jsx
+++ b/frontend/src/components/workspaces/WorkspaceMembersTab.jsx
@@ -1,17 +1,55 @@
import { Plus } from 'lucide-react';
import { ServiceTile, Pill, DataTable, DataTableFooter } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
+const NO_RULES = { match: 'all', rules: [] };
+const BY_NAME = [{ key: 'name', direction: 'asc' }];
+
+// Built-in saved views. Role is the only axis a membership row has, and it is
+// the one that answers "who can change things here".
+const WORKSPACE_MEMBER_VIEWS = [
+ {
+ name: 'All members',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: NO_RULES },
+ },
+ {
+ name: 'Owners',
+ state: {
+ sorts: BY_NAME,
+ hiddenKeys: [],
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'wsm1', field: 'role', op: 'any', value: ['owner'] }],
+ },
+ },
+ },
+];
+
const WorkspaceMembersTab = ({ wsId, members, allUsers, onAddMember, onRemoveMember }) => {
- // DataTable columns. Cell markup and classNames are identical to the
- // hand-rolled table they replace, so _workspaces.scss keeps applying
- // (.sk-cell-name, .sk-cell-sub, .ws-row__av).
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-ws-members-sort' });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-ws-members-cols' });
+
+ // DataTable columns. Cell markup and classNames are unchanged, so the
+ // shared .sk-cell-name / .sk-cell-sub rules keep applying.
const columns = [
{
key: 'name',
header: 'Member',
sortable: true,
hideable: false,
+ // There is no `name` key on the row — the cell falls back from
+ // username to email, so `value` has to do the same or the filter
+ // would match nothing at all.
+ type: 'text',
+ value: (m) => m.username || m.email || '',
sortValue: (m) => m.username || m.email || '',
render: (m) => (
<div className="sk-cell-name">
@@ -27,6 +65,12 @@ const WorkspaceMembersTab = ({ wsId, members, allUsers, onAddMember, onRemoveMem
key: 'role',
header: 'Role',
sortable: true,
+ // Declared, not inferred: a workspace with an owner and one member
+ // fails the enum cardinality test and would fall back to text,
+ // turning the pick-list into a typed fragment and "Owners" into a
+ // no-op.
+ type: 'enum',
+ value: (m) => m.role || '',
sortValue: (m) => m.role || '',
render: (m) => (
m.role === 'owner'
@@ -48,23 +92,71 @@ const WorkspaceMembersTab = ({ wsId, members, allUsers, onAddMember, onRemoveMem
},
];
+ // One ROUTE renders four of these tabs, so each carries its own view
+ // namespace and its own `urlScope` — without the scope they would all write
+ // `?view=`/`?sort=` and a link saved on Members would reopen on Servers.
+ const chrome = useTableChrome({
+ columns,
+ rows: members,
+ viewPageKey: 'workspace-members',
+ builtinViews: WORKSPACE_MEMBER_VIEWS,
+ noun: 'members',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ urlScope: 'members',
+ });
+
+ const unassigned = allUsers.filter(u => !members.find(m => m.user_id === u.id));
+
return (
<>
+ {/* Inline chrome, not hoisted: this is a tab inside a detail page
+ that already owns the top bar, so hoisting would hijack it. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="members"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
<DataTable
- columns={columns}
+ columns={chrome.columns}
data={members}
keyField="id"
- storageKey="serverkit-table-ws-members"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ {...chrome.tableProps}
className="ws-detail__tablecard"
emptyTitle="No members"
emptyMessage="This workspace has no members yet."
- footer={<DataTableFooter shown={members.length} total={members.length} noun="member" />}
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={members.length}
+ noun="member"
+ />
+ )}
/>
- {allUsers.filter(u => !members.find(m => m.user_id === u.id)).length > 0 && (
+
+ <GridFilterDrawer {...chrome.drawerProps} />
+
+ {unassigned.length > 0 && (
<>
<div className="ws-pick-label">Add a member</div>
<div className="ws-pick">
- {allUsers.filter(u => !members.find(m => m.user_id === u.id)).map(u => (
+ {unassigned.map(u => (
<div key={u.id} className="ws-pick__item" onClick={() => onAddMember(u.id)}>
<ServiceTile name={u.username || u.email || '?'} size={24} className="ws-row__av" />
<span className="ws-pick__name">{u.username || u.email}</span>
diff --git a/frontend/src/components/workspaces/WorkspaceServersTab.jsx b/frontend/src/components/workspaces/WorkspaceServersTab.jsx
index 3cf590a6..45e4e1b8 100644
--- a/frontend/src/components/workspaces/WorkspaceServersTab.jsx
+++ b/frontend/src/components/workspaces/WorkspaceServersTab.jsx
@@ -1,23 +1,65 @@
import { useNavigate } from 'react-router-dom';
import { Server, Plus } from 'lucide-react';
import { ServiceTile, Pill, DataTable, DataTableFooter } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import EmptyState from '../EmptyState';
const SERVER_PILL = { online: 'green', pending: 'amber', offline: 'red' };
+// What the Status cell shows when the row carries none. A real word, not '':
+// `ruleIsArmed` drops any rule whose value is empty, so a rule on '' would
+// silently filter nothing.
+const UNKNOWN = 'unknown';
+
+// Built-in saved views. The membership question ("is it in this workspace")
+// is already answered by the tab itself, so reachability is the axis left.
+const NO_RULES = { match: 'all', rules: [] };
+const BY_NAME = [{ key: 'name', direction: 'asc' }];
+
+const WORKSPACE_SERVER_VIEWS = [
+ {
+ name: 'All servers',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: NO_RULES },
+ },
+ {
+ // Stated as "not online" rather than as a list of bad statuses, so a
+ // status we have never seen still shows up here.
+ name: 'Needs attention',
+ state: {
+ sorts: BY_NAME,
+ hiddenKeys: [],
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'wss1', field: 'status', op: 'none', value: ['online'] }],
+ },
+ },
+ },
+];
+
const WorkspaceServersTab = ({ wsId, srvIn, srvOut, onMoveServer }) => {
const navigate = useNavigate();
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-ws-servers-sort' });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-ws-servers-cols' });
- // DataTable columns. Cell markup and classNames are identical to the
- // hand-rolled table they replace, so _workspaces.scss keeps applying
- // (.sk-cell-name, .sk-cell-sub, .ws-detail__rowactions).
+ // DataTable columns. Cell markup and classNames are unchanged, so the
+ // shared .sk-cell-name / .sk-cell-sub rules keep applying.
const columns = [
{
key: 'name',
header: 'Server',
sortable: true,
hideable: false,
+ // Hostnames are near-unique per row — you type a fragment.
+ type: 'text',
+ value: (s) => s.name || '',
sortValue: (s) => s.name || '',
render: (s) => (
<div className="sk-cell-name">
@@ -33,8 +75,15 @@ const WorkspaceServersTab = ({ wsId, srvIn, srvOut, onMoveServer }) => {
key: 'status',
header: 'Status',
sortable: true,
- sortValue: (s) => s.status || 'unknown',
- render: (s) => <Pill kind={SERVER_PILL[s.status] || 'gray'}>{s.status || 'unknown'}</Pill>,
+ // Declared, not inferred: a workspace holding two servers of two
+ // statuses fails the enum cardinality test and would fall back to
+ // text, turning the pick-list into a typed fragment and the view
+ // above into a no-op. `value` is the word the Pill shows.
+ type: 'enum',
+ enumOrder: ['online', 'pending', 'offline', UNKNOWN],
+ value: (s) => s.status || UNKNOWN,
+ sortValue: (s) => s.status || UNKNOWN,
+ render: (s) => <Pill kind={SERVER_PILL[s.status] || 'gray'}>{s.status || UNKNOWN}</Pill>,
},
{
key: 'actions',
@@ -50,21 +99,69 @@ const WorkspaceServersTab = ({ wsId, srvIn, srvOut, onMoveServer }) => {
},
];
+ // One ROUTE renders four of these tabs, so each carries its own view
+ // namespace and its own `urlScope` — without the scope they would all write
+ // `?view=`/`?sort=` and a link saved on Servers would reopen on Members.
+ const chrome = useTableChrome({
+ columns,
+ rows: srvIn,
+ viewPageKey: 'workspace-servers',
+ builtinViews: WORKSPACE_SERVER_VIEWS,
+ noun: 'servers',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ urlScope: 'servers',
+ });
+
return (
<>
- {srvIn.length === 0 ? (
- <EmptyState icon={Server} title="No servers in this workspace yet" description="Move one in below." />
- ) : (
- <DataTable
- columns={columns}
- data={srvIn}
- keyField="id"
- storageKey="serverkit-table-ws-servers"
- onRowClick={(s) => navigate(`/servers/${s.id}`)}
- className="ws-detail__tablecard"
- footer={<DataTableFooter shown={srvIn.length} total={srvIn.length} noun="server" />}
- />
- )}
+ {/* Inline chrome, not hoisted: this is a tab inside a detail page
+ that already owns the top bar, so hoisting would hijack it. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="servers"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ <DataTable
+ columns={chrome.columns}
+ data={srvIn}
+ keyField="id"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ {...chrome.tableProps}
+ onRowClick={(s) => navigate(`/servers/${s.id}`)}
+ className="ws-detail__tablecard"
+ emptyState={(
+ <EmptyState icon={Server} title="No servers in this workspace yet" description="Move one in below." />
+ )}
+ footer={(
+ <DataTableFooter
+ // DataTable applies the column rules itself, so the
+ // shown count comes from the chrome — `srvIn` is only
+ // ever the whole membership.
+ shown={chrome.shownCount}
+ total={srvIn.length}
+ noun="server"
+ />
+ )}
+ />
+
+ <GridFilterDrawer {...chrome.drawerProps} />
+
{srvOut.length > 0 && (
<>
<div className="ws-pick-label">Move a server into this workspace</div>
diff --git a/frontend/src/components/workspaces/WorkspaceServicesTab.jsx b/frontend/src/components/workspaces/WorkspaceServicesTab.jsx
index f4a1fdd6..7566fadc 100644
--- a/frontend/src/components/workspaces/WorkspaceServicesTab.jsx
+++ b/frontend/src/components/workspaces/WorkspaceServicesTab.jsx
@@ -1,23 +1,63 @@
import { useNavigate } from 'react-router-dom';
import { Box, Plus } from 'lucide-react';
import { ServiceTile, Pill, DataTable, DataTableFooter } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import EmptyState from '../EmptyState';
const APP_PILL = { running: 'green', stopped: 'gray', failed: 'red' };
+// What the Status cell shows when the row carries none. A real word, not '':
+// `ruleIsArmed` drops any rule whose value is empty.
+const UNKNOWN = 'unknown';
+
+const NO_RULES = { match: 'all', rules: [] };
+const BY_NAME = [{ key: 'name', direction: 'asc' }];
+
+// Built-in saved views. Membership is already the tab's job, so what is left
+// worth slicing is whether the container is actually up.
+const WORKSPACE_SERVICE_VIEWS = [
+ {
+ name: 'All services',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: NO_RULES },
+ },
+ {
+ // Stated as "not running" rather than as a list of bad statuses, so
+ // 'error', 'deploying' and anything new all land here.
+ name: 'Not running',
+ state: {
+ sorts: BY_NAME,
+ hiddenKeys: [],
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'wsv1', field: 'status', op: 'none', value: ['running'] }],
+ },
+ },
+ },
+];
+
const WorkspaceServicesTab = ({ wsId, services, appsOut, onMoveApp, onShare }) => {
const navigate = useNavigate();
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-ws-services-sort' });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-ws-services-cols' });
- // DataTable columns. Cell markup and classNames are identical to the
- // hand-rolled table they replace, so _workspaces.scss keeps applying
- // (.sk-cell-name, .sk-cell-sub, .ws-detail__rowactions).
+ // DataTable columns. Cell markup and classNames are unchanged, so the
+ // shared .sk-cell-name / .sk-cell-sub rules keep applying.
const columns = [
{
key: 'name',
header: 'Service',
sortable: true,
hideable: false,
+ type: 'text',
+ value: (a) => a.name || '',
sortValue: (a) => a.name || '',
render: (a) => (
<div className="sk-cell-name">
@@ -33,8 +73,15 @@ const WorkspaceServicesTab = ({ wsId, services, appsOut, onMoveApp, onShare }) =
key: 'status',
header: 'Status',
sortable: true,
- sortValue: (a) => a.status || 'unknown',
- render: (a) => <Pill kind={APP_PILL[a.status] || 'amber'}>{a.status || 'unknown'}</Pill>,
+ // Declared, not inferred: a workspace holding two services of two
+ // statuses fails the enum cardinality test and would fall back to
+ // text, turning the pick-list into a typed fragment and the view
+ // above into a no-op. No `enumOrder` — the options come from the
+ // data, which is the only source that agrees with itself here.
+ type: 'enum',
+ value: (a) => a.status || UNKNOWN,
+ sortValue: (a) => a.status || UNKNOWN,
+ render: (a) => <Pill kind={APP_PILL[a.status] || 'amber'}>{a.status || UNKNOWN}</Pill>,
},
{
key: 'actions',
@@ -51,21 +98,66 @@ const WorkspaceServicesTab = ({ wsId, services, appsOut, onMoveApp, onShare }) =
},
];
+ // One ROUTE renders four of these tabs, so each carries its own view
+ // namespace and its own `urlScope` — without the scope they would all write
+ // `?view=`/`?sort=` and a link saved on Services would reopen on Sites.
+ const chrome = useTableChrome({
+ columns,
+ rows: services,
+ viewPageKey: 'workspace-services',
+ builtinViews: WORKSPACE_SERVICE_VIEWS,
+ noun: 'services',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ urlScope: 'services',
+ });
+
return (
<>
- {services.length === 0 ? (
- <EmptyState icon={Box} title="No services in this workspace yet" description="Move one in below." />
- ) : (
- <DataTable
- columns={columns}
- data={services}
- keyField="id"
- storageKey="serverkit-table-ws-services"
- onRowClick={(a) => navigate(`/services/${a.id}`)}
- className="ws-detail__tablecard"
- footer={<DataTableFooter shown={services.length} total={services.length} noun="service" />}
- />
- )}
+ {/* Inline chrome, not hoisted: this is a tab inside a detail page
+ that already owns the top bar, so hoisting would hijack it. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="services"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ <DataTable
+ columns={chrome.columns}
+ data={services}
+ keyField="id"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ {...chrome.tableProps}
+ onRowClick={(a) => navigate(`/services/${a.id}`)}
+ className="ws-detail__tablecard"
+ emptyState={(
+ <EmptyState icon={Box} title="No services in this workspace yet" description="Move one in below." />
+ )}
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={services.length}
+ noun="service"
+ />
+ )}
+ />
+
+ <GridFilterDrawer {...chrome.drawerProps} />
+
{appsOut.length > 0 && (
<>
<div className="ws-pick-label">Move an application into this workspace</div>
diff --git a/frontend/src/components/workspaces/WorkspaceSitesTab.jsx b/frontend/src/components/workspaces/WorkspaceSitesTab.jsx
index 438221e1..07f0fe57 100644
--- a/frontend/src/components/workspaces/WorkspaceSitesTab.jsx
+++ b/frontend/src/components/workspaces/WorkspaceSitesTab.jsx
@@ -1,23 +1,63 @@
import { useNavigate } from 'react-router-dom';
import { Globe, Plus } from 'lucide-react';
import { ServiceTile, Pill, DataTable, DataTableFooter } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { Button } from '@/components/ui/button';
import EmptyState from '../EmptyState';
const APP_PILL = { running: 'green', stopped: 'gray', failed: 'red' };
+// What the Status cell shows when the row carries none. A real word, not '':
+// `ruleIsArmed` drops any rule whose value is empty.
+const UNKNOWN = 'unknown';
+
+const NO_RULES = { match: 'all', rules: [] };
+const BY_NAME = [{ key: 'name', direction: 'asc' }];
+
+// Built-in saved views. Every row here is already a WordPress app, so the axis
+// left is whether the site is actually serving.
+const WORKSPACE_SITE_VIEWS = [
+ {
+ name: 'All sites',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: NO_RULES },
+ },
+ {
+ // Stated as "not running" rather than as a list of bad statuses, so
+ // 'error', 'deploying' and anything new all land here.
+ name: 'Not running',
+ state: {
+ sorts: BY_NAME,
+ hiddenKeys: [],
+ columnFilters: {
+ match: 'all',
+ rules: [{ id: 'wsi1', field: 'status', op: 'none', value: ['running'] }],
+ },
+ },
+ },
+];
+
const WorkspaceSitesTab = ({ wsId, sites, appsOut, onMoveApp, onShare }) => {
const navigate = useNavigate();
+ const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-ws-sites-sort' });
+ const {
+ hiddenKeys, setHiddenKeys,
+ } = useColumnVisibility({ storageKey: 'serverkit-table-ws-sites-cols' });
- // DataTable columns. Cell markup and classNames are identical to the
- // hand-rolled table they replace, so _workspaces.scss keeps applying
- // (.sk-cell-name, .sk-cell-sub, .ws-detail__rowactions).
+ // DataTable columns. Cell markup and classNames are unchanged, so the
+ // shared .sk-cell-name / .sk-cell-sub rules keep applying.
const columns = [
{
key: 'name',
header: 'Site',
sortable: true,
hideable: false,
+ type: 'text',
+ value: (a) => a.name || '',
sortValue: (a) => a.name || '',
render: (a) => (
<div className="sk-cell-name">
@@ -33,8 +73,15 @@ const WorkspaceSitesTab = ({ wsId, sites, appsOut, onMoveApp, onShare }) => {
key: 'status',
header: 'Status',
sortable: true,
- sortValue: (a) => a.status || 'unknown',
- render: (a) => <Pill kind={APP_PILL[a.status] || 'amber'}>{a.status || 'unknown'}</Pill>,
+ // Declared, not inferred: a workspace holding two sites of two
+ // statuses fails the enum cardinality test and would fall back to
+ // text, turning the pick-list into a typed fragment and the view
+ // above into a no-op. No `enumOrder` — the options come from the
+ // data, which is the only source that agrees with itself here.
+ type: 'enum',
+ value: (a) => a.status || UNKNOWN,
+ sortValue: (a) => a.status || UNKNOWN,
+ render: (a) => <Pill kind={APP_PILL[a.status] || 'amber'}>{a.status || UNKNOWN}</Pill>,
},
{
key: 'actions',
@@ -51,21 +98,66 @@ const WorkspaceSitesTab = ({ wsId, sites, appsOut, onMoveApp, onShare }) => {
},
];
+ // One ROUTE renders four of these tabs, so each carries its own view
+ // namespace and its own `urlScope` — without the scope they would all write
+ // `?view=`/`?sort=` and a link saved on Sites would reopen on Services.
+ const chrome = useTableChrome({
+ columns,
+ rows: sites,
+ viewPageKey: 'workspace-sites',
+ builtinViews: WORKSPACE_SITE_VIEWS,
+ noun: 'sites',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ urlScope: 'sites',
+ });
+
return (
<>
- {sites.length === 0 ? (
- <EmptyState icon={Globe} title="No sites in this workspace yet" description="Move one in below." />
- ) : (
- <DataTable
- columns={columns}
- data={sites}
- keyField="id"
- storageKey="serverkit-table-ws-sites"
- onRowClick={(a) => navigate(`/services/${a.id}`)}
- className="ws-detail__tablecard"
- footer={<DataTableFooter shown={sites.length} total={sites.length} noun="site" />}
- />
- )}
+ {/* Inline chrome, not hoisted: this is a tab inside a detail page
+ that already owns the top bar, so hoisting would hijack it. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="sites"
+ onCreate={chrome.createView}
+ actions={(
+ <>
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} />
+ </>
+ )}
+ />
+
+ <GridChips {...chrome.chipProps} />
+
+ <DataTable
+ columns={chrome.columns}
+ data={sites}
+ keyField="id"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ {...chrome.tableProps}
+ onRowClick={(a) => navigate(`/services/${a.id}`)}
+ className="ws-detail__tablecard"
+ emptyState={(
+ <EmptyState icon={Globe} title="No sites in this workspace yet" description="Move one in below." />
+ )}
+ footer={(
+ <DataTableFooter
+ shown={chrome.shownCount}
+ total={sites.length}
+ noun="site"
+ />
+ )}
+ />
+
+ <GridFilterDrawer {...chrome.drawerProps} />
+
{appsOut.length > 0 && (
<>
<div className="ws-pick-label">Move a site into this workspace</div>
diff --git a/frontend/src/pages/Databases.jsx b/frontend/src/pages/Databases.jsx
index 77877c9c..52bbfeca 100644
--- a/frontend/src/pages/Databases.jsx
+++ b/frontend/src/pages/Databases.jsx
@@ -1,13 +1,14 @@
import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import {
- PanelLeftClose, PanelLeftOpen, Search, X, RefreshCw, Plus, Terminal,
+ PanelLeftClose, PanelLeftOpen, X, RefreshCw, Plus, Terminal,
Archive, Database, Table2, Server, ChevronDown,
Trash2, DatabaseBackup, Copy, FileCode2, Lock, BookMarked, Activity,
SlidersHorizontal, Layers, ExternalLink, Download,
} from 'lucide-react';
import api from '../services/api';
import Modal from '@/components/Modal';
+import { SearchField } from '@/components/ds';
import ManagedDatabasesPanel from '../components/databases/ManagedDatabasesPanel';
import { formatBytes } from '@/utils/formatBytes';
import { useToast } from '../contexts/ToastContext';
@@ -777,17 +778,14 @@ export default function Databases() {
{sidebarVisible && (
<aside className="dbx-tree-panel" aria-label="Database sources">
<div className="dbx-tree-search">
- <Search size={14} aria-hidden="true" />
- <input
- type="text"
- placeholder="Filter tables…"
+ {/* The shared search box, not a hand-rolled input —
+ it debounces and clears itself, which is what the
+ icon + input + X this replaces was reimplementing. */}
+ <SearchField
value={filter}
- onChange={(e) => setFilter(e.target.value)}
- aria-label="Filter sources"
+ onSearch={setFilter}
+ placeholder="Filter tables…"
/>
- {filter && (
- <button type="button" onClick={() => setFilter('')} aria-label="Clear filter"><X size={13} aria-hidden="true" /></button>
- )}
</div>
<div className="dbx-tree-scroll">
{statusLoading ? (
diff --git a/frontend/src/pages/Deployments.jsx b/frontend/src/pages/Deployments.jsx
index 09eca5da..4cca6829 100644
--- a/frontend/src/pages/Deployments.jsx
+++ b/frontend/src/pages/Deployments.jsx
@@ -1,56 +1,101 @@
-import { useState, useEffect, useRef, useMemo } from 'react';
+import { useState, useEffect, useMemo, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
-import {
- CheckCircle2,
- XCircle,
- Clock,
- RefreshCw,
- Loader2,
- PlayCircle,
- FlaskConical,
- ChevronRight,
-} from 'lucide-react';
+import { RefreshCw, Loader2, PlayCircle, FlaskConical } from 'lucide-react';
import api from '../services/api';
import Modal from '../components/Modal';
-import Skeleton from '../components/Skeleton';
import EmptyState from '../components/EmptyState';
import { Button } from '@/components/ui/button';
-import { SegControl, SearchField, ListToolbar } from '@/components/ds';
-import { useTopbarActions } from '@/hooks/useTopbarActions';
+import { DataTable, DataTableFooter, Pill, SearchField } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
+import { useTopbarActions, useTopbarChrome } from '@/hooks/useTopbarActions';
+import { useTableSort } from '@/hooks/useTableSort';
+import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import RequiresDocker from '../components/RequiresDocker';
+
+// How many jobs one fetch pulls. The column rules run over what has been
+// fetched, so this is the reach of a filter until the user asks for more.
+const PAGE = 100;
import {
KIND_CHIP,
stepTicks,
sourceRef,
formatDuration,
relativeTime,
- groupDeploys,
+ activityGroup,
} from '../utils/deployActivity';
-const STATE_ICON = {
- succeeded: { Icon: CheckCircle2, cls: 'succeeded' },
- failed: { Icon: XCircle, cls: 'failed' },
- running: { Icon: Loader2, cls: 'running' },
- pending: { Icon: Clock, cls: 'pending' },
+const STATUS_KIND = {
+ succeeded: 'green',
+ failed: 'red',
+ running: 'cyan',
+ pending: 'gray',
};
-const STATUS_FILTERS = [
- ['all', 'All'],
- ['running', 'Running'],
- ['succeeded', 'Succeeded'],
- ['failed', 'Failed'],
+// Built-in saved views. These replace the segmented All/Running/Succeeded/Failed
+// strip: the strip was a status rule wearing a button, could not combine with
+// anything (you could not ask for "failed, on that server"), and reported counts
+// the footer already reports. Every rule matches the `status` column's `value`,
+// which is the raw job status the Pill also prints.
+const NO_RULES = { match: 'all', rules: [] };
+const NEWEST_FIRST = [{ key: 'started', direction: 'desc' }];
+const STATUS_IS = (...value) => ({
+ match: 'all',
+ rules: [{ id: 'dp-st', field: 'status', op: 'any', value }],
+});
+
+const BUILTIN_VIEWS = [
+ {
+ name: 'All deploys',
+ state: {
+ sorts: NEWEST_FIRST, hiddenKeys: [], groupBy: null, columnFilters: NO_RULES,
+ },
+ },
+ {
+ // Queued rides along with running: both answer "is anything happening
+ // right now", and a job sitting in the queue is the one worth chasing.
+ name: 'In flight',
+ state: {
+ sorts: NEWEST_FIRST,
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: STATUS_IS('running', 'pending'),
+ },
+ },
+ {
+ name: 'Failed',
+ state: {
+ sorts: NEWEST_FIRST, hiddenKeys: [], groupBy: null, columnFilters: STATUS_IS('failed'),
+ },
+ },
+ {
+ name: 'Succeeded',
+ state: {
+ sorts: NEWEST_FIRST,
+ hiddenKeys: [],
+ groupBy: null,
+ columnFilters: STATUS_IS('succeeded'),
+ },
+ },
+ {
+ // The old feed's Queued / Today / Earlier buckets, kept as a grouping
+ // rather than a fixed layout — the chronological read is worth having,
+ // but it is one way of looking at the runs, not the only one.
+ name: 'By day',
+ state: {
+ sorts: NEWEST_FIRST, hiddenKeys: [], groupBy: 'started', columnFilters: NO_RULES,
+ },
+ },
];
const Deployments = () => {
const navigate = useNavigate();
const [jobs, setJobs] = useState([]);
const [loading, setLoading] = useState(true);
- const [statusFilter, setStatusFilter] = useState('all');
- const [serverFilter, setServerFilter] = useState('all');
const [search, setSearch] = useState('');
- const [servers, setServers] = useState([]);
const [autoRefresh, setAutoRefresh] = useState(true);
- const refreshRef = useRef(null);
// Simulated deployments (dev-only): null until the backend confirms the
// gate is on — a 404 (production) simply keeps the trigger hidden.
@@ -59,32 +104,44 @@ const Deployments = () => {
const [simSpeed, setSimSpeed] = useState('fast');
const [simBusy, setSimBusy] = useState(null);
- // Status is filtered client-side so the segmented control can show a live
- // count per state; only the server filter narrows the query.
- const loadJobs = async () => {
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: NEWEST_FIRST,
+ storageKey: 'serverkit-table-deployments-sort',
+ });
+ const { hiddenKeys, setHiddenKeys } = useColumnVisibility({
+ storageKey: 'serverkit-table-deployments-cols',
+ });
+ // Not persisted separately: a grouping worth keeping is a saved view.
+ const [groupBy, setGroupBy] = useState(null);
+ const [hasMore, setHasMore] = useState(false);
+ const [loaded, setLoaded] = useState(PAGE);
+ const [loadingMore, setLoadingMore] = useState(false);
+
+ // One unfiltered query. The target server used to narrow it server-side
+ // through a <select>; it is the Target column now, so its pick-list is built
+ // from the servers that actually deployed something and combines with every
+ // other rule instead of replacing them.
+ //
+ // That trade has a catch worth being honest about: the rules run over the
+ // rows FETCHED, where `?server_id=` searched the whole history. So the
+ // window is explicit — when a page comes back full there is certainly more
+ // behind it, and the footer offers to go get it rather than quietly
+ // filtering a truncated list.
+ const loadJobs = useCallback(async (limit = PAGE) => {
try {
- const params = { limit: 100 };
- if (serverFilter !== 'all') params.serverId = serverFilter;
- const data = await api.getDeploymentJobs(params);
- setJobs(data.jobs || []);
+ const data = await api.getDeploymentJobs({ limit });
+ const rows = data.jobs || [];
+ setJobs(rows);
+ setHasMore(rows.length >= limit);
+ setLoaded(limit);
} catch (err) {
console.error('Failed to load deployment jobs', err);
} finally {
setLoading(false);
}
- };
-
- const loadServers = async () => {
- try {
- const data = await api.getAvailableServers();
- setServers(Array.isArray(data) ? data : []);
- } catch {
- setServers([]);
- }
- };
+ }, []);
useEffect(() => {
- loadServers();
api.getDeploySimulateInfo()
.then((data) => setSimInfo(data?.enabled ? data : null))
.catch(() => setSimInfo(null));
@@ -101,19 +158,14 @@ const Deployments = () => {
}
};
- useEffect(() => {
- loadJobs();
- }, [serverFilter]);
+ useEffect(() => { loadJobs(); }, [loadJobs]);
useEffect(() => {
- if (refreshRef.current) clearInterval(refreshRef.current);
if (!autoRefresh) return undefined;
- refreshRef.current = setInterval(loadJobs, 3000);
- return () => clearInterval(refreshRef.current);
- }, [autoRefresh, serverFilter]);
+ const timer = setInterval(loadJobs, 3000);
+ return () => clearInterval(timer);
+ }, [autoRefresh, loadJobs]);
- // Search narrows the set the counts are taken from, so the numbers always
- // describe what a click on that filter would actually show.
const searched = useMemo(() => {
const q = search.trim().toLowerCase();
if (!q) return jobs;
@@ -124,26 +176,170 @@ const Deployments = () => {
);
}, [jobs, search]);
- const counts = useMemo(() => {
- const c = { all: searched.length, running: 0, succeeded: 0, failed: 0 };
- searched.forEach((j) => {
- if (c[j.status] !== undefined) c[j.status] += 1;
- });
- return c;
- }, [searched]);
+ // Two accessors where they differ: `value` is what the column menu, the
+ // filter rules and the export read; `sortValue` is what the sorter reads.
+ // Every derived column carries a `render` — without one DataTable falls back
+ // to row[key], and none of these keys exist on a deployment job payload.
+ const columns = useMemo(() => [
+ {
+ key: 'status',
+ header: 'Status',
+ sortable: true,
+ hideable: false,
+ // Declared, not inferred: a panel with three deploys in it fails the
+ // enum cardinality test, and the views above would silently become
+ // free-text rules that match nothing.
+ type: 'enum',
+ enumOrder: ['running', 'pending', 'succeeded', 'failed'],
+ value: (job) => job.status,
+ sortValue: (job) => job.status,
+ // `animate-spin` rather than the `spin` the retired feed rows used:
+ // only the former is a real global rule, so `spin` never rotated
+ // anything it was put on.
+ render: (job) => (
+ <Pill kind={STATUS_KIND[job.status] || 'gray'} dot={job.status !== 'running'}>
+ {job.status === 'running' && <Loader2 size={11} className="animate-spin" />}
+ {job.status}
+ </Pill>
+ ),
+ },
+ {
+ key: 'deploy',
+ header: 'Deploy',
+ sortable: true,
+ hideable: false,
+ type: 'text',
+ value: (job) => job.app_name || 'deployment',
+ sortValue: (job) => job.app_name || 'deployment',
+ render: (job) => (
+ <div className="sk-cell-name">
+ <span>
+ <div>{job.app_name || 'deployment'}</div>
+ <div className="sk-cell-sub">
+ {sourceRef(job) || job.id.slice(0, 8)} · {job.trigger || 'manual'}
+ {job.status === 'failed' && job.error_message && (
+ <span className="deployments-page__error"> · {job.error_message}</span>
+ )}
+ </div>
+ </span>
+ </div>
+ ),
+ },
+ {
+ key: 'kind',
+ header: 'Type',
+ sortable: true,
+ type: 'enum',
+ // Filter and sort on the word the chip prints, so a rule reads the
+ // way the row does rather than exposing the backend enum.
+ value: (job) => KIND_CHIP[job.kind] || job.kind,
+ sortValue: (job) => KIND_CHIP[job.kind] || job.kind,
+ render: (job) => (
+ <span className="deployments-page__kind">{KIND_CHIP[job.kind] || job.kind}</span>
+ ),
+ },
+ {
+ key: 'pipeline',
+ header: 'Pipeline',
+ sortable: true,
+ type: 'num',
+ unit: '%',
+ value: (job) => job.progress_percent ?? 0,
+ sortValue: (job) => job.progress_percent ?? 0,
+ render: (job) => (
+ <span className="deployments-page__pipe">
+ <span className="deployments-page__ticks">
+ {stepTicks(job).map((state, i) => (
+ <i key={i} className={`is-${state}`} />
+ ))}
+ </span>
+ <span className="deployments-page__pipe-count">
+ {job.current_step || 0}/{job.total_steps || 0}
+ </span>
+ </span>
+ ),
+ },
+ {
+ key: 'target',
+ header: 'Target',
+ sortable: true,
+ type: 'enum',
+ groupable: true,
+ // A job with no target server ran on the panel's own box; spelling
+ // that out keeps the pick-list honest instead of offering a blank.
+ value: (job) => job.target_server_name || 'Local server',
+ sortValue: (job) => job.target_server_name || 'Local server',
+ groupValue: (job) => job.target_server_name || 'Local server',
+ cellClassName: 'sk-cell-mono',
+ render: (job) => job.target_server_name || 'Local server',
+ },
+ {
+ key: 'took',
+ header: 'Took',
+ sortable: true,
+ type: 'num',
+ unit: 's',
+ value: (job) => job.duration ?? null,
+ sortValue: (job) => job.duration ?? null,
+ cellClassName: 'sk-cell-mono',
+ render: (job) => formatDuration(job.duration),
+ },
+ {
+ key: 'started',
+ header: 'Started',
+ sortable: true,
+ type: 'date',
+ groupable: true,
+ value: (job) => job.started_at || job.created_at || null,
+ sortValue: (job) => {
+ const time = Date.parse(job.started_at || job.created_at);
+ return Number.isNaN(time) ? null : time;
+ },
+ groupValue: (job) => activityGroup(job),
+ cellClassName: 'sk-cell-mono',
+ render: (job) => (job.status === 'pending'
+ ? 'queued'
+ : relativeTime(job.started_at || job.created_at)),
+ },
+ ], []);
+
+ // No `pageState`: search is the only page-private control left, and a saved
+ // view carrying somebody's half-typed search term is not a view of the data.
+ const chrome = useTableChrome({
+ columns,
+ rows: searched,
+ viewPageKey: 'deployments',
+ builtinViews: BUILTIN_VIEWS,
+ noun: 'deploys',
+ sorts,
+ setSorts,
+ hiddenKeys,
+ setHiddenKeys,
+ groupBy,
+ setGroupBy,
+ });
- const groups = useMemo(() => {
- const shown = statusFilter === 'all'
- ? searched
- : searched.filter((j) => j.status === statusFilter);
- return groupDeploys(shown);
- }, [searched, statusFilter]);
+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(
+ <>
+ <SearchField
+ value={search}
+ onSearch={setSearch}
+ placeholder="Search deploys…"
+ />
+ <GridFilterButton
+ count={chrome.filterCount}
+ onClick={() => chrome.setDrawerOpen(true)}
+ />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadJobs} />
+ </>,
+ );
useTopbarActions(() =>
<>
{/* No "New service" button here: unlike the design mock, this tab
group already carries a New Service tab, and a second entry
- point crowded the strip into overflow. */}
+ point crowded the strip into overflow. No Refresh button
+ either — the chrome's "⋮" owns "Refresh data" on every page. */}
{simInfo?.enabled && (
<Button variant="outline" size="sm" onClick={() => setSimOpen(true)}>
<FlaskConical size={16} />
@@ -159,157 +355,62 @@ const Deployments = () => {
<RefreshCw size={16} className={autoRefresh ? 'spin' : ''} />
{autoRefresh ? 'Live' : 'Paused'}
</Button>
- <Button variant="outline" size="sm" onClick={loadJobs}>
- <RefreshCw size={16} /> Refresh
- </Button>
- <SearchField
- value={search}
- onSearch={setSearch}
- placeholder="Search deploys…"
- />
</>,
- [autoRefresh, simInfo?.enabled, search]
+ [autoRefresh, simInfo?.enabled]
);
return (
<RequiresDocker what="Deployments">
<div className="sk-tabgroup__inner deployments-page">
- <ListToolbar
- filters={(
- <SegControl
- value={statusFilter}
- onChange={setStatusFilter}
- options={STATUS_FILTERS.map(([value, label]) => ({
- value,
- label,
- count: counts[value],
- }))}
- aria-label="Filter by status"
- />
- )}
- >
- <select
- className="sk-listhead__select"
- value={serverFilter}
- onChange={(e) => setServerFilter(e.target.value)}
- aria-label="Filter by target server"
- >
- <option value="all">All servers</option>
- {servers.map((s) => (
- <option key={s.id} value={s.id}>
- {s.name}{s.is_local ? ' (local)' : ''}
- </option>
- ))}
- </select>
- </ListToolbar>
-
- {loading ? (
- <div className="deployments-page__loading" aria-busy="true">
- {[0, 1, 2, 3].map((i) => (
- <div key={i} className="deployments-page__loading-row">
- <Skeleton variant="line" width={96} />
- <Skeleton variant="line" width="34%" />
- <Skeleton variant="line" width="20%" />
- <Skeleton variant="line" width="26%" />
- </div>
- ))}
- </div>
- ) : groups.length === 0 ? (
- <EmptyState
- icon={PlayCircle}
- title={jobs.length === 0 ? 'No deployment jobs yet' : 'No deploys match this filter'}
- description={jobs.length === 0
- ? 'Create a service from a repository or install a template to see activity here.'
- : 'Try a different status, server, or search term.'}
- />
- ) : (
- <div className="deployments-page__feed">
- <div className="deployments-page__feed-head" aria-hidden="true">
- <span />
- <span>Deploy</span>
- <span>Pipeline</span>
- <span>Target</span>
- <span className="is-right">Took</span>
- <span className="is-right">Started</span>
- <span />
- </div>
+ {topbarChrome}
- {groups.map(({ group, items }) => (
- <div className="deployments-page__group" key={group}>
- <div className="deployments-page__group-head">
- {group}
- <i />
- </div>
- {items.map((job) => {
- const meta = STATE_ICON[job.status] || STATE_ICON.pending;
- const { Icon } = meta;
- const ticks = stepTicks(job);
- return (
- <button
- type="button"
- key={job.id}
- className={`deployments-page__row deployments-page__row--${meta.cls}`}
- onClick={() => navigate(`/deployments/${job.id}`)}
- title="Open the Deploy Console"
- >
- <span className={`deployments-page__row-ico is-${meta.cls}`}>
- <Icon size={15} className={job.status === 'running' ? 'spin' : ''} />
- </span>
+ <GridViewPicker
+ views={chrome.views}
+ label="deploys"
+ onCreate={chrome.createView}
+ actions={chromeActions}
+ />
- <span className="deployments-page__row-main">
- <span className="deployments-page__row-name">
- {job.app_name || 'deployment'}
- <span className="deployments-page__row-kind">
- {KIND_CHIP[job.kind] || job.kind}
- </span>
- </span>
- <span className="deployments-page__row-sub">
- <span className="deployments-page__row-ref">
- {sourceRef(job) || job.id.slice(0, 8)}
- </span>
- <span className="deployments-page__row-sep">·</span>
- <span>{job.trigger || 'manual'}</span>
- {job.status === 'failed' && job.error_message && (
- <>
- <span className="deployments-page__row-sep">·</span>
- <span className="deployments-page__row-error">
- {job.error_message}
- </span>
- </>
- )}
- </span>
- </span>
+ <GridChips {...chrome.chipProps} />
- <span className="deployments-page__pipe">
- <span className="deployments-page__ticks">
- {ticks.map((state, i) => (
- <i key={i} className={`is-${state}`} />
- ))}
- </span>
- <span className="deployments-page__pipe-count">
- {job.current_step || 0}/{job.total_steps || 0}
- </span>
- </span>
+ <DataTable
+ columns={chrome.columns}
+ data={searched}
+ keyField="id"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ groupBy={groupBy}
+ onGroupByChange={setGroupBy}
+ {...chrome.tableProps}
+ loading={loading && jobs.length === 0}
+ onRowClick={(job) => navigate(`/deployments/${job.id}`)}
+ emptyState={(
+ <EmptyState
+ icon={PlayCircle}
+ title={jobs.length === 0 ? 'No deployment jobs yet' : 'No deploys match this search'}
+ description={jobs.length === 0
+ ? 'Create a service from a repository or install a template to see activity here.'
+ : 'Try a different search term, or pick another view.'}
+ />
+ )}
+ footer={(
+ <DataTableFooter
+ // DataTable applies the column rules itself, so the shown
+ // count comes from the chrome; `jobs` is the whole query.
+ shown={chrome.shownCount}
+ total={jobs.length}
+ noun="deploy"
+ hasMore={hasMore}
+ loading={loadingMore}
+ onLoadMore={() => {
+ setLoadingMore(true);
+ loadJobs(loaded + PAGE).finally(() => setLoadingMore(false));
+ }}
+ />
+ )}
+ />
- <span className="deployments-page__row-target">
- {job.target_server_name || 'Local server'}
- </span>
- <span className="deployments-page__row-took">
- {formatDuration(job.duration)}
- </span>
- <span className="deployments-page__row-when">
- {job.status === 'pending'
- ? 'queued'
- : relativeTime(job.started_at || job.created_at)}
- </span>
- <ChevronRight size={15} className="deployments-page__row-chev" />
- </button>
- );
- })}
- </div>
- ))}
- </div>
- )}
+ <GridFilterDrawer {...chrome.drawerProps} />
<Modal
open={simOpen}
diff --git a/frontend/src/pages/FTPServer.jsx b/frontend/src/pages/FTPServer.jsx
index 21c8fdd7..c992697c 100644
--- a/frontend/src/pages/FTPServer.jsx
+++ b/frontend/src/pages/FTPServer.jsx
@@ -6,7 +6,11 @@ import {
import useTabParam from '../hooks/useTabParam';
import { useTopbarActions } from '@/hooks/useTopbarActions';
import { api } from '../services/api';
-import { DataTable, DataTableFooter, MetricCard, KpiBand, Pill } from '@/components/ds';
+import { DataTable, DataTableFooter, MetricCard, KpiBand, Pill, ListToolbar } from '@/components/ds';
+import {
+ useTableChrome, GridViewPicker, GridChips, GridFilterButton,
+ GridToolsMenu, GridFilterDrawer,
+} from '@/components/ds/grid';
import { useTableSort } from '@/hooks/useTableSort';
import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { useToast } from '../contexts/ToastContext';
@@ -21,6 +25,37 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
const VALID_TABS = ['overview', 'users', 'connections', 'logs'];
+// Built-in saved views for the users table. An FTP account has one axis worth
+// slicing — whether its shell still permits a login — and it is the axis the
+// row already renders as a pill, so the rules below match the `status` column's
+// `value`, which is the same word the Pill shows.
+const NO_RULES = { match: 'all', rules: [] };
+const BY_NAME = [{ key: 'username', direction: 'asc' }];
+const STATUS_IS = (value) => ({
+ match: 'all',
+ rules: [{ id: 'fu1', field: 'status', op: 'any', value: [value] }],
+});
+
+const FTP_USER_VIEWS = [
+ {
+ // Every account the panel can see, in the order you would read them.
+ name: 'All users',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: NO_RULES },
+ },
+ {
+ // Who can actually connect right now — the unfiltered table cannot
+ // answer that at a glance once a few accounts have been parked.
+ name: 'Active',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: STATUS_IS('Active') },
+ },
+ {
+ // The other half: accounts left in /etc/passwd with a nologin shell.
+ // Worth reading before creating a user that duplicates one.
+ name: 'Disabled',
+ state: { sorts: BY_NAME, hiddenKeys: [], columnFilters: STATUS_IS('Disabled') },
+ },
+];
+
function FTPServer() {
const [status, setStatus] = useState(null);
const [users, setUsers] = useState([]);
@@ -256,6 +291,9 @@ function FTPServer() {
header: 'Username',
sortable: true,
hideable: false,
+ // A login name is a fragment you type, not a value you pick.
+ type: 'text',
+ value: (user) => user.username || '',
sortValue: (user) => user.username || '',
render: (user) => (
<>
@@ -270,6 +308,8 @@ function FTPServer() {
key: 'home',
header: 'Home Directory',
sortable: true,
+ type: 'text',
+ value: (user) => user.home || '',
sortValue: (user) => user.home || '',
cellClassName: 'sk-cell-mono',
render: (user) => (
@@ -285,6 +325,10 @@ function FTPServer() {
key: 'usage',
header: 'Usage',
sortable: true,
+ // Filter on the byte count, not on the "1.2 MB" string the cell
+ // shows — "greater than" is the only useful question here.
+ type: 'num',
+ value: (user) => user.home_size ?? null,
sortValue: (user) => user.home_size ?? null,
cellClassName: 'sk-cell-mono',
render: (user) => user.home_size_human,
@@ -293,6 +337,14 @@ function FTPServer() {
key: 'status',
header: 'Status',
sortable: true,
+ // Declared, not inferred: a box with two FTP accounts of two
+ // statuses fails the enum cardinality test and would fall back to
+ // text, which turns the pick-list into a typed fragment and both
+ // status views above into no-ops. There is no `status` key on the
+ // row either — `value` is what the rules read.
+ type: 'enum',
+ enumOrder: ['Active', 'Disabled'],
+ value: (user) => (user.is_active ? 'Active' : 'Disabled'),
sortValue: (user) => (user.is_active ? 'Active' : 'Disabled'),
render: (user) => (
<Pill kind={user.is_active ? 'green' : 'gray'}>
@@ -343,6 +395,9 @@ function FTPServer() {
header: 'Local Address',
sortable: true,
hideable: false,
+ // addr:port pairs are near-unique per row — you type a fragment.
+ type: 'text',
+ value: (conn) => conn.local || '',
sortValue: (conn) => conn.local || '',
cellClassName: 'sk-cell-mono',
render: (conn) => <code>{conn.local}</code>,
@@ -351,6 +406,8 @@ function FTPServer() {
key: 'remote',
header: 'Remote Address',
sortable: true,
+ type: 'text',
+ value: (conn) => conn.remote || '',
sortValue: (conn) => conn.remote || '',
cellClassName: 'sk-cell-mono',
render: (conn) => <code>{conn.remote}</code>,
@@ -359,6 +416,10 @@ function FTPServer() {
key: 'state',
header: 'State',
sortable: true,
+ // Declared: with a single connection listed the one distinct value
+ // fails the cardinality test and the column would drop to text.
+ type: 'enum',
+ value: (conn) => conn.state || '',
sortValue: (conn) => conn.state || '',
render: (conn) => (
<Pill kind="green">{conn.state}</Pill>
@@ -383,6 +444,38 @@ function FTPServer() {
},
];
+ // Chrome stays INLINE rather than hoisted: /ftp is one page in the Files
+ // tab group, so its top bar is shared with File Manager, and these tables
+ // are two of four inner tabs — a hoisted picker would sit over Overview and
+ // Logs too. One route, two tables, so each needs its own `urlScope`:
+ // without it both would write `?view=`/`?sort=` and clobber each other.
+ const userChrome = useTableChrome({
+ columns: userColumns,
+ rows: users,
+ viewPageKey: 'ftp-users',
+ builtinViews: FTP_USER_VIEWS,
+ noun: 'users',
+ sorts: userSorts,
+ setSorts: setUserSorts,
+ hiddenKeys: userHiddenKeys,
+ setHiddenKeys: setUserHiddenKeys,
+ urlScope: 'users',
+ });
+
+ // No built-in views: every row here is an established session to port 21,
+ // so there is no second slice to name — `ss` reports nothing else.
+ const connChrome = useTableChrome({
+ columns: connectionColumns,
+ rows: connections,
+ viewPageKey: 'ftp-connections',
+ noun: 'connections',
+ sorts: connSorts,
+ setSorts: setConnSorts,
+ hiddenKeys: connHiddenKeys,
+ setHiddenKeys: setConnHiddenKeys,
+ urlScope: 'connections',
+ });
+
const isInstalled = status?.any_installed;
const isRunning = status?.any_running;
@@ -569,86 +662,124 @@ function FTPServer() {
<TabsContent value="users">
<div className="users-tab">
- <div className="section-header">
- <h3>FTP Users</h3>
- <div className="section-header__actions">
- <Button onClick={() => setShowUserModal(true)}>
- Add User
- </Button>
- </div>
- </div>
- {users.length === 0 ? (
- <EmptyState
- icon={UserPlus}
- title="No FTP users configured"
- action={<Button onClick={() => setShowUserModal(true)}>Create First User</Button>}
- />
- ) : (
- <DataTable
- columns={userColumns}
- data={users}
- keyField="username"
- sorts={userSorts}
- onSortsChange={setUserSorts}
- hiddenKeys={userHiddenKeys}
- onHiddenKeysChange={setUserHiddenKeys}
- className="users-table"
- footer={(
- <DataTableFooter
- shown={users.length}
- total={users.length}
- noun="user"
+ {/* The view name replaces the old "FTP Users"
+ eyebrow: one heading, and it now names the
+ slice you are looking at. Add User keeps its
+ own bar because it acts on the server, not
+ on what you are looking at; Refresh is in
+ the "⋮". */}
+ <GridViewPicker
+ views={userChrome.views}
+ label="users"
+ onCreate={userChrome.createView}
+ actions={(
+ <>
+ <GridFilterButton
+ count={userChrome.filterCount}
+ onClick={() => userChrome.setDrawerOpen(true)}
/>
- )}
- />
- )}
+ <GridToolsMenu {...userChrome.toolsProps} onRefresh={loadUsers} />
+ </>
+ )}
+ />
+ <ListToolbar>
+ <Button onClick={() => setShowUserModal(true)}>
+ Add User
+ </Button>
+ </ListToolbar>
+
+ <GridChips {...userChrome.chipProps} />
+
+ <DataTable
+ columns={userChrome.columns}
+ data={users}
+ keyField="username"
+ sorts={userSorts}
+ onSortsChange={setUserSorts}
+ {...userChrome.tableProps}
+ className="users-table"
+ emptyState={(
+ <EmptyState
+ icon={UserPlus}
+ title="No FTP users configured"
+ action={<Button onClick={() => setShowUserModal(true)}>Create First User</Button>}
+ />
+ )}
+ footer={(
+ <DataTableFooter
+ // DataTable applies the column rules
+ // itself, so the shown count comes
+ // from the chrome — `users` is only
+ // ever the whole account list.
+ shown={userChrome.shownCount}
+ total={users.length}
+ noun="user"
+ />
+ )}
+ />
+
+ <GridFilterDrawer {...userChrome.drawerProps} />
</div>
</TabsContent>
<TabsContent value="connections">
<div className="connections-tab">
- <div className="section-header">
- <h3>Active Connections</h3>
- <div className="section-header__actions">
- <Button variant="outline" onClick={loadConnections}>
- <RefreshCw size={14} />
- Refresh
- </Button>
- </div>
- </div>
- {connections.length === 0 ? (
- <EmptyState icon={Network} title="No active connections" />
- ) : (
- <DataTable
- columns={connectionColumns}
- data={connections}
- keyField={(conn) => conn.pid ?? `${conn.local}-${conn.remote}`}
- sorts={connSorts}
- onSortsChange={setConnSorts}
- hiddenKeys={connHiddenKeys}
- onHiddenKeysChange={setConnHiddenKeys}
- className="connections-table"
- footer={(
- <DataTableFooter
- shown={connections.length}
- total={connections.length}
- noun="connection"
+ {/* Refresh moved into the "⋮" so it stays
+ reachable even with nothing connected —
+ the empty state is the table's now. */}
+ <GridViewPicker
+ views={connChrome.views}
+ label="connections"
+ onCreate={connChrome.createView}
+ actions={(
+ <>
+ <GridFilterButton
+ count={connChrome.filterCount}
+ onClick={() => connChrome.setDrawerOpen(true)}
/>
- )}
- />
- )}
+ <GridToolsMenu {...connChrome.toolsProps} onRefresh={loadConnections} />
+ </>
+ )}
+ />
+
+ <GridChips {...connChrome.chipProps} />
+
+ <DataTable
+ columns={connChrome.columns}
+ data={connections}
+ keyField={(conn) => conn.pid ?? `${conn.local}-${conn.remote}`}
+ sorts={connSorts}
+ onSortsChange={setConnSorts}
+ {...connChrome.tableProps}
+ className="connections-table"
+ emptyState={<EmptyState icon={Network} title="No active connections" />}
+ footer={(
+ <DataTableFooter
+ shown={connChrome.shownCount}
+ total={connections.length}
+ noun="connection"
+ />
+ )}
+ />
+
+ <GridFilterDrawer {...connChrome.drawerProps} />
</div>
</TabsContent>
<TabsContent value="logs">
<div className="logs-tab">
- <div className="section-header">
- <h3>Server Logs</h3>
- <Button variant="outline" onClick={loadLogs}>
- <RefreshCw size={14} />
- Refresh
- </Button>
- </div>
+ {/* No table here, so no view picker — a title
+ and the one action, through the shared
+ toolbar instead of a hand-rolled row. */}
+ <ListToolbar
+ title="Server logs"
+ tools={(
+ <Button variant="outline" onClick={loadLogs}>
+ <RefreshCw size={14} />
+ Refresh
+ </Button>
+ )}
+ />
<div className="log-viewer">
<pre>{logs}</pre>
</div>
diff --git a/frontend/src/pages/Templates.jsx b/frontend/src/pages/Templates.jsx
index 30a4d7c9..cf93875d 100644
--- a/frontend/src/pages/Templates.jsx
+++ b/frontend/src/pages/Templates.jsx
@@ -1,7 +1,7 @@
import { useState, useEffect, useMemo } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import {
- Search, X, Star, ExternalLink, BookOpen, Container, Globe, BarChart3,
+ Search, Star, ExternalLink, BookOpen, Container, Globe, BarChart3,
Database, Shield, Cloud, MessageSquare, Video, Music, Image, Home,
Code, Server, GitBranch, Workflow, HardDrive, Lock, Users, FileText,
Settings, Layers, LayoutTemplate, Check, Tag, Cpu,
@@ -15,9 +15,12 @@ import { Input } from '@/components/ui/input';
import { Badge } from '@/components/ui/badge';
import {
SearchField, FilterDrawer, FilterButton, countActiveFilters, Drawer,
+ DataTableFooter,
} from '@/components/ds';
+import { useTableChrome, GridViewPicker, GridToolsMenu } from '@/components/ds/grid';
import ServerPicker from '@/components/templates/ServerPicker';
-import { useTopbarActions } from '@/hooks/useTopbarActions';
+import { useTopbarChrome } from '@/hooks/useTopbarActions';
+import { applyTableSorts, useTableSort } from '@/hooks/useTableSort';
import EmptyState from '../components/EmptyState';
// Featured templates (curated list)
@@ -158,17 +161,58 @@ const TEMPLATE_ICONS = {
'node-app': Code
};
-const SORT_OPTIONS = [
- { value: 'featured', label: 'Featured first' },
- { value: 'name-asc', label: 'Name (A–Z)' },
- { value: 'name-desc', label: 'Name (Z–A)' },
-];
-
const KIND_OPTIONS = [
{ value: 'compose', label: 'One-click' },
{ value: 'repo', label: 'Git repo' },
];
+const isFeatured = (templateId) => FEATURED_TEMPLATES.includes(templateId);
+const kindLabel = (template) => ((template.kind || 'compose') === 'repo' ? 'Git repo' : 'One-click');
+
+// The catalog stays a card grid — a template is something you read, not a row
+// you scan — but the chrome around it still has to know what a template IS.
+// These descriptors are what the saved views sort by and what the "⋮" exports;
+// nothing renders them, so none of them carries a `render`.
+const templateColumns = [
+ { key: 'name', header: 'Template', type: 'text', value: (t) => t.name || '', sortValue: (t) => t.name || '' },
+ {
+ key: 'featured',
+ header: 'Featured',
+ type: 'bool',
+ value: (t) => isFeatured(t.id),
+ // 1/0 rather than the boolean: applyTableSorts compares booleans as the
+ // strings "true"/"false", which happens to work and would stop working
+ // the moment anyone renamed the labels.
+ sortValue: (t) => (isFeatured(t.id) ? 1 : 0),
+ },
+ { key: 'kind', header: 'Type', type: 'enum', enumOrder: ['One-click', 'Git repo'], value: kindLabel, sortValue: kindLabel },
+ { key: 'version', header: 'Version', type: 'text', value: (t) => t.version || '', sortValue: (t) => t.version || '' },
+ { key: 'categories', header: 'Categories', type: 'text', value: (t) => (t.categories || []).join(', ') },
+ { key: 'description', header: 'Description', type: 'text', value: (t) => t.description || '' },
+];
+
+// Sort orders are built-in saved views now. The two-button Featured / A–Z strip
+// beside the result count and the drawer's own "Sort" group were the same three
+// orders offered twice, and neither could be saved or shared as a link.
+//
+// The views describe ORDER only — no `page` bag. Type and category stay
+// URL-backed drawer filters, and a view that also wrote them could not win: the
+// router defers its own state update, so `useViewLink` rewrites `?view=` from
+// the search string as it was BEFORE the view was applied and drops any param
+// the same apply had just written. A view whose type slice silently did nothing
+// is worse than no such view.
+const NO_RULES = { match: 'all', rules: [] };
+const FEATURED_SORT = [
+ { key: 'featured', direction: 'desc' },
+ { key: 'name', direction: 'asc' },
+];
+
+const TEMPLATE_VIEWS = [
+ { name: 'Featured first', state: { sorts: FEATURED_SORT, hiddenKeys: [], columnFilters: NO_RULES } },
+ { name: 'A–Z', state: { sorts: [{ key: 'name', direction: 'asc' }], hiddenKeys: [], columnFilters: NO_RULES } },
+ { name: 'Z–A', state: { sorts: [{ key: 'name', direction: 'desc' }], hiddenKeys: [], columnFilters: NO_RULES } },
+];
+
const Templates = () => {
const navigate = useNavigate();
const toast = useToast();
@@ -186,9 +230,13 @@ const Templates = () => {
const selectedCategory = searchParams.get('category') || '';
const selectedKind = searchParams.get('kind') || '';
const searchQuery = searchParams.get('search') || '';
- const sortBy = searchParams.get('sort') || 'featured';
const installTemplateId = searchParams.get('install');
+ const { sorts, setSorts } = useTableSort({
+ defaultSorts: FEATURED_SORT,
+ storageKey: 'serverkit-table-templates-sort',
+ });
+
useEffect(() => {
loadData();
}, []);
@@ -230,28 +278,28 @@ const Templates = () => {
loadTemplates();
}, [selectedCategory, searchQuery]);
+ // Functional update: ?view= is written by the chrome from its own copy of
+ // the search string, so rebuilding this one from a captured `searchParams`
+ // would drop whichever of the two landed first.
function updateFilters(updates) {
- const newParams = new URLSearchParams(searchParams);
- Object.entries(updates).forEach(([key, value]) => {
- if (value) {
- newParams.set(key, value);
- } else {
- newParams.delete(key);
- }
+ setSearchParams((previous) => {
+ const next = new URLSearchParams(previous);
+ Object.entries(updates).forEach(([key, value]) => {
+ if (value) next.set(key, value);
+ else next.delete(key);
+ });
+ return next;
});
- setSearchParams(newParams);
- }
-
- function setSelectedCategoryFilter(category) {
- updateFilters({ category });
}
function setSearchQueryFilter(search) {
updateFilters({ search: search || null });
}
+ // Clears the filters, not the whole query string — ?view= is which view you
+ // are in, not something the filters put there.
function clearAllFilters() {
- setSearchParams(new URLSearchParams());
+ updateFilters({ category: null, kind: null, search: null });
}
async function loadData() {
@@ -419,42 +467,18 @@ const Templates = () => {
}
}
- function isFeatured(templateId) {
- return FEATURED_TEMPLATES.includes(templateId);
- }
-
- // Sort templates
- function sortTemplates(list) {
- const sorted = [...list];
- switch (sortBy) {
- case 'name-asc':
- return sorted.sort((a, b) => a.name.localeCompare(b.name));
- case 'name-desc':
- return sorted.sort((a, b) => b.name.localeCompare(a.name));
- case 'featured':
- return sorted.sort((a, b) => {
- const aFeatured = isFeatured(a.id);
- const bFeatured = isFeatured(b.id);
- if (aFeatured && !bFeatured) return -1;
- if (!aFeatured && bFeatured) return 1;
- return a.name.localeCompare(b.name);
- });
- default:
- return sorted;
- }
- }
-
// Kind is filtered client-side (the list endpoint filters category + search).
- const kindFiltered = selectedKind
- ? templates.filter(t => (t.kind || 'compose') === selectedKind)
- : templates;
- const sortedTemplates = sortTemplates(kindFiltered);
+ const kindFiltered = useMemo(
+ () => (selectedKind
+ ? templates.filter(t => (t.kind || 'compose') === selectedKind)
+ : templates),
+ [templates, selectedKind],
+ );
// The active-filter badge counts real filters only (category + kind); sort is
// an ordering, not a filter, so it never inflates the count.
const activeFilterCount = countActiveFilters({ category: selectedCategory, kind: selectedKind });
- const hasActiveFilters = Boolean(selectedCategory || selectedKind || searchQuery
- || (sortBy && sortBy !== 'featured'));
+ const hasActiveFilters = Boolean(selectedCategory || selectedKind || searchQuery);
// How many templates each option would match, counted over the whole
// catalog rather than the current result set — a count that shrank to 0 as
@@ -489,25 +513,41 @@ const Templates = () => {
count: optionCounts.byCategory[cat] || 0,
})),
},
- {
- key: 'sort',
- label: 'Sort',
- type: 'single',
- options: SORT_OPTIONS,
- },
];
- const filterValue = { category: selectedCategory, kind: selectedKind, sort: sortBy };
+ const filterValue = { category: selectedCategory, kind: selectedKind };
function handleFilterChange(next) {
updateFilters({
category: next.category || null,
kind: next.kind || null,
- sort: next.sort && next.sort !== 'featured' ? next.sort : null,
});
}
- useTopbarActions(() =>
+ // No `pageState`: type and category are the drawer's, and a template belongs
+ // to SEVERAL categories at once, so neither could become a column rule
+ // either — the rule engine compares one value per row, and "is any of" would
+ // miss every template whose match is its second category.
+ const chrome = useTableChrome({
+ columns: templateColumns,
+ rows: kindFiltered,
+ viewPageKey: 'templates',
+ builtinViews: TEMPLATE_VIEWS,
+ noun: 'templates',
+ sorts,
+ setSorts,
+ });
+
+ // No <DataTable> to apply the view's sort, so the cards do it themselves
+ // from the same state a table would have used.
+ const sortedTemplates = useMemo(
+ () => applyTableSorts(chrome.shownRows, sorts, chrome.columns),
+ [chrome.shownRows, sorts, chrome.columns],
+ );
+
+ // Search, the filter button and the "⋮" ride the tab group's top bar, so the
+ // view row below is the view name alone.
+ const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(
<>
<SearchField
value={searchQuery}
@@ -515,8 +555,8 @@ const Templates = () => {
placeholder="Search templates…"
/>
<FilterButton count={activeFilterCount} onClick={() => setFiltersOpen(true)} />
+ <GridToolsMenu {...chrome.toolsProps} onRefresh={loadData} />
</>,
- [searchQuery, activeFilterCount]
);
if (loading) {
@@ -529,6 +569,7 @@ const Templates = () => {
return (
<div className="sk-tabgroup__inner templates-page">
+ {topbarChrome}
{/* The catalog is not the only way in: a repo or an archive skips
templates entirely, so both routes lead the page rather than
hiding behind the New Service tab. */}
@@ -551,57 +592,15 @@ const Templates = () => {
</button>
</div>
- {/* One header row: result count, whatever filtering is currently in
- force (as removable chips), and sort. Categories are not listed
- here — every filter lives in the FilterDrawer, so there is one
- place to look rather than two competing ones. */}
- <div className="templates-results-header">
- <span className="results-count">
- {sortedTemplates.length} template{sortedTemplates.length !== 1 ? 's' : ''}
- </span>
- <div className="active-filters">
- {selectedKind && (
- <button type="button" className="filter-chip"
- onClick={() => updateFilters({ kind: null })}>
- {KIND_OPTIONS.find(k => k.value === selectedKind)?.label || selectedKind}
- <X size={12} />
- </button>
- )}
- {selectedCategory && (
- <button type="button" className="filter-chip"
- onClick={() => setSelectedCategoryFilter(null)}>
- {selectedCategory}
- <X size={12} />
- </button>
- )}
- {searchQuery && (
- <button type="button" className="filter-chip"
- onClick={() => setSearchQueryFilter('')}>
- &ldquo;{searchQuery}&rdquo;
- <X size={12} />
- </button>
- )}
- {hasActiveFilters && (
- <Button variant="ghost" size="sm" className="clear-all-btn" onClick={clearAllFilters}>
- Clear all
- </Button>
- )}
- </div>
- {/* The two orders people actually reach for; the full sort list
- (incl. Z–A) stays in the filter drawer. */}
- <div className="tpl-sort" role="group" aria-label="Sort templates">
- {[['featured', 'Featured'], ['name-asc', 'A–Z']].map(([value, label]) => (
- <button
- type="button"
- key={value}
- className={sortBy === value ? 'is-active' : ''}
- onClick={() => updateFilters({ sort: value === 'featured' ? null : value })}
- >
- {label}
- </button>
- ))}
- </div>
- </div>
+ {/* The one row of chrome: the active view names what you are looking
+ at, and its actions ride the top bar. The count that used to sit
+ here is under the cards now, next to what it is counting. */}
+ <GridViewPicker
+ views={chrome.views}
+ label="templates"
+ onCreate={chrome.createView}
+ actions={chromeActions}
+ />
{/* Templates Grid */}
<div className="templates-grid">
@@ -672,6 +671,16 @@ const Templates = () => {
)}
</div>
+ {/* Under the cards, not above them: `templates` is what the category
+ and search query returned, `sortedTemplates` is what the kind
+ slice left of it. */}
+ {sortedTemplates.length > 0 && (
+ <DataTableFooter
+ shown={sortedTemplates.length}
+ total={templates.length}
+ noun="template"
+ />
+ )}
{/* Install Modal (compose templates only) */}
{showInstallModal && selectedTemplate && (
diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsx
index 0cdbc597..badab0ac 100644
--- a/frontend/src/pages/Terminal.jsx
+++ b/frontend/src/pages/Terminal.jsx
@@ -10,12 +10,14 @@ import LogToolbar from '../components/log-viewer/LogToolbar';
import LogContent from '../components/log-viewer/LogContent';
import { formatBytes, logKindFromPath } from '../components/log-viewer/logHelpers';
import { formatBytes as formatMemory } from '@/utils/formatBytes';
-import { Pill, Drawer } from '../components/ds';
+import { Drawer } from '../components/ds';
+import ProcessTable, { procUser } from '../components/ProcessTable';
+import SystemdServicesTab from '../components/serverdetail/ServicesTab';
+import { useTableSort } from '@/hooks/useTableSort';
import PageLayout from '../layouts/PageLayout';
-import { Button } from '@/components/ui/button';
import {
- FileText, Clock, AlertCircle, Search, X, RefreshCw, AlertTriangle, Activity,
- Play, Square, RotateCw, Terminal as TerminalIcon, Server as ServerIcon,
+ FileText, Clock, AlertCircle, Search, X, AlertTriangle, Activity,
+ Terminal as TerminalIcon, Server as ServerIcon,
ScrollText, Cpu, Settings,
} from 'lucide-react';
@@ -782,6 +784,10 @@ function priorityColor(value) {
return '#646b7a';
}
+// Server-side page sizes for /processes. Not a table concern — the endpoint
+// returns a top-N slice, so this decides what is fetched, not what is shown.
+const PROCESS_LIMITS = [25, 50, 100, 250];
+
const ProcessesTab = () => {
const toast = useToast();
const { confirm } = useConfirm();
@@ -791,28 +797,32 @@ const ProcessesTab = () => {
const [processes, setProcesses] = useState([]);
const [loading, setLoading] = useState(true);
- const [sortBy, setSortBy] = useState('cpu');
- const [sortDir, setSortDir] = useState('desc');
const [limit, setLimit] = useState(100);
- const [searchTerm, setSearchTerm] = useState('');
- const [statusFilter, setStatusFilter] = useState('all');
- const [userFilter, setUserFilter] = useState(null);
const [selectedProcess, setSelectedProcess] = useState(null);
const [autoRefresh, setAutoRefresh] = useState(false);
const [lastUpdated, setLastUpdated] = useState(null);
+ // The table sorts client-side, but /processes answers with a TOP-N slice:
+ // the top 100 by CPU re-sorted by memory is NOT the top 100 by memory. So
+ // the sort lives here and the fetch follows whatever the table is showing.
+ const { sorts, setSorts } = useTableSort({
+ storageKey: 'serverkit-table-processes-sort',
+ defaultSorts: [{ key: 'cpu', direction: 'desc' }],
+ });
+ const fetchSort = sorts[0]?.key === 'memory' ? 'memory' : 'cpu';
+
const intervalRef = useRef(null);
useEffect(() => {
loadProcesses();
- }, [sortBy, limit, target.kind, target.server_id]); // eslint-disable-line
+ }, [fetchSort, limit, target.kind, target.server_id]); // eslint-disable-line
useEffect(() => {
if (autoRefresh) {
intervalRef.current = setInterval(() => loadProcesses(false), 4000);
}
return () => { if (intervalRef.current) clearInterval(intervalRef.current); };
- }, [autoRefresh, sortBy, limit]); // eslint-disable-line
+ }, [autoRefresh, fetchSort, limit]); // eslint-disable-line
async function loadProcesses(showSpinner = true) {
if (isRemote) {
@@ -822,7 +832,7 @@ const ProcessesTab = () => {
}
if (showSpinner) setLoading(true);
try {
- const data = await api.getProcesses(limit, sortBy);
+ const data = await api.getProcesses(limit, fetchSort);
setProcesses(data.processes || []);
setLastUpdated(new Date());
} catch (err) {
@@ -833,6 +843,27 @@ const ProcessesTab = () => {
}
}
+ // The list payload is a summary — no thread count, no resident bytes, no
+ // command line. Ask for the full record when a row is opened so the drawer
+ // shows answers instead of dashes.
+ async function openProcess(p) {
+ setSelectedProcess(p);
+ try {
+ const data = await api.getProcess(p.pid);
+ const detail = data?.process;
+ if (!detail) return;
+ setSelectedProcess((prev) => (prev?.pid === p.pid ? {
+ ...prev,
+ ...detail,
+ // psutil hands back an argv ARRAY; rendered raw React would
+ // concatenate it without spaces.
+ command: Array.isArray(detail.cmdline) ? detail.cmdline.join(' ') : prev.command,
+ } : prev));
+ } catch {
+ /* the summary row is still worth showing */
+ }
+ }
+
async function handleKillProcess(pid, force = false) {
const confirmMsg = force
? `Force-kill PID ${pid}? Unsaved data may be lost.`
@@ -854,65 +885,10 @@ const ProcessesTab = () => {
}
}
- function toggleSort(col) {
- if (sortBy === col) {
- setSortDir(sortDir === 'asc' ? 'desc' : 'asc');
- } else {
- setSortBy(col);
- setSortDir(col === 'name' || col === 'user' ? 'asc' : 'desc');
- }
- }
-
- const userGroups = useMemo(() => {
- const map = new Map();
- for (const p of processes) {
- const u = p.user || 'unknown';
- map.set(u, (map.get(u) || 0) + 1);
- }
- return [...map.entries()].sort((a, b) => b[1] - a[1]);
- }, [processes]);
-
- const statusCounts = useMemo(() => {
- const counts = { all: processes.length, running: 0, sleeping: 0, stopped: 0, zombie: 0 };
- for (const p of processes) {
- const s = (p.status || '').toLowerCase();
- if (s === 'running') counts.running++;
- else if (s === 'sleeping') counts.sleeping++;
- else if (s === 'stopped') counts.stopped++;
- else if (s === 'zombie') counts.zombie++;
- }
- return counts;
- }, [processes]);
-
const totalCpu = useMemo(() => processes.reduce((s, p) => s + (p.cpu_percent || 0), 0), [processes]);
- const totalMem = useMemo(() => processes.reduce((s, p) => s + (p.memory_info?.rss || 0), 0), [processes]);
-
- const filtered = useMemo(() => {
- let list = processes;
- if (userFilter) list = list.filter(p => (p.user || 'unknown') === userFilter);
- if (statusFilter !== 'all') list = list.filter(p => (p.status || '').toLowerCase() === statusFilter);
- const q = searchTerm.toLowerCase();
- if (q) {
- list = list.filter(p =>
- p.name?.toLowerCase().includes(q) ||
- p.command?.toLowerCase().includes(q) ||
- String(p.pid).includes(q)
- );
- }
- const dir = sortDir === 'asc' ? 1 : -1;
- const sorted = [...list];
- sorted.sort((a, b) => {
- switch (sortBy) {
- case 'pid': return ((a.pid || 0) - (b.pid || 0)) * dir;
- case 'name': return (a.name || '').localeCompare(b.name || '') * dir;
- case 'user': return (a.user || '').localeCompare(b.user || '') * dir;
- case 'memory': return ((a.memory_percent || 0) - (b.memory_percent || 0)) * dir;
- case 'cpu':
- default: return ((a.cpu_percent || 0) - (b.cpu_percent || 0)) * dir;
- }
- });
- return sorted;
- }, [processes, userFilter, statusFilter, searchTerm, sortBy, sortDir]);
+ // Percent, not bytes: the list endpoint reports memory_percent and leaves
+ // memory_info to the per-PID call, so a byte total here was always "0 B".
+ const totalMem = useMemo(() => processes.reduce((s, p) => s + (p.memory_percent || 0), 0), [processes]);
return (
<div className="proc-page">
@@ -927,18 +903,16 @@ const ProcessesTab = () => {
</span>
)}
</div>
+ {/* No process count here — DataTableFooter reports it, under
+ the rows it is counting. */}
<div className="lv-header-stats">
- <span className="lv-stat">
- <span className="lv-stat-label">Total</span>
- <span className="lv-stat-value">{processes.length}</span>
- </span>
<span className="lv-stat">
<span className="lv-stat-label">CPU</span>
<span className="lv-stat-value">{totalCpu.toFixed(1)}%</span>
</span>
<span className="lv-stat">
<span className="lv-stat-label">Memory</span>
- <span className="lv-stat-value">{formatMemory(totalMem)}</span>
+ <span className="lv-stat-value">{totalMem.toFixed(1)}%</span>
</span>
{lastUpdated && (
<span className="lv-stat">
@@ -949,182 +923,48 @@ const ProcessesTab = () => {
</div>
</div>
- <div className="proc-toolbar">
- <div className="proc-filter-chips">
- {[
- { id: 'all', label: 'All', count: statusCounts.all },
- { id: 'running', label: 'Running', count: statusCounts.running },
- { id: 'sleeping', label: 'Sleeping', count: statusCounts.sleeping },
- { id: 'stopped', label: 'Stopped', count: statusCounts.stopped },
- { id: 'zombie', label: 'Zombie', count: statusCounts.zombie },
- ].map(c => (
- <button type="button"
- key={c.id}
- className={`proc-chip ${statusFilter === c.id ? 'active' : ''}`}
- onClick={() => setStatusFilter(c.id)}
- disabled={c.id !== 'all' && c.count === 0}
- >
- <span>{c.label}</span>
- <span className="proc-chip-count">{c.count}</span>
- </button>
- ))}
- </div>
- <div className="proc-toolbar-right">
- <div className="lv-search-field">
- <Search size={13} className="lv-search-field-icon" />
- <input
- type="text"
- value={searchTerm}
- onChange={(e) => setSearchTerm(e.target.value)}
- placeholder="Filter PID, name, command…"
- />
- {searchTerm && (
- <button type="button" className="lv-search-field-clear" onClick={() => setSearchTerm('')}>
- <X size={11} />
- </button>
- )}
- </div>
- <select
- className="lv-select"
- value={limit}
- onChange={(e) => setLimit(parseInt(e.target.value, 10))}
- >
- <option value={25}>Top 25</option>
- <option value={50}>Top 50</option>
- <option value={100}>Top 100</option>
- <option value={250}>Top 250</option>
- </select>
- <button type="button"
- className={`lv-chip ${autoRefresh ? 'active' : ''}`}
- onClick={() => setAutoRefresh(!autoRefresh)}
- disabled={isRemote}
- >
- <span className={`lv-pulse ${autoRefresh ? 'on' : ''}`} />
- <span>Live</span>
- </button>
- <Button size="icon" variant="ghost" className="lv-icon-btn" onClick={() => loadProcesses()} title="Refresh" aria-label="Refresh processes">
- <RefreshCw size={13} className={loading ? 'spinning' : ''} />
- </Button>
- </div>
- </div>
-
- <div className="proc-layout">
- <aside className="proc-sidebar">
- <div className="lv-sidebar-header">
- <span className="lv-header-label is-indented">Users</span>
- </div>
- <div className="lv-sidebar-body">
- <button type="button"
- className={`lv-file ${!userFilter ? 'active' : ''}`}
- onClick={() => setUserFilter(null)}
- >
- <span className="lv-file-dot is-accent" />
- <span className="lv-file-name">All users</span>
- <span className="lv-file-size">{processes.length}</span>
- </button>
- {userGroups.map(([user, count]) => (
+ {/* Only the FIRST load swaps the table out. This list auto-refreshes
+ on a timer, and swapping on every `loading` tick unmounted the
+ whole table — chrome, active view, column rules, sort and scroll
+ position with it — then remounted a second later. */}
+ {loading && processes.length === 0 ? (
+ <div className="lv-content-loading">Loading processes…</div>
+ ) : (
+ <ProcessTable
+ processes={processes}
+ selectedPid={selectedProcess?.pid ?? null}
+ onSelect={openProcess}
+ onKill={(p) => handleKillProcess(p.pid)}
+ onForceKill={(p) => handleKillProcess(p.pid, true)}
+ onRefresh={() => loadProcesses()}
+ formatMemory={formatMemory}
+ viewPageKey="terminal-processes"
+ sorts={sorts}
+ onSortsChange={setSorts}
+ actions={(
+ <>
+ <select
+ className="lv-select"
+ value={limit}
+ onChange={(e) => setLimit(parseInt(e.target.value, 10))}
+ title="Processes to fetch"
+ >
+ {PROCESS_LIMITS.map((n) => (
+ <option key={n} value={n}>Top {n}</option>
+ ))}
+ </select>
<button type="button"
- key={user}
- className={`lv-file ${userFilter === user ? 'active' : ''}`}
- onClick={() => setUserFilter(user)}
+ className={`lv-chip ${autoRefresh ? 'active' : ''}`}
+ onClick={() => setAutoRefresh(!autoRefresh)}
+ disabled={isRemote}
>
- <span className="lv-file-dot" style={{ background: hashColor(user) }} />
- <span className="lv-file-name">{user}</span>
- <span className="lv-file-size">{count}</span>
+ <span className={`lv-pulse ${autoRefresh ? 'on' : ''}`} />
+ <span>Live</span>
</button>
- ))}
- </div>
- </aside>
-
- <div className="proc-main">
- {loading ? (
- <div className="lv-content-loading">Loading processes…</div>
- ) : filtered.length === 0 ? (
- <div className="lv-empty-hint is-medium">
- <p>No processes match your filters.</p>
- </div>
- ) : (
- <div className="proc-table-wrap">
- <table className="proc-table">
- <thead>
- <tr>
- <th onClick={() => toggleSort('pid')} className={sortBy === 'pid' ? 'active' : ''}>
- PID {sortBy === 'pid' && (sortDir === 'asc' ? '↑' : '↓')}
- </th>
- <th onClick={() => toggleSort('name')} className={sortBy === 'name' ? 'active' : ''}>
- Process {sortBy === 'name' && (sortDir === 'asc' ? '↑' : '↓')}
- </th>
- <th onClick={() => toggleSort('user')} className={sortBy === 'user' ? 'active' : ''}>
- User {sortBy === 'user' && (sortDir === 'asc' ? '↑' : '↓')}
- </th>
- <th onClick={() => toggleSort('cpu')} className={sortBy === 'cpu' ? 'active' : ''}>
- CPU {sortBy === 'cpu' && (sortDir === 'asc' ? '↑' : '↓')}
- </th>
- <th onClick={() => toggleSort('memory')} className={sortBy === 'memory' ? 'active' : ''}>
- Memory {sortBy === 'memory' && (sortDir === 'asc' ? '↑' : '↓')}
- </th>
- <th>Status</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- {filtered.map(p => {
- const cpu = Math.min(Number(p.cpu_percent) || 0, 100);
- const mem = Math.min(Number(p.memory_percent) || 0, 100);
- const isSelected = selectedProcess?.pid === p.pid;
- return (
- <tr
- key={p.pid}
- className={isSelected ? 'selected' : ''}
- onClick={() => setSelectedProcess(p)}
- >
- <td className="mono">{p.pid}</td>
- <td>
- <div className="proc-name-cell">
- <span className="proc-name">{p.name}</span>
- {p.command && (
- <span className="proc-cmd" title={p.command}>{p.command}</span>
- )}
- </div>
- </td>
- <td>
- <span className="proc-user-tag">
- <span className="proc-user-dot" style={{ background: hashColor(p.user) }} />
- {p.user}
- </span>
- </td>
- <td>
- <div className="proc-bar-cell">
- <span className="proc-bar-value">{cpu.toFixed(1)}%</span>
- <div className="proc-bar"><div className="proc-bar-fill cpu" style={{ width: `${cpu}%` }} /></div>
- </div>
- </td>
- <td>
- <div className="proc-bar-cell">
- <span className="proc-bar-value">{formatMemory(p.memory_info?.rss)}</span>
- <div className="proc-bar"><div className="proc-bar-fill mem" style={{ width: `${mem}%` }} /></div>
- </div>
- </td>
- <td>
- <Pill kind={processStatusKind(p.status)}>{p.status}</Pill>
- </td>
- <td className="proc-actions" onClick={(e) => e.stopPropagation()}>
- <button type="button" className="lv-icon-btn" onClick={() => handleKillProcess(p.pid)} title="Kill (SIGTERM)">
- <X size={13} />
- </button>
- <button type="button" className="lv-icon-btn danger" onClick={() => handleKillProcess(p.pid, true)} title="Force kill (SIGKILL)">
- <AlertTriangle size={13} />
- </button>
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
- </div>
+ </>
)}
- </div>
- </div>
+ />
+ )}
{/* The shared DS drawer, not a hand-rolled slide-over: focus trap,
escape-to-close and the same chrome as every other drawer. */}
@@ -1132,7 +972,7 @@ const ProcessesTab = () => {
open={!!selectedProcess}
onOpenChange={(open) => { if (!open) setSelectedProcess(null); }}
title={selectedProcess?.name || ''}
- subtitle={selectedProcess ? `PID ${selectedProcess.pid} · ${selectedProcess.user}` : ''}
+ subtitle={selectedProcess ? `PID ${selectedProcess.pid} · ${procUser(selectedProcess)}` : ''}
icon={<Activity size={18} />}
width={520}
flush
@@ -1146,7 +986,7 @@ const ProcessesTab = () => {
</div>
<div className="meta-item">
<span className="meta-label">User</span>
- <span className="meta-value">{selectedProcess.user}</span>
+ <span className="meta-value">{procUser(selectedProcess)}</span>
</div>
<div className="meta-item">
<span className="meta-label">Status</span>
@@ -1196,158 +1036,12 @@ const ProcessesTab = () => {
);
};
-// Stable colour from a string — used to tag users by colour (categorical
-// tints aligned to the redesign palette).
-function hashColor(str) {
- if (!str) return '#646b7a';
- const palette = ['#6d7cff', '#3ddc97', '#f5b945', '#ec4899', '#14b8a6', '#b07bf5', '#49c7f0', '#fb7185'];
- let h = 0;
- for (let i = 0; i < str.length; i++) h = (h * 31 + str.charCodeAt(i)) | 0;
- return palette[Math.abs(h) % palette.length];
-}
-
-// Map a service status kind onto a ds Pill tone.
-const SVC_PILL_KIND = { running: 'green', failed: 'red', stopped: 'gray', other: 'amber' };
-
+// Services renders the SAME converged systemd table Server Detail does — the
+// only thing this tab adds is the choice of which host answers, and that choice
+// is what the component's `serverId` already meant. Remounting on it keeps one
+// host's unit list, search and view state from bleeding into the other's.
const ServicesTab = () => {
- const toast = useToast();
- const { confirm } = useConfirm();
-
const [target, setTarget] = useState({ kind: 'local' });
- const isRemote = target.kind === 'agent';
-
- const [services, setServices] = useState([]);
- const [loading, setLoading] = useState(true);
- const [actionLoading, setActionLoading] = useState(null);
- const [statusFilter, setStatusFilter] = useState('all');
- const [searchTerm, setSearchTerm] = useState('');
- const [selectedService, setSelectedService] = useState(null);
- const [serviceLogs, setServiceLogs] = useState('');
- const [logsLoading, setLogsLoading] = useState(false);
- const [logSearch, setLogSearch] = useState('');
- const [appliedLogSearch, setAppliedLogSearch] = useState('');
- const [logLineCount, setLogLineCount] = useState(200);
- const [logShowLineNumbers, setLogShowLineNumbers] = useState(true);
- const [logWrap, setLogWrap] = useState(true);
- const [logAutoRefresh, setLogAutoRefresh] = useState(false);
- const logContentRef = useRef(null);
- const logIntervalRef = useRef(null);
-
- useEffect(() => {
- loadServices();
- }, [target.kind, target.server_id]); // eslint-disable-line
-
- useEffect(() => {
- if (logAutoRefresh && selectedService) {
- logIntervalRef.current = setInterval(() => loadServiceLogs(selectedService, false), 3000);
- }
- return () => { if (logIntervalRef.current) clearInterval(logIntervalRef.current); };
- }, [logAutoRefresh, selectedService, logLineCount, appliedLogSearch]); // eslint-disable-line
-
- async function loadServices() {
- if (isRemote) {
- setServices([]);
- setLoading(false);
- return;
- }
- setLoading(true);
- try {
- const data = await api.getServicesStatus();
- setServices(data.services || []);
- } catch (err) {
- toast.error(`Failed: ${err.message}`);
- } finally {
- setLoading(false);
- }
- }
-
- async function handleAction(serviceName, action) {
- const isDestructive = action === 'stop' || action === 'restart';
- if (isDestructive) {
- const ok = await confirm({
- title: action === 'stop' ? 'Stop service' : 'Restart service',
- message: `${action === 'stop' ? 'Stop' : 'Restart'} ${serviceName}?`,
- variant: 'warning',
- confirmText: action === 'stop' ? 'Stop' : 'Restart',
- });
- if (!ok) return;
- }
- setActionLoading(`${serviceName}-${action}`);
- try {
- await api.controlService(serviceName, action);
- toast.success(`${serviceName} ${action}ed`);
- await loadServices();
- } catch (err) {
- toast.error(`Failed to ${action} ${serviceName}: ${err.message}`);
- } finally {
- setActionLoading(null);
- }
- }
-
- async function loadServiceLogs(serviceName, showSpinner = true) {
- if (showSpinner) setLogsLoading(true);
- try {
- const data = await api.getJournalLogs(serviceName, logLineCount);
- setServiceLogs(data.lines?.join('\n') || '');
- if (logAutoRefresh && logContentRef.current) {
- logContentRef.current.scrollTop = logContentRef.current.scrollHeight;
- }
- } catch (err) {
- setServiceLogs(`Error: ${err.message}`);
- } finally {
- setLogsLoading(false);
- }
- }
-
- function openServiceDrawer(service) {
- setSelectedService(service);
- setLogSearch('');
- setAppliedLogSearch('');
- loadServiceLogs(service.name);
- }
-
- function closeServiceDrawer() {
- setSelectedService(null);
- setLogAutoRefresh(false);
- setServiceLogs('');
- }
-
- function statusKind(status) {
- const s = (status || '').toLowerCase();
- if (s === 'running' || s === 'active') return 'running';
- if (s === 'failed') return 'failed';
- if (s === 'stopped' || s === 'inactive' || s === 'dead') return 'stopped';
- return 'other';
- }
-
- const counts = useMemo(() => {
- const c = { all: services.length, running: 0, stopped: 0, failed: 0 };
- for (const s of services) {
- const k = statusKind(s.status);
- if (k === 'running') c.running++;
- else if (k === 'stopped') c.stopped++;
- else if (k === 'failed') c.failed++;
- }
- return c;
- }, [services]);
-
- const filtered = useMemo(() => {
- let list = services;
- if (statusFilter !== 'all') list = list.filter(s => statusKind(s.status) === statusFilter);
- const q = searchTerm.toLowerCase();
- if (q) {
- list = list.filter(s =>
- s.name?.toLowerCase().includes(q) ||
- s.description?.toLowerCase().includes(q)
- );
- }
- return list.slice().sort((a, b) => {
- const ak = statusKind(a.status), bk = statusKind(b.status);
- const order = { failed: 0, running: 1, other: 2, stopped: 3 };
- if (ak !== bk) return (order[ak] ?? 4) - (order[bk] ?? 4);
- return (a.name || '').localeCompare(b.name || '');
- });
- }, [services, statusFilter, searchTerm]);
return (
<div className="svc-page">
@@ -1355,275 +1049,14 @@ const ServicesTab = () => {
<div className="lv-header-target">
<span className="lv-header-label">Source</span>
<TargetPicker feature="services" value={target} onChange={setTarget} />
- {isRemote && (
- <span className="lv-header-hint">
- <AlertCircle size={12} />
- Remote service control isn&apos;t available yet for {target.name}.
- </span>
- )}
- </div>
- <div className="lv-header-stats">
- <span className="lv-stat">
- <span className="lv-stat-label">Total</span>
- <span className="lv-stat-value">{services.length}</span>
- </span>
- <button type="button"
- className="lv-icon-btn"
- onClick={loadServices}
- title="Refresh"
- >
- <RefreshCw size={13} className={loading ? 'spinning' : ''} />
- </button>
- </div>
- </div>
-
- <div className="svc-toolbar">
- <div className="proc-filter-chips">
- {[
- { id: 'all', label: 'All', count: counts.all },
- { id: 'running', label: 'Running', count: counts.running },
- { id: 'failed', label: 'Failed', count: counts.failed },
- { id: 'stopped', label: 'Stopped', count: counts.stopped },
- ].map(c => (
- <button type="button"
- key={c.id}
- className={`proc-chip ${statusFilter === c.id ? 'active' : ''}`}
- onClick={() => setStatusFilter(c.id)}
- disabled={c.id !== 'all' && c.count === 0}
- >
- <span>{c.label}</span>
- <span className="proc-chip-count">{c.count}</span>
- </button>
- ))}
- </div>
- <div className="lv-search-field is-wide">
- <Search size={13} className="lv-search-field-icon" />
- <input
- type="text"
- value={searchTerm}
- onChange={(e) => setSearchTerm(e.target.value)}
- placeholder="Filter services…"
- />
- {searchTerm && (
- <button type="button" className="lv-search-field-clear" onClick={() => setSearchTerm('')}>
- <X size={11} />
- </button>
- )}
</div>
</div>
-
- {loading ? (
- <div className="lv-content-loading is-medium">Loading services…</div>
- ) : filtered.length === 0 ? (
- <div className="lv-empty-hint is-medium">
- <p>{services.length === 0 ? 'No services found.' : 'No services match the current filters.'}</p>
- </div>
- ) : (
- <div className="svc-grid">
- {filtered.map(service => {
- const kind = statusKind(service.status);
- const isRunning = kind === 'running';
- const isFailed = kind === 'failed';
- return (
- <div
- key={service.name}
- className={`svc-card status-${kind}`}
- onClick={() => openServiceDrawer(service)}
- >
- <div className="svc-card-head">
- <div className="svc-card-title">
- <span className={`svc-status-dot status-${kind}`} />
- <h4>{service.name}</h4>
- </div>
- <Pill kind={SVC_PILL_KIND[kind] || 'gray'}>
- {service.status || 'unknown'}
- </Pill>
- </div>
- {service.description && (
- <p className="svc-card-desc" title={service.description}>
- {service.description}
- </p>
- )}
- <div className="svc-card-meta">
- {service.pid && (
- <span><span className="svc-meta-label">PID</span> {service.pid}</span>
- )}
- {service.memory && (
- <span><span className="svc-meta-label">Mem</span> {service.memory}</span>
- )}
- </div>
- <div className="svc-card-actions" onClick={(e) => e.stopPropagation()}>
- {isRunning ? (
- <>
- <button type="button"
- className="svc-action-btn"
- onClick={() => handleAction(service.name, 'restart')}
- disabled={actionLoading === `${service.name}-restart`}
- >
- <RotateCw size={12} /> Restart
- </button>
- <button type="button"
- className="svc-action-btn"
- onClick={() => handleAction(service.name, 'stop')}
- disabled={actionLoading === `${service.name}-stop`}
- >
- <Square size={12} /> Stop
- </button>
- </>
- ) : (
- <button type="button"
- className={`svc-action-btn primary ${isFailed ? 'danger' : ''}`}
- onClick={() => handleAction(service.name, 'start')}
- disabled={actionLoading === `${service.name}-start`}
- >
- <Play size={12} /> Start
- </button>
- )}
- <button type="button"
- className="svc-action-btn ghost"
- onClick={() => openServiceDrawer(service)}
- >
- <FileText size={12} /> Logs
- </button>
- </div>
- </div>
- );
- })}
- </div>
- )}
-
- <Drawer
- open={!!selectedService}
- onOpenChange={(open) => { if (!open) closeServiceDrawer(); }}
- title={selectedService?.name || ''}
- subtitle={selectedService
- ? (selectedService.description || `journalctl -u ${selectedService.name}`)
- : ''}
- icon={selectedService
- ? <span className={`svc-status-dot status-${statusKind(selectedService.status)} is-large`} />
- : null}
- width={520}
- flush
- >
- {selectedService && (
- <>
- <div className="preview-drawer-meta">
- <div className="meta-item">
- <span className="meta-label">Status</span>
- <span className="meta-value">{selectedService.status || 'unknown'}</span>
- </div>
- {selectedService.pid && (
- <div className="meta-item">
- <span className="meta-label">PID</span>
- <span className="meta-value mono">{selectedService.pid}</span>
- </div>
- )}
- {selectedService.memory && (
- <div className="meta-item">
- <span className="meta-label">Memory</span>
- <span className="meta-value">{selectedService.memory}</span>
- </div>
- )}
- </div>
-
- <div className="preview-drawer-actions">
- {statusKind(selectedService.status) === 'running' ? (
- <>
- <button type="button"
- className="drawer-action-btn"
- onClick={() => handleAction(selectedService.name, 'restart')}
- disabled={actionLoading === `${selectedService.name}-restart`}
- >
- <RotateCw size={14} /> Restart
- </button>
- <button type="button"
- className="drawer-action-btn"
- onClick={() => handleAction(selectedService.name, 'stop')}
- disabled={actionLoading === `${selectedService.name}-stop`}
- >
- <Square size={14} /> Stop
- </button>
- </>
- ) : (
- <button type="button"
- className="drawer-action-btn"
- onClick={() => handleAction(selectedService.name, 'start')}
- disabled={actionLoading === `${selectedService.name}-start`}
- >
- <Play size={14} /> Start
- </button>
- )}
- </div>
-
- <LogToolbar
- searchPattern={logSearch}
- onSearchChange={setLogSearch}
- onSearchSubmit={() => setAppliedLogSearch(logSearch)}
- onSearchClear={() => { setLogSearch(''); setAppliedLogSearch(''); }}
- lineCount={logLineCount}
- onLineCountChange={(n) => { setLogLineCount(n); setTimeout(() => loadServiceLogs(selectedService.name), 0); }}
- autoRefresh={logAutoRefresh}
- onAutoRefreshToggle={() => setLogAutoRefresh(!logAutoRefresh)}
- showLineNumbers={logShowLineNumbers}
- onToggleLineNumbers={() => setLogShowLineNumbers(!logShowLineNumbers)}
- wrapLines={logWrap}
- onToggleWrap={() => setLogWrap(!logWrap)}
- isFullscreen={false}
- onToggleFullscreen={() => {}}
- onRefresh={() => loadServiceLogs(selectedService.name)}
- onDownload={() => {
- if (!serviceLogs) return;
- const blob = new Blob([serviceLogs], { type: 'text/plain' });
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.href = url;
- a.download = `${selectedService.name}-${Date.now()}.log`;
- a.click();
- URL.revokeObjectURL(url);
- }}
- onClear={() => toast.error('Journal logs cannot be truncated.')}
- onScrollToBottom={() => {
- if (logContentRef.current) logContentRef.current.scrollTop = logContentRef.current.scrollHeight;
- }}
- canAct={true}
- />
-
- <div className="preview-drawer-body">
- <LogContent
- ref={logContentRef}
- live={logAutoRefresh}
- scrollKey={selectedService?.name}
- content={serviceLogs}
- loading={logsLoading}
- emptyMessage="No log output."
- showLineNumbers={logShowLineNumbers}
- wrapLines={logWrap}
- searchPattern={appliedLogSearch}
- />
- </div>
- </>
- )}
- </Drawer>
+ <SystemdServicesTab
+ key={target.server_id || 'local'}
+ serverId={target.kind === 'agent' ? target.server_id : null}
+ />
</div>
);
};
-// Map a process status onto a ds Pill tone.
-function processStatusKind(status) {
- switch (status?.toLowerCase()) {
- case 'running':
- return 'green';
- case 'sleeping':
- return 'cyan';
- case 'stopped':
- case 'zombie':
- return 'red';
- case 'idle':
- case 'disk-sleep':
- return 'amber';
- default:
- return 'gray';
- }
-}
-
export default Terminal;
diff --git a/frontend/src/styles/components/_design-system.scss b/frontend/src/styles/components/_design-system.scss
index dd224299..5ba8f4f8 100644
--- a/frontend/src/styles/components/_design-system.scss
+++ b/frontend/src/styles/components/_design-system.scss
@@ -1520,48 +1520,6 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
&__message { font-size: 13px; color: var(--text-dim); max-width: 420px; margin: 0 0 16px; }
}
-// ------------------------------------------------------------
-// SearchFilterBar — reusable search + filter + sort bar.
-// ------------------------------------------------------------
-.sk-search-filter-bar {
- display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
-
- &__search { position: relative; flex: 1 1 220px; min-width: 180px; }
- &__search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
- &__input { padding-left: 32px; }
- &__clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
-
- &__filters { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
- &__chip {
- display: inline-flex; align-items: center; gap: 5px;
- padding: 5px 11px; border-radius: 7px;
- font-size: 12.5px; font-weight: 450;
- color: var(--text-dim); background: var(--surface-2);
- border: 1px solid var(--border-soft);
- cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
-
- &:hover { background: var(--surface-3); }
- &.is-active { color: var(--accent-bright); background: var(--accent-bg-soft); border-color: var(--accent-dim); }
- }
- &__count {
- font-family: var(--mono); font-size: 10.5px; color: var(--text-faint);
- .is-active & { color: var(--accent-bright); }
- }
-
- &__sort {
- select {
- appearance: none;
- padding: 6px 24px 6px 10px;
- border-radius: 7px;
- border: 1px solid var(--border-soft);
- background: var(--surface-2);
- color: var(--text-dim);
- font-size: 12.5px;
- cursor: pointer;
- }
- }
-}
-
// ------------------------------------------------------------
// CopyButton — copy-to-clipboard with feedback.
// ------------------------------------------------------------
diff --git a/frontend/src/styles/pages/_databases.scss b/frontend/src/styles/pages/_databases.scss
index a9eeaa32..cbc4041a 100644
--- a/frontend/src/styles/pages/_databases.scss
+++ b/frontend/src/styles/pages/_databases.scss
@@ -200,36 +200,17 @@ $dbx-sqlite: #3d8fd1;
}
}
+ // Holds a <SearchField>, which brings its own icon/input styling — this is
+ // only the strip it sits in.
.dbx-tree-search {
display: flex;
align-items: center;
- gap: $space-2;
padding: $space-2 $space-3;
border-bottom: 1px solid $border-default;
background: $bg-elevated;
flex-shrink: 0;
- > svg { color: $text-tertiary; flex-shrink: 0; }
- input {
- flex: 1;
- min-width: 0;
- background: transparent;
- border: none;
- color: $text-primary;
- font-size: $font-size-sm;
- outline: none;
- &::placeholder { color: $text-tertiary; }
- }
- button {
- display: flex;
- background: transparent;
- border: none;
- color: $text-tertiary;
- cursor: pointer;
- padding: 2px;
- border-radius: $radius-sm;
- &:hover { background: $bg-hover; color: $text-primary; }
- }
+ .sk-searchfield { flex: 1; min-width: 0; }
}
.dbx-tree-scroll {
@@ -543,8 +524,7 @@ $dbx-sqlite: #3d8fd1;
.dbx-console { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dbx-console-toolbar,
- .dbx-table-toolbar,
- .dbx-backups-toolbar {
+ .dbx-table-toolbar {
display: flex;
align-items: center;
gap: $space-2;
@@ -747,18 +727,6 @@ $dbx-sqlite: #3d8fd1;
.dbx-results { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
- .dbx-results-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: $space-1 $space-3;
- background: $bg-elevated;
- border-bottom: 1px solid $border-subtle;
- flex-shrink: 0;
- .dbx-results-count { font-size: $font-size-xs; color: $success; font-weight: $font-weight-medium; }
- .dbx-results-time { font-family: $font-mono; font-size: $font-size-xs; color: $text-tertiary; }
- }
-
.dbx-console-hint {
flex: 1;
display: flex;
@@ -782,6 +750,18 @@ $dbx-sqlite: #3d8fd1;
.dbx-table-tab { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dbx-table-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
+ // The Structure view is a real list surface (chrome, then rows); the Data
+ // view next to it is a raw result set and keeps the bare grid.
+ .dbx-structure-pane {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ padding: $space-3;
+ }
+
.dbx-segmented {
display: inline-flex;
gap: 2px;
@@ -905,21 +885,24 @@ $dbx-sqlite: #3d8fd1;
tbody tr:hover .dbx-grid-rownum { background: $bg-tertiary; }
}
- // structure + backups tables read as normal text, not data dumps
- .dbx-structure tbody td,
- .dbx-backups-table tbody td { font-family: $font-main; font-size: $font-size-sm; }
- .dbx-structure .dbx-mono,
- .dbx-backups-table .dbx-mono { font-family: $font-mono; font-size: $font-size-xs; color: $text-secondary; }
+ // A converted table inside the workspace: the chrome above it stays put and
+ // the rows scroll under a pinned header, which is what the hand-rolled
+ // tables did with their own sticky <thead>.
+ .dbx-pane-scroll {
+ flex: 1;
+ min-height: 0;
+ overflow: auto;
- .dbx-col-name {
- display: flex;
- align-items: center;
- gap: 6px;
- color: $text-primary !important;
- font-weight: $font-weight-medium;
- .dbx-pk { color: $color-star; flex-shrink: 0; }
+ .sk-dtable thead th {
+ position: sticky;
+ top: 0;
+ z-index: 2;
+ background: $bg-elevated;
+ }
}
+ .dbx-pk { color: $color-star; flex-shrink: 0; }
+
.dbx-engine-tag {
display: inline-block;
padding: 1px 8px;
@@ -956,9 +939,13 @@ $dbx-sqlite: #3d8fd1;
.dbx-structure-fallback { padding: $space-6; color: $text-secondary; font-size: $font-size-sm; }
// ─── Backups tab ──────────────────────────────────────
- .dbx-backups { display: flex; flex-direction: column; height: 100%; min-height: 0; }
- .dbx-backups-body { flex: 1; min-height: 0; overflow: auto; }
- .dbx-backups-table { width: 100%; }
+ .dbx-backups {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ min-height: 0;
+ padding: $space-3;
+ }
// ─── Status bar ───────────────────────────────────────
.dbx-statusbar {
diff --git a/frontend/src/styles/pages/_db-processes.scss b/frontend/src/styles/pages/_db-processes.scss
index 68c708b2..9f5acdd0 100644
--- a/frontend/src/styles/pages/_db-processes.scss
+++ b/frontend/src/styles/pages/_db-processes.scss
@@ -9,36 +9,17 @@
height: 100%;
min-height: 0;
overflow: hidden;
+ padding: $space-3;
- .dbp-toolbar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: $space-3;
- padding: $space-2 $space-3;
- border-bottom: 1px solid $border-color;
- flex-shrink: 0;
- }
-
- .dbp-count {
- display: inline-flex;
- align-items: center;
- gap: $space-2;
- color: $text-secondary;
- font-size: $font-size-sm;
- font-weight: $font-weight-medium;
- }
-
- .dbp-toolbar-right {
- display: inline-flex;
- align-items: center;
- gap: $space-3;
- }
-
+ // Rides the view-picker line next to the search box, so it must not wrap:
+ // on a narrow workspace the label broke across two lines and dragged the
+ // whole chrome row taller than the icons beside it.
.dbp-auto {
display: inline-flex;
align-items: center;
gap: $space-2;
+ flex-shrink: 0;
+ white-space: nowrap;
color: $text-secondary;
font-size: $font-size-sm;
cursor: pointer;
@@ -48,7 +29,7 @@
}
.dbp-error {
- margin: $space-3;
+ margin: 0 0 $space-3;
padding: $space-2 $space-3;
background: $danger-bg;
border: 1px solid $danger-border;
@@ -64,47 +45,6 @@
justify-content: center;
}
- .dbp-scroll {
- flex: 1;
- min-height: 0;
- overflow: auto;
- }
-
- .dbp-table {
- width: 100%;
- border-collapse: collapse;
- font-size: $font-size-sm;
-
- th {
- position: sticky;
- top: 0;
- z-index: 1;
- background: $bg-tertiary;
- color: $text-secondary;
- font-weight: $font-weight-medium;
- text-align: left;
- padding: $space-2 $space-3;
- border-bottom: 1px solid $border-color;
- white-space: nowrap;
- }
-
- td {
- padding: $space-2 $space-3;
- border-bottom: 1px solid $border-color;
- color: $text-primary;
- vertical-align: top;
- white-space: nowrap;
- }
-
- tbody tr:hover td { background: $bg-hover; }
- }
-
- .dbp-mono {
- font-family: $font-family-mono;
- font-size: $font-size-xs;
- color: $text-secondary;
- }
-
.dbp-state {
display: inline-block;
padding: 1px $space-2;
@@ -114,10 +54,14 @@
font-size: $font-size-xs;
}
+ // The cell used to inherit `white-space: nowrap` from the hand-rolled
+ // table; the shared table does not set it, and without it a long statement
+ // wraps to six lines instead of truncating.
.dbp-query {
max-width: 480px;
overflow: hidden;
text-overflow: ellipsis;
+ white-space: nowrap;
font-family: $font-family-mono;
font-size: $font-size-xs;
}
diff --git a/frontend/src/styles/pages/_deployments.scss b/frontend/src/styles/pages/_deployments.scss
index 5cb6705a..355ab6f7 100644
--- a/frontend/src/styles/pages/_deployments.scss
+++ b/frontend/src/styles/pages/_deployments.scss
@@ -1,117 +1,24 @@
// ============================================
// DEPLOYMENTS PAGE (/deployments)
-// Deploy Activity — a chronological feed of runs grouped into Queued / Today /
-// Earlier. Each row deep-links to the Deploy Console (/deployments/:jobId,
-// _deploy-console.scss). Replaced the plain jobs table in the plan 51.5 UI pass.
+// Deploy Activity — the runs table. Each row deep-links to the Deploy Console
+// (/deployments/:jobId, _deploy-console.scss). The table, its chrome and its
+// footer are the shared ds/DataTable + ds/grid components, so only the two cells
+// with a shape of their own live here: the type chip and the pipeline ticks.
// ============================================
-// Column track shared by the feed header and its rows so the two stay locked
-// together; `minmax(0, 1fr)` lets the long ref/error subline ellipsize instead
-// of stretching the grid.
-$deploy-feed-cols: 20px minmax(0, 1fr) 132px 116px 56px 76px 14px;
-
.deployments-page {
- // A fixed reading column rather than full bleed: the feed's rightmost
- // columns (took / started) are narrow and fixed, so on a wide monitor a
- // full-bleed row strands the name miles from its own timing.
+ // A fixed reading column rather than full bleed: the rightmost columns
+ // (took / started) are narrow and fixed, so on a wide monitor a full-bleed
+ // row strands the name miles from its own timing.
max-width: 1180px;
margin: 0 auto;
- // The toolbar row is the shared ListToolbar (.sk-listhead); the empty
- // state is the shared EmptyState component.
-
- &__loading {
- display: grid;
- gap: $space-4;
- padding: $space-4;
- }
-
- &__loading-row {
- display: grid;
- grid-template-columns: 110px 1fr 1fr 1fr;
- gap: $space-4;
- align-items: center;
- }
-
- // ---- feed ----
- &__feed-head {
- display: grid;
- grid-template-columns: $deploy-feed-cols;
- align-items: center;
- gap: 18px;
- padding: 0 16px 8px;
- color: var(--text-ghost);
- font-family: var(--mono);
- font-size: 10px;
- letter-spacing: 0.13em;
- text-transform: uppercase;
-
- .is-right { text-align: right; }
- }
-
- &__group + &__group { margin-top: 22px; }
-
- &__group-head {
- display: flex;
- align-items: center;
- gap: 12px;
- padding: 0 16px 7px;
- color: $text-tertiary;
- font-family: var(--mono);
- font-size: 10.5px;
- letter-spacing: 0.13em;
- text-transform: uppercase;
-
- i { flex: 1; height: 1px; background: $border-subtle; }
- }
-
- &__row {
- display: grid;
- grid-template-columns: $deploy-feed-cols;
- align-items: center;
- gap: 18px;
- width: 100%;
- padding: 12px 16px;
- background: $bg-card;
- border: 1px solid $border-subtle;
- border-radius: $radius-lg;
- text-align: left;
- cursor: pointer;
- transition: background $transition-fast, border-color $transition-fast;
-
- + .deployments-page__row { margin-top: 5px; }
-
- &:hover {
- background: $bg-hover;
- border-color: var(--border);
- }
+ // Target / Took / Started are short and fixed, but they sit beside a Deploy
+ // cell that takes every spare pixel — left to wrap, "Local server" alone
+ // doubles the height of every row.
+ .sk-cell-mono { white-space: nowrap; }
- &--pending .deployments-page__row-name { color: $text-secondary; }
- }
-
- &__row-ico {
- display: flex;
- justify-content: center;
-
- &.is-succeeded { color: var(--green); }
- &.is-failed { color: var(--red); }
- &.is-running { color: var(--amber); }
- &.is-pending { color: var(--text-ghost); }
- }
-
- &__row-main { min-width: 0; }
-
- &__row-name {
- display: flex;
- align-items: center;
- gap: 9px;
- color: $text-primary;
- font-size: 13.5px;
- font-weight: 550;
- letter-spacing: -0.01em;
- }
-
- &__row-kind {
+ &__kind {
padding: 1px 5px;
border: 1px solid var(--border);
border-radius: 4px;
@@ -122,30 +29,7 @@ $deploy-feed-cols: 20px minmax(0, 1fr) 132px 116px 56px 76px 14px;
text-transform: uppercase;
}
- &__row-sub {
- display: flex;
- align-items: center;
- gap: 8px;
- min-width: 0;
- margin-top: 4px;
- color: $text-tertiary;
- font-size: 11.5px;
- white-space: nowrap;
- }
-
- &__row-ref {
- flex-shrink: 0;
- color: $text-secondary;
- font-family: var(--mono);
- }
-
- &__row-sep { color: var(--text-ghost); }
-
- &__row-error {
- overflow: hidden;
- color: var(--red);
- text-overflow: ellipsis;
- }
+ &__error { color: var(--red); }
&__pipe {
display: flex;
@@ -179,36 +63,6 @@ $deploy-feed-cols: 20px minmax(0, 1fr) 132px 116px 56px 76px 14px;
font-size: 10.5px;
}
- &__row-target {
- min-width: 0;
- overflow: hidden;
- color: $text-secondary;
- font-family: var(--mono);
- font-size: 12px;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- &__row-took,
- &__row-when {
- font-family: var(--mono);
- font-size: 11.5px;
- text-align: right;
- }
-
- &__row-took { color: $text-secondary; }
- &__row-when { color: $text-tertiary; }
-
- &__row-chev {
- color: var(--text-ghost);
- transition: transform $transition-fast, color $transition-fast;
- }
-
- &__row:hover &__row-chev {
- color: var(--accent-bright);
- transform: translateX(2px);
- }
-
// ---- test-deployment (simulated) scenario picker ----
&__sim-intro {
margin: 0 0 $space-3;
@@ -281,15 +135,3 @@ $deploy-feed-cols: 20px minmax(0, 1fr) 132px 116px 56px 76px 14px;
0%, 100% { opacity: 1; }
50% { opacity: 0.35; }
}
-
-@media (max-width: $breakpoint-md) {
- .deployments-page {
- .sk-seg { overflow-x: auto; }
-
- // Below the grid's natural width the feed scrolls sideways rather than
- // collapsing the pipeline/target columns into unreadable slivers.
- &__feed { overflow-x: auto; }
- &__feed-head,
- &__row { min-width: 720px; }
- }
-}
diff --git a/frontend/src/styles/pages/_docker.scss b/frontend/src/styles/pages/_docker.scss
index 3a7347d0..672b2038 100644
--- a/frontend/src/styles/pages/_docker.scss
+++ b/frontend/src/styles/pages/_docker.scss
@@ -159,154 +159,9 @@
// Content area - no padding needed, tabs handle their own
}
-// Table Header (filter + search)
-.docker-table-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: $space-3 $space-5;
- border-bottom: 1px solid $border-subtle;
- background: $bg-hover;
-}
-
-.docker-filter-toggle {
- display: flex;
- align-items: center;
- gap: $space-2;
- font-size: $font-size-sm;
- color: $text-secondary;
- cursor: pointer;
-
- input[type="checkbox"] {
- width: 14px;
- height: 14px;
- accent-color: $accent-primary;
- }
-}
-
-.docker-search {
- background: $bg-card;
- border: 1px solid $border-subtle;
- padding: $space-2 $space-3;
- border-radius: $radius-sm;
- color: $text-primary;
- font-size: $font-size-xs;
- width: 200px;
-
- &::placeholder {
- color: $text-tertiary;
- }
-
- &:focus {
- outline: none;
- border-color: $accent-primary;
- }
-}
-
-// Docker Table
-.docker-table {
- width: 100%;
- border-collapse: collapse;
- font-size: $font-size-sm;
-
- th {
- text-align: left;
- padding: $space-3 $space-5;
- background: $bg-hover;
- color: $text-tertiary;
- font-size: $font-size-xs;
- text-transform: uppercase;
- letter-spacing: 0.05em;
- font-weight: $font-weight-semibold;
- }
-
- td {
- padding: $space-4 $space-5;
- border-bottom: 1px solid $border-subtle;
- vertical-align: middle;
- }
-
- tr:hover {
- background: $bg-hover;
- }
-
- tr:last-child td {
- border-bottom: none;
- }
-}
-
-// Container Name & ID
-.docker-container-name {
- font-weight: $font-weight-semibold;
- color: $text-primary;
- font-size: $font-size-sm;
- display: block;
- margin-bottom: $space-1;
-}
-
-.docker-container-id {
- font-family: $font-mono;
- color: $accent-primary;
- font-size: $font-size-xs;
-}
-
-// Image Tag
-.docker-image-tag {
- font-family: $font-mono;
- color: $text-secondary;
- font-size: $font-size-xs;
- background: $bg-hover;
- padding: $space-1 $space-2;
- border-radius: $radius-sm;
-}
-
-// Status Pill
-.docker-status-pill {
- display: inline-flex;
- align-items: center;
- gap: $space-2;
- font-size: $font-size-xs;
- font-weight: $font-weight-semibold;
- padding: $space-1 $space-2;
- border-radius: $radius-full;
-
- &.running {
- background: fade($success-raw, 10%);
- color: $success;
- border: 1px solid fade($success-raw, 20%);
- }
-
- &.exited {
- background: fade($danger-raw, 10%);
- color: $danger;
- border: 1px solid fade($danger-raw, 20%);
- }
-}
-
-.docker-status-dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background: currentColor;
-}
-
-.docker-status-detail {
- font-size: $font-size-xs;
- color: $text-tertiary;
- margin-top: $space-1;
-}
-
-// Ports
-.docker-ports {
- font-family: $font-mono;
- color: $text-primary;
- font-size: $font-size-xs;
- line-height: 1.6;
-
- &.faded {
- opacity: 0.4;
- }
-}
+// The hand-rolled `.docker-table` markup and its cell/pill/toolbar styles are
+// gone: every Docker tab renders through <DataTable> under .dx-manager-table
+// now, and each one carries its own chrome row instead of a bespoke toolbar.
// Resource Bars
.docker-res-container {
@@ -351,43 +206,6 @@
opacity: 0.3;
}
-// Icon Actions
-.docker-actions-cell {
- text-align: right;
- white-space: nowrap;
-}
-
-.docker-icon-action {
- background: transparent;
- border: 1px solid transparent;
- color: $text-tertiary;
- width: 28px;
- height: 28px;
- border-radius: $radius-sm;
- cursor: pointer;
- transition: all 0.2s;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- padding: 0;
-
- &:hover:not(:disabled) {
- color: $text-primary;
- background: $bg-hover;
- border-color: $border-subtle;
- }
-
- &:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
-
- svg {
- width: 14px;
- height: 14px;
- }
-}
-
// Empty & Loading States
.docker-empty {
text-align: center;
@@ -1113,6 +931,21 @@
flex-direction: column;
}
+// Images · Volumes · Networks · Compose. Same shape as the containers pane,
+// minus the inspector column: the chrome row stays put and the table scrolls.
+.dx-list-pane {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+
+ .dx-resource-list {
+ flex: 1;
+ min-height: 0;
+ margin-top: $space-3;
+ }
+}
+
// Status filter rendered as a segmented control (redesign seg look).
.dx-filter-chips {
display: inline-flex;
@@ -1300,6 +1133,16 @@
th:nth-child(6) { width: 10%; }
th:nth-child(7) { width: 116px; }
+ // Those track widths are tuned for the Containers grid (checkbox + seven
+ // columns). The sibling resource tabs have four or five and no row click,
+ // so they drop the track list and let their own column descriptors decide.
+ // `table-layout: fixed` stays: without it a 64-character volume name or a
+ // long mountpoint widens the row and pushes the actions off the right edge.
+ &.dx-plain-table {
+ th:nth-child(n) { width: auto; }
+ tbody tr { cursor: default; }
+ }
+
tbody tr {
cursor: pointer;
@include transition(background);
diff --git a/frontend/src/styles/pages/_ftp-server.scss b/frontend/src/styles/pages/_ftp-server.scss
index d617f630..4040cbe9 100644
--- a/frontend/src/styles/pages/_ftp-server.scss
+++ b/frontend/src/styles/pages/_ftp-server.scss
@@ -1,7 +1,7 @@
// ============================================
// FTP SERVER PAGE (redesign — Files group, see docs/REDESIGN_MAP.md #7):
-// MetricCard KPI strip + mono-uppercase eyebrow section headers + dense
-// .sk-dtable user/connection tables on flat surface cards.
+// MetricCard KPI strip + dense .sk-dtable user/connection tables on flat
+// surface cards, each under the shared GridViewPicker chrome row.
// ============================================
.ftp-server {
@@ -11,32 +11,6 @@
// the rule got lost in a rebuild and left the tiles stacked full-width.
.sk-kpiband-wrap { margin-bottom: $space-5; }
- // ─── Mono eyebrow section headers (Users / Connections / Logs) ───
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: $space-3;
- margin-bottom: $space-3;
-
- h3 {
- margin: 0;
- font-family: var(--mono);
- font-size: 10.5px;
- font-weight: $font-weight-semibold;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- color: var(--text-faint);
- }
- }
-
- // Right-end cluster of a section header (sort/column menus + action button)
- .section-header__actions {
- display: flex;
- align-items: center;
- gap: $space-2;
- }
-
// ─── Overview: config + connection-info cards ───────
.overview-tab {
display: grid;
diff --git a/frontend/src/styles/pages/_server-services.scss b/frontend/src/styles/pages/_server-services.scss
index ba3df6a4..56144e73 100644
--- a/frontend/src/styles/pages/_server-services.scss
+++ b/frontend/src/styles/pages/_server-services.scss
@@ -10,11 +10,6 @@
// The toolbar row is the shared ListToolbar (.sk-listhead).
- &__search {
- flex: 1 1 280px;
- }
-
- &__filters,
&__actions {
display: flex;
gap: 0.4rem;
@@ -77,18 +72,4 @@
flex-wrap: wrap;
justify-content: flex-end;
}
-
- &__logs {
- max-height: 60vh;
- overflow: auto;
- padding: 0.75rem;
- border: 1px solid var(--border-soft);
- border-radius: var(--radius-sm);
- background: var(--bg-code);
- color: var(--text-code);
- font-family: var(--mono);
- font-size: 12px;
- white-space: pre-wrap;
- margin: 0;
- }
}
diff --git a/frontend/src/styles/pages/_templates.scss b/frontend/src/styles/pages/_templates.scss
index fc188fbc..a4c6de6e 100644
--- a/frontend/src/styles/pages/_templates.scss
+++ b/frontend/src/styles/pages/_templates.scss
@@ -179,166 +179,10 @@
}
}
-// Filters
-.templates-filters {
- display: flex;
- flex-direction: column;
- gap: $space-4;
- margin-bottom: $space-4;
-}
-
-// Scoped: Servers carries its own .search-box definition
-.templates-page .search-box {
- position: relative;
- max-width: 400px;
- width: min(400px, 42vw);
-
- .search-icon {
- position: absolute;
- left: $space-3;
- top: 50%;
- transform: translateY(-50%);
- color: $text-tertiary;
- pointer-events: none;
- }
-
- input {
- width: 100%;
- min-height: 36px;
- padding: $space-2 $space-4;
- padding-left: $space-10;
- padding-right: $space-10;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: $radius-lg;
- color: $text-primary;
- font-size: $font-size-sm + 1;
-
- &:focus {
- outline: none;
- border-color: var(--accent-primary);
- box-shadow: 0 0 0 3px var(--accent-bg-soft);
- }
-
- &::placeholder {
- color: var(--text-faint);
- }
- }
-
- .search-clear {
- position: absolute;
- right: $space-2;
- top: 50%;
- transform: translateY(-50%);
- padding: $space-1;
- background: transparent;
- border: none;
- color: $text-tertiary;
- cursor: pointer;
- border-radius: $radius-sm;
- display: flex;
- align-items: center;
- justify-content: center;
-
- &:hover {
- color: $text-primary;
- background: var(--surface-hover);
- }
- }
-}
-
-// Active filters — removable chips, inline in the results header.
-.active-filters {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: $space-2;
- min-width: 0;
-}
-
-// The whole chip is the remove control — clicking anywhere on it drops that
-// filter, so there is no small × to aim at.
-.filter-chip {
- display: inline-flex;
- align-items: center;
- gap: 5px;
- padding: 3px 8px;
- background: var(--accent-bg);
- border: 1px solid var(--accent-dim);
- border-radius: $radius-md;
- color: $text-secondary;
- font-size: $font-size-sm;
- text-transform: capitalize;
- cursor: pointer;
- transition: background $transition-fast, color $transition-fast;
-
- &:hover {
- background: var(--accent-bg-soft, var(--accent-bg));
- color: $text-primary;
- }
-
- svg {
- flex-shrink: 0;
- color: $text-tertiary;
- }
-
- &:hover svg { color: $text-primary; }
-}
-
-.clear-all-btn {
- padding: $space-1 $space-3;
- background: transparent;
- border: 1px solid var(--border);
- border-radius: $radius-full;
- font-size: $font-size-sm;
- color: $text-secondary;
- cursor: pointer;
- transition: all $transition-fast;
-
- &:hover {
- background: var(--surface-hover);
- border-color: var(--border-strong);
- color: $text-primary;
- }
-}
-
-// Quick-chips row + result count + sort. Full category list, kind, and the
-// remaining sort orders live in the shared FilterDrawer opened from the topbar.
-.templates-results-header {
- display: grid;
- grid-template-columns: auto minmax(0, 1fr) auto;
- align-items: center;
- gap: $space-3;
- margin-bottom: $space-4;
- padding-bottom: $space-3;
- border-bottom: 1px solid var(--border-soft);
-}
-
-// Two-way sort toggle beside the result count.
-.tpl-sort {
- display: flex;
- gap: 2px;
- padding: 3px;
- background: var(--surface-2);
- border: 1px solid var(--border);
- border-radius: $radius-lg;
-
- button {
- padding: 6px 12px;
- background: none;
- border: none;
- border-radius: $radius-md;
- color: $text-tertiary;
- font-size: $font-size-sm;
- font-weight: $font-weight-medium;
- white-space: nowrap;
- cursor: pointer;
- transition: background $transition-fast, color $transition-fast;
-
- &:hover { color: $text-primary; }
- &.is-active { background: var(--surface-3); color: $text-primary; }
- }
-}
+// The result count, the removable filter chips and the two-button sort toggle
+// that used to sit above the grid are gone: DataTableFooter counts under the
+// cards, the FilterDrawer's badge reports what is filtering, and the sort orders
+// are built-in saved views on the GridViewPicker row.
// ---- quick-start import banner -------------------------------------------
// Repo / archive imports sit above the catalog: they are the two ways in that
@@ -408,13 +252,6 @@
}
}
-.results-count {
- font-family: var(--mono);
- font-size: 11.5px;
- color: var(--text-faint);
- white-space: nowrap;
-}
-
// Kind badge on catalog cards ("Git repo" / "One-click").
.tpl-kind {
text-transform: none;
@@ -880,17 +717,6 @@
pointer-events: auto;
}
}
-
- .search-box {
- width: 100%;
- max-width: none;
- }
-
- .templates-results-header {
- grid-template-columns: 1fr;
- align-items: flex-start;
- gap: $space-3;
- }
}
diff --git a/frontend/src/styles/pages/_terminal.scss b/frontend/src/styles/pages/_terminal.scss
index ded0c414..bf45bef4 100644
--- a/frontend/src/styles/pages/_terminal.scss
+++ b/frontend/src/styles/pages/_terminal.scss
@@ -1,9 +1,9 @@
// ============================================
// TERMINAL & LOGS — flush "infra console" look (REDESIGN_MAP §4 #12).
-// Tab bodies: Log Files + System Journal (lv-*), Processes (proc-*),
-// Services (svc-*). The lv-* viewer classes are also rendered by
-// components/log-viewer/*, and .lv-icon-btn is reused by Docker.jsx —
-// keep their shapes stable.
+// Tab bodies: Log Files + System Journal (lv-*). Processes and Services keep
+// only a page wrapper here — both render converged tables that carry their own
+// chrome. The lv-* viewer classes are also rendered by components/log-viewer/*,
+// and .lv-icon-btn is reused by Docker.jsx — keep their shapes stable.
// ============================================
.terminal-page {
@@ -930,245 +930,24 @@ $lk-default: #646b7a;
}
// ============================================
-// PROCESSES TAB (proc-*) — flush console frame
+// PROCESSES + SERVICES TABS
// ============================================
-.proc-page {
+// Both are now a source-header strip stacked over a converged table
+// (components/ProcessTable.jsx, components/serverdetail/ServicesTab.jsx), which
+// brings its own frame — so the tab itself only has to stack and to give the
+// strip an outline it no longer inherits from a console shell.
+.proc-page,
+.svc-page {
display: flex;
flex-direction: column;
- height: calc(100vh - 220px);
- min-height: 540px;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius-lg);
- overflow: hidden;
-}
-
-.proc-toolbar {
- display: flex;
- justify-content: space-between;
- align-items: center;
gap: $space-3;
- padding: $space-2 $space-4;
- background: var(--surface);
- border-bottom: 1px solid var(--border-soft);
- flex-wrap: wrap;
- flex-shrink: 0;
-}
-
-.proc-filter-chips {
- display: flex;
- gap: 7px;
- flex-wrap: wrap;
-}
-
-// Page-owned status chips (demo cat-chip look). Terminal must not lean on
-// other pages' .filter-chip styles.
-.proc-chip {
- display: inline-flex;
- align-items: center;
- gap: 7px;
- padding: 5px 12px;
- background: var(--surface-2);
- border: 1px solid var(--border);
- border-radius: 8px;
- color: var(--text-faint);
- font-size: $font-size-sm + 0.5;
- font-weight: $font-weight-medium;
- cursor: pointer;
- @include transition(all);
-
- &:hover:not(:disabled) {
- color: $text-primary;
- border-color: var(--border-strong);
- }
- &:disabled { opacity: 0.45; cursor: not-allowed; }
-
- &.active {
- background: var(--accent-bg);
- border-color: var(--accent-dim);
- color: var(--accent-bright);
- }
-}
-
-.proc-chip-count {
- font-family: var(--mono);
- font-size: 10.5px;
- opacity: 0.75;
-}
-
-.proc-toolbar-right {
- display: flex;
- align-items: center;
- gap: $space-2;
- flex-wrap: wrap;
-}
-
-.proc-layout {
- display: grid;
- grid-template-columns: 220px 1fr;
- gap: 0;
- flex: 1;
- min-height: 0;
-
- @media (max-width: $breakpoint-lg) {
- grid-template-columns: 1fr;
- grid-template-rows: 200px 1fr;
-
- .proc-sidebar {
- border-right: none;
- border-bottom: 1px solid var(--border-soft);
- }
- }
-}
-
-.proc-sidebar {
- background: $bg-sidebar;
- border-right: 1px solid var(--border-soft);
- display: flex;
- flex-direction: column;
- overflow: hidden;
- min-height: 0;
-}
-
-.proc-main {
- background: var(--surface);
- overflow: hidden;
- display: flex;
- flex-direction: column;
- min-height: 0;
-}
-
-.proc-table-wrap {
- flex: 1;
- overflow: auto;
- scrollbar-width: thin;
-
- &::-webkit-scrollbar { width: 8px; height: 8px; }
- &::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: $radius-sm; }
-}
-
-// Dense table per the .sk-dtable spec (kept page-local for the sticky
-// sortable header + inline gauges).
-.proc-table {
- width: 100%;
- border-collapse: collapse;
- font-size: 13px;
-
- thead th {
- position: sticky;
- top: 0;
- background: var(--surface);
- text-align: left;
- padding: 10px $space-4;
- font-family: var(--mono);
- font-size: 10.5px;
- font-weight: $font-weight-semibold;
- text-transform: uppercase;
- letter-spacing: 0.06em;
- color: var(--text-faint);
- cursor: pointer;
- @include transition(color);
- z-index: 1;
- border-bottom: 1px solid var(--border);
- user-select: none;
-
- &:hover { color: var(--text-dim); }
- &.active { color: var(--accent-bright); }
- }
-
- tbody tr {
- border-bottom: 1px solid var(--border-soft);
- cursor: pointer;
- @include transition(background);
- &:hover { background: var(--surface-2); }
- &.selected {
- background: var(--accent-bg-soft);
- &:hover { background: var(--accent-bg); }
- }
- }
-
- td {
- padding: 9px $space-4;
- vertical-align: middle;
- }
-
- .mono {
- font-family: var(--mono);
- font-size: $font-size-sm;
- color: var(--text-dim);
+ > .lv-header {
+ border: 1px solid var(--border);
+ border-radius: var(--radius-lg);
}
}
-.proc-name-cell {
- display: flex;
- flex-direction: column;
- min-width: 0;
- max-width: 320px;
-}
-
-.proc-name {
- color: $text-primary;
- font-weight: $font-weight-medium;
- @include truncate();
-}
-
-.proc-cmd {
- font-family: var(--mono);
- font-size: 10.5px;
- color: var(--text-ghost);
- @include truncate();
-}
-
-.proc-user-tag {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- color: var(--text-dim);
- font-size: $font-size-sm + 0.5;
-}
-
-.proc-user-dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
-}
-
-.proc-bar-cell {
- display: flex;
- flex-direction: column;
- gap: 4px;
- min-width: 80px;
-}
-
-.proc-bar-value {
- font-family: var(--mono);
- font-size: 11.5px;
- color: var(--text-dim);
-}
-
-.proc-bar {
- height: 4px;
- background: var(--surface-3);
- border-radius: 3px;
- overflow: hidden;
-}
-
-.proc-bar-fill {
- height: 100%;
- border-radius: 3px;
- @include transition(width);
-
- &.cpu { background: var(--accent-bright); }
- &.mem { background: var(--cyan); }
-}
-
-.proc-actions {
- display: flex;
- gap: 2px;
- justify-content: flex-end;
-}
-
.proc-command {
font-family: var(--mono);
font-size: $font-size-sm;
@@ -1183,196 +962,11 @@ $lk-default: #646b7a;
word-break: break-all;
}
-// ============================================
-// SERVICES TAB (svc-*)
-// ============================================
-.svc-page {
- display: flex;
- flex-direction: column;
- gap: $space-3;
-
- // Standalone header strip (not inside a console frame on this tab)
- > .lv-header {
- border: 1px solid var(--border);
- border-radius: var(--radius-lg);
- }
-}
-
-.svc-toolbar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: $space-3;
- padding: $space-2 $space-3;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius-lg);
- flex-wrap: wrap;
-}
-
-.svc-grid {
- display: grid;
- gap: $space-3;
- grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
-}
-
-.svc-card {
- position: relative;
- background: var(--surface);
- border: 1px solid var(--border-soft);
- border-radius: var(--radius);
- padding: $space-4;
- display: flex;
- flex-direction: column;
- gap: $space-3;
- cursor: pointer;
- @include transition(all);
- overflow: hidden;
-
- &::before {
- content: '';
- position: absolute;
- left: 0; top: 0; bottom: 0;
- width: 3px;
- background: var(--border);
- @include transition(background);
- }
-
- &.status-running::before { background: var(--green); }
- &.status-failed::before { background: var(--red); }
- &.status-stopped::before { background: var(--text-ghost); }
- &.status-other::before { background: var(--amber); }
-
- &:hover {
- border-color: var(--border-strong);
- transform: translateY(-1px);
- box-shadow: var(--shadow-md);
- }
-
- &.status-failed {
- background: linear-gradient(135deg, fade($danger-raw, 5%), var(--surface) 60%);
- }
-}
-
-.svc-card-head {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: $space-2;
-}
-
-.svc-card-title {
- display: flex;
- align-items: center;
- gap: $space-2;
- min-width: 0;
-
- h4 {
- margin: 0;
- font-size: 13px;
- font-weight: $font-weight-semibold;
- color: $text-primary;
- @include truncate();
- font-family: var(--mono);
- }
-}
-
-.svc-status-dot {
- display: inline-block;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: var(--text-ghost);
- flex-shrink: 0;
-
- &.is-large { width: 12px; height: 12px; }
- &.status-running { background: var(--green); box-shadow: 0 0 0 3px fade($success-raw, 18%); }
- &.status-failed { background: var(--red); box-shadow: 0 0 0 3px fade($danger-raw, 18%); }
- &.status-stopped { background: var(--text-ghost); }
- &.status-other { background: var(--amber); }
-}
-
-.svc-card-desc {
- margin: 0;
- font-size: $font-size-sm;
- color: var(--text-dim);
- line-height: 1.5;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
-}
-
-.svc-card-meta {
- display: flex;
- gap: $space-4;
- font-size: 11.5px;
- color: var(--text-faint);
- font-family: var(--mono);
-}
-
-.svc-meta-label {
- color: var(--text-ghost);
- font-weight: $font-weight-semibold;
- text-transform: uppercase;
- letter-spacing: 0.06em;
- margin-right: 2px;
- font-size: 9.5px;
-}
-
-.svc-card-actions {
- display: flex;
- gap: $space-1;
- margin-top: auto;
- padding-top: $space-3;
- border-top: 1px solid var(--border-soft);
- flex-wrap: wrap;
-}
-
-.svc-action-btn {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- padding: 5px 10px;
- background: var(--surface-2);
- border: 1px solid var(--border);
- border-radius: var(--radius-sm);
- color: $text-primary;
- font-size: $font-size-sm;
- font-weight: $font-weight-medium;
- cursor: pointer;
- @include transition(all);
-
- &:hover:not(:disabled) {
- background: var(--surface-3);
- border-color: var(--border-strong);
- }
- &:disabled { opacity: 0.5; cursor: not-allowed; }
-
- &.primary {
- background: $accent-primary;
- border-color: $accent-primary;
- color: white;
- &:hover:not(:disabled) { background: $accent-hover; border-color: $accent-hover; }
- }
- &.danger {
- background: $danger;
- border-color: $danger;
- color: white;
- &:hover:not(:disabled) { background: $danger-hover; border-color: $danger-hover; }
- }
- &.ghost {
- background: transparent;
- border-color: transparent;
- color: var(--text-dim);
- &:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
- }
-}
-
// ============================================
// LEGACY (pre-redesign) — still consumed by components/JournalControls.jsx,
-// components/ProcessTable.jsx, components/ServiceCard.jsx and StyleGuide.jsx.
-// Not rendered by pages/Terminal.jsx anymore; keep until those move.
+// components/ServiceCard.jsx and StyleGuide.jsx. Keep until those move.
+// .processes-table below is NOT legacy: it is what components/ProcessTable.jsx
+// renders, on Terminal › Processes and in the style guide.
// ============================================
.journal-container {
@@ -1525,10 +1119,8 @@ $lk-default: #646b7a;
.processes-table {
width: 100%;
min-width: 800px;
- table-layout: fixed;
border-collapse: collapse;
- // Column widths: PID | Name | User | CPU% | Mem% | Memory | Status | Actions
th, td {
padding: $space-2 $space-3;
text-align: left;
@@ -1549,15 +1141,9 @@ $lk-default: #646b7a;
border-bottom: 1px solid $border-subtle;
}
- // Explicit column widths for alignment
- th:nth-child(1), td:nth-child(1) { width: 70px; } // PID
- th:nth-child(2), td:nth-child(2) { width: auto; } // Name (flexible)
- th:nth-child(3), td:nth-child(3) { width: 90px; } // User
- th:nth-child(4), td:nth-child(4) { width: 110px; } // CPU %
- th:nth-child(5), td:nth-child(5) { width: 110px; } // Memory %
- th:nth-child(6), td:nth-child(6) { width: 90px; } // Memory
- th:nth-child(7), td:nth-child(7) { width: 80px; } // Status
- th:nth-child(8), td:nth-child(8) { width: 110px; } // Actions
+ // No nth-child column widths: columns can now be hidden and reordered from
+ // the header menu, so a width pinned to a POSITION lands on whatever column
+ // happens to sit there.
tr {
cursor: pointer;
@@ -1576,11 +1162,6 @@ $lk-default: #646b7a;
border-bottom: 1px solid $border-subtle;
}
- .mono {
- font-family: $font-mono;
- font-size: $font-size-xs;
- }
-
.process-name {
overflow: hidden;
text-overflow: ellipsis;
diff --git a/frontend/src/utils/deployActivity.js b/frontend/src/utils/deployActivity.js
index 36555056..4006a676 100644
--- a/frontend/src/utils/deployActivity.js
+++ b/frontend/src/utils/deployActivity.js
@@ -68,32 +68,15 @@ export function relativeTime(iso, now = Date.now()) {
return `${Math.floor(mins / 1440)}d ago`;
}
-// Queued runs float to the top; everything else falls into a day bucket so the
-// feed reads chronologically without printing a date on every row.
+// Day bucket for a run, so the table can group chronologically without printing
+// a date on every row. Queued runs are their own bucket — they have no start
+// time to place them by, and they are the ones worth reading first.
+//
+// The hand-rolled orderer that used to sit here went with the feed: the table's
+// own grouping sorts the buckets by the active sort, which is the same answer
+// without a second copy of the ordering rules.
export function activityGroup(job, now = Date.now()) {
if (job.status === 'pending' || !job.started_at) return 'Queued';
const mins = (now - new Date(job.started_at).getTime()) / 60000;
return mins < 1440 ? 'Today' : 'Earlier';
}
-
-const GROUP_ORDER = { Queued: 0, Today: 1, Earlier: 2 };
-
-// Group into ordered buckets, newest first inside each.
-export function groupDeploys(jobs, now = Date.now()) {
- const buckets = new Map();
- jobs.forEach((job) => {
- const g = activityGroup(job, now);
- if (!buckets.has(g)) buckets.set(g, []);
- buckets.get(g).push(job);
- });
- return [...buckets.entries()]
- .sort((a, b) => GROUP_ORDER[a[0]] - GROUP_ORDER[b[0]])
- .map(([group, items]) => ({
- group,
- items: items.sort((a, b) => {
- const ta = new Date(a.started_at || a.created_at).getTime() || 0;
- const tb = new Date(b.started_at || b.created_at).getTime() || 0;
- return tb - ta;
- }),
- }));
-}