RepoPulse: update frontend/src and backend/app (+4 areas)
Public changes compared with the previous published export: 19 files changed. Affected areas: - backend/app: 3 files - dependencies: 2 files - documentation: 1 file - frontend: 2 files - frontend/src: 10 files - tests: 1 file Changed files: - Updated: "backend/app/acquisition.py" - Added: "backend/app/icons.py" - Updated: "backend/app/main.py" - Added: "backend/tests/test_icons.py" - Updated: "docs/ARCHITECTURE.md" - Updated: "frontend/package-lock.json" - Updated: "frontend/package.json" - Updated: "frontend/playwright.config.ts" - Updated: "frontend/src/App.tsx" - Updated: "frontend/src/components/DashboardView.tsx" - Added: "frontend/src/components/HealthRing.tsx" - Updated: "frontend/src/components/HistoryView.tsx" - Added: "frontend/src/components/Icon.tsx" - Updated: "frontend/src/components/PortfolioAtlas.tsx" - Updated: "frontend/src/components/RemediationCenter.tsx" - Added: "frontend/src/components/RepoAvatar.tsx" - Updated: "frontend/src/main.tsx" - Updated: "frontend/src/styles.css" - Updated: "frontend/vite.config.ts" Export provenance/manifests refreshed; excluded from the change summary. Publish curated RepoPulse source from 7a60c53ee2c1daebecd66a01656e323f1db72e56
This commit is contained in:
1 parent
d5ab22ddf1
commit
787a2b1dc3
21 files changed
+1543
-759
No files matched your search
Generated
+25
-33
@@ -8,12 +8,13 @@
|
||||
"name": "repopulse-frontend",
|
||||
"version": "1.5.1",
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@xyflow/react": "^12.8.5",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.55.0",
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.3",
|
||||
"@types/react": "^19.1.12",
|
||||
@@ -983,6 +984,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource-variable/inter": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.3.0.tgz",
|
||||
"integrity": "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==",
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
@@ -1054,19 +1064,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.55.0.tgz",
|
||||
"integrity": "sha512-04IXzPwHrW69XusN/SIdDdKZBzMfOT9UNT/YiJit/xpy2VuAoB8NHc8Aplb96zsWDddLnbkPL3TsmrS04ZU2xQ==",
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz",
|
||||
"integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.55.0"
|
||||
"playwright": "1.64.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
@@ -2592,50 +2602,32 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.0.tgz",
|
||||
"integrity": "sha512-sdCWStblvV1YU909Xqx0DhOjPZE4/5lJsIS84IfN9dAZfcl/CIZ5O8l3o0j7hPMjDvqoTF8ZUcc+i/GL5erstA==",
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz",
|
||||
"integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.55.0"
|
||||
"playwright-core": "1.64.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.0.tgz",
|
||||
"integrity": "sha512-GvZs4vU3U5ro2nZpeiwyb0zuFaqb9sUiAJuyrWpcGouD8y9/HLgGbNRjIph7zU9D3hnPaisMl9zG9CgFi/biIg==",
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
|
||||
"integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright/node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
"test:e2e": "playwright test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@xyflow/react": "^12.8.5",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.55.0",
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.3",
|
||||
"@types/react": "^19.1.12",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineConfig, devices } from '@playwright/test'
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
timeout: 30_000,
|
||||
timeout: 60_000, // one long end-to-end journey; cold Vite compiles on a loaded runner need headroom
|
||||
fullyParallel: false,
|
||||
workers: 6,
|
||||
reporter: 'list',
|
||||
@@ -30,7 +30,7 @@ export default defineConfig({
|
||||
command: 'node e2e/start-vite.mjs',
|
||||
url: 'http://127.0.0.1:4173',
|
||||
reuseExistingServer: false,
|
||||
timeout: 30_000,
|
||||
timeout: 60_000, // one long end-to-end journey; cold Vite compiles on a loaded runner need headroom
|
||||
},
|
||||
],
|
||||
})
|
||||
+21
-9
@@ -3,6 +3,9 @@ import { type FormEvent, lazy, Suspense, useCallback, useEffect, useMemo, useRef
|
||||
import { api, type AppMeta, type RepositorySummary, type ScanComparison, type ScanJob, type ScanReport, type ScanSummary, type TrendPoint } from './api'
|
||||
import { filterRepositories, orderSwitcherRepositories, paginateRepositories, readinessLabel, repositoryReadiness, sortRepositories, stateLabel, type CatalogFilters, type CatalogSort, type CatalogSortKey, type Readiness } from './catalog'
|
||||
import { BrandLockup, BrandMark } from './components/Brand'
|
||||
import { Icon, type IconName } from './components/Icon'
|
||||
import { HealthRing } from './components/HealthRing'
|
||||
import { RepoAvatar } from './components/RepoAvatar'
|
||||
import { DashboardView } from './components/DashboardView'
|
||||
import { DependenciesView } from './components/DependenciesView'
|
||||
import { FindingsView } from './components/FindingsView'
|
||||
@@ -40,7 +43,7 @@ function formatDate(value: string | null) { if (!value) return 'Never'; const da
|
||||
function formatRelativeDate(value: string | null) { if (!value) return 'Never scanned'; const difference = Date.now() - new Date(value).getTime(); if (Number.isNaN(difference)) return 'Unknown'; if (difference < 3_600_000) return `${Math.max(1, Math.floor(difference / 60_000))}m ago`; if (difference < 86_400_000) return `${Math.floor(difference / 3_600_000)}h ago`; return `${Math.floor(difference / 86_400_000)}d ago` }
|
||||
function downloadText(filename: string, content: string, mime: string) { const url = URL.createObjectURL(new Blob([content], { type: mime })); const anchor = document.createElement('a'); anchor.href = url; anchor.download = filename; anchor.style.display = 'none'; document.body.appendChild(anchor); anchor.click(); window.setTimeout(() => { anchor.remove(); URL.revokeObjectURL(url) }, 0) }
|
||||
function reportFilename(repositoryName: string, format: 'html' | 'json') { const safeName = repositoryName.replace(/[\u0000-\u001f\u007f<>:"/\\|?*]/g, '_').replace(/[ .]+$/g, '').slice(0, 100).replace(/[ .]+$/g, '') || 'repository'; return `repopulse-${safeName}.${format}` }
|
||||
function detailViewLabel(view: DetailView, report: ScanReport | null) { if (view === 'overview') return 'Overview'; if (view === 'findings') return `Findings (${report?.findings.filter((finding) => !finding.suppressed).length ?? 0})`; if (view === 'architecture') return `Architecture (${report?.architecture.nodes.length ?? 0})`; if (view === 'hotspots') return `Hotspots (${report?.hotspots.length ?? 0})`; if (view === 'dependencies') return 'Dependencies'; if (view === 'history') return 'History'; return 'Scan runs' }
|
||||
function detailViewLabel(view: DetailView, report: ScanReport | null) { if (view === 'overview') return 'Overview'; if (view === 'findings') return report ? `Findings (${report.findings.filter((finding) => !finding.suppressed).length})` : 'Findings'; if (view === 'architecture') return report ? `Architecture (${report.architecture.nodes.length})` : 'Architecture'; if (view === 'hotspots') return report ? `Hotspots (${report.hotspots.length})` : 'Hotspots'; if (view === 'dependencies') return 'Dependencies'; if (view === 'history') return 'History'; return 'Scan runs' }
|
||||
|
||||
export default function App() {
|
||||
const [route, setRoute] = useState<Route>(() => parseRoute(window.location.pathname))
|
||||
@@ -162,20 +165,29 @@ export default function App() {
|
||||
const selectScan = async (summary: ScanSummary) => { try { setBusy(true); setError(null); setReport(await api.repositoryScan(summary.repository_id, summary.id)); navigate({ page: 'repositories', repositoryId: summary.repository_id, view: 'overview' }) } catch (err) { setError(err instanceof Error ? err.message : 'Could not load the selected scan.') } finally { setBusy(false) } }
|
||||
const exportReport = async (format: 'html' | 'json') => { if (!report) return; try { downloadText(reportFilename(report.repository_name, format), await api.exportReport(report.id, format), format === 'html' ? 'text/html' : 'application/json') } catch (err) { setError(err instanceof Error ? err.message : 'Report export failed.') } }
|
||||
|
||||
const renderGlobalNav = () => <nav className="global-nav" aria-label="Primary navigation"><a className={route.page === 'dashboard' ? 'active' : ''} aria-current={route.page === 'dashboard' ? 'page' : undefined} href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })}>Dashboard</a><a className={route.page === 'repositories' ? 'active' : ''} aria-current={route.page === 'repositories' ? 'page' : undefined} href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Repositories <span>{repositories.length || '—'}</span></a><a className={route.page === 'activity' ? 'active' : ''} aria-current={route.page === 'activity' ? 'page' : undefined} href="/activity" onClick={(event) => handleNavigation(event, { page: 'activity' })}>Activity</a><a className={route.page === 'queue' ? 'active' : ''} aria-current={route.page === 'queue' ? 'page' : undefined} href="/queue" onClick={(event) => handleNavigation(event, { page: 'queue' })}>Scan queue</a><a className={route.page === 'settings' ? 'active' : ''} aria-current={route.page === 'settings' ? 'page' : undefined} href="/settings" onClick={(event) => handleNavigation(event, { page: 'settings' })}>Settings</a></nav>
|
||||
const renderTopbar = () => <header className="app-header"><a className="brand-home" href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })} aria-label="RepoPulse dashboard"><BrandLockup /></a>{renderGlobalNav()}<div className="header-actions"><button className="shortcut-button" type="button" onClick={() => setSwitcherOpen(true)} aria-keyshortcuts="Control+K Meta+K"><span>Quick switch</span><kbd>⌘K</kbd></button><button className="icon-button sync-icon" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy} aria-label="Synchronize Gitea catalog" title="Synchronize Gitea catalog">↻</button></div></header>
|
||||
const navItems: { page: Route['page']; label: string; href: string; icon: IconName; count?: number }[] = [
|
||||
{ page: 'dashboard', label: 'Dashboard', href: '/', icon: 'dashboard' },
|
||||
{ page: 'repositories', label: 'Repositories', href: '/repositories', icon: 'repositories', count: repositories.length },
|
||||
{ page: 'activity', label: 'Activity', href: '/activity', icon: 'activity' },
|
||||
{ page: 'queue', label: 'Scan queue', href: '/queue', icon: 'queue', count: repositories.filter((repository) => repository.active_job_id || repository.state === 'queued' || repository.state === 'scanning').length || undefined },
|
||||
{ page: 'settings', label: 'Settings', href: '/settings', icon: 'settings' },
|
||||
]
|
||||
const lastSync = meta?.gitea.last_sync && typeof meta.gitea.last_sync === 'object' && 'synced_at' in meta.gitea.last_sync ? String(meta.gitea.last_sync.synced_at) : null
|
||||
const renderGlobalNav = () => <nav className="global-nav" aria-label="Primary navigation">{navItems.map((item) => <a key={item.page} className={route.page === item.page ? 'active' : ''} aria-current={route.page === item.page ? 'page' : undefined} href={item.href} title={item.label} onClick={(event) => handleNavigation(event, { page: item.page })}><Icon name={item.icon} size={18} /><span className="nav-label">{item.label}</span>{item.count != null && <span className="nav-count">{item.count || '—'}</span>}</a>)}</nav>
|
||||
const renderSidebar = () => <aside className="sidebar"><a className="brand-home" href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })} aria-label="RepoPulse dashboard"><BrandLockup /></a>{renderGlobalNav()}<div className="sidebar-footer"><span className={`live-dot ${meta?.gitea.configured ? 'ok' : 'unknown'}`} aria-hidden="true" /><span><strong>{meta?.gitea.configured ? 'Gitea connected' : meta ? 'Gitea not configured' : 'Connecting…'}</strong><small>{lastSync ? `Synced ${formatRelativeDate(lastSync)}` : 'No sync recorded'}{meta?.version ? ` · v${meta.version}` : ''}</small></span></div></aside>
|
||||
const renderTopbar = () => <header className="app-header"><a className="brand-home mobile-brand" href="/" onClick={(event) => handleNavigation(event, { page: 'dashboard' })} aria-label="RepoPulse home"><BrandLockup compact /></a><button className="shortcut-button" type="button" onClick={() => setSwitcherOpen(true)} aria-keyshortcuts="Control+K Meta+K"><Icon name="search" /><span>Quick switch</span><kbd>Ctrl K</kbd></button><div className="header-actions"><button className="ghost sync-button" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy} aria-label="Synchronize Gitea catalog" title="Synchronize Gitea catalog"><Icon name="refresh" className={catalogBusy ? 'spin' : ''} /><span>{catalogBusy ? 'Syncing…' : 'Sync'}</span></button></div></header>
|
||||
|
||||
const renderCatalogPage = () => <section className="page-content explorer-page" aria-labelledby="repositories-title"><div className="page-heading"><div><span className="eyebrow">Repository explorer</span><h1 id="repositories-title">Repositories <span className="count-badge">{repositories.length}</span></h1><p className="muted">High-density catalog controls when you need breadth; switch to visual identity tiles when you need pattern recognition.</p></div><div className="page-heading-actions"><button className="ghost" type="button" onClick={() => setSwitcherOpen(true)}>Quick switcher <kbd>⌘K</kbd></button><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>{catalogBusy ? 'Syncing…' : 'Sync Gitea catalog'}</button></div></div><section className="catalog-toolbar section-card" aria-label="Repository filters"><div className="search-control"><span className="search-glyph" aria-hidden="true">⌕</span><label className="sr-only" htmlFor="catalog-search">Search repositories</label><input id="catalog-search" value={catalogFilters.query} onChange={(event) => updateCatalogFilter('query', event.target.value)} placeholder="Search name, owner or full name" /><kbd>⌘K</kbd></div><div className="filter-grid"><label>State<select aria-label="Filter by state" value={catalogFilters.state} onChange={(event) => updateCatalogFilter('state', event.target.value as CatalogFilters['state'])}><option value="all">All states</option><option value="current">Current</option><option value="stale">Stale</option><option value="scanning">Scanning</option><option value="failed">Failed</option><option value="never_scanned">Never scanned</option><option value="archived">Archived</option></select></label><label>Readiness<select aria-label="Filter by readiness" value={catalogFilters.readiness} onChange={(event) => updateCatalogFilter('readiness', event.target.value as CatalogFilters['readiness'])}><option value="all">All readiness</option><option value="ready">Ready</option><option value="warnings">Warnings</option><option value="blocked">Blocked</option></select></label><label>Owner<select aria-label="Filter by owner" value={catalogFilters.owner} onChange={(event) => updateCatalogFilter('owner', event.target.value)}><option value="all">All owners</option>{ownerOptions.map((owner) => <option key={owner} value={owner}>{owner}</option>)}</select></label><label>Branch<select aria-label="Filter by branch" value={catalogFilters.branch} onChange={(event) => updateCatalogFilter('branch', event.target.value)}><option value="all">All branches</option>{branchOptions.map((branch) => <option key={branch} value={branch}>{branch}</option>)}</select></label><label>Visibility<select aria-label="Filter by visibility" value={catalogFilters.visibility} onChange={(event) => updateCatalogFilter('visibility', event.target.value as CatalogFilters['visibility'])}><option value="all">Any visibility</option><option value="private">Private</option><option value="public">Public</option></select></label><label>Lifecycle<select aria-label="Filter by lifecycle" value={catalogFilters.archived} onChange={(event) => updateCatalogFilter('archived', event.target.value as CatalogFilters['archived'])}><option value="active">Active only</option><option value="all">Active and archived</option><option value="archived">Archived only</option></select></label></div><div className="toolbar-footer"><span className="filter-result">{filteredRepositories.length} matching {repositories.length} repositories</span><div className="view-toggle" aria-label="Repository view"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')} aria-pressed={catalogView === 'table'}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')} aria-pressed={catalogView === 'grid'}>Visual grid</button></div><button className="text-button" type="button" onClick={() => { setCatalogFilters(DEFAULT_FILTERS); setCatalogPage(1) }}>Reset filters</button></div></section>{catalogLoading ? <section className="catalog-loading" aria-label="Loading repository catalog"><span /><span /><span /><span /></section> : catalogWindow.items.length ? <>{catalogView === 'table' ? <section className="catalog-table-card section-card" aria-label="Repository catalog results"><div className="table-scroll"><table className="repository-table"><thead><tr><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('name')}>Repository <span>{catalogSort.key === 'name' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('state')}>State <span>{catalogSort.key === 'state' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th>Readiness</th><th>Branch</th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('last_sLine truncated
|
||||
const renderCatalogPage = () => <section className="page-content explorer-page" aria-labelledby="repositories-title"><div className="page-heading"><div><h1 id="repositories-title">Repositories <span className="count-badge">{repositories.length}</span></h1><p className="muted">Every repository RepoPulse discovered in Gitea, with its latest retained scan.</p></div><div className="page-heading-actions"><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}><Icon name="refresh" className={catalogBusy ? 'spin' : ''} />{catalogBusy ? 'Syncing…' : 'Sync Gitea catalog'}</button></div></div><section className="catalog-toolbar section-card" aria-label="Repository filters"><div className="search-control"><span className="search-glyph" aria-hidden="true"><Icon name="search" /></span><label className="sr-only" htmlFor="catalog-search">Search repositories</label><input id="catalog-search" value={catalogFilters.query} onChange={(event) => updateCatalogFilter('query', event.target.value)} placeholder="Search name, owner or full name" /></div><div className="filter-grid"><label>State<select aria-label="Filter by state" value={catalogFilters.state} onChange={(event) => updateCatalogFilter('state', event.target.value as CatalogFilters['state'])}><option value="all">All states</option><option value="current">Current</option><option value="stale">Stale</option><option value="scanning">Scanning</option><option value="failed">Failed</option><option value="never_scanned">Never scanned</option><option value="archived">Archived</option></select></label><label>Readiness<select aria-label="Filter by readiness" value={catalogFilters.readiness} onChange={(event) => updateCatalogFilter('readiness', event.target.value as CatalogFilters['readiness'])}><option value="all">All readiness</option><option value="ready">Ready</option><option value="warnings">Warnings</option><option value="blocked">Blocked</option></select></label><label>Owner<select aria-label="Filter by owner" value={catalogFilters.owner} onChange={(event) => updateCatalogFilter('owner', event.target.value)}><option value="all">All owners</option>{ownerOptions.map((owner) => <option key={owner} value={owner}>{owner}</option>)}</select></label><label>Branch<select aria-label="Filter by branch" value={catalogFilters.branch} onChange={(event) => updateCatalogFilter('branch', event.target.value)}><option value="all">All branches</option>{branchOptions.map((branch) => <option key={branch} value={branch}>{branch}</option>)}</select></label><label>Visibility<select aria-label="Filter by visibility" value={catalogFilters.visibility} onChange={(event) => updateCatalogFilter('visibility', event.target.value as CatalogFilters['visibility'])}><option value="all">Any visibility</option><option value="private">Private</option><option value="public">Public</option></select></label><label>Lifecycle<select aria-label="Filter by lifecycle" value={catalogFilters.archived} onChange={(event) => updateCatalogFilter('archived', event.target.value as CatalogFilters['archived'])}><option value="active">Active only</option><option value="all">Active and archived</option><option value="archived">Archived only</option></select></label></div><div className="toolbar-footer"><span className="filter-result">{filteredRepositories.length} matching {repositories.length} repositories</span><div className="view-toggle" aria-label="Repository view"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')} aria-pressed={catalogView === 'table'}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')} aria-pressed={catalogView === 'grid'}>Visual grid</button></div><button className="text-button" type="button" onClick={() => { setCatalogFilters(DEFAULT_FILTERS); setCatalogPage(1) }}>Reset filters</button></div></section>{catalogLoading ? <section className="catalog-loading" aria-label="Loading repository catalog"><span /><span /><span /><span /></section> : catalogWindow.items.length ? <>{catalogView === 'table' ? <section className="catalog-table-card section-card" aria-label="Repository catalog results"><div className="table-scroll"><table className="repository-table"><thead><tr><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('name')}>Repository <span>{catalogSort.key === 'name' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('state')}>State <span>{catalogSort.key === 'state' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th>Readiness</th><th>Branch</th><th><button className="sort-button" type="button" onClick={() => setCatalogSortKey('last_scan')}>Last scan <span>{catalogSort.key === 'last_scan' ? catalogSort.direction === 'asc' ? '↑' : '↓' : '↕'}</span></button></th><th><buttoLine truncated
|
||||
|
||||
const renderDetailPage = () => {
|
||||
if (!selectedRepository) return <section className="page-content"><div className="empty-state section-card"><BrandMark size={38} label="" /><h1>This repository is not in the current catalog.</h1><p className="muted">It may have been archived, removed or the link may be stale.</p><a className="button-link" href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Back to repositories</a></div></section>
|
||||
const readiness = repositoryReadiness(selectedRepository); const revision = report?.source.actual_revision || selectedRepository.latest_revision
|
||||
return <section className="page-content detail-page" aria-labelledby="repository-title"><div className="breadcrumb-row"><a href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Repository explorer</a><span aria-hidden="true">/</span><button type="button" onClick={() => setSwitcherOpen(true)}>{selectedRepository.full_name} <span aria-hidden="true">⌄</span></button></div><section className="workspace-hero"><div className="workspace-identity"><div><span className="eyebrow">{selectedRepository.provider} repository · {selectedRepository.private ? 'private' : 'public'}</span><h1 id="repository-title">{selectedRepository.full_name}</h1><p>{selectedRepository.description || 'No repository description provided.'}</p><div className="workspace-facts"><span><code>{selectedRepository.default_branch}</code></span><span><code>{shortRevision(revision)}</code></span><span className={`readiness-label readiness-${readiness}`}><i aria-hidden="true" />{stateLabel(selectedRepository.state)}</span></div></div><div className="workspace-score"><strong>{report?.health_score ?? selectedRepository.last_scan_health ?? '—'}</strong><span>health score</span><small>{report?.release_readiness ?? readinessLabel(readiness)}</small></div></div><RepositoryVisual repository={selectedRepository} report={report} className="workspace-visual" /><div className="detail-actions"><button type="button" onClick={() => void analyzeRepository(selectedRepository)} disabled={busy || Boolean(activeJob)}>{activeJob ? 'Scanning…' : 'Scan now'}</button><details className="action-menu"><summary>Reports</summary><div className="menu-popover"><button type="button" onClick={() => void exportReport('html')} disabled={!report}>Export HTML</button><button type="button" onClick={() => void exportReport('json')} disabled={!report}>Export JSON</button></div></details><details className="action-menu"><summary>More</summary><div className="menu-popover"><button type="button" onClick={() => void analyzeRepository(selectedRepository, true)} disabled={busy || Boolean(activeJob)}>Force rescan</button><button type="button" onClick={() => navigate({ page: 'repositories', repositoryId: selectedRepository.id, view: 'scans' })}>View scan runs</button><button type="button" onClick={() => setAdvancedOpen((current) => !current)}>Advanced info</button></div></details><button className={`star-button header-star ${pinnedIds.includes(selectedRepository.id) ? 'pinned' : ''}`} type="button" onClick={() => togglePinned(selectedRepository.id)} aria-label={pinnedIds.includes(selectedRepository.id) ? 'Remove from pinned repositories' : 'Pin repository'} aria-pressed={pinnedIds.includes(selectedRepository.id)}><span aria-hidden="true">{pinnedIds.includes(selectedRepository.id) ? '★' : '☆'}</span></button></div></section>{error && <div className="error-banner" role="alert">{error}</div>}{notice && <div className="notice-banner" role="status">{notice}</div>}{activeJob && <div className="job-progress" role="status"><div><strong>{activeJob.message || 'Analysis in progress'}</strong><span>{activeJob.phase.replaceAll('_', ' ')} · {activeJob.progress}%</span></div><div className="progress-track"><i style={{ width: `${activeJob.progress}%` }} /></div></div>}<nav className="detail-tabs" aria-label="Repository analysis views">{DETAIL_VIEWS.map((view) => <a key={view} className={currentView === view ? 'active' : ''} aria-current={currentView === view ? 'page' : undefined} href={routePath({ page: 'repositories', repositoryId: selectedRepository.id, view })} onClick={(event) => handleNavigation(event, { page: 'repositories', repositoryId: selectedRepository.id, view })}>{detailViewLabel(view, report)}</a>)}</nav>{advancedOpen && <section className="section-card advanced-info"><div><span className="eyebrow">Advanced repository info</span><h2>Identity and policy</h2></div><div className="info-grid"><span><strong>Provider ID</strong><code>{selectedRepository.provider_repository_id}</code></span><span><strong>Visibility</strong>{selectedRepository.private ? 'Private' : 'Public'}</span><span><strong>Auto scan</strong>{selectedRepository.policy.auto_scan ? 'Enabled' : 'Disabled'}</span><span><strong>Minimum health</strong>{selectedRepository.policy.min_health_score}</span><span><strong>Latest revision</strong><code>{shortRevision(selectedRepository.latest_revision)}</code></span><span><strong>Catalog sync</strong>{formatDate(selectedRepository.last_synced_at)}</span></div></section>}{selectedDetailsLoading ? <section className="workspace-loading" role="status"><span /><span /><span /></section> : report ? <section className="detail-content">{currentView === 'overview' && <OverviewView report={report} comparison={comparison} />}{currentView === 'architecture' && <Suspense fallback={<p className="muted" role="status">Loading architecture view…</p>}><ArchitectureView report={report} /></Suspense>}{currentView === 'hotspots' && <HotspotsView report={report} />}{cLine truncated
|
||||
return <section className="page-content detail-page" aria-labelledby="repository-title"><div className="breadcrumb-row"><a href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Repositories</a><span aria-hidden="true"><Icon name="chevronRight" size={14} /></span><button type="button" onClick={() => setSwitcherOpen(true)}>{selectedRepository.full_name} <Icon name="chevronDown" size={14} /></button></div><section className="workspace-hero"><div className="workspace-identity"><RepoAvatar repository={selectedRepository} size="xl" /><div><span className="eyebrow">{selectedRepository.provider} repository · {selectedRepository.private ? 'private' : 'public'}</span><h1 id="repository-title">{selectedRepository.full_name}</h1><p>{selectedRepository.description || 'No repository description provided.'}</p><div className="workspace-facts"><span><Icon name="branch" /><code>{selectedRepository.default_branch}</code></span><span><Icon name="commit" /><code>{shortRevision(revision)}</code></span><span className={`status-label status-${statusClass(selectedRepository.state)}`}><i aria-hidden="true" />{stateLabel(selectedRepository.state)}</span></div></div><div className="workspace-score"><HealthRing value={report?.health_score ?? selectedRepository.last_scan_health} readiness={readiness} size={84} /><span>health score</span><small className={`chip ${readiness}`}>{report?.release_readiness ?? readinessLabel(readiness)}</small></div></div><RepositoryVisual repository={selectedRepository} report={report} className="workspace-visual" /><div className="detail-actions"><button type="button" onClick={() => void analyzeRepository(selectedRepository)} disabled={busy || Boolean(activeJob)}>{activeJob ? 'Scanning…' : 'Scan now'}</button><details className="action-menu"><summary><Icon name="download" />Reports</summary><div className="menu-popover"><button type="button" onClick={() => void exportReport('html')} disabled={!report}>Export HTML</button><button type="button" onClick={() => void exportReport('json')} disabled={!report}>Export JSON</button></div></details><details className="action-menu"><summary><Icon name="more" />More</summary><div className="menu-popover"><button type="button" onClick={() => void analyzeRepository(selectedRepository, true)} disabled={busy || Boolean(activeJob)}>Force rescan</button><button type="button" onClick={() => navigate({ page: 'repositories', repositoryId: selectedRepository.id, view: 'scans' })}>View scan runs</button><button type="button" onClick={() => setAdvancedOpen((current) => !current)}>Advanced info</button></div></details><button className={`star-button header-star ${pinnedIds.includes(selectedRepository.id) ? 'pinned' : ''}`} type="button" onClick={() => togglePinned(selectedRepository.id)} aria-label={pinnedIds.includes(selectedRepository.id) ? 'Remove from pinned repositories' : 'Pin repository'} aria-pressed={pinnedIds.includes(selectedRepository.id)}><span aria-hidden="true">{pinnedIds.includes(selectedRepository.id) ? '★' : '☆'}</span></button></div></section>{error && <div className="error-banner" role="alert">{error}</div>}{notice && <div className="notice-banner" role="status">{notice}</div>}{activeJob && <div className="job-progress" role="status"><div><strong>{activeJob.message || 'Analysis in progress'}</strong><span>{activeJob.phase.replaceAll('_', ' ')} · {activeJob.progress}%</span></div><div className="progress-track"><i style={{ width: `${activeJob.progress}%` }} /></div></div>}<nav className="detail-tabs" aria-label="Repository analysis views">{DETAIL_VIEWS.map((view) => <a key={view} className={currentView === view ? 'active' : ''} aria-current={currentView === view ? 'page' : undefined} href={routePath({ page: 'repositories', repositoryId: selectedRepository.id, view })} onClick={(event) => handleNavigation(event, { page: 'repositories', repositoryId: selectedRepository.id, view })}>{detailViewLabel(view, report)}</a>)}</nav>{advancedOpen && <section className="section-card advanced-info"><div><span className="eyebrow">Advanced repository info</span><h2>Identity and policy</h2></div><div className="info-grid"><span><strong>Provider ID</strong><code>{selectedRepository.provider_repository_id}</code></span><span><strong>Visibility</strong>{selectedRepository.private ? 'Private' : 'Public'}</span><span><strong>Auto scan</strong>{selectedRepository.policy.auto_scan ? 'Enabled' : 'Disabled'}</span><span><strong>Minimum health</strong>{selectedRepository.policy.min_health_score}</span><span><strong>Latest revision</strong><code>{shortRevision(selectedRepository.latest_revision)}</code></span><span><strong>Catalog sync</strong>{formatDate(selectedRepository.last_synced_at)}</span></div></section>}{selectedDetailsLoading ? <section className="workspace-loading" role="status"><span /><span /><span /></section> : report ? <section className="detail-content">{currentView === 'overview' && <OverviewView report={report} comparisLine truncated
|
||||
}
|
||||
|
||||
const renderActivityPage = () => { const activity = [...repositories].filter((repository) => repository.last_scan_at || repository.state === 'scanning' || repository.state === 'queued').sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)); return <section className="page-content activity-page" aria-labelledby="activity-title"><div className="page-heading"><div><span className="eyebrow">Operational timeline</span><h1 id="activity-title">Activity</h1><p className="muted">A visual event feed derived from actual catalog state and persisted scan activity.</p></div></div><div className="summary-strip"><div><span>Catalog</span><strong>{repositories.length}</strong></div><div><span>Current</span><strong>{repositories.filter((repository) => repository.state === 'current').length}</strong></div><div><span>Needs attention</span><strong>{repositories.filter((repository) => repositoryReadiness(repository) !== 'ready').length}</strong></div><div><span>Latest scan</span><strong>{activity[0] ? formatRelativeDate(activity[0].last_scan_at) : '—'}</strong></div></div><section className="activity-timeline section-card"><div className="section-heading"><div><span className="eyebrow">Latest changes</span><h2>Repository activity</h2></div><span className="section-note">Each event opens its repository workspace.</span></div>{activity.length ? activity.slice(0, 30).map((repository) => <button type="button" className="timeline-event" key={repository.id} onClick={() => selectRepository(repository)}><span className={`timeline-rail ${repositoryReadiness(repository)}`} /><RepositoryVisual repository={repository} compact /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' || repository.state === 'queued' ? `${stateLabel(repository.state)} · ${repository.default_branch}` : `Scan completed ${formatRelativeDate(repository.last_scan_at)} · ${repository.default_branch}`}</small></span><b>{repository.last_scan_health ?? '—'}</b></button>) : <div className="empty-state compact-empty"><BrandMark size={34} label="" /><h2>No activity yet</h2><p className="muted">Scan a repository to start building its operational timeline.</p></div>}</section></section> }
|
||||
const renderQueuePage = () => { const queue = repositories.filter((repository) => repository.active_job_id || repository.state === 'queued' || repository.state === 'scanning'); return <section className="page-content queue-page" aria-labelledby="queue-title"><div className="page-heading"><div><span className="eyebrow">Durable background work</span><h1 id="queue-title">Scan queue</h1><p className="muted">Exact revisions are retained while work moves through source acquisition, analysis and scoring.</p></div></div><div className="summary-strip"><div><span>Waiting</span><strong>{queue.filter((repository) => repository.state === 'queued').length}</strong></div><div><span>Active</span><strong>{queue.filter((repository) => repository.state === 'scanning' || repository.active_job_id).length}</strong></div><div><span>Completed</span><strong>{meta?.completed_jobs ?? '—'}</strong></div><div><span>Failed</span><strong>{meta?.failed_jobs ?? '—'}</strong></div></div><section className="queue-workspace section-card"><div className="section-heading"><div><span className="eyebrow">Live queue</span><h2>{queue.length ? 'Scans in progress' : 'Queue is clear'}</h2></div><span className="section-note">No misleading progress percentage is shown before the worker reports one.</span></div>{queue.length ? <div className="queue-list">{queue.map((repository) => <button type="button" className="queue-row" key={repository.id} onClick={() => selectRepository(repository)}><RepositoryVisual repository={repository} compact /><span><strong>{repository.full_name}</strong><small>{repository.default_branch} · {repository.active_job_id ? 'worker active' : 'waiting for worker'}</small></span><span className={`status-label status-${statusClass(repository.state)}`}><i aria-hidden="true" />{stateLabel(repository.state)}</span></button>)}</div> : <div className="queue-empty"><BrandMark size={48} label="" /><div><span className="eyebrow">All clear</span><h2>No scans are waiting</h2><p className="muted">The worker is healthy and the portfolio is up to date. Start a scan from a repository workspace whenever a fresh revision needs analysis.</p><a className="button-link" href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Browse repositories</a></div></div>}</section></section> }
|
||||
const renderSettingsPage = () => <section className="page-content settings-page" aria-labelledby="settings-title"><div className="page-heading"><div><span className="eyebrow">Workspace configuration</span><h1 id="settings-title">Settings</h1><p className="muted">Connection, scanning and local preferences are separated into concise operational sections.</p></div></div><div className="settings-sections"><section className="settings-section"><div><span className="eyebrow">Connections</span><h2>Gitea catalog</h2><p>Provider-backed repository discovery and exact revision acquisition.</p></div><dl><div><dt>Status</dt><dd><span className={`status-label status-${meta?.gitea.configured ? 'current' : 'failed'}`}><i aria-hidden="true" />{meta?.gitea.configured ? 'Configured' : 'Not configured'}</span></dd></div><div><dt>Repositories</dt><dd>{meta?.repository_count ?? repositories.length}</dd></div><div><dt>Last sync</dt><dd>{meta?.gitea.last_sync && typeof meta.gitea.last_sync === 'object' && 'synced_at' in meta.gitea.last_sync ? formatDate(String(meta.gitea.last_sync.synced_at)) : 'Not available'}</dd></div></dl><button className="ghost" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>{catalogBusy ? 'Syncing…' : 'Sync catalog now'}</button></section><section className="settings-section"><div><span className="eyebrow">Scanning & analysis</span><h2>Safe source controls</h2><p>The normal repository flow stays Gitea-native. The advanced path remains available only for mounted local sources.</p></div><dl><div><dt>Scan root</dt><dd>{meta?.scan_root_restricted ? 'Restricted' : 'Configured by server'}</dd></div><div><dt>Concurrency</dt><dd>{meta?.max_concurrent_scans ?? '—'} worker</dd></div><div><dt>Automation</dt><dd>Scheduled discovery enabled</dd></div></dl><form className="local-form" onSubmit={scanLocal}><label><span>Advanced repository path</span><input aria-label="Repository path" value={path} onChange={(event) => setPath(event.target.value)} placeholder="/scan/my-project" required /></label><button disabled={busy}>{busy ? 'Analyzing…' : 'Analyze local source'}</button></form>{standaloneReport && <div className="local-result" role="status"><strong>{standaloneReport.repository_name}</strong><span>{standaloneReport.health_score}/100 · {standaloneReport.release_readiness} · {formatDate(standaloneReport.scanned_at)}</span></div>}</section><section className="settings-section appearance"><div><span className="eyebrow">Appearance</span><h2>Personal workspace preferences</h2><p>Dark signal topology is the primary theme. View modes and navigation preferences are stored locally in this browser.</p></div><dl><div><dt>Explorer view</dt><dd><div className="view-toggle"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')}>Visual grid</button></div></dd></div><div><dt>Pinned repositories</dt><dd>{pinnedIds.length}</dd></div><div><dt>Recent repositories</dt><dd>{recentIds.length}</dd></div></dl></section></div></section>
|
||||
const renderActivityPage = () => { const activity = [...repositories].filter((repository) => repository.last_scan_at || repository.state === 'scanning' || repository.state === 'queued').sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)); return <section className="page-content activity-page" aria-labelledby="activity-title"><div className="page-heading"><div><h1 id="activity-title">Activity</h1><p className="muted">Recent scans and running analysis across the catalog.</p></div></div><div className="summary-strip"><div><span>Catalog</span><strong>{repositories.length}</strong></div><div><span>Current</span><strong>{repositories.filter((repository) => repository.state === 'current').length}</strong></div><div><span>Needs attention</span><strong>{repositories.filter((repository) => !repository.archived && repositoryReadiness(repository) !== 'ready').length}</strong></div><div><span>Latest scan</span><strong>{activity[0] ? formatRelativeDate(activity[0].last_scan_at) : '—'}</strong></div></div><section className="activity-timeline section-card"><div className="section-heading"><div><span className="eyebrow">Latest changes</span><h2>Repository activity</h2></div><span className="section-note">Each event opens its repository workspace.</span></div>{activity.length ? activity.slice(0, 30).map((repository) => <button type="button" className="timeline-event" key={repository.id} onClick={() => selectRepository(repository)}><span className={`timeline-rail ${repositoryReadiness(repository)}`} /><RepoAvatar repository={repository} /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' || repository.state === 'queued' ? `${stateLabel(repository.state)} · ${repository.default_branch}` : `Scan completed ${formatRelativeDate(repository.last_scan_at)} · ${repository.default_branch}`}</small></span><HealthRing value={repository.last_scan_health} readiness={repositoryReadiness(repository)} size={36} /></button>) : <div className="empty-state compact-empty"><BrandMark size={34} label="" /><h2>No activity yet</h2><p className="muted">Scan a repository to start building its operational timeline.</p></div>}</section></section> }
|
||||
const renderQueuePage = () => { const queue = repositories.filter((repository) => repository.active_job_id || repository.state === 'queued' || repository.state === 'scanning'); return <section className="page-content queue-page" aria-labelledby="queue-title"><div className="page-heading"><div><h1 id="queue-title">Scan queue</h1><p className="muted">Background scans, pinned to an exact revision from acquisition to scoring.</p></div></div><div className="summary-strip"><div><span>Waiting</span><strong>{queue.filter((repository) => repository.state === 'queued').length}</strong></div><div><span>Active</span><strong>{queue.filter((repository) => repository.state === 'scanning' || repository.active_job_id).length}</strong></div><div><span>Completed</span><strong>{meta?.completed_jobs ?? '—'}</strong></div><div><span>Failed</span><strong>{meta?.failed_jobs ?? '—'}</strong></div></div><section className="queue-workspace section-card"><div className="section-heading"><div><span className="eyebrow">Live queue</span><h2>{queue.length ? 'Scans in progress' : 'Queue is clear'}</h2></div></div>{queue.length ? <div className="queue-list">{queue.map((repository) => <button type="button" className="queue-row" key={repository.id} onClick={() => selectRepository(repository)}><RepoAvatar repository={repository} /><span><strong>{repository.full_name}</strong><small>{repository.default_branch} · {repository.active_job_id ? 'worker active' : 'waiting for worker'}</small></span><span className={`status-label status-${statusClass(repository.state)}`}><i aria-hidden="true" />{stateLabel(repository.state)}</span></button>)}</div> : <div className="queue-empty"><BrandMark size={48} label="" /><div><h2>No scans are waiting</h2><p className="muted">The worker is healthy and the portfolio is up to date. Start a scan from a repository workspace whenever a fresh revision needs analysis.</p><a className="button-link" href="/repositories" onClick={(event) => handleNavigation(event, { page: 'repositories' })}>Browse repositories</a></div></div>}</section></section> }
|
||||
const renderSettingsPage = () => <section className="page-content settings-page" aria-labelledby="settings-title"><div className="page-heading"><div><h1 id="settings-title">Settings</h1><p className="muted">Connection, scanning and local preferences.</p></div></div><div className="settings-sections"><section className="settings-section"><div><span className="eyebrow">Connections</span><h2>Gitea catalog</h2><p>Provider-backed repository discovery and exact revision acquisition.</p></div><dl><div><dt>Status</dt><dd><span className={`status-label status-${meta?.gitea.configured ? 'current' : 'failed'}`}><i aria-hidden="true" />{meta?.gitea.configured ? 'Configured' : 'Not configured'}</span></dd></div><div><dt>Repositories</dt><dd>{meta?.repository_count ?? repositories.length}</dd></div><div><dt>Last sync</dt><dd>{meta?.gitea.last_sync && typeof meta.gitea.last_sync === 'object' && 'synced_at' in meta.gitea.last_sync ? formatDate(String(meta.gitea.last_sync.synced_at)) : 'Not available'}</dd></div></dl><button className="ghost" type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>{catalogBusy ? 'Syncing…' : 'Sync catalog now'}</button></section><section className="settings-section"><div><span className="eyebrow">Scanning & analysis</span><h2>Safe source controls</h2><p>The normal repository flow stays Gitea-native. The advanced path remains available only for mounted local sources.</p></div><dl><div><dt>Scan root</dt><dd>{meta?.scan_root_restricted ? 'Restricted' : 'Configured by server'}</dd></div><div><dt>Concurrency</dt><dd>{meta?.max_concurrent_scans ?? '—'} worker</dd></div><div><dt>Automation</dt><dd>Scheduled discovery enabled</dd></div></dl><form className="local-form" onSubmit={scanLocal}><label><span>Advanced repository path</span><input aria-label="Repository path" value={path} onChange={(event) => setPath(event.target.value)} placeholder="/scan/my-project" required /></label><button disabled={busy}>{busy ? 'Analyzing…' : 'Analyze local source'}</button></form>{standaloneReport && <div className="local-result" role="status"><strong>{standaloneReport.repository_name}</strong><span>{standaloneReport.health_score}/100 · {standaloneReport.release_readiness} · {formatDate(standaloneReport.scanned_at)}</span></div>}</section><section className="settings-section appearance"><div><span className="eyebrow">Appearance</span><h2>Personal workspace preferences</h2><p>View mode, pinned and recent repositories are stored locally in this browser.</p></div><dl><div><dt>Explorer view</dt><dd><div className="view-toggle"><button className={catalogView === 'table' ? 'active' : ''} type="button" onClick={() => setCatalogView('table')}>Table</button><button className={catalogView === 'grid' ? 'active' : ''} type="button" onClick={() => setCatalogView('grid')}>Visual grid</button></div></dd></div><div><dt>Pinned repositories</dt><dd>{pinnedIds.length}</dd></div><div><dt>Recent repositories</dt><dd>{recentIds.length}</dd></div></dl></section></div></section>
|
||||
|
||||
return <main className="app-shell">{renderTopbar()}{error && !route.repositoryId && <div className="error-banner global-banner" role="alert">{error}</div>}{notice && !route.repositoryId && <div className="notice-banner global-banner" role="status">{notice}</div>}{route.page === 'dashboard' && <DashboardView repositories={repositories} pinnedIds={pinnedIds} onOpenRepository={selectRepository} onExploreReadiness={exploreReadiness} onOpenExplorer={() => navigate({ page: 'repositories' })} />}{route.page === 'activity' && renderActivityPage()}{route.page === 'queue' && renderQueuePage()}{route.page === 'settings' && renderSettingsPage()}{route.page === 'repositories' && (route.repositoryId ? renderDetailPage() : renderCatalogPage())}{switcherOpen && <div className="modal-backdrop" role="presentation" onMouseDown={() => setSwitcherOpen(false)}><section className="switcher-modal" role="dialog" aria-modal="true" aria-labelledby="switcher-title" onMouseDown={(event) => event.stopPropagation()}><div className="switcher-heading"><div><span className="eyebrow">Repository navigation</span><h2 id="switcher-title">Quick switcher</h2></div><button className="icon-button" type="button" onClick={() => setSwitcherOpen(false)} aria-label="Close quick switcher">×</button></div><div className="command-row"><button type="button" onClick={() => { navigate({ page: 'dashboard' }); setSwitcherOpen(false) }}>Open dashboard</button><button type="button" onClick={() => { navigate({ page: 'queue' }); setSwitcherOpen(false) }}>Open scan queue</button><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>Sync Gitea</button></div><label className="switcher-search"><span className="sr-only">Search repositories</span><input ref={switcherInputRef} value={switcherQuery} onChange={(event) => { setSwitcherQuery(event.target.value); setSwitcherIndex(0) }} placeholder="Search repositories…" /><kbd>Esc</kbd></label>{switcherRepositories.length ? <div className="switcher-results" role="listbox" aria-label="Repositories">{switcherRepositories.map((repository, index) => <button className={index === switcherIndex ? 'switcher-item active' : 'switcher-item'} type="button" role="option" aria-selected={index === switcherIndex} key={repository.id} onMouseEnter={() => setSwitcherIndex(index)} onClick={() => { selectRepository(repository); setSwitcherOpen(false) }}><RepositoryVisual repository={repository} compact /><span><strong>{repository.full_name}</strong><small>{repository.owner} · {repository.default_branch} · {repository.last_scan_health ?? 'not scanned'}</small></span><span className={`readiness-label readiness-${repositoryReadiness(repository)}`}><i aria-hidden="true" />{readinessLabel(repositoryReadiness(repository))}</span></button>)}</div> : <div className="empty-state compact-empty"><h2>No repository matches</h2><p className="muted">Try the owner, repository name or branch.</p></div>}<div className="switcher-footer"><span><kbd>↑</kbd><kbd>↓</kbd> Navigate</span><span><kbd>Enter</kbd> Open</span><span><kbd>Esc</kbd> Close</span></div></section></div>}</main>
|
||||
return <div className="app-shell">{renderSidebar()}<main className="app-main">{renderTopbar()}{error && !route.repositoryId && <div className="error-banner global-banner" role="alert">{error}</div>}{notice && !route.repositoryId && <div className="notice-banner global-banner" role="status">{notice}</div>}{route.page === 'dashboard' && <DashboardView repositories={repositories} pinnedIds={pinnedIds} onOpenRepository={selectRepository} onExploreReadiness={exploreReadiness} onOpenExplorer={() => navigate({ page: 'repositories' })} loading={catalogLoading} />}{route.page === 'activity' && renderActivityPage()}{route.page === 'queue' && renderQueuePage()}{route.page === 'settings' && renderSettingsPage()}{route.page === 'repositories' && (route.repositoryId ? renderDetailPage() : renderCatalogPage())}</main>{switcherOpen && <div className="modal-backdrop" role="presentation" onMouseDown={() => setSwitcherOpen(false)}><section className="switcher-modal" role="dialog" aria-modal="true" aria-labelledby="switcher-title" onMouseDown={(event) => event.stopPropagation()}><div className="switcher-heading"><div><span className="eyebrow">Repository navigation</span><h2 id="switcher-title">Quick switcher</h2></div><button className="icon-button" type="button" onClick={() => setSwitcherOpen(false)} aria-label="Close quick switcher"><Icon name="close" /></button></div><div className="command-row"><button type="button" onClick={() => { navigate({ page: 'dashboard' }); setSwitcherOpen(false) }}>Open dashboard</button><button type="button" onClick={() => { navigate({ page: 'queue' }); setSwitcherOpen(false) }}>Open scan queue</button><button type="button" onClick={() => void syncCatalog()} disabled={catalogBusy}>Sync Gitea</button></div><label className="switcher-search"><span className="sr-only">Search repositories</span><input ref={switcherInputRef} value={switcherQuery} onChange={(event) => { setSwitcherQuery(event.target.value); setSwitcherIndex(0) }} placeholder="Search repositories…" /><kbd>Esc</kbd></label>{switcherRepositories.length ? <div className="switcher-results" role="listbox" aria-label="Repositories">{switcherRepositories.map((repository, index) => <button className={index === switcherIndex ? 'switcher-item active' : 'switcher-item'} type="button" role="option" aria-selected={index === switcherIndex} key={repository.id} onMouseEnter={() => setSwitcherIndex(index)} onClick={() => { selectRepository(repository); setSwitcherOpen(false) }}><RepoAvatar repository={repository} /><span><strong>{repository.full_name}</strong><small>{repository.owner} · {repository.default_branch} · {repository.last_scan_health ?? 'not scanned'}</small></span><span className={`readiness-label readiness-${repositoryReadiness(repository)}`}><i aria-hidden="true" />{readinessLabel(repositoryReadiness(repository))}</span></button>)}</div> : <div className="empty-state compact-empty"><h2>No repository matches</h2><p className="muted">Try the owner, repository name or branch.</p></div>}<div className="switcher-footer"><span><kbd>↑</kbd><kbd>↓</kbd> Navigate</span><span><kbd>Enter</kbd> Open</span><span><kbd>Esc</kbd> Close</span></div></section></div>}</div>
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { RepositorySummary } from '../api'
|
||||
import { readinessLabel, repositoryReadiness, type Readiness } from '../catalog'
|
||||
import { CountUp, HealthRing } from './HealthRing'
|
||||
import { Icon, type IconName } from './Icon'
|
||||
import { PortfolioAtlas } from './PortfolioAtlas'
|
||||
import { RemediationCenter } from './RemediationCenter'
|
||||
import { RepositoryVisual } from './RepositoryVisual'
|
||||
import { RepoAvatar } from './RepoAvatar'
|
||||
|
||||
type DashboardViewProps = {
|
||||
repositories: RepositorySummary[]
|
||||
@@ -10,6 +12,7 @@ type DashboardViewProps = {
|
||||
onOpenRepository: (repository: RepositorySummary) => void
|
||||
onExploreReadiness: (readiness: Readiness) => void
|
||||
onOpenExplorer: () => void
|
||||
loading?: boolean
|
||||
}
|
||||
|
||||
function relativeTime(value: string | null) {
|
||||
@@ -35,61 +38,106 @@ function remediationPath(repository: RepositorySummary) {
|
||||
}
|
||||
|
||||
function changeContext(repository: RepositorySummary) {
|
||||
if (repository.last_scan_added_findings > 0) return `${repository.last_scan_added_findings} new signal${repository.last_scan_added_findings === 1 ? '' : 's'} since prior scan`
|
||||
if (repository.last_scan_resolved_findings > 0) return `${repository.last_scan_resolved_findings} resolved since prior scan`
|
||||
return repository.last_scan_health_delta == null ? 'baseline signal' : 'longstanding signal'
|
||||
// Only surface real movement; an unchanged signal adds noise to every row.
|
||||
if (repository.last_scan_added_findings > 0) return `+${repository.last_scan_added_findings} new`
|
||||
if (repository.last_scan_resolved_findings > 0) return `${repository.last_scan_resolved_findings} resolved`
|
||||
return null
|
||||
}
|
||||
|
||||
function triagePriority(repository: RepositorySummary) {
|
||||
return repository.last_scan_priority ?? 0
|
||||
}
|
||||
|
||||
function readinessDescription(readiness: Readiness) {
|
||||
if (readiness === 'blocked') return 'needs intervention'
|
||||
if (readiness === 'warnings') return 'needs review'
|
||||
return 'ready to ship'
|
||||
const KPI: Record<Readiness, { icon: IconName; description: string }> = {
|
||||
blocked: { icon: 'blocked', description: 'Need intervention' },
|
||||
warnings: { icon: 'warning', description: 'Need review' },
|
||||
ready: { icon: 'ready', description: 'Ready to ship' },
|
||||
}
|
||||
|
||||
export function DashboardView({ repositories, pinnedIds, onOpenRepository, onExploreReadiness, onOpenExplorer }: DashboardViewProps) {
|
||||
function percentage(part: number, total: number) {
|
||||
return total ? Math.round((part / total) * 100) : 0
|
||||
}
|
||||
|
||||
export function HealthScore({ value, readiness }: { value: number | null; readiness: Readiness }) {
|
||||
return <span className={`score-pill ${readiness}`} title={value == null ? 'Not scanned' : `${value} / 100 health`}>{value ?? '—'}</span>
|
||||
}
|
||||
|
||||
export function DashboardView({ repositories, pinnedIds, onOpenRepository, onExploreReadiness, onOpenExplorer, loading = false }: DashboardViewProps) {
|
||||
if (loading && !repositories.length) return <section className="page-content dashboard-page" aria-labelledby="dashboard-title" aria-busy="true"><div className="page-heading"><div><h1 id="dashboard-title">Dashboard</h1><p className="muted" role="status">Loading the repository catalog…</p></div></div><div className="catalog-loading" aria-hidden="true"><span /><span /><span /><span /></div><div className="dashboard-skeleton" aria-hidden="true"><span /><span /></div></section>
|
||||
const portfolio = repositories.filter((repository) => !repository.archived)
|
||||
const counts = portfolio.reduce<Record<Readiness, number>>((result, repository) => {
|
||||
result[repositoryReadiness(repository)] += 1
|
||||
return result
|
||||
}, { ready: 0, warnings: 0, blocked: 0 })
|
||||
const attention = [...portfolio].filter((repository) => repositoryReadiness(repository) !== 'ready').sort((left, right) => triagePriority(right) - triagePriority(left) || (left.last_scan_health ?? -1) - (right.last_scan_health ?? -1) || (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 5)
|
||||
const recent = [...portfolio].filter((repository) => repository.last_scan_at).sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 4)
|
||||
const pinned = pinnedIds.map((id) => portfolio.find((repository) => repository.id === id)).filter((repository): repository is RepositorySummary => Boolean(repository)).slice(0, 3)
|
||||
const attention = [...portfolio].filter((repository) => repositoryReadiness(repository) !== 'ready').sort((left, right) => triagePriority(right) - triagePriority(left) || (left.last_scan_health ?? -1) - (right.last_scan_health ?? -1) || (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 8)
|
||||
const recent = [...portfolio].filter((repository) => repository.last_scan_at).sort((left, right) => (Date.parse(right.last_scan_at ?? '') || 0) - (Date.parse(left.last_scan_at ?? '') || 0)).slice(0, 5)
|
||||
const pinned = pinnedIds.map((id) => portfolio.find((repository) => repository.id === id)).filter((repository): repository is RepositorySummary => Boolean(repository)).slice(0, 4)
|
||||
const nextRepository = attention[0] ?? recent[0]
|
||||
const scannedToday = portfolio.filter((repository) => repository.last_scan_at && Date.now() - Date.parse(repository.last_scan_at) < 86_400_000).length
|
||||
const scored = portfolio.filter((repository) => repository.last_scan_health != null)
|
||||
const averageHealth = scored.length ? Math.round(scored.reduce((sum, repository) => sum + (repository.last_scan_health ?? 0), 0) / scored.length) : null
|
||||
|
||||
return (
|
||||
<section className="page-content dashboard-page cockpit-page" aria-labelledby="dashboard-title">
|
||||
<h1 id="dashboard-title" className="sr-only">Dashboard</h1>
|
||||
<section className="page-content dashboard-page" aria-labelledby="dashboard-title">
|
||||
<div className="page-heading">
|
||||
<div>
|
||||
<h1 id="dashboard-title">Dashboard</h1>
|
||||
<p className="muted">{portfolio.length} active repositories · {scannedToday} scanned in the last 24 h{averageHealth != null ? ` · average health ${averageHealth}` : ''}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav className="dashboard-readiness-rail" aria-label="Portfolio readiness summary">
|
||||
{(['blocked', 'warnings', 'ready'] as Readiness[]).map((readiness, index) => <button key={readiness} type="button" className={`readiness-rail-segment ${readiness}`} onClick={() => onExploreReadiness(readiness)} aria-label={`Open ${counts[readiness]} ${readinessLabel(readiness).toLowerCase()} repositories in Explorer`}><span>{String(index + 1).padStart(2, '0')} / {readinessLabel(readiness)}</span><strong>{counts[readiness]}</strong><small>{readinessDescription(readiness)} <b>→</b></small></button>)}
|
||||
<button type="button" className="readiness-rail-segment all" onClick={onOpenExplorer}><span>04 / Catalog</span><strong>{portfolio.length}</strong><small>Open repository explorer <b>→</b></small></button>
|
||||
<nav className="kpi-grid" aria-label="Portfolio readiness summary">
|
||||
{(['blocked', 'warnings', 'ready'] as Readiness[]).map((readiness) => <button key={readiness} type="button" className={`kpi-card ${readiness}`} onClick={() => onExploreReadiness(readiness)} aria-label={`Open ${counts[readiness]} ${readinessLabel(readiness).toLowerCase()} repositories in Explorer`}>
|
||||
<span className="kpi-label"><Icon name={KPI[readiness].icon} />{readinessLabel(readiness)}</span>
|
||||
<strong><CountUp value={counts[readiness]} /></strong>
|
||||
<small>{KPI[readiness].description} · {percentage(counts[readiness], portfolio.length)}%</small>
|
||||
</button>)}
|
||||
<button type="button" className="kpi-card all" onClick={onOpenExplorer}>
|
||||
<span className="kpi-label"><Icon name="catalog" />Catalog</span>
|
||||
<strong><CountUp value={portfolio.length} /></strong>
|
||||
<span className="distribution-bar" aria-hidden="true">{(['blocked', 'warnings', 'ready'] as Readiness[]).map((readiness) => <i key={readiness} className={readiness} style={{ flexGrow: counts[readiness] }} />)}</span>
|
||||
<small>Open repository explorer</small>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div className="cockpit-focus-grid">
|
||||
<section className="dashboard-section attention-section" aria-labelledby="attention-title">
|
||||
<div className="section-heading"><div><span className="eyebrow">Triage, in priority order</span><h2 id="attention-title">Why attention is needed</h2></div><button className="text-button" type="button" onClick={() => onExploreReadiness('blocked')}>Open blocked lane</button></div>
|
||||
{attention.length ? <div className="attention-list">{attention.map((repository, index) => <button type="button" className="attention-row" key={repository.id} onClick={() => onOpenRepository(repository)}><span className="attention-rank">{String(index + 1).padStart(2, '0')}</span><RepositoryVisual repository={repository} compact /><span className="attention-copy"><strong>{repository.full_name}</strong><small>{attentionReason(repository)}</small><span className="attention-context"><i>{repository.last_scan_primary_signal?.category ?? readinessLabel(repositoryReadiness(repository))}</i><em>{changeContext(repository)}</em></span></span><span className="attention-score"><b>{repository.last_scan_health ?? '—'}</b><small>{relativeTime(repository.last_scan_at)}</small></span></button>)}</div> : <p className="empty-inline">No repository needs attention right now.</p>}
|
||||
<div className="dashboard-grid">
|
||||
<section className="panel attention-section" aria-labelledby="attention-title">
|
||||
<div className="panel-heading"><h2 id="attention-title">Why attention is needed</h2><button className="text-button" type="button" onClick={() => onExploreReadiness('blocked')}>View all blocked <Icon name="chevronRight" /></button></div>
|
||||
{attention.length ? <div className="attention-list">{attention.map((repository) => <button type="button" className="attention-row" key={repository.id} onClick={() => onOpenRepository(repository)}>
|
||||
<RepoAvatar repository={repository} />
|
||||
<span className="attention-copy"><strong>{repository.full_name}</strong><small>{attentionReason(repository)}</small></span>
|
||||
<span className="attention-context"><i className={`chip ${repositoryReadiness(repository)}`}>{repository.last_scan_primary_signal?.category ?? readinessLabel(repositoryReadiness(repository))}</i>{changeContext(repository) && <em className={repository.last_scan_added_findings > 0 ? 'worse' : 'better'}>{changeContext(repository)}</em>}</span>
|
||||
<span className="attention-score"><HealthRing value={repository.last_scan_health} readiness={repositoryReadiness(repository)} size={38} /><small>{relativeTime(repository.last_scan_at)}</small></span>
|
||||
</button>)}</div> : <p className="empty-inline">No repository needs attention right now.</p>}
|
||||
</section>
|
||||
|
||||
<section className="dashboard-section next-move" aria-labelledby="next-move-title">
|
||||
<span className="eyebrow">Recommended next move</span><h2 id="next-move-title">{nextRepository ? nextRepository.full_name : 'Portfolio is clear'}</h2>
|
||||
{nextRepository ? <button type="button" className="next-move-action" onClick={() => onOpenRepository(nextRepository)}><RepositoryVisual repository={nextRepository} /><span><strong>{nextRepository.last_scan_health ?? '—'} health</strong><small>{attentionReason(nextRepository)}</small><em className="next-move-context"><i>{nextRepository.last_scan_primary_signal?.category ?? 'Portfolio signal'}</i>{remediationPath(nextRepository)}</em><b>Open workspace →</b></span></button> : <p className="muted">Keep the next immutable scan as the portfolio baseline.</p>}
|
||||
</section>
|
||||
<div className="dashboard-side">
|
||||
<section className="panel next-move" aria-labelledby="next-move-title">
|
||||
<span className="panel-kicker">Recommended next move</span>
|
||||
<h2 id="next-move-title">{nextRepository ? nextRepository.full_name : 'Portfolio is clear'}</h2>
|
||||
{nextRepository ? <button type="button" className="next-move-action" onClick={() => onOpenRepository(nextRepository)}>
|
||||
<span className="next-move-meta"><RepoAvatar repository={nextRepository} size="lg" /><span><strong>{nextRepository.last_scan_primary_signal?.category ?? readinessLabel(repositoryReadiness(nextRepository))}</strong><small>{relativeTime(nextRepository.last_scan_at)} · {nextRepository.default_branch}</small></span><HealthRing value={nextRepository.last_scan_health} readiness={repositoryReadiness(nextRepository)} size={52} /></span>
|
||||
<small>{attentionReason(nextRepository)}</small>
|
||||
<em className="next-move-context"><Icon name="wrench" />{remediationPath(nextRepository)}</em>
|
||||
<b>Open workspace <Icon name="arrowRight" /></b>
|
||||
</button> : <p className="muted">Keep the next immutable scan as the portfolio baseline.</p>}
|
||||
</section>
|
||||
|
||||
<section className="panel pinned-section" aria-labelledby="pinned-title">
|
||||
<div className="panel-heading"><h2 id="pinned-title">Pinned repositories</h2></div>
|
||||
{pinned.length ? <div className="compact-list">{pinned.map((repository) => <button key={repository.id} type="button" className="compact-row" onClick={() => onOpenRepository(repository)}><RepoAvatar repository={repository} size="sm" /><span><strong>{repository.name}</strong><small>{readinessLabel(repositoryReadiness(repository))}</small></span><HealthScore value={repository.last_scan_health} readiness={repositoryReadiness(repository)} /></button>)}</div> : <div className="pin-empty"><Icon name="star" /><span>Pin repositories in the explorer to keep them here.</span><button className="text-button" type="button" onClick={onOpenExplorer}>Browse repositories</button></div>}
|
||||
</section>
|
||||
|
||||
<section className="panel activity-section" aria-labelledby="recent-title">
|
||||
<div className="panel-heading"><h2 id="recent-title">Recently scanned</h2><button className="text-button" type="button" onClick={onOpenExplorer}>Explorer <Icon name="chevronRight" /></button></div>
|
||||
{recent.length ? <div className="compact-list">{recent.map((repository) => <button type="button" key={repository.id} className="compact-row" onClick={() => onOpenRepository(repository)}><RepoAvatar repository={repository} size="sm" /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' ? 'Analysis in progress' : relativeTime(repository.last_scan_at)} · {repository.default_branch}</small></span><HealthScore value={repository.last_scan_health} readiness={repositoryReadiness(repository)} /></button>)}</div> : <p className="empty-inline">No retained scans yet.</p>}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RemediationCenter repositories={portfolio} onOpenRepository={onOpenRepository} />
|
||||
|
||||
<PortfolioAtlas repositories={portfolio} onOpenRepository={onOpenRepository} />
|
||||
|
||||
<div className="dashboard-bottom-grid">
|
||||
<section className="dashboard-section activity-section" aria-labelledby="recent-title"><div className="section-heading"><div><span className="eyebrow">Change feed</span><h2 id="recent-title">Recently scanned</h2></div><button className="text-button" type="button" onClick={onOpenExplorer}>Open explorer</button></div><div className="activity-rail">{recent.map((repository) => <button type="button" key={repository.id} className="activity-rail-item" onClick={() => onOpenRepository(repository)}><span className={`status-orb ${repositoryReadiness(repository)}`} /><span><strong>{repository.full_name}</strong><small>{repository.state === 'scanning' ? 'Analysis in progress' : `Retained scan ${relativeTime(repository.last_scan_at)}`} · {repository.default_branch}</small></span><b>{repository.last_scan_health ?? '—'}</b></button>)}</div></section>
|
||||
<section className="dashboard-section pinned-section" aria-labelledby="pinned-title"><div className="section-heading"><div><span className="eyebrow">Your focus</span><h2 id="pinned-title">Pinned repositories</h2></div></div>{pinned.length ? <div className="pinned-grid">{pinned.map((repository) => <button key={repository.id} type="button" className="pinned-tile" onClick={() => onOpenRepository(repository)}><RepositoryVisual repository={repository} compact /><span><strong>{repository.name}</strong><small>{repository.last_scan_health ?? '—'} health · {readinessLabel(repositoryReadiness(repository))}</small></span><b>→</b></button>)}</div> : <div className="pin-empty"><span>Pin repositories in Explorer to keep active work in this command deck.</span><button className="text-button" type="button" onClick={onOpenExplorer}>Browse repositories</button></div>}</section>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import type { Readiness } from '../catalog'
|
||||
|
||||
function prefersReducedMotion() {
|
||||
try { return window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false } catch { return false }
|
||||
}
|
||||
|
||||
/** Animate a number from 0 to its value once; static when reduced motion is requested. */
|
||||
export function useCountUp(value: number, duration = 700) {
|
||||
const [display, setDisplay] = useState(() => (prefersReducedMotion() || typeof window.requestAnimationFrame !== 'function' ? value : 0))
|
||||
useEffect(() => {
|
||||
if (prefersReducedMotion() || typeof window.requestAnimationFrame !== 'function') { setDisplay(value); return }
|
||||
let frame = 0
|
||||
let synchronous = true
|
||||
const start = performance.now()
|
||||
const tick = () => {
|
||||
// Some environments run animation callbacks synchronously; settle immediately there.
|
||||
if (synchronous) { setDisplay(value); return }
|
||||
const progress = Math.max(0, Math.min(1, (performance.now() - start) / duration))
|
||||
const eased = 1 - Math.pow(1 - progress, 3)
|
||||
setDisplay(Math.round(value * eased))
|
||||
if (progress < 1) frame = window.requestAnimationFrame(tick)
|
||||
}
|
||||
frame = window.requestAnimationFrame(tick)
|
||||
synchronous = false
|
||||
return () => window.cancelAnimationFrame(frame)
|
||||
}, [value, duration])
|
||||
return display
|
||||
}
|
||||
|
||||
export function CountUp({ value }: { value: number }) {
|
||||
return <>{useCountUp(value)}</>
|
||||
}
|
||||
|
||||
/** A compact health gauge: the arc follows the retained 0–100 score, coloured by readiness. */
|
||||
export function HealthRing({ value, readiness, size = 40, label = true }: { value: number | null; readiness: Readiness; size?: number; label?: boolean }) {
|
||||
const stroke = size >= 64 ? 5 : 3.5
|
||||
const radius = (size - stroke) / 2
|
||||
const circumference = 2 * Math.PI * radius
|
||||
const score = value == null ? 0 : Math.max(0, Math.min(100, value))
|
||||
return (
|
||||
<span className={`health-ring ${readiness} ${value == null ? 'unknown' : ''}`} style={{ width: size, height: size }} title={value == null ? 'Not scanned' : `${value} / 100 health`}>
|
||||
<svg viewBox={`0 0 ${size} ${size}`} width={size} height={size} aria-hidden="true">
|
||||
<circle className="health-ring-track" cx={size / 2} cy={size / 2} r={radius} strokeWidth={stroke} fill="none" />
|
||||
<circle className="health-ring-value" cx={size / 2} cy={size / 2} r={radius} strokeWidth={stroke} fill="none" strokeLinecap="round" strokeDasharray={circumference} strokeDashoffset={circumference * (1 - score / 100)} transform={`rotate(-90 ${size / 2} ${size / 2})`} style={{ ['--ring-length' as string]: circumference }} />
|
||||
</svg>
|
||||
{label && <b>{value ?? '—'}</b>}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -1,24 +1,60 @@
|
||||
import type { ScanComparison, ScanSummary, TrendPoint } from '../api'
|
||||
|
||||
function chronological(trend: TrendPoint[]) {
|
||||
return [...trend].sort((left, right) => Date.parse(left.scanned_at) - Date.parse(right.scanned_at))
|
||||
}
|
||||
|
||||
function shortDate(value: string) {
|
||||
const date = new Date(value)
|
||||
return Number.isNaN(date.getTime()) ? '—' : date.toLocaleDateString([], { day: 'numeric', month: 'short' })
|
||||
}
|
||||
|
||||
function TrendDelta({ trend }: { trend: TrendPoint[] }) {
|
||||
const points = chronological(trend)
|
||||
const delta = points[points.length - 1].health_score - points[0].health_score
|
||||
return <span className={`trend-delta ${delta > 0 ? 'positive' : delta < 0 ? 'negative' : ''}`}>{delta > 0 ? '+' : ''}{delta} since {shortDate(points[0].scanned_at)}</span>
|
||||
}
|
||||
|
||||
/** Health per persisted snapshot as an area chart; the y-domain hugs the observed range. */
|
||||
function TrendChart({ trend }: { trend: TrendPoint[] }) {
|
||||
const points = chronological(trend)
|
||||
const scores = points.map((point) => point.health_score)
|
||||
const low = Math.max(0, Math.floor((Math.min(...scores) - 6) / 5) * 5)
|
||||
const high = Math.min(100, Math.ceil((Math.max(...scores) + 6) / 5) * 5)
|
||||
const span = Math.max(1, high - low)
|
||||
const x = (index: number) => (points.length === 1 ? 50 : (index / (points.length - 1)) * 100)
|
||||
const y = (score: number) => 100 - ((score - low) / span) * 100
|
||||
const line = points.map((point, index) => `${index ? 'L' : 'M'}${x(index).toFixed(2)} ${y(point.health_score).toFixed(2)}`).join(' ')
|
||||
const area = `${line} L${x(points.length - 1).toFixed(2)} 100 L${x(0).toFixed(2)} 100 Z`
|
||||
const last = points[points.length - 1]
|
||||
const ticks = [high, Math.round((high + low) / 2), low]
|
||||
return (
|
||||
<div className="trend-chart" role="img" aria-label={`Repository health trend: ${points.length} snapshots from ${scores[0]} to ${last.health_score}`}>
|
||||
<div className="trend-axis" aria-hidden="true">{ticks.map((tick) => <span key={tick}>{tick}</span>)}</div>
|
||||
<div className="trend-plot">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true">
|
||||
<defs><linearGradient id="trend-fill" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stopColor="var(--accent)" stopOpacity=".32" /><stop offset="1" stopColor="var(--accent)" stopOpacity="0" /></linearGradient></defs>
|
||||
{[0, 50, 100].map((grid) => <line key={grid} className="trend-grid" x1="0" x2="100" y1={grid} y2={grid} vectorEffect="non-scaling-stroke" />)}
|
||||
<path className="trend-area" d={area} fill="url(#trend-fill)" />
|
||||
<path className="trend-line" d={line} vectorEffect="non-scaling-stroke" />
|
||||
</svg>
|
||||
<span className="trend-marker" style={{ left: `${x(points.length - 1)}%`, top: `${y(last.health_score)}%` }} aria-hidden="true"><b>{last.health_score}</b></span>
|
||||
<div className="trend-hits">{points.map((point) => <span key={point.scan_id} title={`${new Date(point.scanned_at).toLocaleString()} · ${point.health_score}/100 · ${point.findings} finding(s)`} />)}</div>
|
||||
</div>
|
||||
<div className="trend-dates" aria-hidden="true"><span>{shortDate(points[0].scanned_at)}</span>{points.length > 2 && <span>{shortDate(points[Math.floor(points.length / 2)].scanned_at)}</span>}<span>{shortDate(last.scanned_at)}</span></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function HistoryView({ trend, comparison, scanSummaries = [], currentScanId, onSelectScan }: { trend: TrendPoint[]; comparison: ScanComparison | null; scanSummaries?: ScanSummary[]; currentScanId?: string; onSelectScan?: (summary: ScanSummary) => void }) {
|
||||
return (
|
||||
<div className="view-stack">
|
||||
<section className="section-card">
|
||||
<div className="section-heading">
|
||||
<div><span className="eyebrow">History</span><h3>Repository health over time</h3></div>
|
||||
<span className="section-note">Each bar is one persisted scan snapshot.</span>
|
||||
<div><h3>Repository health over time</h3><p className="panel-subtitle">{trend.length} persisted scan snapshot{trend.length === 1 ? '' : 's'}</p></div>
|
||||
{trend.length > 1 && <TrendDelta trend={trend} />}
|
||||
</div>
|
||||
{trend.length ? (
|
||||
<div className="trend-chart" aria-label="Repository health trend">
|
||||
{trend.map((point) => (
|
||||
<div className="trend-column" key={point.scan_id} title={`${new Date(point.scanned_at).toLocaleString()} · ${point.health_score}/100`}>
|
||||
<span>{point.health_score}</span>
|
||||
<div className="trend-track"><i style={{ height: `${Math.max(4, point.health_score)}%` }} /></div>
|
||||
<small>{new Date(point.scanned_at).toLocaleDateString()}</small>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : <div className="empty-inline">Run multiple scans of the same repository to build a trend.</div>}
|
||||
{trend.length ? <TrendChart trend={trend} /> : <div className="empty-inline">Run multiple scans of the same repository to build a trend.</div>}
|
||||
</section>
|
||||
|
||||
<section className="comparison-grid">
|
||||
@@ -53,7 +89,7 @@ export function HistoryView({ trend, comparison, scanSummaries = [], currentScan
|
||||
|
||||
<section className="section-card scan-run-card">
|
||||
<div className="section-heading">
|
||||
<div><span className="eyebrow">Persisted snapshots</span><h3>Scan runs</h3></div>
|
||||
<div><h3>Scan runs</h3></div>
|
||||
<span className="section-note">Select a revision to inspect its report.</span>
|
||||
</div>
|
||||
{scanSummaries.length ? (
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* A small inline icon set. Paths follow the Lucide icon set (ISC licence) so
|
||||
* the interface gets consistent 24px line icons without a runtime dependency.
|
||||
*/
|
||||
const PATHS = {
|
||||
dashboard: ['M3 3h7v9H3z', 'M14 3h7v5h-7z', 'M14 12h7v9h-7z', 'M3 16h7v5H3z'],
|
||||
repositories: ['M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z'],
|
||||
activity: ['M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2'],
|
||||
queue: ['M3 12h.01', 'M3 18h.01', 'M3 6h.01', 'M8 12h13', 'M8 18h13', 'M8 6h13'],
|
||||
settings: ['M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z', 'M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z'],
|
||||
search: ['M21 21l-4.34-4.34', 'M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0z'],
|
||||
refresh: ['M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8', 'M21 3v5h-5', 'M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16', 'M8 16H3v5'],
|
||||
arrowRight: ['M5 12h14', 'M12 5l7 7-7 7'],
|
||||
chevronRight: ['M9 18l6-6-6-6'],
|
||||
chevronDown: ['M6 9l6 6 6-6'],
|
||||
blocked: ['M12 8v4', 'M12 16h.01', 'M15.31 2a2 2 0 0 1 1.42.59l4.68 4.68A2 2 0 0 1 22 8.69v6.62a2 2 0 0 1-.59 1.42l-4.68 4.68a2 2 0 0 1-1.42.59H8.69a2 2 0 0 1-1.42-.59l-4.68-4.68A2 2 0 0 1 2 15.31V8.69a2 2 0 0 1 .59-1.42l4.68-4.68A2 2 0 0 1 8.69 2z'],
|
||||
warning: ['M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3', 'M12 9v4', 'M12 17h.01'],
|
||||
ready: ['M21.8 10A10 10 0 1 1 17 3.34', 'M9 11l3 3L22 4'],
|
||||
catalog: ['M12 2 2 7l10 5 10-5-10-5z', 'M2 17l10 5 10-5', 'M2 12l10 5 10-5'],
|
||||
clock: ['M12 6v6l4 2', 'M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0z'],
|
||||
wrench: ['M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z'],
|
||||
star: ['M11.53 2.3a.53.53 0 0 1 .95 0l2.31 4.68a2.12 2.12 0 0 0 1.6 1.16l5.16.76a.53.53 0 0 1 .3.9l-3.74 3.64a2.12 2.12 0 0 0-.61 1.88l.88 5.14a.53.53 0 0 1-.77.56l-4.62-2.43a2.12 2.12 0 0 0-1.97 0L6.4 21.01a.53.53 0 0 1-.77-.56l.88-5.13a2.12 2.12 0 0 0-.61-1.88L2.16 9.8a.53.53 0 0 1 .29-.9l5.17-.76a2.12 2.12 0 0 0 1.6-1.16z'],
|
||||
branch: ['M6 3v12', 'M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z', 'M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z', 'M18 9a9 9 0 0 1-9 9'],
|
||||
commit: ['M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z', 'M3 12h6', 'M15 12h6'],
|
||||
close: ['M18 6 6 18', 'M6 6l12 12'],
|
||||
download: ['M12 15V3', 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4', 'M7 10l5 5 5-5'],
|
||||
more: ['M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z', 'M19 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z', 'M5 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2z'],
|
||||
play: ['M6 4l14 8-14 8z'],
|
||||
} as const
|
||||
|
||||
export type IconName = keyof typeof PATHS
|
||||
|
||||
export function Icon({ name, size = 16, className = '' }: { name: IconName; size?: number; className?: string }) {
|
||||
return (
|
||||
<svg className={`icon ${className}`} width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false">
|
||||
{PATHS[name].map((d) => <path key={d} d={d} />)}
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -10,9 +10,9 @@ type PortfolioAtlasProps = {
|
||||
const laneOrder: Readiness[] = ['blocked', 'warnings', 'ready']
|
||||
|
||||
const laneCopy: Record<Readiness, { title: string; description: string }> = {
|
||||
blocked: { title: 'Intervention lane', description: 'Release-blocking repository signals' },
|
||||
warnings: { title: 'Review lane', description: 'Warnings worth resolving before the next release' },
|
||||
ready: { title: 'Clear lane', description: 'Repositories with a clear release signal' },
|
||||
blocked: { title: 'Blocked', description: 'Release-blocking signals' },
|
||||
warnings: { title: 'Warnings', description: 'Worth resolving before the next release' },
|
||||
ready: { title: 'Ready', description: 'Clear release signal' },
|
||||
}
|
||||
|
||||
function scanRhythm(repository: RepositorySummary) {
|
||||
@@ -26,10 +26,6 @@ function scanRhythm(repository: RepositorySummary) {
|
||||
return `scanned ${Math.floor(difference / 86_400_000)}d ago`
|
||||
}
|
||||
|
||||
function signalStrength(repository: RepositorySummary) {
|
||||
return Math.max(16, Math.min(100, repository.last_scan_health ?? 36))
|
||||
}
|
||||
|
||||
export function PortfolioAtlas({ repositories, onOpenRepository }: PortfolioAtlasProps) {
|
||||
const ordered = [...repositories].sort((left, right) => {
|
||||
const lane = laneOrder.indexOf(repositoryReadiness(left)) - laneOrder.indexOf(repositoryReadiness(right))
|
||||
@@ -38,38 +34,35 @@ export function PortfolioAtlas({ repositories, onOpenRepository }: PortfolioAtla
|
||||
const density = ordered.length > 160 ? 'compact' : ordered.length > 96 ? 'dense' : 'comfortable'
|
||||
|
||||
return (
|
||||
<section className="portfolio-atlas dashboard-section" aria-labelledby="atlas-title" data-density={density}>
|
||||
<div className="section-heading atlas-heading">
|
||||
<div><span className="eyebrow">Portfolio topology</span><h2 id="atlas-title">Repository signal landscape</h2></div>
|
||||
<span className="section-note">{ordered.length} repositories · every signal opens its workspace</span>
|
||||
</div>
|
||||
<div className="atlas-field">
|
||||
<svg className="atlas-contours" viewBox="0 0 1200 330" aria-hidden="true" preserveAspectRatio="none"><path d="M-20 270C118 216 190 318 335 246S525 172 656 230s250 38 390-55 154 3 210-38" /><path d="M-30 178c127-71 214 32 350-44s283 9 425-53 248 24 478-72" /><path d="M-10 90c156 27 230-67 390-8s209-18 362 24 252-56 475-13" /></svg>
|
||||
<div className="atlas-bands">
|
||||
{laneOrder.map((lane, laneIndex) => {
|
||||
const laneRepositories = ordered.filter((repository) => repositoryReadiness(repository) === lane)
|
||||
const copy = laneCopy[lane]
|
||||
return <section className={`atlas-band ${lane}`} key={lane} aria-labelledby={`atlas-${lane}-title`} data-lane={lane}>
|
||||
<header><i className="atlas-lane-beacon" aria-hidden="true" /><span>{String(laneIndex + 1).padStart(2, '0')} / {copy.title}</span><strong id={`atlas-${lane}-title`}>{laneRepositories.length}</strong><small>{copy.description}</small></header>
|
||||
<div className="atlas-river"><ol className="atlas-tiles" aria-label={`${readinessLabel(lane)} repositories`}>
|
||||
{laneRepositories.map((repository, index) => {
|
||||
const health = repository.last_scan_health ?? 0
|
||||
const style = { '--signal-strength': `${signalStrength(repository)}%`, '--signal-index': index, '--signal-phase': index % 7 } as CSSProperties
|
||||
const primary = repository.last_scan_primary_signal
|
||||
const signalDetail = primary ? `${primary.count} ${primary.category.toLowerCase()} signal${primary.count === 1 ? '' : 's'}` : 'no primary finding retained'
|
||||
return <li key={repository.id}><button type="button" className={`atlas-repository ${repository.stale ? 'stale' : ''} ${repository.state === 'scanning' ? 'scanning' : ''}`} onClick={() => onOpenRepository(repository)} style={style} aria-label={`Open ${repository.full_name}: ${health || 'not scanned'} health, ${readinessLabel(lane)}, ${signalDetail}, ${scanRhythm(repository)}`}>
|
||||
<span className="atlas-repository-orbit" aria-hidden="true" />
|
||||
<span className="atlas-repository-name">{repository.name.slice(0, 3).toUpperCase()}</span>
|
||||
<span className="atlas-repository-health">{health || '—'}</span>
|
||||
<i aria-hidden="true" />
|
||||
</button></li>
|
||||
})}
|
||||
</ol></div>
|
||||
</section>
|
||||
})}
|
||||
<section className="portfolio-atlas panel" aria-labelledby="atlas-title" data-density={density}>
|
||||
<div className="panel-heading">
|
||||
<div>
|
||||
<h2 id="atlas-title">Portfolio health map</h2>
|
||||
<p className="panel-subtitle">{ordered.length} repositories, lowest health first. Select a cell to open its workspace.</p>
|
||||
</div>
|
||||
<p className="atlas-legend" aria-hidden="true"><span><i className="swatch stale" />Stale scan</span><span><i className="swatch scanning" />Scanning</span></p>
|
||||
</div>
|
||||
<div className="atlas-bands">
|
||||
{laneOrder.map((lane) => {
|
||||
const laneRepositories = ordered.filter((repository) => repositoryReadiness(repository) === lane)
|
||||
const copy = laneCopy[lane]
|
||||
return <section className={`atlas-band ${lane}`} key={lane} aria-labelledby={`atlas-${lane}-title`} data-lane={lane}>
|
||||
<header><i className={`status-orb ${lane}`} aria-hidden="true" /><span id={`atlas-${lane}-title`}>{copy.title}</span><strong>{laneRepositories.length}</strong><small>{copy.description}</small></header>
|
||||
{laneRepositories.length ? <ol className="atlas-tiles" aria-label={`${readinessLabel(lane)} repositories`}>
|
||||
{laneRepositories.map((repository) => {
|
||||
const health = repository.last_scan_health ?? 0
|
||||
const style = { '--health': `${Math.max(0, Math.min(100, health))}` } as CSSProperties
|
||||
const primary = repository.last_scan_primary_signal
|
||||
const signalDetail = primary ? `${primary.count} ${primary.category.toLowerCase()} signal${primary.count === 1 ? '' : 's'}` : 'no primary finding retained'
|
||||
return <li key={repository.id}><button type="button" className={`atlas-repository ${repository.stale ? 'stale' : ''} ${repository.state === 'scanning' ? 'scanning' : ''}`} onClick={() => onOpenRepository(repository)} style={style} title={`${repository.full_name} · ${health || '—'} health`} aria-label={`Open ${repository.full_name}: ${health || 'not scanned'} health, ${readinessLabel(lane)}, ${signalDetail}, ${scanRhythm(repository)}`}>
|
||||
<span className="atlas-repository-health">{health || '—'}</span>
|
||||
<span className="atlas-repository-name">{repository.name}</span>
|
||||
</button></li>
|
||||
})}
|
||||
</ol> : <p className="empty-inline">No repositories in this lane.</p>}
|
||||
</section>
|
||||
})}
|
||||
</div>
|
||||
<p className="atlas-legend"><span><i className="blocked" />Health bar height follows the retained score.</span><span><i className="stale" />A dashed frame means the scan needs refreshing.</span><span><i className="scanning" />A live ring means analysis is in progress.</span></p>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { RepositorySummary } from '../api'
|
||||
import { repositoryReadiness } from '../catalog'
|
||||
import { Icon } from './Icon'
|
||||
import { RepoAvatar } from './RepoAvatar'
|
||||
|
||||
type RemediationCenterProps = {
|
||||
repositories: RepositorySummary[]
|
||||
@@ -15,13 +17,12 @@ export function RemediationCenter({ repositories, onOpenRepository }: Remediatio
|
||||
if (!candidates.length) return null
|
||||
|
||||
return (
|
||||
<section className="dashboard-section remediation-center" aria-labelledby="remediation-center-title">
|
||||
<div className="section-heading">
|
||||
<section className="panel remediation-center" aria-labelledby="remediation-center-title">
|
||||
<div className="panel-heading">
|
||||
<div>
|
||||
<span className="eyebrow">Backend-ranked candidates</span>
|
||||
<h2 id="remediation-center-title">Remediation Center</h2>
|
||||
<p className="panel-subtitle">Highest-priority fixes, ranked by the backend from retained scan evidence.</p>
|
||||
</div>
|
||||
<span className="remediation-live">retained evidence</span>
|
||||
</div>
|
||||
<ol className="remediation-list">
|
||||
{candidates.map((repository) => {
|
||||
@@ -31,14 +32,14 @@ export function RemediationCenter({ repositories, onOpenRepository }: Remediatio
|
||||
return (
|
||||
<li key={repository.id}>
|
||||
<button type="button" className="remediation-row" onClick={() => onOpenRepository(repository)}>
|
||||
<span className="remediation-priority" aria-label={`Priority ${repository.last_scan_priority ?? 0}`}>{repository.last_scan_priority ?? 0}</span>
|
||||
<RepoAvatar repository={repository} />
|
||||
<span className="remediation-copy">
|
||||
<strong>{repository.full_name}</strong>
|
||||
<span className="remediation-title"><strong>{repository.full_name}</strong><span className="remediation-priority" aria-label={`Priority ${repository.last_scan_priority ?? 0}`}>P{repository.last_scan_priority ?? 0}</span></span>
|
||||
<small>{guidance?.remediation_class ?? signal.category} · {guidance?.confidence ?? 'review'} confidence</small>
|
||||
<em>{guidance?.why ?? signal.message}</em>
|
||||
<b>{guidance?.recommended_action ?? 'Open the retained evidence and select the smallest safe next action.'}</b>
|
||||
<b><Icon name="wrench" />{guidance?.recommended_action ?? 'Open the retained evidence and select the smallest safe next action.'}</b>
|
||||
</span>
|
||||
<span className="remediation-arrow" aria-hidden="true">→</span>
|
||||
<span className="remediation-arrow" aria-hidden="true"><Icon name="chevronRight" /></span>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
import type { RepositorySummary } from '../api'
|
||||
import { repositoryReadiness } from '../catalog'
|
||||
|
||||
// Repositories without a usable icon answer 404 once; remember that for this session.
|
||||
const missingIcons = new Set<string>()
|
||||
|
||||
export function repositoryIconUrl(repository: RepositorySummary) {
|
||||
const revision = repository.last_scan_revision ?? repository.latest_revision
|
||||
return revision ? `/api/v1/repositories/${encodeURIComponent(repository.id)}/icon?rev=${encodeURIComponent(revision)}` : null
|
||||
}
|
||||
|
||||
function initialsFor(name: string) {
|
||||
const words = name.replace(/([a-z])([A-Z])/g, '$1 $2').split(/[\s_.-]+/).filter(Boolean)
|
||||
return (words.length > 1 ? `${words[0][0]}${words[1][0]}` : name.slice(0, 2)).toUpperCase()
|
||||
}
|
||||
|
||||
/** The project's own favicon or logo from its retained revision, with honest initials as fallback. */
|
||||
export function RepoAvatar({ repository, size = 'md' }: { repository: RepositorySummary; size?: 'sm' | 'md' | 'lg' | 'xl' }) {
|
||||
const url = repositoryIconUrl(repository)
|
||||
const [failed, setFailed] = useState(() => !url || missingIcons.has(url))
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
const showIcon = Boolean(url) && !failed
|
||||
return (
|
||||
<span className={`repo-avatar repo-avatar-${size} ${repositoryReadiness(repository)} ${repository.state === 'scanning' ? 'scanning' : ''} ${showIcon && loaded ? 'has-icon' : ''}`} aria-hidden="true">
|
||||
{(!showIcon || !loaded) && <span className="repo-avatar-initials">{initialsFor(repository.name)}</span>}
|
||||
{showIcon && url && <img src={url} alt="" loading="lazy" decoding="async" draggable={false} onLoad={() => setLoaded(true)} onError={() => { missingIcons.add(url); setFailed(true) }} style={loaded ? undefined : { opacity: 0 }} />}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import App from './App'
|
||||
import '@fontsource-variable/inter/wght.css'
|
||||
import './styles.css'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
|
||||
+862
-595
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,9 @@ export default defineConfig(({ mode }) => {
|
||||
|
||||
return {
|
||||
plugins: [react()],
|
||||
// The Architecture view is lazy-loaded; pre-bundle React Flow so the dev server never
|
||||
// re-optimizes and reloads mid-session when that chunk is first requested.
|
||||
optimizeDeps: { include: ['@xyflow/react'] },
|
||||
server: {
|
||||
port: 5174,
|
||||
proxy: {
|
||||
|
||||
Reference in new issue
Block a user