diff --git a/VERSION b/VERSION index 3a41d7db..0dce36ba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.41 +1.11.42 diff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.py index fb2949b5..c7fefa90 100644 --- a/backend/app/services/dashboard_service.py +++ b/backend/app/services/dashboard_service.py @@ -52,13 +52,14 @@ MAX_WIDGETS_PER_BOARD = 100 # A board can also hold the Overview layout a user saved for a page: one kind # of detail page (every server page shares the user's server layout, the # page's own server being the board's variable) or a single overview page -# (Monitoring, Backups). It is an ordinary board row whose slug names the +# (Monitoring, Backups, Security). It is an ordinary board row whose slug names the # page, so it reuses the same storage, validation and ownership rules; it is # just never listed among the dashboard tabs. ENTITY_SCOPE_PREFIX = 'entity:' ENTITY_SCOPES = ( 'entity:server', 'entity:service', - 'entity:monitoring', 'entity:backups', + 'entity:workspace', + 'entity:monitoring', 'entity:backups', 'entity:security', ) diff --git a/backend/tests/test_dashboards.py b/backend/tests/test_dashboards.py index 6cc9ba81..64dc127d 100644 --- a/backend/tests/test_dashboards.py +++ b/backend/tests/test_dashboards.py @@ -486,7 +486,8 @@ def test_overview_layout_is_stored_but_is_not_a_dashboard_tab(client, auth_heade @pytest.mark.parametrize('scope', [ - 'entity:server', 'entity:service', 'entity:monitoring', 'entity:backups', + 'entity:server', 'entity:service', 'entity:workspace', + 'entity:monitoring', 'entity:backups', 'entity:security', ]) def test_overview_layout_is_empty_until_saved(client, auth_headers, scope): resp = client.get(f'/api/v1/dashboards?scope={scope}', headers=auth_headers) diff --git a/docs/MIGRATION_INVENTORY.md b/docs/MIGRATION_INVENTORY.md index aa1e02b0..951bc903 100644 --- a/docs/MIGRATION_INVENTORY.md +++ b/docs/MIGRATION_INVENTORY.md @@ -19,7 +19,7 @@ debt. Regenerate with `python scripts/generate-migration-inventory.py`. | Hand-shaped {'error': ...} bodies in app/api | typed errors + the global handler | 849 | 850 | migrate when touched; new endpoints raise | | Raw subprocess calls outside the runners | app/utils/system.py runners | 23 | 23 | migrate when touched | | Controller-boundary violations (routes doing service work) | service layer extraction | 453 | 453 | migrate when touched (first-wave ratchet) | -| raw api.* calls in pages/ | E1: useServerQuery/useServerMutation | 371 | 371 | migrate when touched | +| raw api.* calls in pages/ | E1: useServerQuery/useServerMutation | 363 | 371 | migrate when touched | | per-page toast.error extractions in pages/ | E1: query-layer error presentation | 185 | 206 | migrate when touched | | hand-rolled form-group blocks | F2: FormField/useForm | 206 | 206 | migrate when touched | | unencoded ?k=${v} query interpolations in services/api | C4: buildQuery/encoding template | 0 | 0 | INVARIANT at 0 | diff --git a/frontend/package.json b/frontend/package.json index dbf34cc8..4f8a131c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,7 +9,7 @@ "test": "node --test", "test:browser": "node scripts/settings-browser.mjs", "test:settings-ui": "node scripts/settings-ui-browser.mjs", - "lint": "node scripts/lint.mjs && node scripts/check-font-integrity.mjs && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-shared-fields.mjs && node scripts/check-tables.mjs && node scripts/check-type-scale.mjs && node scripts/check-geometry.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs && node scripts/check-orphan-files.mjs && node scripts/check-label-association.mjs", + "lint": "node scripts/lint.mjs && node scripts/check-font-integrity.mjs && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-shared-fields.mjs && node scripts/check-tables.mjs && node scripts/check-list-chrome.mjs && node scripts/check-type-scale.mjs && node scripts/check-geometry.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs && node scripts/check-orphan-files.mjs && node scripts/check-label-association.mjs", "lint:baseline": "node scripts/lint.mjs --update", "test:layout": "node scripts/layout-screenshots-browser.mjs", "test:controls": "node scripts/controls-browser.mjs", @@ -27,6 +27,7 @@ "lint:fonts": "node scripts/check-font-integrity.mjs", "lint:status": "node scripts/check-status-one-door.mjs", "lint:shared-fields": "node scripts/check-shared-fields.mjs", + "lint:list-chrome": "node scripts/check-list-chrome.mjs", "lint:type-scale": "node scripts/check-type-scale.mjs", "lint:geometry": "node scripts/check-geometry.mjs", "lint:i18n": "node scripts/check-i18n-literals.mjs", diff --git a/frontend/scripts/check-list-chrome.mjs b/frontend/scripts/check-list-chrome.mjs new file mode 100644 index 00000000..6dfb0cff --- /dev/null +++ b/frontend/scripts/check-list-chrome.mjs @@ -0,0 +1,148 @@ +#!/usr/bin/env node +// One list-page shell. Every page with a table puts its controls in the same +// places, so the create button and the search box never move between pages: +// +// top bar [secondary …] [create] [search] (ds/ListActions) +// view selector saved views · filters and fields · copy link / export / +// reset · page extras (GridViewPicker) +// +// Fails when a page: +// +// - renders a filter icon or a "⋮" tools menu of its own (they are entries in +// the view selector's menu: ``), +// - hoists table controls into the top bar with useTopbarChrome, +// - puts a filter button in the top bar, or orders the bar differently +// (create after search, anything after search), +// - adds a KPI strip to a page that is not an overview. +// +// The allowlists are the known exceptions, each with its reason. They may only +// shrink. Extension copies under src/plugins/ are out of scope. + +import { readFileSync, readdirSync, statSync } from 'node:fs'; +import { join, relative, sep } from 'node:path'; + +const SRC = new URL('../src', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1'); + +// Files that may render / . +const CHROME_OWNERS = new Set([ + // A table with no saved views has no selector to hold them (SDK surface). + 'components/layouts/ResourceListPage.jsx', + // Living documentation of the primitives. + 'pages/StyleGuide.jsx', +]); + +// Files that may call useTopbarChrome. +const TOPBAR_CHROME_USERS = new Set([ + 'hooks/useTopbarActions.js', + // A workspace, not a table: its view switch and path tools ride the bar. + 'pages/FileManager.jsx', +]); + +// Top bars that keep a filter button: card catalogues with no view selector. +const TOPBAR_FILTER_USERS = new Set([ + 'pages/Marketplace.jsx', +]); + +// Overview surfaces: the only places a KPI strip belongs. A list of records +// gets none — its counts are the table footer and the saved views. +const KPI_OWNERS = new Set([ + 'components/ds/KpiBand.jsx', + 'pages/StyleGuide.jsx', + 'components/backups/ProtectionStatusCard.jsx', + 'pages/Monitoring.jsx', + // The agent fleet's Dashboard tab and the FTP server's status block. + 'pages/AgentFleet.jsx', + 'pages/FTPServer.jsx', + // Detail pages; they move to the shared detail header with the rest. + 'pages/MonitorDetail.jsx', + 'pages/QueueDetail.jsx', +]); + +function* walk(dir) { + for (const name of readdirSync(dir)) { + const p = join(dir, name); + if (statSync(p).isDirectory()) { + if (name === 'node_modules' || name === '__tests__' || name === 'plugins') continue; + yield* walk(p); + } else if (/\.jsx?$/.test(name)) { + yield p; + } + } +} + +function stripComments(src) { + return src + .replace(/\{\/\*[\s\S]*?\*\/\}/g, (m) => m.replace(/[^\n]/g, ' ')) + .replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' ')) + .replace(/(^|[^:'"`])\/\/.*$/gm, (m, lead) => lead + ' '.repeat(m.length - lead.length)); +} + +// The balanced (...) argument list of the call that starts at `from`. +function callBlock(src, from) { + const start = src.indexOf('(', from); + let depth = 0; + for (let i = start; i < src.length; i += 1) { + if (src[i] === '(') depth += 1; + else if (src[i] === ')') { + depth -= 1; + if (depth === 0) return src.slice(start, i + 1); + } + } + return ''; +} + +const lineOf = (src, index) => src.slice(0, index).split('\n').length; + +const problems = []; +for (const file of walk(SRC)) { + const rel = relative(SRC, file).split(sep).join('/'); + const src = stripComments(readFileSync(file, 'utf8')); + const inGrid = rel.startsWith('components/ds/grid/'); + + if (!inGrid && !CHROME_OWNERS.has(rel)) { + for (const m of src.matchAll(/<(GridFilterButton|GridToolsMenu)\b/g)) { + problems.push(`${rel}:${lineOf(src, m.index)} <${m[1]}> — fold it into the view selector: `); + } + } + + if (!TOPBAR_CHROME_USERS.has(rel)) { + for (const m of src.matchAll(/(? — KPI strips belong to overview surfaces, not list pages`); + } + } + + if (rel === 'hooks/useTopbarActions.js') continue; + for (const m of src.matchAll(/(?').slice(1)) { + const search = part.indexOf(' { useTopbarChrome). No count on it — the footer reports that, under the rows it is counting. */} { onSearch={setSearch} placeholder={t('app.environmentVariables.searchKeysOrDescriptions', 'Search keys or descriptions…')} /> - chrome.setDrawerOpen(true)} - /> - )} /> diff --git a/frontend/src/components/ProcessTable.jsx b/frontend/src/components/ProcessTable.jsx index c4b699a5..bb2e99ba 100644 --- a/frontend/src/components/ProcessTable.jsx +++ b/frontend/src/components/ProcessTable.jsx @@ -6,8 +6,7 @@ import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { DataTable, DataTableFooter, SearchField } from '@/components/ds'; import { - useTableChrome, GridViewPicker, GridChips, GridFilterButton, - GridToolsMenu, GridFilterDrawer, + useTableChrome, GridViewPicker, GridChips, GridFilterDrawer, } from '@/components/ds/grid'; import { useTableSort } from '@/hooks/useTableSort'; import { useColumnVisibility } from '@/hooks/useColumnVisibility'; @@ -298,9 +297,9 @@ export function ProcessTable({ {/* One row of chrome: the view name is the heading, and search, the host's own controls, the filter button and the "⋮" ride it. */} {actions} - chrome.setDrawerOpen(true)} - /> - )} /> diff --git a/frontend/src/components/backups/BackupsOverview.jsx b/frontend/src/components/backups/BackupsOverview.jsx index b1ba0e59..0695d360 100644 --- a/frontend/src/components/backups/BackupsOverview.jsx +++ b/frontend/src/components/backups/BackupsOverview.jsx @@ -7,7 +7,7 @@ import { } from 'lucide-react'; import api from '../../services/api'; import { formatBytes } from '@/utils/formatBytes'; -import { KpiBand, MetricCard, Pill, DataTable, DataTableFooter } from '@/components/ds'; +import { MetricCard, Pill, DataTable, DataTableFooter } from '@/components/ds'; import EmptyState from '../EmptyState'; import InfoTip from '../InfoTip'; import { OverviewBoard, OverviewSection } from '@/components/detail/OverviewBoard'; @@ -103,6 +103,8 @@ const LATEST_COLUMNS = [ // "is my data safe?", not "show me every file". // Dashboard widget types the Backups overview can carry besides its blocks. const BACKUPS_WIDGET_TYPES = ['note']; +// Board rows a KPI tile takes: value, label and its sub line. +const KPI_TILE_ROWS = 3; export default function BackupsOverview({ stats, storageConfig, costSummary, schedules = [], backups = [], onGo, storageWarning = false, @@ -259,8 +261,9 @@ export default function BackupsOverview({ return (
- - + {/* One block per KPI: each is its own tile on the board, never a + section holding a strip of them. */} + } @@ -271,6 +274,8 @@ export default function BackupsOverview({ {protection.detail || t('app.backupsOverview.fromTheBackupArchive', 'from the backup archive')}
+ + } @@ -281,6 +286,8 @@ export default function BackupsOverview({ {t('app.backupsOverview.acrossDestinations', { count: destinations.count, defaultValue_one: 'across 1 destination', defaultValue_other: 'across {{count}} destinations' })} + + = 99 ? 'green' : successRate >= 90 ? 'amber' : 'red'} icon={} @@ -292,6 +299,8 @@ export default function BackupsOverview({ {finished30.length ? t('app.backupsOverview.runsLast30Days', { count: finished30.length, defaultValue_one: '1 run · last 30 days', defaultValue_other: '{{count}} runs · last 30 days' }) : t('app.backupsOverview.noRunsRecordedYet', 'no runs recorded yet')} + + } @@ -306,7 +315,6 @@ export default function BackupsOverview({ - diff --git a/frontend/src/components/dashboard/grid/WidgetFrame.jsx b/frontend/src/components/dashboard/grid/WidgetFrame.jsx index 2c56d355..4a3918ec 100644 --- a/frontend/src/components/dashboard/grid/WidgetFrame.jsx +++ b/frontend/src/components/dashboard/grid/WidgetFrame.jsx @@ -50,6 +50,9 @@ export function WidgetFrame({ const className = [ 'skw-frame', + // A bare widget is its own card (a KPI tile): no header outside edit + // mode, where the header is still needed as the drag handle. + type?.bare && 'skw-frame--bare', edit && 'skw-frame--edit', selected && 'skw-frame--selected', ].filter(Boolean).join(' '); diff --git a/frontend/src/components/databases/BackupsTab.jsx b/frontend/src/components/databases/BackupsTab.jsx index 206c60a4..a1c8f86a 100644 --- a/frontend/src/components/databases/BackupsTab.jsx +++ b/frontend/src/components/databases/BackupsTab.jsx @@ -6,8 +6,7 @@ import { useConfirm } from '../../hooks/useConfirm'; import { formatBytes } from '@/utils/formatBytes'; import { DataTable, DataTableFooter, SearchField } from '@/components/ds'; import { - useTableChrome, GridViewPicker, GridChips, GridFilterButton, - GridToolsMenu, GridFilterDrawer, + useTableChrome, GridViewPicker, GridChips, GridFilterDrawer, } from '@/components/ds/grid'; import { useTableSort } from '@/hooks/useTableSort'; import { useColumnVisibility } from '@/hooks/useColumnVisibility'; @@ -222,10 +221,9 @@ export default function BackupsTab() { return (
} /> - chrome.setDrawerOpen(true)} - /> - )} /> diff --git a/frontend/src/components/databases/ProcessListPanel.jsx b/frontend/src/components/databases/ProcessListPanel.jsx index 16de77db..11a25bc6 100644 --- a/frontend/src/components/databases/ProcessListPanel.jsx +++ b/frontend/src/components/databases/ProcessListPanel.jsx @@ -7,8 +7,7 @@ import { usePolling } from '../../hooks/usePolling'; import EmptyState from '../EmptyState'; import { DataTable, DataTableFooter, SearchField } from '@/components/ds'; import { - useTableChrome, GridViewPicker, GridChips, GridFilterButton, - GridToolsMenu, GridFilterDrawer, + useTableChrome, GridViewPicker, GridChips, GridFilterDrawer, } from '@/components/ds/grid'; import { useTableSort } from '@/hooks/useTableSort'; import { useColumnVisibility } from '@/hooks/useColumnVisibility'; @@ -320,9 +319,9 @@ export default function ProcessListPanel({ conn, engine, active, isAdmin }) { is in the "⋮". No process count here — the footer reports it, under the rows it is counting. */} load() }} label="sessions" - onCreate={chrome.createView} actions={( <>