import { registerAppBarAction, registerDetailsViewSection, registerPluginSettings, registerRoute, registerSidebarEntry, } from '@kinvolk/headlamp-plugin/lib'; import { SectionBox, StatusLabel } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import React from 'react'; import { PolarisDataProvider } from './api/PolarisDataContext'; import AppBarScoreBadge from './components/AppBarScoreBadge'; import DashboardView from './components/DashboardView'; import InlineAuditSection from './components/InlineAuditSection'; import NamespacesListView from './components/NamespacesListView'; import PolarisSettings from './components/PolarisSettings'; // --- Error boundary for plugin components --- interface ErrorBoundaryState { error: string | null; } class PolarisErrorBoundary extends React.Component< { children: React.ReactNode }, ErrorBoundaryState > { state: ErrorBoundaryState = { error: null }; static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { error: error.message }; } render() { if (this.state.error) { return ( {this.state.error} ); } return this.props.children; } } // --- Sidebar entries --- registerSidebarEntry({ parent: null, name: 'polaris', label: 'Polaris', url: '/polaris', icon: 'mdi:shield-check', }); registerSidebarEntry({ parent: 'polaris', name: 'polaris-overview', label: 'Overview', url: '/polaris', icon: 'mdi:view-dashboard', }); registerSidebarEntry({ parent: 'polaris', name: 'polaris-namespaces', label: 'Namespaces', url: '/polaris/namespaces', icon: 'mdi:dns', }); // --- Routes --- registerRoute({ path: '/polaris', sidebar: 'polaris-overview', name: 'polaris', exact: true, component: () => ( ), }); registerRoute({ path: '/polaris/namespaces', sidebar: 'polaris-namespaces', name: 'polaris-namespaces', exact: true, component: () => ( ), }); // Register plugin settings registerPluginSettings('headlamp-polaris', PolarisSettings, true); // Register details view section for supported controller types registerDetailsViewSection(({ resource }) => { const supportedKinds = ['Deployment', 'StatefulSet', 'DaemonSet', 'Job', 'CronJob']; if (!supportedKinds.includes(resource?.kind)) { return null; } return ( ); }); // Register app bar score badge registerAppBarAction(() => ( ));