feat: restructure sidebar hierarchy and add full audit view

Reorganize the sidebar into a proper hierarchy (Overview, Full Audit,
Namespaces) and add a Full Audit dashboard view that includes skipped
checks. Namespace routes move to /polaris/ns/:namespace to avoid
path collisions, and namespace detail pages now link out to the
Polaris dashboard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 09:50:28 -05:00
parent 9a1d7f961f
commit 1559a9ffcd
5 changed files with 112 additions and 29 deletions
@@ -6,7 +6,7 @@ import {
StatusLabel,
} from '@kinvolk/headlamp-plugin/lib/CommonComponents';
import React from 'react';
import { AuditData, computeScore, countResults, ResultCounts } from '../api/polaris';
import { AuditData, countResults, ResultCounts } from '../api/polaris';
import { usePolarisDataContext } from '../api/PolarisDataContext';
function scoreStatus(score: number): 'success' | 'warning' | 'error' {
@@ -15,10 +15,41 @@ function scoreStatus(score: number): 'success' | 'warning' | 'error' {
return 'error';
}
function OverviewSection(props: { data: AuditData; counts: ResultCounts }) {
const score = computeScore(props.counts);
function OverviewSection(props: {
data: AuditData;
counts: ResultCounts;
includeSkipped: boolean;
}) {
const { counts, includeSkipped } = props;
const displayTotal = includeSkipped ? counts.total : counts.total - counts.skipped;
const displayPass = counts.pass;
const score = displayTotal === 0 ? 0 : Math.round((displayPass / displayTotal) * 100);
const status = scoreStatus(score);
const summaryRows: { name: string; value: React.ReactNode }[] = [
{ name: 'Total Checks', value: String(displayTotal) },
{
name: 'Pass',
value: <StatusLabel status="success">{counts.pass}</StatusLabel>,
},
{
name: 'Warning',
value: <StatusLabel status="warning">{counts.warning}</StatusLabel>,
},
{
name: 'Danger',
value: <StatusLabel status="error">{counts.danger}</StatusLabel>,
},
];
if (includeSkipped) {
summaryRows.push({
name: 'Skipped',
value: <StatusLabel status="">{counts.skipped}</StatusLabel>,
});
}
return (
<>
<SectionBox title="Score">
@@ -32,23 +63,7 @@ function OverviewSection(props: { data: AuditData; counts: ResultCounts }) {
/>
</SectionBox>
<SectionBox title="Check Summary">
<NameValueTable
rows={[
{ name: 'Total Checks', value: String(props.counts.total) },
{
name: 'Pass',
value: <StatusLabel status="success">{props.counts.pass}</StatusLabel>,
},
{
name: 'Warning',
value: <StatusLabel status="warning">{props.counts.warning}</StatusLabel>,
},
{
name: 'Danger',
value: <StatusLabel status="error">{props.counts.danger}</StatusLabel>,
},
]}
/>
<NameValueTable rows={summaryRows} />
</SectionBox>
<SectionBox title="Cluster Info">
<NameValueTable
@@ -64,8 +79,9 @@ function OverviewSection(props: { data: AuditData; counts: ResultCounts }) {
);
}
export default function PolarisView() {
export default function DashboardView(props: { includeSkipped: boolean }) {
const { data, loading, error } = usePolarisDataContext();
const title = props.includeSkipped ? 'Polaris — Full Audit' : 'Polaris — Overview';
if (loading) {
return <Loader title="Loading Polaris audit data..." />;
@@ -75,7 +91,7 @@ export default function PolarisView() {
return (
<>
<SectionHeader title="Polaris" />
<SectionHeader title={title} />
{error && (
<SectionBox title="Error">
@@ -90,7 +106,9 @@ export default function PolarisView() {
</SectionBox>
)}
{data && counts && <OverviewSection data={data} counts={counts} />}
{data && counts && (
<OverviewSection data={data} counts={counts} includeSkipped={props.includeSkipped} />
)}
{!data && !error && (
<SectionBox title="No Data">
+2 -2
View File
@@ -16,10 +16,10 @@ export default function DynamicSidebarRegistrar() {
if (registeredNamespaces.has(ns)) continue;
registeredNamespaces.add(ns);
registerSidebarEntry({
parent: 'polaris',
parent: 'polaris-namespaces',
name: `polaris-ns-${ns}`,
label: ns,
url: `/polaris/${ns}`,
url: `/polaris/ns/${ns}`,
icon: 'mdi:folder-outline',
});
}
+16
View File
@@ -12,6 +12,7 @@ import {
computeScore,
countResultsForItems,
filterResultsByNamespace,
POLARIS_DASHBOARD_PROXY,
Result,
ResultCounts,
} from '../api/polaris';
@@ -82,6 +83,21 @@ export default function NamespaceDetailView() {
<>
<SectionHeader title={`Polaris — ${namespace}`} />
<SectionBox title="External">
<NameValueTable
rows={[
{
name: 'Polaris Dashboard',
value: (
<a href={POLARIS_DASHBOARD_PROXY} target="_blank" rel="noopener noreferrer">
View in Polaris Dashboard
</a>
),
},
]}
/>
</SectionBox>
<SectionBox title="Namespace Score">
<NameValueTable
rows={[