811059cf75
Major new features: - App bar score badge showing cluster Polaris score - Inline audit results in Deployment/StatefulSet/DaemonSet/Job/CronJob detail views - Exemption management UI with annotation PATCH support - Top issues table on overview dashboard - Audit time display and manual refresh button - Connection test button in settings - Check ID to human-readable name mapping - Enhanced error messages with context Technical improvements: - Added triggerRefresh to PolarisDataContext for manual refresh - Created checkMapping.ts for check metadata - Created topIssues.ts for extracting common failures - Enhanced DashboardView with top issues and refresh - Enhanced PolarisSettings with connection test - Created InlineAuditSection for details view integration - Created AppBarScoreBadge for app bar integration - Created ExemptionManager for annotation patches UI enhancements: - 1000px namespace detail panel - Theme-aware styling throughout - Improved formatting and layout - Better status indicators Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { Chip } from '@mui/material';
|
|
import { Shield as ShieldIcon } from '@mui/icons-material';
|
|
import React from 'react';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { usePolarisDataContext } from '../api/PolarisDataContext';
|
|
import { computeScore, countResults } from '../api/polaris';
|
|
|
|
/**
|
|
* App bar badge showing cluster Polaris score
|
|
* Clicking navigates to the overview dashboard
|
|
*/
|
|
export default function AppBarScoreBadge() {
|
|
const { data, loading } = usePolarisDataContext();
|
|
const history = useHistory();
|
|
|
|
if (loading || !data) {
|
|
return null; // Graceful degradation when Polaris unavailable
|
|
}
|
|
|
|
const counts = countResults(data);
|
|
const score = computeScore(counts);
|
|
|
|
// Color based on score
|
|
const getColor = (score: number): 'success' | 'warning' | 'error' => {
|
|
if (score >= 80) return 'success';
|
|
if (score >= 50) return 'warning';
|
|
return 'error';
|
|
};
|
|
|
|
const handleClick = () => {
|
|
history.push('/polaris');
|
|
};
|
|
|
|
return (
|
|
<Chip
|
|
icon={<ShieldIcon />}
|
|
label={`Polaris: ${score}%`}
|
|
color={getColor(score)}
|
|
size="small"
|
|
onClick={handleClick}
|
|
style={{ cursor: 'pointer', marginRight: '8px' }}
|
|
/>
|
|
);
|
|
}
|