ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
refactor(list): drop the status segments on Services, Workspaces and Servers
Juan Denise0a175809436
diff --git a/frontend/src/components/layouts/ResourceListPage.jsx b/frontend/src/components/layouts/ResourceListPage.jsxindex 3eade819..b452dbd7 100644--- a/frontend/src/components/layouts/ResourceListPage.jsx+++ b/frontend/src/components/layouts/ResourceListPage.jsx@@ -25,7 +25,6 @@ import { useColumnVisibility } from '@/hooks/useColumnVisibility';// columns={columns} keyField="id" // columns opt into sorting with `sortable: true`// onRowClick={app => navigate(...)} rowClassName={rowClassName}// storageKey="serverkit-list-services" // optional: persist sort/columns/page-size-// filters={[{ value, label, count }]} activeFilter={statusFilter} onFilterChange={setStatusFilter}// searchTerm={searchTerm} onSearchChange={setSearchTerm} searchPlaceholder="Search services…"// selectedCount={selectedIds.size} onClearSelection={clear} bulkActions={<>…</>}// emptyIcon={Layers} emptyTitle="…" emptyDescription="…" emptyAction={<Button…/>}@@ -48,8 +47,10 @@ export default function ResourceListPage({// Optional localStorage namespace for sort / column / page-size choices.storageKey,// Saved views: pass the page's view key (e.g. 'services') plus any built-in- // views to grow a Views menu in the toolbar. A view state is- // { filter, search, sorts, hiddenKeys, pageSize } — all keys optional.+ // views to grow the heading view picker. A view state is the shared+ // envelope — { sorts, hiddenKeys, columnOrder, groupBy, columnFilters,+ // page } — where this wrapper's `page` bag is { filter, search, pageSize }.+ // See components/ds/grid/viewState.js.viewPageKey,builtinViews = [],// Plural label used by the view picker, footer and export filename.@@ -58,6 +59,14 @@ export default function ResourceListPage({// state (e.g. a one-time credentials banner)header,// toolbar+ // DEPRECATED — the status segment row. No core page passes these any more:+ // a fixed bucket row is a second, weaker way to narrow rows next to the+ // column's own menu, which combines, shows live per-value counts and can be+ // saved into a view. Express it as a `columnFilters` rule instead.+ //+ // Still accepted because this component is SDK surface (plugins/sdk exports+ // it, which pins its props as contract), so an extension may still be+ // passing them. Remove on the next SDK major.filters,activeFilter,onFilterChange,diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsxindex 69b309aa..93e973e9 100644--- a/frontend/src/pages/Servers.jsx+++ b/frontend/src/pages/Servers.jsx@@ -8,7 +8,7 @@ import Modal from '@/components/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import {- DataTable, DataTableFooter, Drawer, Gauge, ListToolbar, Pill, SearchField, SegControl,+ DataTable, DataTableFooter, Drawer, Gauge, ListToolbar, Pill, SearchField,} from '@/components/ds';import { useTopbarActions } from '@/hooks/useTopbarActions';import { useTableSort } from '@/hooks/useTableSort';@@ -30,17 +30,21 @@ const STATUS_KIND = {pending: 'gray',};-const STATUS_FILTERS = ['all', 'online', 'offline', 'connecting', 'pending'];--// Built-in saved views. States only use real SegControl values-// (STATUS_FILTERS), group values ('all') and column keys (SERVER_COLUMNS).+// Built-in saved views. States only use real column keys (SERVER_COLUMNS) —+// there is no separate status segment or group select any more; the Status and+// Group columns' own menus are the one place the fleet is narrowed, and they+// carry live per-value counts neither control had.+//// 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).+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: { status: 'online', group: 'all', search: '', sorts: [], hiddenKeys: [] } },- { name: 'Offline', state: { status: 'offline', group: 'all', search: '', sorts: [], hiddenKeys: [] } },- { name: 'By CPU', state: { status: 'all', group: 'all', search: '', sorts: [{ key: 'cpu', direction: 'desc' }], hiddenKeys: [] } },+ { 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 } },{// Machines that HAVE an agent but stopped answering, longest silence// first. `pending` is excluded — that means nobody ever installed one.@@ -48,7 +52,7 @@ const SERVER_BUILTIN_VIEWS = [// would render an em-dash.name: 'Not reporting',state: {- status: 'all', group: 'all', search: '', groupBy: null,+ search: '', groupBy: null,sorts: [{ key: 'lastSeen', direction: 'asc' }],hiddenKeys: ['cpu', 'memory', 'disk'],columnFilters: {@@ -60,9 +64,15 @@ const SERVER_BUILTIN_VIEWS = [{// Saturated on EITHER axis — a box swapping at 95% memory with calm CPU// is the one that falls over, so match:any rather than all.+ //+ // No `status is online` rule here, deliberately: `match` is per VIEW,+ // not per rule, so adding one to an `any` list would OR it in and widen+ // the view to every online server. It is not needed — the metrics are+ // null on a non-live row and `gt` rejects null, so both rules already+ // only ever match a reporting machine.name: 'Under load',state: {- status: 'online', group: 'all', search: '', groupBy: null, hiddenKeys: [],+ search: '', groupBy: null, hiddenKeys: [],sorts: [{ key: 'cpu', direction: 'desc' }],columnFilters: {match: 'any',@@ -77,23 +87,31 @@ const SERVER_BUILTIN_VIEWS = [// The one fleet metric that never recovers on its own.name: 'Disk pressure',state: {- status: 'online', group: 'all', search: '', groupBy: null,+ search: '', groupBy: null,sorts: [{ key: 'disk', direction: 'desc' }],hiddenKeys: ['agent', 'cpu', 'memory'],columnFilters: {match: 'all',- rules: [{ id: 'dp1', field: 'disk', op: 'gt', value: 85 }],+ rules: [+ { id: 'dp0', field: 'status', op: 'any', value: ['online'] },+ { id: 'dp1', field: 'disk', op: 'gt', value: 85 },+ ],},},},{// Fleet commands target a group_id, so an ungrouped server is silently// skipped by every bulk action. This view is the worklist that fixes it.+ // 'Ungrouped' is the Group column's own label for a null group_name,+ // not a sentinel — see the `value` accessor on that column.name: 'Ungrouped',state: {- status: 'all', group: 'ungrouped', search: '', groupBy: null, hiddenKeys: [],+ search: '', groupBy: null, hiddenKeys: [],sorts: [{ key: 'name', direction: 'asc' }],- columnFilters: { match: 'all', rules: [] },+ columnFilters: {+ match: 'all',+ rules: [{ id: 'ug1', field: 'group', op: 'any', value: ['Ungrouped'] }],+ },},},];@@ -171,10 +189,30 @@ const SERVER_COLUMNS = [cellClassName: 'sk-cell-mono servers-row__agent',render: (server) => server.agent_version || 'not installed',},+ {+ key: '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">Ungrouped</span>+ ),+ },{key: 'status',header: 'Status',sortable: true,+ type: 'enum',+ // Explicit, rather than leaning on the sortValue fallback: this pins+ // the null -> 'pending' coercion as the FILTER value too, so a server+ // that never reported does not stringify to 'null' in a rule.+ value: (server) => server.status || 'pending',sortValue: (server) => server.status || 'pending',groupable: true,groupLabel: (value) => (value ? value.charAt(0).toUpperCase() + value.slice(1) : 'None'),@@ -217,8 +255,6 @@ const Servers = () => {// Quick-create deep link: /servers?focus=create:server opens the add modal.useFocusParam('create', () => setShowAddModal(true));const [showGroupModal, setShowGroupModal] = useState(false);- const [selectedGroup, setSelectedGroup] = useState('all');- const [selectedStatus, setSelectedStatus] = useState('all');const [searchTerm, setSearchTerm] = useState('');const [selectedIds, setSelectedIds] = useState(new Set());const [bulkBusy, setBulkBusy] = useState(false);@@ -245,18 +281,12 @@ const Servers = () => {}};- // Page-owned view state (the status segment, the group select, search);- // useTableChrome owns the rest — sorts, hidden columns, grouping, column- // rules and order — and gives back the shared list chrome.- const viewPageState = useMemo(() => ({- status: selectedStatus,- group: selectedGroup,- search: searchTerm,- }), [selectedStatus, selectedGroup, searchTerm]);+ // Page-owned view state — search is all that is left. Status and group used+ // to live here too, as a segment row and a select; both are column rules+ // now, which useTableChrome captures itself.+ const viewPageState = useMemo(() => ({ search: searchTerm }), [searchTerm]);const applyViewPageState = useCallback((saved) => {- if (saved.status !== undefined) setSelectedStatus(saved.status);- if (saved.group !== undefined) setSelectedGroup(saved.group);if (saved.search !== undefined) setSearchTerm(saved.search);}, []);@@ -282,24 +312,15 @@ const Servers = () => {}, [loadData]);const filteredServers = servers.filter((server) => {- const matchesGroup = selectedGroup === 'all'- || (selectedGroup === 'ungrouped' && !server.group_id)- || String(server.group_id) === String(selectedGroup);- const matchesStatus = selectedStatus === 'all' || server.status === selectedStatus;const q = searchTerm.trim().toLowerCase();- const matchesSearch = !q+ return !q|| server.name?.toLowerCase().includes(q)|| server.hostname?.toLowerCase().includes(q)|| server.ip_address?.toLowerCase().includes(q)|| server.group_name?.toLowerCase().includes(q);- return matchesGroup && matchesStatus && matchesSearch;});const online = servers.filter((s) => s.status === 'online').length;- const statusCounts = servers.reduce((acc, server) => {- acc[server.status] = (acc[server.status] || 0) + 1;- return acc;- }, {});// The tab-group top bar owns this page's controls, search included.useTopbarActions(() => (@@ -354,18 +375,6 @@ const Servers = () => {onCreate={chrome.createView}/><ListToolbar- filters={(- <SegControl- value={selectedStatus}- onChange={setSelectedStatus}- options={STATUS_FILTERS.map((key) => ({- value: key,- label: key === 'all' ? 'All' : key.charAt(0).toUpperCase() + key.slice(1),- count: key === 'all' ? servers.length : (statusCounts[key] || 0),- }))}- aria-label="Filter by status"- />- )}count={(<>{filteredServers.length} of {servers.length} server{servers.length === 1 ? '' : 's'}@@ -382,20 +391,7 @@ const Servers = () => {<GridToolsMenu {...chrome.toolsProps} onRefresh={loadData} /></>)}- >- {groups.length > 0 && (- <select- className="sk-listhead__select"- value={selectedGroup}- onChange={(e) => setSelectedGroup(e.target.value)}- aria-label="Filter by group"- >- <option value="all">All groups</option>- {groups.map((g) => <option key={g.id} value={g.id}>{g.name}</option>)}- <option value="ungrouped">Ungrouped</option>- </select>- )}- </ListToolbar>+ /><GridChips {...chrome.chipProps} />@@ -405,7 +401,7 @@ const Servers = () => {title={servers.length === 0 ? 'No servers yet' : 'No servers match these filters'}description={servers.length === 0? 'Pair an agent and the machine shows up here with its CPU, memory and disk alongside every other box you run.'- : 'Adjust the status, group or search to see your servers.'}+ : 'Adjust the search or clear the column filters to see your servers.'}action={servers.length === 0 ? (<Button onClick={() => setShowAddModal(true)}><Plus size={16} /> Add your first server@@ -414,9 +410,8 @@ const Servers = () => {<Buttonvariant="outline"onClick={() => {- setSelectedGroup('all');- setSelectedStatus('all');setSearchTerm('');+ chrome.api.resetToView();}}>Clear filtersdiff --git a/frontend/src/pages/Services.jsx b/frontend/src/pages/Services.jsxindex ec50e0c3..2ba64c90 100644--- a/frontend/src/pages/Services.jsx+++ b/frontend/src/pages/Services.jsx@@ -33,13 +33,30 @@ const NO_ENV = '__no_env__';// Preset views: the questions people open this page to answer. Each is a// snapshot of the same chrome state a personal view saves, so any of them can// be tweaked and re-saved under a new name.+//+// `status` values are the RAW statuses the column's `value` accessor returns+// (running · deploying · building · stopped · failed) — NOT the pill labels,+// which are prettified by getStatusConfig(). There is no separate status+// segment any more: the Status column's own menu is the one place services are+// narrowed by state, and it carries live per-value counts the segment never had.+const RULES = (...value) => ({ match: 'all', rules: [{ id: 'st', field: 'status', op: 'any', value }] });+const NO_RULES = { match: 'all', rules: [] };+const SERVICE_VIEWS = [- { name: 'Running', state: { filter: 'running', search: '', sorts: [], hiddenKeys: [] } },- { name: 'Stopped', state: { filter: 'stopped', search: '', sorts: [], hiddenKeys: [] } },+ { name: 'Running', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: RULES('running') } },+ {+ // The old segment meant "not running", so it also swallowed failed,+ // deploying and building. Keep that meaning rather than narrowing it.+ name: 'Stopped',+ state: {+ search: '', sorts: [], hiddenKeys: [],+ columnFilters: { match: 'all', rules: [{ id: 'st', field: 'status', op: 'none', value: ['running'] }] },+ },+ },{name: 'Recently deployed',state: {- filter: 'all', search: '', hiddenKeys: [],+ search: '', hiddenKeys: [], columnFilters: NO_RULES,sorts: [{ key: 'last_deploy', direction: 'desc' }],},},@@ -47,7 +64,7 @@ const SERVICE_VIEWS = [// Anything not cleanly live — the triage list during an incident.name: 'Broken or unknown',state: {- filter: 'all', search: '', hiddenKeys: ['bandwidth'], groupBy: null,+ search: '', hiddenKeys: ['bandwidth'], groupBy: null,sorts: [{ key: 'status', direction: 'desc' }, { key: 'name', direction: 'asc' }],columnFilters: {match: 'any',@@ -59,16 +76,16 @@ const SERVICE_VIEWS = [// Live, but nobody has shipped to it in a long time.name: 'Stale live services',state: {- filter: 'running', search: '', hiddenKeys: ['source', 'bandwidth'], groupBy: null,+ search: '', hiddenKeys: ['source', 'bandwidth'], groupBy: null,sorts: [{ key: 'last_deploy', direction: 'asc' }],- columnFilters: { match: 'all', rules: [] },+ columnFilters: RULES('running'),},},{// Deployed by hand or by upload — the ones with no git history to roll back to.name: 'Not git-deployed',state: {- filter: 'all', search: '', hiddenKeys: ['bandwidth'], groupBy: null,+ search: '', hiddenKeys: ['bandwidth'], groupBy: null,sorts: [{ key: 'name', direction: 'asc' }],columnFilters: {match: 'all',@@ -79,9 +96,9 @@ const SERVICE_VIEWS = [{name: 'By project',state: {- filter: 'all', search: '', hiddenKeys: ['source', 'bandwidth'], groupBy: 'project',+ search: '', hiddenKeys: ['source', 'bandwidth'], groupBy: 'project',sorts: [{ key: 'status', direction: 'asc' }, { key: 'name', direction: 'asc' }],- columnFilters: { match: 'all', rules: [] },+ columnFilters: NO_RULES,},},];@@ -92,7 +109,6 @@ const Services = () => {const [apps, setApps] = useState([]);const [loading, setLoading] = useState(true);const [searchTerm, setSearchTerm] = useState('');- const [statusFilter, setStatusFilter] = useState('all');const [actionLoading, setActionLoading] = useState(null);const [selectedIds, setSelectedIds] = useState(new Set());const [bulkLoading, setBulkLoading] = useState(false);@@ -157,17 +173,11 @@ const Services = () => {const filteredApps = useMemo(() => {const q = searchTerm.trim().toLowerCase();return apps- .filter(app => {- if (statusFilter !== 'all' && (statusFilter === 'running' ? app.status !== 'running' : app.status === 'running')) return false;- if (q && !app.name.toLowerCase().includes(q)) return false;- return true;- })+ .filter(app => !q || app.name.toLowerCase().includes(q)).sort((a, b) => {return (STATUS_SORT_ORDER[a.status] ?? 5) - (STATUS_SORT_ORDER[b.status] ?? 5) || a.name.localeCompare(b.name);});- }, [apps, searchTerm, statusFilter]);-- const runningCount = useMemo(() => apps.filter(a => a.status === 'running').length, [apps]);+ }, [apps, searchTerm]);useTopbarActions(() =><>@@ -384,13 +394,6 @@ const Services = () => {selectedIds={selectedIds}onToggleSelect={toggleOne}onSelectAll={(checked) => setSelectedIds(checked ? new Set(filteredApps.map(a => a.id)) : new Set())}- filters={[- { value: 'all', label: 'All', count: apps.length },- { value: 'running', label: 'Running', count: runningCount },- { value: 'stopped', label: 'Stopped', count: apps.length - runningCount },- ]}- activeFilter={statusFilter}- onFilterChange={setStatusFilter}selectedCount={selectedIds.size}onClearSelection={() => setSelectedIds(new Set())}bulkActions={diff --git a/frontend/src/pages/Workspaces.jsx b/frontend/src/pages/Workspaces.jsxindex c85a10b6..b4bd852e 100644--- a/frontend/src/pages/Workspaces.jsx+++ b/frontend/src/pages/Workspaces.jsx@@ -15,15 +15,34 @@ import { Textarea } from '@/components/ui/textarea';// Matches WorkspaceSwitcher: the active workspace id lives in localStorage.const ACTIVE_KEY = 'active_workspace_id';-// Preset views. Only three: `servers` and `users` are quota CEILINGS, not-// usage, so there is no column to express "near capacity" against.+// Preset views. `servers` and `users` are quota CEILINGS, not usage, so there+// is no column to express "near capacity" against.+//+// `status` values are the RAW ws.status the column's `value` accessor returns.+// The old "Inactive" segment meant `!== 'active'`, not literally 'inactive', so+// it translates to `is none of [active]` rather than `is any of [inactive]` —+// otherwise workspaces in any other state would silently drop out of the view.+// There is no separate status segment any more: the Status column's own menu is+// the one place workspaces are narrowed by state.+const NOT_ACTIVE = { id: 'st', field: 'status', op: 'none', value: ['active'] };+const NO_RULES = { match: 'all', rules: [] };+const WORKSPACE_VIEWS = [- { name: 'Active', state: { filter: 'active', search: '', sorts: [], hiddenKeys: [] } },- { name: 'Inactive', state: { filter: 'inactive', search: '', sorts: [], hiddenKeys: [] } },+ {+ name: 'Active',+ state: {+ search: '', sorts: [], hiddenKeys: [],+ columnFilters: { match: 'all', rules: [{ id: 'st', field: 'status', op: 'any', value: ['active'] }] },+ },+ },+ {+ name: 'Inactive',+ state: { search: '', sorts: [], hiddenKeys: [], columnFilters: { match: 'all', rules: [NOT_ACTIVE] } },+ },{name: 'Most members',state: {- filter: 'all', search: '', hiddenKeys: [],+ search: '', hiddenKeys: [], columnFilters: NO_RULES,sorts: [{ key: 'members', direction: 'desc' }],},},@@ -31,7 +50,7 @@ const WORKSPACE_VIEWS = [// Created and then never staffed — candidates to archive.name: 'Empty workspaces',state: {- filter: 'all', search: '', hiddenKeys: ['servers', 'users'], groupBy: null,+ search: '', hiddenKeys: ['servers', 'users'], groupBy: null,sorts: [{ key: 'name', direction: 'asc' }],columnFilters: {match: 'all',@@ -43,11 +62,11 @@ const WORKSPACE_VIEWS = [// Deactivated but people are still attached — access that outlived the workspace.name: 'Archived but still staffed',state: {- filter: 'inactive', search: '', hiddenKeys: ['servers', 'users'], groupBy: null,+ search: '', hiddenKeys: ['servers', 'users'], groupBy: null,sorts: [{ key: 'members', direction: 'desc' }],columnFilters: {match: 'all',- rules: [{ id: 'as1', field: 'members', op: 'gt', value: 0 }],+ rules: [NOT_ACTIVE, { id: 'as1', field: 'members', op: 'gt', value: 0 }],},},},@@ -67,7 +86,6 @@ const Workspaces = () => {const navigate = useNavigate();const [workspaces, setWorkspaces] = useState([]);const [loading, setLoading] = useState(true);- const [statusFilter, setStatusFilter] = useState('all'); // all | active | inactiveconst [search, setSearch] = useState('');const [selectedIds, setSelectedIds] = useState(new Set());const [showCreateModal, setShowCreateModal] = useState(false);@@ -117,15 +135,10 @@ const Workspaces = () => {};const q = search.trim().toLowerCase();- const shownWorkspaces = workspaces.filter(ws => {- const matchesStatus = statusFilter === 'all'- || (statusFilter === 'active' ? ws.status === 'active' : ws.status !== 'active');- const matchesSearch = q === '' || [ws.name, ws.slug, ws.description]- .some(v => v && String(v).toLowerCase().includes(q));- return matchesStatus && matchesSearch;- });-- const activeCount = workspaces.filter(ws => ws.status === 'active').length;+ const shownWorkspaces = workspaces.filter(ws => (+ q === '' || [ws.name, ws.slug, ws.description]+ .some(v => v && String(v).toLowerCase().includes(q))+ ));const toggleOne = (id, checked) => {setSelectedIds(prev => {@@ -173,6 +186,14 @@ const Workspaces = () => {key: 'status',header: 'Status',sortable: true,+ type: 'enum',+ // `value` is the FILTER value, `sortValue` is the ORDERING key, and+ // here they are different things — so the column has to say so.+ // Without an explicit `value` the rule engine falls back to+ // sortValue, sees 0/1, types the column `num`, and offers "is under+ // / is over" instead of a pick-list; a `status is any of [active]`+ // rule would then match nothing at all.+ value: (ws) => ws.status || 'unknown',// Matches the pill: the active workspace (and active status) first.sortValue: (ws) => (activeId === String(ws.id) || ws.status === 'active' ? 0 : 1),groupable: true,@@ -212,13 +233,6 @@ const Workspaces = () => {selectedIds={selectedIds}onToggleSelect={toggleOne}onSelectAll={(checked) => setSelectedIds(checked ? new Set(shownWorkspaces.map(ws => ws.id)) : new Set())}- filters={[- { value: 'all', label: 'All', count: workspaces.length },- { value: 'active', label: 'Active', count: activeCount },- { value: 'inactive', label: 'Inactive', count: workspaces.length - activeCount },- ]}- activeFilter={statusFilter}- onFilterChange={setStatusFilter}searchTerm={search}onSearchChange={setSearch}searchPlaceholder="Search workspaces…"