@skyhook-io/radar-app 1.20.1 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +65 -16
  3. package/src/api/client.audit-gating.test.tsx +105 -5
  4. package/src/api/client.auditBadgesSync.test.tsx +118 -0
  5. package/src/api/client.capabilitiesPoll.test.ts +61 -0
  6. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  7. package/src/api/client.pauseDeployment.test.tsx +77 -0
  8. package/src/api/client.restartError.test.ts +14 -0
  9. package/src/api/client.revisionRefresh.test.tsx +44 -0
  10. package/src/api/client.rollbackError.test.ts +14 -0
  11. package/src/api/client.ts +347 -16
  12. package/src/api/namespaceScopeRetry.test.ts +14 -0
  13. package/src/api/networkAttachments.test.tsx +120 -0
  14. package/src/api/networkAttachments.ts +30 -0
  15. package/src/api/radarFeatures.test.ts +5 -0
  16. package/src/api/radarFeatures.ts +10 -0
  17. package/src/api/secretsStore.test.ts +33 -0
  18. package/src/api/secretsStore.ts +37 -0
  19. package/src/api/substrateHealth.ts +134 -0
  20. package/src/api/velero.test.ts +60 -0
  21. package/src/api/velero.ts +201 -0
  22. package/src/api/vulnerabilities.ts +255 -0
  23. package/src/components/ConnectionErrorView.test.tsx +11 -0
  24. package/src/components/ConnectionErrorView.tsx +19 -0
  25. package/src/components/ContextSwitcher.tsx +9 -2
  26. package/src/components/NamespaceSwitcher.tsx +3 -1
  27. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  28. package/src/components/applications/ApplicationsView.tsx +8 -11
  29. package/src/components/audit/AuditView.tsx +4 -0
  30. package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
  31. package/src/components/audit/ChecksViewTabs.tsx +11 -1
  32. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  33. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  34. package/src/components/audit/VulnerabilitiesView.tsx +907 -0
  35. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  36. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  37. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  38. package/src/components/cnpg/CNPGView.tsx +43 -117
  39. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  40. package/src/components/cnpg/host.tsx +2 -2
  41. package/src/components/cnpg/routes.ts +3 -1
  42. package/src/components/cnpg/shared.tsx +5 -53
  43. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  44. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  45. package/src/components/community.tsx +42 -0
  46. package/src/components/cost/CostView.tsx +27 -9
  47. package/src/components/diagnose/InvestigationView.tsx +12 -3
  48. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  49. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  50. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
  51. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  52. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  53. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  54. package/src/components/diagnose/investigationMetrics.ts +2 -1
  55. package/src/components/dock/BottomDock.tsx +1 -0
  56. package/src/components/dock/LogsTab.tsx +3 -0
  57. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  58. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  59. package/src/components/dock/TerminalPreferences.tsx +73 -0
  60. package/src/components/gitops/GitOpsView.tsx +2 -10
  61. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  62. package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
  63. package/src/components/helm/HelmView.tsx +25 -19
  64. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  65. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  66. package/src/components/helm/OwnedResources.test.tsx +86 -0
  67. package/src/components/helm/OwnedResources.tsx +69 -11
  68. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  69. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  70. package/src/components/home/ClusterHealthCard.tsx +25 -11
  71. package/src/components/home/HelmSummary.tsx +15 -15
  72. package/src/components/home/HomeAgentBlock.tsx +3 -0
  73. package/src/components/home/HomeView.tsx +7 -0
  74. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  75. package/src/components/home/MCPSetupDialog.tsx +4 -2
  76. package/src/components/home/mcpToolCatalog.ts +17 -4
  77. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  78. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  79. package/src/components/logs/LogsViewer.tsx +3 -1
  80. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  81. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  82. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  83. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  84. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  85. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  86. package/src/components/resource/RightsizingStrip.tsx +53 -4
  87. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  88. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  89. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  90. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  91. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  92. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  93. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  94. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  95. package/src/components/resources/ResourcesView.tsx +12 -6
  96. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  97. package/src/components/resources/pod-file-upload.ts +266 -0
  98. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  99. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  100. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  101. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  102. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  103. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  104. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  105. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  106. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  107. package/src/components/rightsizing/RightsizingScanView.tsx +19 -3
  108. package/src/components/rightsizing/model.test.ts +11 -0
  109. package/src/components/rightsizing/model.ts +3 -1
  110. package/src/components/rightsizing/presentation.test.ts +46 -0
  111. package/src/components/rightsizing/presentation.ts +17 -2
  112. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  113. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  114. package/src/components/timeline/TimelineView.tsx +3 -1
  115. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  116. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  117. package/src/components/traffic/TrafficData.test.tsx +37 -0
  118. package/src/components/traffic/TrafficData.tsx +27 -0
  119. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  120. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  121. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  122. package/src/components/traffic/TrafficGraph.tsx +135 -64
  123. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  124. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  125. package/src/components/traffic/TrafficView.tsx +72 -155
  126. package/src/components/traffic/trafficFilters.test.ts +189 -1
  127. package/src/components/traffic/trafficFilters.ts +169 -1
  128. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  129. package/src/components/ui/Omnibar.tsx +4 -1
  130. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  131. package/src/components/ui/RadarOmnibar.tsx +7 -1
  132. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  133. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  134. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  135. package/src/components/ui/UpdateNotification.test.tsx +54 -3
  136. package/src/components/ui/UpdateNotification.tsx +60 -19
  137. package/src/components/ui/command-items.ts +24 -1
  138. package/src/components/ui/omnibar-match.test.ts +7 -0
  139. package/src/components/ui/omnibar-match.ts +1 -0
  140. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  141. package/src/components/ui/searchCoverageNote.ts +31 -7
  142. package/src/components/useContextSwitchFlow.tsx +9 -1
  143. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  144. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  145. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  146. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  147. package/src/components/velero/VeleroDetailPage.tsx +148 -0
  148. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  149. package/src/components/velero/VeleroKindLists.tsx +43 -0
  150. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  151. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  152. package/src/components/velero/VeleroLocations.tsx +240 -0
  153. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  154. package/src/components/velero/VeleroOverview.tsx +485 -0
  155. package/src/components/velero/VeleroPages.test.tsx +516 -0
  156. package/src/components/velero/VeleroPages.tsx +1056 -0
  157. package/src/components/velero/VeleroRunLists.tsx +309 -0
  158. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  159. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  160. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  161. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  162. package/src/components/velero/VeleroSchedules.tsx +255 -0
  163. package/src/components/velero/VeleroView.tsx +59 -0
  164. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  165. package/src/components/velero/attention.test.ts +178 -0
  166. package/src/components/velero/attention.ts +281 -0
  167. package/src/components/velero/backupDelete.test.tsx +91 -0
  168. package/src/components/velero/backupDelete.tsx +182 -0
  169. package/src/components/velero/coverage.test.ts +87 -0
  170. package/src/components/velero/coverage.ts +150 -0
  171. package/src/components/velero/host.tsx +86 -0
  172. package/src/components/velero/routes.ts +78 -0
  173. package/src/components/velero/runs.tsx +121 -0
  174. package/src/components/velero/shared.test.ts +84 -0
  175. package/src/components/velero/shared.tsx +423 -0
  176. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  177. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  178. package/src/components/velero/velero.fixtures.ts +61 -0
  179. package/src/components/velero/workspaceRoute.ts +21 -0
  180. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
  181. package/src/components/vulnerabilities/parts.test.ts +72 -0
  182. package/src/components/vulnerabilities/parts.tsx +291 -0
  183. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  184. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  185. package/src/components/workload/WorkloadView.tsx +114 -37
  186. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  187. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  188. package/src/components/workspace/coverage.ts +61 -0
  189. package/src/components/workspace/layout.test.tsx +29 -1
  190. package/src/components/workspace/layout.tsx +15 -5
  191. package/src/components/workspace/sidebar.ts +9 -0
  192. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  193. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  194. package/src/context/ConnectionContext.test.ts +1 -0
  195. package/src/context/ConnectionContext.tsx +2 -2
  196. package/src/desktop/AboutDialog.test.ts +12 -0
  197. package/src/desktop/AboutDialog.tsx +151 -0
  198. package/src/desktop/WindowsTitleBar.tsx +359 -0
  199. package/src/desktop/titleBar.test.ts +61 -0
  200. package/src/desktop/titleBar.ts +45 -0
  201. package/src/index.css +19 -0
  202. package/src/integrations/resourceHost.ts +5 -1
  203. package/src/integrations/resourceHosts.test.tsx +15 -3
  204. package/src/integrations/resourceHosts.tsx +26 -6
  205. package/src/integrations/workspaceRoute.ts +1 -1
  206. package/src/integrations/workspaceRoutes.test.ts +11 -0
  207. package/src/integrations/workspaceRoutes.ts +3 -1
  208. package/src/integrations/workspaceScreens.tsx +2 -0
  209. package/src/main.tsx +8 -0
  210. package/src/utils/desktop-zoom.test.ts +53 -0
  211. package/src/utils/desktop-zoom.ts +30 -0
  212. package/src/utils/namespacePick.test.ts +87 -0
  213. package/src/utils/namespacePick.ts +88 -0
  214. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  215. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -52,7 +52,7 @@ import {
52
52
  } from "../../api/client";
53
53
  import { useConnection } from "../../context/ConnectionContext";
54
54
  import { useTimelineSource } from "../../context/TimelineSource";
55
- import { apiVersionToGroup, buildWorkloadPath, kindToPluralWithGroup } from "../../utils/navigation";
55
+ import { apiVersionToGroup, kindToPluralWithGroup, relatedResourcePath, withCrossViewParams } from "../../utils/navigation";
56
56
  import { WorkloadView } from "../workload/WorkloadView";
57
57
  import { ApplicationCostTab } from "../cost/ApplicationCostTab";
58
58
  import { useTimelineRetentionNote } from "../../context/TimelineCustomization";
@@ -484,21 +484,18 @@ function AppDetailRoute({
484
484
  const openWorkloadResource = useCallback(
485
485
  (resource: SelectedResource) => {
486
486
  const pluralKind = kindToPluralWithGroup(resource.kind, resource.group ?? "")
487
- if (pluralKind.toLowerCase() !== "pods") {
487
+ // The peek never covers the inline workload view: opening it drops
488
+ // ?workload so the app overview sits behind it. A single-workload app
489
+ // has no app overview and puts ?workload straight back, which would hide
490
+ // the peek, so its resources open on their own page instead.
491
+ if (pluralKind.toLowerCase() !== "pods" && !singleWorkloadKey) {
488
492
  onOpenResource(resource);
489
493
  return;
490
494
  }
491
495
 
492
- const [pathname, rawSearch = ""] = buildWorkloadPath({
493
- ...resource,
494
- kind: pluralKind,
495
- }).split("?");
496
- const params = new URLSearchParams(rawSearch);
497
- const activeNamespaces = searchParams.get("namespaces");
498
- if (activeNamespaces) params.set("namespaces", activeNamespaces);
499
- navigate({ pathname, search: params.toString() });
496
+ navigate(withCrossViewParams(relatedResourcePath(resource), searchParams.toString()));
500
497
  },
501
- [navigate, onOpenResource, searchParams],
498
+ [navigate, onOpenResource, searchParams, singleWorkloadKey],
502
499
  );
503
500
  const openSource = useCallback(
504
501
  (source: AppSourceRef) => {
@@ -9,6 +9,7 @@ import { Tooltip } from '../ui/Tooltip'
9
9
  import { useConnection } from '../../context/ConnectionContext'
10
10
  import { ChecksViewTabs } from './ChecksViewTabs'
11
11
  import { UpgradeReadinessView } from './UpgradeReadinessView'
12
+ import { VulnerabilitiesView } from './VulnerabilitiesView'
12
13
 
13
14
  interface AuditViewProps {
14
15
  namespaces: string[]
@@ -26,6 +27,9 @@ export function AuditView({ namespaces, onNavigateToResource }: AuditViewProps)
26
27
  if (pathname.startsWith('/checks/upgrade')) {
27
28
  return <UpgradeReadinessView namespaces={namespaces} onNavigateToResource={onNavigateToResource} />
28
29
  }
30
+ if (pathname.startsWith('/checks/vulnerabilities')) {
31
+ return <VulnerabilitiesView namespaces={namespaces} onNavigateToResource={onNavigateToResource} />
32
+ }
29
33
  return <BestPracticesView namespaces={namespaces} onNavigateToResource={onNavigateToResource} />
30
34
  }
31
35
 
@@ -1,15 +1,30 @@
1
1
  import { renderToStaticMarkup } from 'react-dom/server'
2
2
  import { MemoryRouter } from 'react-router-dom'
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
4
  import { describe, expect, it } from 'vitest'
5
+ import type { APIResource } from '../../types'
4
6
  import { ChecksViewTabs } from './ChecksViewTabs'
5
7
 
8
+ const vulnerabilityReports: APIResource = {
9
+ name: 'vulnerabilityreports', kind: 'VulnerabilityReport', group: 'aquasecurity.github.io', version: 'v1alpha1',
10
+ namespaced: true, verbs: ['list', 'get'], isCrd: true,
11
+ }
12
+
13
+ function render(path: string, resources: APIResource[] = []) {
14
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
15
+ client.setQueryData(['api-resources'], resources)
16
+ return renderToStaticMarkup(
17
+ <QueryClientProvider client={client}>
18
+ <MemoryRouter initialEntries={[path]}>
19
+ <ChecksViewTabs />
20
+ </MemoryRouter>
21
+ </QueryClientProvider>,
22
+ )
23
+ }
24
+
6
25
  describe('ChecksViewTabs', () => {
7
26
  it('keeps browsing scope across tabs without leaking upgrade-only target state', () => {
8
- const html = renderToStaticMarkup(
9
- <MemoryRouter initialEntries={['/checks/upgrade?namespaces=shop%2Cprod&target=1.36&resource=shop%2Fapi']}>
10
- <ChecksViewTabs />
11
- </MemoryRouter>,
12
- )
27
+ const html = render('/checks/upgrade?namespaces=shop%2Cprod&target=1.36&resource=shop%2Fapi')
13
28
 
14
29
  expect(html).toContain('href="/checks?namespaces=shop%2Cprod"')
15
30
  expect(html).toContain('href="/checks/upgrade?namespaces=shop%2Cprod&amp;target=1.36"')
@@ -17,4 +32,17 @@ describe('ChecksViewTabs', () => {
17
32
  expect(html).toContain('aria-current="page"')
18
33
  expect(html).not.toContain('role="tab"')
19
34
  })
35
+
36
+ it('shows Vulnerabilities only where the cluster serves VulnerabilityReports', () => {
37
+ expect(render('/checks')).not.toContain('Vulnerabilities')
38
+
39
+ const html = render('/checks?namespaces=shop', [vulnerabilityReports])
40
+ expect(html).toContain('href="/checks/vulnerabilities?namespaces=shop"')
41
+ expect(html).toContain('Vulnerabilities')
42
+ })
43
+
44
+ it('marks Vulnerabilities as the current tab on its route', () => {
45
+ const html = render('/checks/vulnerabilities', [vulnerabilityReports])
46
+ expect(html).toMatch(/aria-current="page"[^>]*href="\/checks\/vulnerabilities"|href="\/checks\/vulnerabilities"[^>]*aria-current="page"/)
47
+ })
20
48
  })
@@ -1,9 +1,13 @@
1
1
  import { clsx } from 'clsx'
2
2
  import { Link, useLocation, type To } from 'react-router-dom'
3
+ import { useAPIResources } from '../../api/apiResources'
4
+ import { hasVulnerabilityReports } from '../../api/vulnerabilities'
3
5
 
4
6
  export function ChecksViewTabs() {
5
7
  const { pathname, search } = useLocation()
8
+ const { data: resources } = useAPIResources()
6
9
  const upgrade = pathname.startsWith('/checks/upgrade')
10
+ const vulnerabilities = pathname.startsWith('/checks/vulnerabilities')
7
11
  const current = new URLSearchParams(search)
8
12
  const browsing = new URLSearchParams()
9
13
  for (const key of ['namespace', 'namespaces']) {
@@ -16,12 +20,18 @@ export function ChecksViewTabs() {
16
20
 
17
21
  return (
18
22
  <nav className="flex items-center gap-1 border-b border-theme-border" aria-label="Check views">
19
- <ChecksTab to={{ pathname: '/checks', search: browsing.toString() }} active={!upgrade}>
23
+ <ChecksTab to={{ pathname: '/checks', search: browsing.toString() }} active={!upgrade && !vulnerabilities}>
20
24
  Best practices
21
25
  </ChecksTab>
22
26
  <ChecksTab to={{ pathname: '/checks/upgrade', search: upgradeSearch.toString() }} active={upgrade}>
23
27
  Upgrade impact
24
28
  </ChecksTab>
29
+ {/* Shown only where a scanner writes reports: the tab reads them, it doesn't scan. */}
30
+ {(vulnerabilities || hasVulnerabilityReports(resources)) && (
31
+ <ChecksTab to={{ pathname: '/checks/vulnerabilities', search: browsing.toString() }} active={vulnerabilities}>
32
+ Vulnerabilities
33
+ </ChecksTab>
34
+ )}
25
35
  </nav>
26
36
  )
27
37
  }
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
2
2
  import { renderToStaticMarkup } from 'react-dom/server'
3
3
  import { ApiError } from '../../api/client'
4
4
  import { RadarFeatureUnsupportedError } from '../../api/radarFeatures'
5
- import { UPGRADE_IMPACT_DOCS_URL, UpgradeReadinessError, groupFindings, incompleteUpgradeCheckCount, issueSpecificReferences, summaryMeta, upgradeEvaluationSummary, upgradeEvidenceCoverageLabel, upgradeUnavailableKindsMessage } from './UpgradeReadinessView'
5
+ import { UPGRADE_IMPACT_DOCS_URL, UpgradePlansNotice, distributionUpgradePlans, planCountIsLowerBound, UpgradeReadinessError, groupFindings, incompleteUpgradeCheckCount, issueSpecificReferences, summaryMeta, upgradeEvaluationSummary, upgradeEvidenceCoverageLabel, upgradeUnavailableKindsMessage } from './UpgradeReadinessView'
6
6
 
7
7
  describe('UpgradeReadinessError', () => {
8
8
  it('maps an unsupported-feature error to the v1.9 upgrade message', () => {
@@ -160,3 +160,37 @@ describe('issueSpecificReferences', () => {
160
160
  expect(issueSpecificReferences(checkReferences, findingReferences)).toEqual([findingReferences[1]])
161
161
  })
162
162
  })
163
+
164
+ describe('upgrade Plans notice', () => {
165
+ const plan = (name: string, image: string, conditions: any[] = []) => ({
166
+ apiVersion: 'upgrade.cattle.io/v1', kind: 'Plan', metadata: { name, namespace: 'system-upgrade' },
167
+ spec: { version: 'v1.32.1+k3s1', upgrade: { image } }, status: { conditions },
168
+ })
169
+ it('lists only k3s and rke2 upgrade Plans', () => {
170
+ expect(distributionUpgradePlans([
171
+ plan('k3s-server', 'rancher/k3s-upgrade', [{ type: 'Complete', status: 'True' }]),
172
+ plan('system-agent-upgrader', 'rancher/system-agent:v0.3.13-suc'),
173
+ ])).toEqual([{ namespace: 'system-upgrade', name: 'k3s-server', version: 'v1.32.1+k3s1', state: 'Complete' }])
174
+ })
175
+ it('returns nothing for no Plans or an unread list', () => {
176
+ expect(distributionUpgradePlans(undefined)).toEqual([])
177
+ expect(distributionUpgradePlans([])).toEqual([])
178
+ })
179
+ it('renders the notice with a link per Plan', () => {
180
+ const html = renderToStaticMarkup(UpgradePlansNotice({ plans: [{ namespace: 'system-upgrade', name: 'k3s-server', version: 'v1.32.1+k3s1', state: 'Complete' }], onNavigateToResource: () => {} }))
181
+ expect(html).toContain('1 upgrade Plan is defined for this cluster')
182
+ expect(html).toContain('k3s-server')
183
+ expect(html).toContain('v1.32.1+k3s1')
184
+ })
185
+ it('says at least N when the caller could list only some Plans', () => {
186
+ const html = renderToStaticMarkup(UpgradePlansNotice({ partial: true, plans: [{ namespace: 'system-upgrade', name: 'k3s-server', version: 'v1', state: 'Complete' }], onNavigateToResource: () => {} }))
187
+ expect(html).toContain('At least 1 upgrade Plan is defined for this cluster')
188
+ })
189
+ it('counts Plans exactly only when the list covers the cluster', () => {
190
+ expect(planCountIsLowerBound({ status: 'complete' } as any)).toBe(false)
191
+ expect(planCountIsLowerBound({ status: 'partial' } as any)).toBe(true)
192
+ expect(planCountIsLowerBound({ status: 'complete', narrowedBy: ['namespace_collection'] } as any)).toBe(true)
193
+ expect(planCountIsLowerBound({ status: 'unknown' } as any)).toBe(true)
194
+ expect(planCountIsLowerBound(undefined)).toBe(true)
195
+ })
196
+ })
@@ -29,6 +29,7 @@ import {
29
29
  } from '@skyhook-io/k8s-ui'
30
30
  import {
31
31
  ApiError,
32
+ useResources,
32
33
  useUpgradeReadiness,
33
34
  type UpgradeReadinessCheck,
34
35
  type UpgradeReadinessCheckStatus,
@@ -38,6 +39,10 @@ import {
38
39
  } from '../../api/client'
39
40
  import type { SelectedResource } from '../../types'
40
41
  import { useConnection } from '../../context/ConnectionContext'
42
+ import { useAPIResources } from '../../api/apiResources'
43
+ import { getUpgradePlanStatus, isDistributionUpgradePlan, upgradePlanTarget } from '@skyhook-io/k8s-ui/components/resources/resource-utils-upgrade-plan'
44
+ import { isLowerBound } from '@skyhook-io/k8s-ui/utils/resource-coverage'
45
+ import type { ResourceCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
41
46
  import { ChecksViewTabs } from './ChecksViewTabs'
42
47
 
43
48
  interface UpgradeReadinessViewProps {
@@ -81,6 +86,13 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
81
86
  const requestedTarget = new URLSearchParams(location.search).get('target') ?? undefined
82
87
  const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refreshScan } = useUpgradeReadiness(requestedTarget)
83
88
  const { connection } = useConnection()
89
+ const { data: apiResources } = useAPIResources()
90
+ const plansServed = !!apiResources?.some((r) => r.group === 'upgrade.cattle.io' && r.name === 'plans')
91
+ const plansQuery = useResources<any>('plans', undefined, 'upgrade.cattle.io', { enabled: plansServed })
92
+ // An unreadable Plan list shows no notice: absence of Plans is not claimed.
93
+ const upgradePlans = useMemo(() => (plansQuery.error ? [] : distributionUpgradePlans(plansQuery.data)), [plansQuery.error, plansQuery.data])
94
+ const plansPartial = planCountIsLowerBound(plansQuery.coverage)
95
+ const plansNotice = upgradePlans.length > 0 ? <UpgradePlansNotice plans={upgradePlans} partial={plansPartial} onNavigateToResource={onNavigateToResource} /> : null
84
96
  const targetOptions = useMemo(
85
97
  () => buildTargetOptions(data?.currentVersion, data?.reviewedThrough, requestedTarget ?? data?.targetVersion),
86
98
  [data?.currentVersion, data?.reviewedThrough, data?.targetVersion, requestedTarget],
@@ -104,6 +116,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
104
116
  return (
105
117
  <div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
106
118
  <ChecksViewTabs />
119
+ {plansNotice}
107
120
  <PaneLoader label="Analyzing upgrade impact…" className="flex-1" />
108
121
  </div>
109
122
  )
@@ -112,6 +125,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
112
125
  return (
113
126
  <div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
114
127
  <ChecksViewTabs />
128
+ {plansNotice}
115
129
  <div className="flex flex-1 items-center justify-center">
116
130
  <UpgradeReadinessError error={error} onResetTarget={resetTarget} />
117
131
  </div>
@@ -217,6 +231,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
217
231
  {data.coverage.state === 'partial' && !data.coverage.scopedNamespaces?.length && !data.coverage.unavailableKinds?.length && scopedKinds.length === 0 && (
218
232
  <CoverageNotice headline="Some evidence is incomplete" body="Evidence labels on affected rows explain what Radar could not verify." />
219
233
  )}
234
+ {plansNotice}
220
235
  {data.coverage.state === 'no_access' ? (
221
236
  <section className="shrink-0">
222
237
  <EmptyState
@@ -236,7 +251,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
236
251
  <span className="text-right text-xs tabular-nums text-theme-text-tertiary">{upgradeEvaluationSummary(data.checks.length, data.summary, incompleteUpgradeCheckCount(data.checks))}</span>
237
252
  </div>
238
253
  <CoverageMethodology data={data} />
239
- <div className="hidden grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] gap-4 border-b-subtle bg-theme-elevated px-4 py-2 text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary md:grid">
254
+ <div className="hidden grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] gap-4 border-b-subtle bg-theme-elevated px-3.5 py-2 text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary md:grid">
240
255
  <span>Check</span>
241
256
  <span>Result</span>
242
257
  <span>Status</span>
@@ -422,6 +437,49 @@ export function summaryMeta(
422
437
  }
423
438
  }
424
439
 
440
+ // The visible Plans are a lower bound unless the list covers the whole
441
+ // cluster: a partial read, a list narrowed to the namespaces Radar collects,
442
+ // or an older Radar that reports no coverage can't establish a total.
443
+ export function planCountIsLowerBound(coverage: ResourceCoverage | undefined): boolean {
444
+ return !coverage || coverage.status === 'unknown' || isLowerBound(coverage)
445
+ }
446
+
447
+ // system-upgrade-controller Plans that upgrade the distribution itself (k3s,
448
+ // RKE2). Other Plans (Rancher's system-agent upgrader, OS packages) don't
449
+ // change the Kubernetes version, so they aren't listed here.
450
+ export function distributionUpgradePlans(plans: any[] | undefined): { namespace: string; name: string; version: string; state: string }[] {
451
+ return (plans ?? []).filter(isDistributionUpgradePlan).map((p) => ({
452
+ namespace: p.metadata?.namespace ?? '',
453
+ name: p.metadata?.name ?? '',
454
+ version: upgradePlanTarget(p),
455
+ state: getUpgradePlanStatus(p).text,
456
+ }))
457
+ }
458
+
459
+ export function UpgradePlansNotice({ plans, partial, onNavigateToResource }: { plans: ReturnType<typeof distributionUpgradePlans>; partial?: boolean; onNavigateToResource: (resource: SelectedResource) => void }) {
460
+ return (
461
+ <div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs">
462
+ <FileSearch className="mt-0.5 h-4 w-4 shrink-0 text-theme-text-tertiary" />
463
+ <div>
464
+ <span className="font-medium text-theme-text-secondary">
465
+ {partial ? 'At least ' : ''}{plans.length} upgrade {plans.length === 1 ? 'Plan is' : 'Plans are'} defined for this cluster.
466
+ </span>{' '}
467
+ <span className="text-theme-text-tertiary">system-upgrade-controller upgrades the nodes it selects:</span>
468
+ <ul className="mt-1 space-y-0.5">
469
+ {plans.map((p) => (
470
+ <li key={`${p.namespace}/${p.name}`} className="text-theme-text-tertiary">
471
+ <button type="button" className="text-accent hover:underline" onClick={() => onNavigateToResource({ kind: 'plans', group: 'upgrade.cattle.io', namespace: p.namespace, name: p.name })}>
472
+ {p.namespace}/{p.name}
473
+ </button>{' '}
474
+ · {p.version} · {p.state}
475
+ </li>
476
+ ))}
477
+ </ul>
478
+ </div>
479
+ </div>
480
+ )
481
+ }
482
+
425
483
  function CoverageNotice({ headline, body }: { headline: string; body: string }) {
426
484
  return (
427
485
  <div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs">
@@ -446,7 +504,7 @@ function CheckRow({ check, onNavigateToResource }: { check: UpgradeReadinessChec
446
504
  type="button"
447
505
  aria-expanded={open}
448
506
  onClick={() => setOpen((value) => !value)}
449
- className="grid w-full cursor-pointer items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-theme-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-theme-text-primary/20 md:grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] md:gap-4"
507
+ className={clsx('grid w-full cursor-pointer items-center gap-3 text-left transition-colors hover:bg-theme-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-theme-text-primary/20 md:grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] md:gap-4', 'px-3.5 py-2.5' /* TABLE_DENSITY.cellClass in k8s-ui */)}
450
508
  >
451
509
  <div className="flex min-w-0 items-center gap-2.5">
452
510
  <Icon className={clsx('h-4 w-4 shrink-0', meta.iconClass)} />