Fold the servers table controls into the view

The servers top bar carried Groups, Sync, Add, search, a filter icon
and a tools menu, and the table opened with every column it had, so it
scrolled sideways.

The view selector's menu now holds Filters and fields, the table tools
(copy link, export, reset) and Manage groups; the top bar keeps Sync,
Add and search. The table opens with eight columns. Everything else
the list returns about a server is an optional field: services and
domains counts, IP, OS, architecture, cores, capacity, Docker, tags,
date added. Reset returns to that default set, not to "show all".

The Fields pane splits into what is in the table (reorder, switch off)
and the fields that can be added, with a search once the list is long.

GridViewPicker takes `filters`, `tools` and `extra`; GridToolsMenu's
content is now GridToolsPanel so it can live in either place. Other
tables keep their top-bar controls for now.
This commit is contained in:
Juan Denis committed 2026-11-14 14:46:24 -05:00
1 parent 4fa5caef79
commit 6ecd3245bc
26 files changed
+549 -256

No files matched your search

@@ -1,5 +1,5 @@
import { useState } from 'react';
import { Filter, Layers, X, Plus, History, GripVertical } from 'lucide-react';
import { Filter, Layers, X, Plus, History, GripVertical, Search } from 'lucide-react';
import { Drawer } from '../Drawer';
import { Button } from '@/components/ui/button';
import { Switch } from '@/components/ui/switch';
@@ -11,6 +11,9 @@ import {
isDecorative, isFilterable, isSortable, optionsFor,
} from './fields';
// A field search only earns its row once the list is long enough to scan.
const FIELD_SEARCH_MIN = 9;
// Two panes behind one drawer, because they are the two halves of "what am I
// looking at": FILTERS decides which rows, FIELDS decides which columns (and in
// what order, at what density, with which detail line). The header menu is the
@@ -30,6 +33,7 @@ export function GridFilterDrawer({
const { t } = useTranslation();
const [tab, setTab] = useState('filters');
const [dragging, setDragging] = useState(null);
const [fieldQuery, setFieldQuery] = useState('');
const map = byKey(columns);
const rules = cfg.filters.rules;
@@ -47,6 +51,8 @@ export function GridFilterDrawer({
const namedColumns = columns.filter((column) => !isDecorative(column));
const shownCount = cfg.cols.filter((key) => !isDecorative(map.get(key))).length;
const hiddenCount = namedColumns.length - shownCount;
const fieldNeedle = fieldQuery.trim().toLowerCase();
const fieldMatches = (column) => !fieldNeedle || columnLabel(column).toLowerCase().includes(fieldNeedle);
const patchRule = (id, patch) => grid.setRules(
rules.map((r) => (r.id === id ? { ...r, ...patch } : r)),
@@ -271,23 +277,36 @@ export function GridFilterDrawer({
{tab === 'fields' && (
<>
{namedColumns.length >= FIELD_SEARCH_MIN && (
<div className="sk-gridfind">
<Search size={14} aria-hidden="true" />
<input
type="search"
value={fieldQuery}
onChange={(e) => setFieldQuery(e.target.value)}
placeholder={t('app.gridFilterDrawer.findField', 'Find a field')}
aria-label={t('app.gridFilterDrawer.findField', 'Find a field')}
/>
</div>
)}
{/* In the table, in table order: drag to reorder, switch off to remove. */}
<div className="sk-gridsec">
<div className="sk-gridsec__head">
<div className="sk-gridsec__t">{t('app.gridFilterDrawer.columns', 'Columns')}</div>
<span className="sk-gridsec__meta">
{t('app.gridFilterDrawer.shownOf', '{{shown}} of {{total}} shown', { shown: shownCount, total: namedColumns.length })}
</span>
<div className="sk-gridsec__t">{t('app.gridFilterDrawer.shown', 'In the table')}</div>
<span className="sk-gridsec__meta">{shownCount}</span>
</div>
{ordered.map((key, i) => {
const column = map.get(key);
if (!column || isDecorative(column)) return null;
const on = cfg.cols.includes(key);
if (!column || isDecorative(column) || !cfg.cols.includes(key) || !fieldMatches(column)) return null;
const locked = !!column.locked || column.hideable === false;
return (
<div
key={key}
draggable={!locked && on}
className={cn('sk-gridcol', !on && 'is-off', locked && 'is-locked', dragging === i && 'is-drag')}
// Reordering while a search hides part of the list
// would drop the field at an index nobody can see.
draggable={!locked && !fieldNeedle}
className={cn('sk-gridcol', locked && 'is-locked', dragging === i && 'is-drag')}
onDragStart={() => setDragging(i)}
onDragEnd={() => setDragging(null)}
onDragOver={(e) => {
@@ -301,9 +320,9 @@ export function GridFilterDrawer({
? <span className="sk-gridcol__lock">{t('app.gridFilterDrawer.pinned', 'pinned')}</span>
: (
<Switch
checked={on}
checked
onCheckedChange={() => grid.toggleColumn(key, allKeys)}
aria-label={t('app.gridFilterDrawer.show', 'Show {{value}}', { value: columnLabel(column) })}
aria-label={t('app.gridFilterDrawer.hide', 'Hide {{value}}', { value: columnLabel(column) })}
/>
)}
</div>
@@ -311,6 +330,37 @@ export function GridFilterDrawer({
})}
</div>
{/* Everything else the table knows about each row. */}
{hiddenCount > 0 && (
<div className="sk-gridsec">
<div className="sk-gridsec__head">
<div className="sk-gridsec__t">{t('app.gridFilterDrawer.available', 'More fields')}</div>
<span className="sk-gridsec__meta">{hiddenCount}</span>
</div>
<div className="sk-gridsec__tags">
{namedColumns.filter((column) => !cfg.cols.includes(column.key) && fieldMatches(column)).map((column) => (
<Button variant="unstyled"
key={column.key}
type="button"
className="sk-gridrule__tag sk-gridstart__field"
onClick={() => grid.toggleColumn(column.key, allKeys)}
aria-label={t('app.gridFilterDrawer.show', 'Show {{value}}', { value: columnLabel(column) })}
>
<Plus size={12} aria-hidden="true" />{columnLabel(column)}
</Button>
))}
</div>
</div>
)}
{fieldNeedle && !namedColumns.some(fieldMatches) && (
<div className="sk-gridsec">
<p className="sk-gridstart__lead">
{t('app.gridFilterDrawer.noFieldMatches', 'No field matches "{{query}}".', { query: fieldQuery.trim() })}
</p>
</div>
)}
{(showRowDetail || showDensity) && (
<div className="sk-gridsec">
{showRowDetail && (
+128 -104
View File
@@ -1,25 +1,34 @@
import { useState } from 'react';
import { MoreVertical, Download, RefreshCw, History, Check, Link2, Rows2, Rows3 } from 'lucide-react';
import { MoreVertical, ChevronLeft, Download, RefreshCw, History, Check, Link2, Rows2, Rows3 } from 'lucide-react';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { cn } from '@/lib/utils';
import { byKey, exportRows } from './fields';
import { useTranslation } from 'react-i18next';
import { Button as SharedButton } from '@/components/ui/button';
// The toolbar's "⋮" — everything that is neither a filter nor a per-column
// action: export, refresh, row density, and discarding unsaved view changes.
// One button instead of four keeps the top bar the same shape on every page,
// which is the whole point of putting search there.
export function GridToolsMenu({
// Everything about a table that is neither a filter nor a per-column action:
// copying a link to the view, export, refresh, row density, and discarding
// unsaved view changes.
//
// GridToolsPanel is the content; it is shown either inside its own "⋮"
// popover (GridToolsMenu, below) or inside the view selector's menu
// (GridViewPicker `tools`), where it is `embedded` and reports which pane it
// is on so the host can step aside while the export options are open.
export function GridToolsPanel({
cfg, columns, rows, selectedRows = [], viewName, noun = 'rows',
onRefresh, onReset, onDensity, onExported, onCopyLink,
// Off for hosts whose table auto-sizes its rows (<DataTable>) — showing a
// density toggle that changes nothing is worse than not showing one.
showDensity = true,
onClose,
embedded = false,
pane: paneProp,
onPaneChange,
}) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [pane, setPane] = useState('root'); // root | export
const [ownPane, setOwnPane] = useState('root'); // root | export
const pane = paneProp ?? ownPane;
const setPane = onPaneChange ?? setOwnPane;
const [scope, setScope] = useState('view');
const [copied, setCopied] = useState(null);
const [allCols, setAllCols] = useState(false);
@@ -28,7 +37,7 @@ export function GridToolsMenu({
const set = scope === 'picked' ? selectedRows : rows;
const exportCols = allCols ? columns : cfg.cols.map((k) => map.get(k)).filter(Boolean);
const close = () => { setOpen(false); setPane('root'); };
const close = () => { setPane('root'); onClose?.(); };
const go = (format) => {
const n = exportRows(
@@ -41,6 +50,115 @@ export function GridToolsMenu({
close();
};
return pane === 'root' ? (
<>
{onCopyLink && (
<SharedButton variant="unstyled"
type="button"
className="sk-gridmenu__opt"
onClick={async () => {
const res = await onCopyLink();
setCopied(res?.copied ? 'ok' : 'fail');
setTimeout(() => setCopied(null), 1800);
}}
>
{copied === 'ok' ? <Check size={13} /> : <Link2 size={13} />}
{copied === 'ok' ? t('app.gridToolsMenu.linkCopied', 'Link copied')
: copied === 'fail' ? t('app.gridToolsMenu.copyFailed', "Couldn't copy the link. Check clipboard permissions.")
: t('app.gridToolsMenu.copyLinkToThisView', 'Copy link to this view')}
</SharedButton>
)}
<SharedButton variant="unstyled" type="button" className="sk-gridmenu__opt" onClick={() => setPane('export')}>
<Download size={13} />{t('app.gridToolsMenu.export', 'Export…')}
</SharedButton>
{onRefresh && (
<SharedButton variant="unstyled"
type="button"
className="sk-gridmenu__opt"
onClick={() => { onRefresh(); close(); }}
>
<RefreshCw size={13} />{t('app.gridToolsMenu.refreshData', 'Refresh data')}
</SharedButton>
)}
{showDensity && (
<>
<div className="sk-gridmenu__sep" />
<div className="sk-gridmenu__head">{t('app.gridToolsMenu.rowDensity', 'Row density')}</div>
{[['cozy', 'Cozy', Rows2], ['compact', 'Compact', Rows3]].map(([value, text, Icon]) => (
<SharedButton variant="unstyled"
key={value}
type="button"
className={cn('sk-gridmenu__opt', cfg.density === value && 'is-on')}
onClick={() => onDensity(value)}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
<Icon size={13} />{text}
</SharedButton>
))}
</>
)}
<div className="sk-gridmenu__sep" />
<SharedButton variant="unstyled"
type="button"
className="sk-gridmenu__opt"
onClick={() => { onReset(); close(); }}
>
<History size={13} />{t('app.gridToolsMenu.resetViewChanges', 'Reset view changes')}
</SharedButton>
</>
) : (
<>
{embedded ? (
<SharedButton variant="unstyled" type="button" className="sk-gridmenu__opt sk-gridmenu__back" onClick={() => setPane('root')}>
<ChevronLeft size={13} />{t('app.gridToolsMenu.export2', 'Export')}
</SharedButton>
) : (
<div className="sk-gridmenu__head">{t('app.gridToolsMenu.export2', 'Export')}</div>
)}
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', scope === 'view' && 'is-on')}
onClick={() => setScope('view')}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridToolsMenu.rowsInThisView', 'Rows in this view')}
<span className="sk-gridmenu__rest">{rows.length}</span>
</SharedButton>
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', scope === 'picked' && 'is-on')}
disabled={!selectedRows.length}
disabledReason={t('app.gridToolsMenu.selectSomeRowsFirst', 'Select some rows first')}
onClick={() => setScope('picked')}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridToolsMenu.selectedRows', 'Selected rows')}
<span className="sk-gridmenu__rest">{selectedRows.length}</span>
</SharedButton>
<div className="sk-gridmenu__sep" />
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', allCols && 'is-on')}
onClick={() => setAllCols((v) => !v)}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridToolsMenu.includeHiddenFields', 'Include hidden fields')}
<span className="sk-gridmenu__rest">{exportCols.length}</span>
</SharedButton>
<div className="sk-gridmenu__foot">
<SharedButton variant="unstyled" type="button" onClick={() => go('json')}>JSON</SharedButton>
<SharedButton variant="unstyled" type="button" className="is-primary" onClick={() => go('csv')}>{t('app.gridToolsMenu.downloadCsv', 'Download CSV')}</SharedButton>
</div>
</>
);
}
// The standalone "⋮" for tables that keep their tools on their own button.
export function GridToolsMenu(props) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [pane, setPane] = useState('root');
return (
<Popover
open={open}
@@ -52,101 +170,7 @@ export function GridToolsMenu({
</SharedButton>
</PopoverTrigger>
<PopoverContent align="end" sideOffset={6} className="ui-popover-panel sk-gridmenu">
{pane === 'root' ? (
<>
{onCopyLink && (
<SharedButton variant="unstyled"
type="button"
className="sk-gridmenu__opt"
onClick={async () => {
const res = await onCopyLink();
setCopied(res?.copied ? 'ok' : 'fail');
setTimeout(() => setCopied(null), 1800);
}}
>
{copied === 'ok' ? <Check size={13} /> : <Link2 size={13} />}
{copied === 'ok' ? t('app.gridToolsMenu.linkCopied', 'Link copied')
: copied === 'fail' ? t('app.gridToolsMenu.copyFailed', "Couldn't copy the link. Check clipboard permissions.")
: t('app.gridToolsMenu.copyLinkToThisView', 'Copy link to this view')}
</SharedButton>
)}
<SharedButton variant="unstyled" type="button" className="sk-gridmenu__opt" onClick={() => setPane('export')}>
<Download size={13} />{t('app.gridToolsMenu.export', 'Export…')}
</SharedButton>
{onRefresh && (
<SharedButton variant="unstyled"
type="button"
className="sk-gridmenu__opt"
onClick={() => { onRefresh(); close(); }}
>
<RefreshCw size={13} />{t('app.gridToolsMenu.refreshData', 'Refresh data')}
</SharedButton>
)}
{showDensity && (
<>
<div className="sk-gridmenu__sep" />
<div className="sk-gridmenu__head">{t('app.gridToolsMenu.rowDensity', 'Row density')}</div>
{[['cozy', 'Cozy', Rows2], ['compact', 'Compact', Rows3]].map(([value, text, Icon]) => (
<SharedButton variant="unstyled"
key={value}
type="button"
className={cn('sk-gridmenu__opt', cfg.density === value && 'is-on')}
onClick={() => onDensity(value)}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
<Icon size={13} />{text}
</SharedButton>
))}
</>
)}
<div className="sk-gridmenu__sep" />
<SharedButton variant="unstyled"
type="button"
className="sk-gridmenu__opt"
onClick={() => { onReset(); close(); }}
>
<History size={13} />{t('app.gridToolsMenu.resetViewChanges', 'Reset view changes')}
</SharedButton>
</>
) : (
<>
<div className="sk-gridmenu__head">{t('app.gridToolsMenu.export2', 'Export')}</div>
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', scope === 'view' && 'is-on')}
onClick={() => setScope('view')}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridToolsMenu.rowsInThisView', 'Rows in this view')}
<span className="sk-gridmenu__rest">{rows.length}</span>
</SharedButton>
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', scope === 'picked' && 'is-on')}
disabled={!selectedRows.length}
disabledReason={t('app.gridToolsMenu.selectSomeRowsFirst', 'Select some rows first')}
onClick={() => setScope('picked')}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridToolsMenu.selectedRows', 'Selected rows')}
<span className="sk-gridmenu__rest">{selectedRows.length}</span>
</SharedButton>
<div className="sk-gridmenu__sep" />
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', allCols && 'is-on')}
onClick={() => setAllCols((v) => !v)}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridToolsMenu.includeHiddenFields', 'Include hidden fields')}
<span className="sk-gridmenu__rest">{exportCols.length}</span>
</SharedButton>
<div className="sk-gridmenu__foot">
<SharedButton variant="unstyled" type="button" onClick={() => go('json')}>JSON</SharedButton>
<SharedButton variant="unstyled" type="button" className="is-primary" onClick={() => go('csv')}>{t('app.gridToolsMenu.downloadCsv', 'Download CSV')}</SharedButton>
</div>
</>
)}
<GridToolsPanel {...props} pane={pane} onPaneChange={setPane} onClose={() => setOpen(false)} />
</PopoverContent>
</Popover>
);
@@ -1,11 +1,12 @@
import { useState } from 'react';
import {
ChevronDown, Star, Copy, Trash2, Plus, MoreVertical, Check, History, AlertTriangle,
ChevronDown, Star, Copy, Trash2, Plus, MoreVertical, Check, History, AlertTriangle, SlidersHorizontal,
} from 'lucide-react';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { cn } from '@/lib/utils';
import { useTranslation } from 'react-i18next';
import { Button as SharedButton } from '@/components/ui/button';
import { GridToolsPanel } from './GridToolsMenu';
// The saved-view selector, rendered as the page's own heading rather than yet
// another toolbar button — the view IS what you are looking at, so its name is
@@ -21,17 +22,30 @@ import { Button as SharedButton } from '@/components/ui/button';
// there instead (see useTopbarChrome) and passes nothing here; an inner or sub
// table, which has no top bar of its own, passes it and keeps it inline.
//
// A page can instead fold the table's controls INTO this menu, so the page has
// one place for "what am I looking at and what can I do with it" and its top
// bar keeps only the actions that create or reload things:
//
// filters { count, hidden, onOpen } opens the filters and fields drawer
// tools the GridToolsMenu props copy link, export, reset…
// extra [{ icon, label, onSelect }] page-specific entries (Manage groups)
//
// There is deliberately no row count. It was rendered twice on every page that
// also had a toolbar underneath — once next to the view name, once on the right
// of the second bar — and the footer already says how many rows there are,
// under the rows it is counting.
export function GridViewPicker({ views, counts, onCreate, label = 'items', actions }) {
export function GridViewPicker({ views, counts, onCreate, label = 'items', actions, filters, tools, extra }) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [menuFor, setMenuFor] = useState(null);
const [creating, setCreating] = useState(false);
const [name, setName] = useState('');
const [fromCurrent, setFromCurrent] = useState(true);
// While the tools section shows its export options, the rest of the menu
// steps aside so the options are not buried under the list of views.
const [toolsPane, setToolsPane] = useState('root');
const exporting = toolsPane !== 'root';
const closeMenu = () => { setOpen(false); setMenuFor(null); setToolsPane('root'); };
const active = views.activeView;
const activeName = active?.name || `All ${label}`;
@@ -101,7 +115,7 @@ export function GridViewPicker({ views, counts, onCreate, label = 'items', actio
return (
<div className="sk-viewbar">
<Popover open={open} onOpenChange={setOpen}>
<Popover open={open} onOpenChange={(o) => { setOpen(o); if (!o) setToolsPane('root'); }}>
<PopoverTrigger asChild>
<SharedButton variant="unstyled" type="button" className={cn('sk-viewpick', open && 'is-open')}>
<span className="sk-viewpick__title">{activeName}</span>
@@ -110,48 +124,102 @@ export function GridViewPicker({ views, counts, onCreate, label = 'items', actio
</SharedButton>
</PopoverTrigger>
<PopoverContent align="start" sideOffset={6} className="ui-popover-panel sk-gridmenu sk-viewpick__menu">
{!!builtins.length && <div className="sk-gridmenu__head">{t('app.gridViewPicker.builtIn', 'Built in')}</div>}
{builtins.map(renderRow)}
<div className="sk-gridmenu__head">{t('app.gridViewPicker.myViews', 'My views')}</div>
{mine.length ? mine.map(renderRow) : (
<div className="sk-gridmenu__note">
{t('app.gridViewPicker.noPersonalViewsYetTuneThe', 'No personal views yet. Tune the grid, then save it here.')}
</div>
)}
<div className="sk-gridmenu__sep" />
{creating ? (
{!exporting && (
<>
<div className="sk-gridmenu__mini sk-gridmenu__mini--input">
<input
autoFocus
value={name}
placeholder={t('app.gridViewPicker.eGCloudflareProd', 'e.g. Cloudflare prod')}
onChange={(e) => setName(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') submitNew();
if (e.key === 'Escape') setCreating(false);
}}
/>
</div>
{!!builtins.length && <div className="sk-gridmenu__head">{t('app.gridViewPicker.builtIn', 'Built in')}</div>}
{builtins.map(renderRow)}
<div className="sk-gridmenu__head">{t('app.gridViewPicker.myViews', 'My views')}</div>
{mine.length ? mine.map(renderRow) : (
<div className="sk-gridmenu__note">
{t('app.gridViewPicker.noPersonalViewsYetTuneThe', 'No personal views yet. Tune the grid, then save it here.')}
</div>
)}
<div className="sk-gridmenu__sep" />
{creating ? (
<>
<div className="sk-gridmenu__mini sk-gridmenu__mini--input">
<input
autoFocus
value={name}
placeholder={t('app.gridViewPicker.eGCloudflareProd', 'e.g. Cloudflare prod')}
onChange={(e) => setName(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') submitNew();
if (e.key === 'Escape') setCreating(false);
}}
/>
</div>
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', fromCurrent && 'is-on')}
onClick={() => setFromCurrent((v) => !v)}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridViewPicker.startFromCurrentFiltersColumns', 'Start from current filters and columns')}
</SharedButton>
<div className="sk-gridmenu__foot">
<SharedButton variant="unstyled" type="button" onClick={() => setCreating(false)}>{t('common.actions.cancel', 'Cancel')}</SharedButton>
<SharedButton variant="unstyled" type="button" className="is-primary" disabled={!name.trim()} disabledReason={t('app.gridViewPicker.enterAViewNameFirst', 'Enter a view name first')} onClick={submitNew}>
{t('common.actions.create', 'Create')}
</SharedButton>
</div>
</>
) : (
<SharedButton variant="unstyled" type="button" className="sk-gridmenu__opt" onClick={() => setCreating(true)}>
<Plus size={13} />{t('app.gridViewPicker.saveCurrentView', 'Save current view…')}
</SharedButton>
)}
</>
)}
{filters && !exporting && (
<>
<div className="sk-gridmenu__sep" />
<SharedButton variant="unstyled"
type="button"
className={cn('sk-gridmenu__opt', fromCurrent && 'is-on')}
onClick={() => setFromCurrent((v) => !v)}
className="sk-gridmenu__opt"
onClick={() => { closeMenu(); filters.onOpen(); }}
>
<span className="sk-gridmenu__box"><Check size={11} /></span>
{t('app.gridViewPicker.startFromCurrentFiltersColumns', 'Start from current filters and columns')}
<SlidersHorizontal size={13} />{t('app.gridViewPicker.filtersAndFields', 'Filters and fields')}
{(filters.count > 0 || filters.hidden > 0) && (
<span className="sk-gridmenu__rest">
{[
filters.count > 0 && t('app.gridViewPicker.filterCount', { count: filters.count, defaultValue_one: '1 filter', defaultValue_other: '{{count}} filters' }),
filters.hidden > 0 && t('app.gridViewPicker.moreFields', '{{count}} more fields', { count: filters.hidden }),
].filter(Boolean).join(' \u00b7 ')}
</span>
)}
</SharedButton>
<div className="sk-gridmenu__foot">
<SharedButton variant="unstyled" type="button" onClick={() => setCreating(false)}>{t('common.actions.cancel', 'Cancel')}</SharedButton>
<SharedButton variant="unstyled" type="button" className="is-primary" disabled={!name.trim()} disabledReason={t('app.gridViewPicker.enterAViewNameFirst', 'Enter a view name first')} onClick={submitNew}>
{t('common.actions.create', 'Create')}
</SharedButton>
</div>
</>
) : (
<SharedButton variant="unstyled" type="button" className="sk-gridmenu__opt" onClick={() => setCreating(true)}>
<Plus size={13} />{t('app.gridViewPicker.saveCurrentView', 'Save current view…')}
</SharedButton>
)}
{tools && (
<>
{!exporting && <div className="sk-gridmenu__sep" />}
<GridToolsPanel
{...tools}
embedded
pane={toolsPane}
onPaneChange={setToolsPane}
onClose={closeMenu}
/>
</>
)}
{!!extra?.length && !exporting && (
<>
<div className="sk-gridmenu__sep" />
{extra.map(({ icon: Icon, label: text, onSelect }) => (
<SharedButton variant="unstyled"
key={text}
type="button"
className="sk-gridmenu__opt"
onClick={() => { closeMenu(); onSelect(); }}
>
{Icon && <Icon size={13} />}{text}
</SharedButton>
))}
</>
)}
</PopoverContent>
</Popover>
@@ -31,6 +31,8 @@ const NO_FILTERS = { match: 'all', rules: [] };
* every page, which is what makes a saved view, a shareable link and a guard
* one concept instead of eleven.
*/
const NO_KEYS = [];
export function useTableChrome({
columns,
rows = [],
@@ -41,6 +43,10 @@ export function useTableChrome({
setSorts,
hiddenKeys = [],
setHiddenKeys,
// Columns a fresh table keeps out of sight. "Reset" goes back to THIS set,
// not to "show everything": a table that offers twenty fields does not want
// all twenty on screen the moment someone clears a filter.
defaultHiddenKeys = NO_KEYS,
groupBy = null,
setGroupBy,
pageState,
@@ -112,8 +118,8 @@ export function useTableChrome({
),
setSub: () => {},
setDensity: () => {},
resetToView: () => { clearRules(); setHiddenKeys?.([]); setColumnOrder(null); },
}), [setMatch, removeRule, clearRules, hiddenKeys, setHiddenKeys]);
resetToView: () => { clearRules(); setHiddenKeys?.([...defaultHiddenKeys]); setColumnOrder(null); },
}), [setMatch, removeRule, clearRules, hiddenKeys, setHiddenKeys, defaultHiddenKeys]);
// The envelope. The column rules are `columnFilters`, never `filters`:
// three pages persist a `filters` key of their own meaning a SERVER-side
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "تم إنشاء المجموعة",
"groupDeleted": "تم حذف المجموعة",
"groupUpdated": "تم تحديث المجموعة",
"groups": "المجموعات",
"host": "يستضيف",
"hostname": "اسم المضيف:",
"lastSeen": "شوهد آخر مرة",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "গ্রুপ তৈরি হয়েছে",
"groupDeleted": "গ্রুপ মুছে ফেলা হয়েছে",
"groupUpdated": "গ্রুপ আপডেট করা হয়েছে",
"groups": "গোষ্ঠী",
"host": "হোস্ট",
"hostname": "হোস্টনাম:",
"lastSeen": "শেষ দেখা",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Gruppe erstellt",
"groupDeleted": "Gruppe gelöscht",
"groupUpdated": "Gruppe aktualisiert",
"groups": "Gruppen",
"host": "Gastgeber",
"hostname": "Hostname:",
"lastSeen": "Zuletzt gesehen",
+15 -3
View File
@@ -3044,7 +3044,7 @@
"gridFilterDrawer": {
"addCondition": "Add condition",
"and": "and",
"columns": "Columns",
"available": "More fields",
"combine": "How conditions combine",
"countAll": "{{count}} {{noun}}",
"countOf": "{{matching}} of {{total}} {{noun}}",
@@ -3055,6 +3055,9 @@
"filterBy": "Filter by",
"filters": "Filters",
"filtersFields": "Filters and fields",
"findField": "Find a field",
"hide": "Hide {{value}}",
"noFieldMatches": "No field matches \"{{query}}\".",
"nothingFiltered_one": "The only {{noun}} is showing.",
"nothingFiltered_other": "All {{count}} {{noun}} are showing.",
"off": "Off",
@@ -3065,7 +3068,7 @@
"reset": "Reset",
"rowDetail": "Row detail",
"show": "Show {{value}}",
"shownOf": "{{shown}} of {{total}} shown"
"shown": "In the table"
},
"gridFooter": {
"firstPage": "First page",
@@ -3099,7 +3102,11 @@
"duplicateView": "Duplicate view",
"eGCloudflareProd": "e.g. Cloudflare prod",
"enterAViewNameFirst": "Enter a view name first",
"filterCount_one": "1 filter",
"filterCount_other": "{{count}} filters",
"filtersAndFields": "Filters and fields",
"makeDefault": "Make default",
"moreFields": "{{count}} more fields",
"myViews": "My views",
"noPersonalViewsYetTuneThe": "No personal views yet. Tune the grid, then save it here.",
"reset": "Reset",
@@ -5871,10 +5878,12 @@
"abc123": "ABC-123",
"addServer": "Add server",
"addYourFirstServer": "Add your first server",
"added": "Added",
"adjustTheSearchOrClearThe": "Adjust the search or clear the column filters to see your servers.",
"agent": "Agent",
"agentFound": "Agent found",
"agentPairedSuccessfully": "Agent paired",
"architecture": "Architecture",
"autoDetectedFromAgentOptional": "Auto-detected from agent (optional)",
"capAllowed": "allowed",
"capBlocked": "blocked",
@@ -5884,6 +5893,7 @@
"connectionStringReady": "Connection string ready",
"couldNotSetTheGroup": "Couldn't set the group.",
"couldntLoadServers": "Couldn't load servers.",
"cpuCores": "CPU cores",
"curlTarSudoAndSystemd": "curl, tar, sudo, and systemd",
"deleteGroup": "Delete group",
"deleteServerGroup": "Delete server group",
@@ -5899,7 +5909,6 @@
"groupCreated": "Group created",
"groupDeleted": "Group deleted",
"groupUpdated": "Group updated",
"groups": "Groups",
"health": "Health",
"healthDegraded": "Degraded",
"healthFailing": "Failing",
@@ -5925,6 +5934,7 @@
"levelProtectCannot": "Cannot touch Docker, files, packages, services, shell or updates.",
"linkPanel": "Link panel",
"linux": "Linux",
"manageGroups": "Manage groups",
"manageServerGroups": "Manage server groups",
"movedServersTo_one": "Moved 1 server to {{groupName}}",
"movedServersTo_other": "Moved {{count}} servers to {{groupName}}",
@@ -5938,6 +5948,7 @@
"onTheTargetMachineStartThe": "On the target server, start the agent. It will display a 6-character pair code and a passphrase. Enter both below.",
"online": "Online",
"openTheAgentOnYourTarget": "Open the agent on your target server and paste the connection string.",
"os": "OS",
"pairAgentAction": "Pair agent",
"pairAnAgentAndTheMachine": "Pair an agent and the server shows up here with its CPU, memory and disk alongside every other server you run.",
"pairCode": "Pair code",
@@ -5964,6 +5975,7 @@
"stepStartAgent": "Start agent",
"sync": "Sync",
"syncShort": "Sync",
"tags": "Tags",
"theAgentRegistersAutomaticallyAndReports": "The agent registers automatically and reports its hostname back as the server name.",
"theCodeIsShownInThe": "The code is shown in the terminal output or system tray.",
"theRowInThisListWill": "The row in this list will switch from",
-1
View File
@@ -5645,7 +5645,6 @@
"groupCreated": "Grupo creado",
"groupDeleted": "Grupo eliminado",
"groupUpdated": "Grupo actualizado",
"groups": "Grupos",
"host": "Host",
"hostname": "Hostname:",
"lastSeen": "Visto por última vez",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Groupe créé",
"groupDeleted": "Groupe supprimé",
"groupUpdated": "Groupe mis à jour",
"groups": "Groupes",
"host": "Hôte",
"hostname": "Nom d'hôte :",
"lastSeen": "Vu pour la dernière fois",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Grup dibuat",
"groupDeleted": "Grup dihapus",
"groupUpdated": "Grup diperbarui",
"groups": "Grup",
"host": "Tuan rumah",
"hostname": "Nama host:",
"lastSeen": "Terakhir terlihat",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Gruppo creato",
"groupDeleted": "Gruppo eliminato",
"groupUpdated": "Gruppo aggiornato",
"groups": "Gruppi",
"host": "Ospite",
"hostname": "Nome host:",
"lastSeen": "Visto l'ultima volta",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "그룹이 생성되었습니다.",
"groupDeleted": "그룹이 삭제되었습니다.",
"groupUpdated": "그룹이 업데이트되었습니다.",
"groups": "그룹",
"host": "호스트",
"hostname": "호스트 이름:",
"lastSeen": "마지막으로 본",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Grupa utworzona",
"groupDeleted": "Grupa usunięta",
"groupUpdated": "Grupa zaktualizowana",
"groups": "Grupy",
"host": "Gospodarz",
"hostname": "Nazwa hosta:",
"lastSeen": "Ostatnio widziany",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Grupo criado",
"groupDeleted": "Grupo excluído",
"groupUpdated": "Grupo atualizado",
"groups": "Grupos",
"host": "Host",
"hostname": "Nome do host:",
"lastSeen": "Visto pela última vez",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Группа создана",
"groupDeleted": "Группа удалена",
"groupUpdated": "Группа обновлена",
"groups": "Группы",
"host": "Хост",
"hostname": "Имя хоста:",
"lastSeen": "Последняя активность",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "สร้างกลุ่มแล้ว",
"groupDeleted": "ลบกลุ่มแล้ว",
"groupUpdated": "อัปเดตกลุ่มแล้ว",
"groups": "กลุ่ม",
"host": "เจ้าภาพ",
"hostname": "ชื่อโฮสต์:",
"lastSeen": "เห็นครั้งสุดท้าย",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Grup oluşturuldu",
"groupDeleted": "Grup silindi",
"groupUpdated": "Grup güncellendi",
"groups": "Gruplar",
"host": "Ev sahibi",
"hostname": "Ana makine adı:",
"lastSeen": "Son görülme",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "Đã tạo nhóm",
"groupDeleted": "Đã xóa nhóm",
"groupUpdated": "Đã cập nhật nhóm",
"groups": "Nhóm",
"host": "Chủ nhà",
"hostname": "Tên máy chủ:",
"lastSeen": "Nhìn thấy lần cuối",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "群组已创建",
"groupDeleted": "群组已删除",
"groupUpdated": "群组已更新",
"groups": "团体",
"host": "主机",
"hostname": "主机名:",
"lastSeen": "上次在线",
-1
View File
@@ -5644,7 +5644,6 @@
"groupCreated": "群組已建立",
"groupDeleted": "群組已刪除",
"groupUpdated": "群組已更新",
"groups": "群組",
"host": "主機",
"hostname": "主機名稱:",
"lastSeen": "最後一次見到",
+201 -81
View File
@@ -18,16 +18,16 @@ import {
import {
DataTable, DataTableFooter, Drawer, Gauge, Pill, SearchField, statusKind,
} from '@/components/ds';
import { useTopbarActions, useTopbarChrome } from '@/hooks/useTopbarActions';
import { useTopbarActions } from '@/hooks/useTopbarActions';
import { useTableSort } from '@/hooks/useTableSort';
import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import { useConfirm } from '@/hooks/useConfirm';
import CopyField from '../components/CopyField';
import {
useTableChrome, GridViewPicker, GridChips, GridFilterButton,
GridToolsMenu, GridFilterDrawer,
useTableChrome, GridViewPicker, GridChips, GridFilterDrawer,
} from '@/components/ds/grid';
import useFocusParam from '@/hooks/useFocusParam';
import { formatBytes } from '@/utils/formatBytes';
import LinkPanelForm from '../components/servers/LinkPanelForm';
import { useTranslation } from 'react-i18next';
import { t } from '../i18n/t';
@@ -51,13 +51,22 @@ const NO_GROUP = '__none';
// NOTE for anyone adding a metric preset: only ever use `gt` on cpu/memory/disk.
// Their sortValue is null for a non-live row, and a `lt` rule would match every
// offline and pending server (see the null guard in ds/grid/fields.js).
// Fields a server HAS but the table does not open with. Everything here is one
// switch away in Filters and fields; the default table shows what you scan a
// fleet for (state, health, load, what it runs, when it last answered).
const DEFAULT_HIDDEN = [
'host', 'ip', 'group', 'level', 'agent', 'os', 'arch', 'cores',
'ram', 'diskTotal', 'docker', 'domains', 'tags', 'added',
];
const hiding = (...extra) => [...DEFAULT_HIDDEN, ...extra];
const STATUS = (...value) => ({ match: 'all', rules: [{ id: 'st', field: 'status', op: 'any', value }] });
const NO_RULES = { match: 'all', rules: [] };
const SERVER_BUILTIN_VIEWS = [
{ name: 'Online', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: STATUS('online') } },
{ name: 'Offline', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: STATUS('offline') } },
{ name: 'By CPU', state: { search: '', sorts: [{ key: 'cpu', direction: 'desc' }], hiddenKeys: [], columnFilters: NO_RULES } },
{ name: 'Online', state: { search: '', sorts: [], hiddenKeys: DEFAULT_HIDDEN, columnFilters: STATUS('online') } },
{ name: 'Offline', state: { search: '', sorts: [], hiddenKeys: DEFAULT_HIDDEN, columnFilters: STATUS('offline') } },
{ name: 'By CPU', state: { search: '', sorts: [{ key: 'cpu', direction: 'desc' }], hiddenKeys: DEFAULT_HIDDEN, columnFilters: NO_RULES } },
{
// Machines that HAVE an agent but stopped answering, longest silence
// first. `pending` is excluded — that means nobody ever installed one.
@@ -67,7 +76,7 @@ const SERVER_BUILTIN_VIEWS = [
state: {
search: '', groupBy: null,
sorts: [{ key: 'lastSeen', direction: 'asc' }],
hiddenKeys: ['cpu', 'memory', 'disk'],
hiddenKeys: hiding('cpu', 'memory', 'disk'),
columnFilters: {
match: 'all',
rules: [{ id: 'nr1', field: 'status', op: 'any', value: ['offline', 'connecting'] }],
@@ -85,7 +94,7 @@ const SERVER_BUILTIN_VIEWS = [
// only ever match a reporting machine.
name: 'Under load',
state: {
search: '', groupBy: null, hiddenKeys: [],
search: '', groupBy: null, hiddenKeys: DEFAULT_HIDDEN,
sorts: [{ key: 'cpu', direction: 'desc' }],
columnFilters: {
match: 'any',
@@ -102,7 +111,7 @@ const SERVER_BUILTIN_VIEWS = [
state: {
search: '', groupBy: null,
sorts: [{ key: 'disk', direction: 'desc' }],
hiddenKeys: ['agent', 'cpu', 'memory'],
hiddenKeys: hiding('cpu', 'memory'),
columnFilters: {
match: 'all',
rules: [
@@ -119,7 +128,8 @@ const SERVER_BUILTIN_VIEWS = [
// not a sentinel — see the `value` accessor on that column.
name: 'Ungrouped',
state: {
search: '', groupBy: null, hiddenKeys: [],
// The Group column is the point of this view, so it shows.
search: '', groupBy: null, hiddenKeys: DEFAULT_HIDDEN.filter((key) => key !== 'group'),
sorts: [{ key: 'name', direction: 'asc' }],
columnFilters: {
match: 'all',
@@ -169,6 +179,56 @@ const meterColumn = (key, header, metricKey) => ({
// Columns for the shared DataTable. Cell markup and classNames are identical
// to the hand-rolled table they replace, so _servers.scss keeps applying
// (.sk-cell-name, .sk-cell-mono, .servers-row__*, .servers-table__meter).
// A count column (services, domains): the number, or a dash for none so a
// column of zeros does not read as data.
const countColumn = (key, header, headerKey, field) => ({
key,
headerKey, header,
sortable: true,
type: 'num',
value: (server) => server[field] ?? 0,
sortValue: (server) => server[field] ?? 0,
width: '96px',
cellClassName: 'sk-cell-dim',
render: (server) => (server[field] ? server[field] : <span className="servers-row__nodata">&mdash;</span>),
});
// A plain text fact about the machine (IP, Docker version): filterable and
// sortable as text, shown in mono.
const factColumn = (key, header, headerKey, read) => ({
key,
headerKey, header,
sortable: true,
type: 'text',
value: (server) => read(server) || '',
sortValue: (server) => read(server) || '',
cellClassName: 'sk-cell-mono',
render: (server) => read(server) || <span className="servers-row__nodata">&mdash;</span>,
});
// A capacity (total memory, total disk): sorts by bytes, reads as a size. Not
// filterable: a rule would have to be typed in bytes.
const capacityColumn = (key, header, headerKey, field) => ({
key,
headerKey, header,
sortable: true,
filterable: false,
sortValue: (server) => server[field] ?? null,
width: '112px',
cellClassName: 'sk-cell-dim',
render: (server) => (server[field]
? formatBytes(server[field])
: <span className="servers-row__nodata">&mdash;</span>),
});
// Columns for the shared DataTable. Cell markup and classNames are identical
// to the hand-rolled table they replace, so _servers.scss keeps applying
// (.sk-cell-name, .sk-cell-mono, .servers-row__*, .servers-table__meter).
//
// Order is the table's default order: what you scan a fleet for first, then
// the facts about each machine. The second half is hidden until asked for
// (DEFAULT_HIDDEN); every field the list endpoint returns about a server is
// here, so "can I see / filter by X" is answered in Filters and fields.
const SERVER_COLUMNS = [
{
key: 'name',
@@ -191,36 +251,6 @@ const SERVER_COLUMNS = [
</div>
),
},
{
key: 'host',
headerKey: 'app.servers.host', header: 'Host',
cellClassName: 'sk-cell-mono',
render: (server) => server.hostname || server.ip_address || '\u2014',
},
{
key: 'agent',
headerKey: 'app.servers.agent', header: 'Agent',
cellClassName: 'sk-cell-dim servers-row__agent',
// The version is a machine value; the "not installed" fallback is words.
render: (server) => (server.agent_version
? <span className="mono">{server.agent_version}</span>
: 'not installed'),
},
{
key: 'group',
headerKey: 'app.servers.group', header: 'Group',
sortable: true,
type: 'enum',
// An ungrouped server needs a real LABEL, not null: the enum engine
// compares String(value), so a null would only ever be matchable as the
// literal string 'null'. This label is what the "Ungrouped" preset
// filters on, and what the column menu lists.
value: (server) => server.group_name || 'Ungrouped',
groupable: true,
render: (server) => (
server.group_name || <span className="servers-row__nodata">{t('app.servers.ungrouped', 'Ungrouped')}</span>
),
},
{
key: 'status',
headerKey: 'common.labels.status', header: 'Status',
@@ -238,6 +268,48 @@ const SERVER_COLUMNS = [
return <Pill kind={statusKind(status)}>{status}</Pill>;
},
},
{
key: 'health',
headerKey: 'app.servers.health', header: 'Health',
sortable: false,
render: (server) => {
const health = serverHealth(server);
const detail = health.failing.length ? ` (${health.failing.join(', ')})` : '';
return (
<Pill kind={health.kind} title={detail || undefined}>
{healthLabel(health.code) + detail}
</Pill>
);
},
},
meterColumn('cpu', 'CPU', 'cpu_percent'),
meterColumn('memory', 'Memory', 'memory_percent'),
meterColumn('disk', 'Disk', 'disk_percent'),
countColumn('services', 'Services', 'common.labels.services', 'services_count'),
countColumn('domains', 'Domains', 'common.labels.domains', 'domains_count'),
{
key: 'lastSeen',
headerKey: 'app.servers.lastSeen', header: 'Last seen',
sortable: true,
sortValue: (server) => (server.last_seen ? new Date(server.last_seen).getTime() : null),
cellClassName: 'sk-cell-dim servers-row__seen',
render: (server) => formatLastSeen(server.last_seen),
},
{
key: 'group',
headerKey: 'app.servers.group', header: 'Group',
sortable: true,
type: 'enum',
// An ungrouped server needs a real LABEL, not null: the enum engine
// compares String(value), so a null would only ever be matchable as the
// literal string 'null'. This label is what the "Ungrouped" preset
// filters on, and what the column menu lists.
value: (server) => server.group_name || 'Ungrouped',
groupable: true,
render: (server) => (
server.group_name || <span className="servers-row__nodata">{t('app.servers.ungrouped', 'Ungrouped')}</span>
),
},
{
key: 'level',
headerKey: 'app.servers.levelColumn', header: 'Level',
@@ -257,29 +329,80 @@ const SERVER_COLUMNS = [
},
},
{
key: 'health',
headerKey: 'app.servers.health', header: 'Health',
sortable: false,
render: (server) => {
const health = serverHealth(server);
const detail = health.failing.length ? ` (${health.failing.join(', ')})` : '';
return (
<Pill kind={health.kind} title={detail || undefined}>
{healthLabel(health.code) + detail}
</Pill>
);
},
key: 'host',
headerKey: 'app.servers.host', header: 'Host',
cellClassName: 'sk-cell-mono',
render: (server) => server.hostname || server.ip_address || '\u2014',
},
meterColumn('cpu', 'CPU', 'cpu_percent'),
meterColumn('memory', 'Memory', 'memory_percent'),
meterColumn('disk', 'Disk', 'disk_percent'),
factColumn('ip', 'IP address', 'common.labels.ipAddress', (server) => server.ip_address),
{
key: 'lastSeen',
headerKey: 'app.servers.lastSeen', header: 'Last seen',
key: 'agent',
headerKey: 'app.servers.agent', header: 'Agent',
sortable: true,
sortValue: (server) => (server.last_seen ? new Date(server.last_seen).getTime() : null),
cellClassName: 'sk-cell-dim servers-row__seen',
render: (server) => formatLastSeen(server.last_seen),
type: 'text',
value: (server) => server.agent_version || 'not installed',
sortValue: (server) => server.agent_version || '',
cellClassName: 'sk-cell-dim servers-row__agent',
// The version is a machine value; the "not installed" fallback is words.
render: (server) => (server.agent_version
? <span className="mono">{server.agent_version}</span>
: 'not installed'),
},
{
key: 'os',
headerKey: 'app.servers.os', header: 'OS',
sortable: true,
type: 'enum',
groupable: true,
value: (server) => server.os_type || 'unknown',
sortValue: (server) => `${server.os_type || ''} ${server.os_version || ''}`.trim(),
cellClassName: 'sk-cell-dim',
render: (server) => [server.os_type, server.os_version].filter(Boolean).join(' ')
|| <span className="servers-row__nodata">&mdash;</span>,
},
{
key: 'arch',
headerKey: 'app.servers.architecture', header: 'Architecture',
sortable: true,
type: 'enum',
groupable: true,
value: (server) => server.architecture || 'unknown',
cellClassName: 'sk-cell-mono',
render: (server) => server.architecture || <span className="servers-row__nodata">&mdash;</span>,
},
{
key: 'cores',
headerKey: 'app.servers.cpuCores', header: 'CPU cores',
sortable: true,
type: 'num',
value: (server) => server.cpu_cores ?? null,
sortValue: (server) => server.cpu_cores ?? null,
width: '104px',
cellClassName: 'sk-cell-dim',
render: (server) => server.cpu_cores || <span className="servers-row__nodata">&mdash;</span>,
},
capacityColumn('ram', 'Total memory', 'app.servers.totalMemory', 'total_memory'),
capacityColumn('diskTotal', 'Total disk', 'app.servers.totalDisk', 'total_disk'),
factColumn('docker', 'Docker', 'common.labels.docker', (server) => server.docker_version),
{
key: 'tags',
headerKey: 'app.servers.tags', header: 'Tags',
sortable: false,
type: 'text',
value: (server) => (server.tags || []).join(', '),
render: (server) => ((server.tags || []).length
? <span className="servers-row__tags">{server.tags.map((tag) => <Pill key={tag} kind="gray" dot={false}>{tag}</Pill>)}</span>
: <span className="servers-row__nodata">&mdash;</span>),
},
{
key: 'added',
headerKey: 'app.servers.added', header: 'Added',
sortable: true,
type: 'date',
value: (server) => (server.created_at || '').slice(0, 10),
sortValue: (server) => (server.created_at ? new Date(server.created_at).getTime() : null),
cellClassName: 'sk-cell-dim',
render: (server) => (server.created_at ? formatDate(server.created_at) : <span className="servers-row__nodata">&mdash;</span>),
},
{
key: 'open',
@@ -312,7 +435,7 @@ const Servers = () => {
const { sorts, setSorts } = useTableSort({ storageKey: 'serverkit-table-servers-sort' });
const {
hiddenKeys, setHiddenKeys,
} = useColumnVisibility({ storageKey: 'serverkit-table-servers-cols' });
} = useColumnVisibility({ storageKey: 'serverkit-table-servers-cols-v2', defaultHidden: DEFAULT_HIDDEN });
const [groupBy, setGroupBy] = useState(() => {
try {
return window.localStorage.getItem('serverkit-table-servers-group') || null;
@@ -381,9 +504,6 @@ const Servers = () => {
// The tab-group top bar owns this page's controls, search included.
useTopbarActions(() => (
<>
<Button variant="outline" size="sm" onClick={() => setShowGroupModal(true)}>
<Folder size={16} /> {t('app.servers.groups', 'Groups')}
</Button>
<Button variant="outline" size="sm" onClick={loadData} disabled={loading} title={t('app.servers.sync', 'Sync')} aria-label={t('app.servers.sync', 'Sync')}>
<RefreshCw size={16} className={loading ? 'spin' : ''} /> {t('app.servers.syncShort', 'Sync')}
</Button>
@@ -411,30 +531,22 @@ const Servers = () => {
setSorts,
hiddenKeys,
setHiddenKeys,
defaultHiddenKeys: DEFAULT_HIDDEN,
groupBy,
setGroupBy: changeGroupBy,
pageState: viewPageState,
applyPage: applyViewPageState,
});
// Filter + "⋮" ride in the top bar next to the actions and the search box,
// not in a toolbar under the view name. That toolbar was also repeating the
// row count the view row already showed, with an "N online" tacked on that
// no filter, sort or view ever referred to.
const { portal: topbarChrome, actions: chromeActions } = useTopbarChrome(
<>
<GridFilterButton
count={chrome.filterCount}
onClick={() => chrome.setDrawerOpen(true)}
/>
<GridToolsMenu {...chrome.toolsProps} onRefresh={loadData} />
</>,
);
// Filters, the table tools and group management all live in the view
// selector's menu. The top bar keeps what creates or reloads (Sync, Add)
// and search; three more icons there said nothing a menu under the view's
// own name does not say better.
const hiddenFieldCount = SERVER_COLUMNS.filter((column) => column.header && hiddenKeys.includes(column.key)).length;
if (loading) {
return (
<div className="sk-tabgroup__inner servers-page">
{topbarChrome}
<EmptyState loading loadingVariant="table" title={t('app.servers.scanningFleet', 'Scanning fleet…')} />
</div>
);
@@ -442,13 +554,21 @@ const Servers = () => {
return (
<div className="sk-tabgroup__inner servers-page" data-walkthrough="server-list">
{topbarChrome}
<GridViewPicker
views={chrome.views}
label="servers"
onCreate={chrome.createView}
actions={chromeActions}
filters={{
count: chrome.filterCount,
hidden: hiddenFieldCount,
onOpen: () => chrome.setDrawerOpen(true),
}}
tools={chrome.toolsProps}
extra={[{
icon: Folder,
label: t('app.servers.manageGroups', 'Manage groups'),
onSelect: () => setShowGroupModal(true),
}]}
/>
<GridChips {...chrome.chipProps} />
@@ -874,6 +874,35 @@
&__sp { flex: 1; }
}
// Field search at the top of the Fields pane.
.sk-gridfind {
display: flex;
align-items: center;
gap: $space-2;
margin: $space-4 $space-5 0;
padding: 0 $space-3;
height: $control-md;
border: 1px solid var(--border);
border-radius: $radius-control;
background: var(--surface-2);
color: var(--text-ghost);
&:focus-within { border-color: var(--accent-dim); box-shadow: $focus-ring; }
input {
flex: 1;
min-width: 0;
border: 0;
outline: none;
background: transparent;
color: var(--text);
font-size: $text-sm;
font-family: inherit;
&::placeholder { color: var(--text-ghost); }
}
}
// Empty filters pane: what is showing, and one tap to start narrowing it.
.sk-gridstart {
display: flex;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 33 KiB