@skyhook-io/radar-app 1.20.3 → 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 (152) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +54 -10
  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.ts +129 -5
  7. package/src/api/namespaceScopeRetry.test.ts +14 -0
  8. package/src/api/radarFeatures.ts +7 -0
  9. package/src/api/substrateHealth.ts +134 -0
  10. package/src/api/velero.test.ts +60 -0
  11. package/src/api/velero.ts +201 -0
  12. package/src/api/vulnerabilities.ts +255 -0
  13. package/src/components/NamespaceSwitcher.tsx +3 -1
  14. package/src/components/audit/AuditView.tsx +4 -0
  15. package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
  16. package/src/components/audit/ChecksViewTabs.tsx +11 -1
  17. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  18. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  19. package/src/components/audit/VulnerabilitiesView.tsx +907 -0
  20. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  21. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  22. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  23. package/src/components/cnpg/CNPGView.tsx +43 -117
  24. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  25. package/src/components/cnpg/host.tsx +2 -2
  26. package/src/components/cnpg/routes.ts +3 -1
  27. package/src/components/cnpg/shared.tsx +5 -53
  28. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  29. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  30. package/src/components/community.tsx +42 -0
  31. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  32. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  33. package/src/components/diagnose/investigationMetrics.ts +2 -1
  34. package/src/components/dock/BottomDock.tsx +1 -0
  35. package/src/components/dock/LogsTab.tsx +3 -0
  36. package/src/components/gitops/GitOpsView.tsx +1 -1
  37. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  38. package/src/components/helm/HelmView.tsx +20 -16
  39. package/src/components/helm/OwnedResources.tsx +4 -3
  40. package/src/components/home/ClusterHealthCard.tsx +3 -1
  41. package/src/components/home/HomeAgentBlock.tsx +3 -0
  42. package/src/components/home/HomeView.tsx +7 -0
  43. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  44. package/src/components/home/MCPSetupDialog.tsx +4 -2
  45. package/src/components/home/mcpToolCatalog.ts +15 -2
  46. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  47. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  48. package/src/components/logs/LogsViewer.tsx +3 -1
  49. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  50. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  51. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  52. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  53. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  54. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  55. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  56. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  57. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  58. package/src/components/resources/ResourcesView.tsx +12 -6
  59. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  60. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  61. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  62. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  63. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  64. package/src/components/rightsizing/RightsizingScanView.tsx +3 -2
  65. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  66. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  67. package/src/components/timeline/TimelineView.tsx +3 -1
  68. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  69. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  70. package/src/components/traffic/TrafficData.test.tsx +37 -0
  71. package/src/components/traffic/TrafficData.tsx +27 -0
  72. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  73. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  74. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  75. package/src/components/traffic/TrafficGraph.tsx +135 -64
  76. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  77. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  78. package/src/components/traffic/TrafficView.tsx +46 -129
  79. package/src/components/traffic/trafficFilters.test.ts +172 -1
  80. package/src/components/traffic/trafficFilters.ts +139 -0
  81. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  82. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  83. package/src/components/ui/UpdateNotification.test.tsx +31 -2
  84. package/src/components/ui/UpdateNotification.tsx +34 -17
  85. package/src/components/ui/command-items.ts +24 -1
  86. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  87. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  88. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  89. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  90. package/src/components/velero/VeleroDetailPage.tsx +148 -0
  91. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  92. package/src/components/velero/VeleroKindLists.tsx +43 -0
  93. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  94. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  95. package/src/components/velero/VeleroLocations.tsx +240 -0
  96. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  97. package/src/components/velero/VeleroOverview.tsx +485 -0
  98. package/src/components/velero/VeleroPages.test.tsx +516 -0
  99. package/src/components/velero/VeleroPages.tsx +1056 -0
  100. package/src/components/velero/VeleroRunLists.tsx +309 -0
  101. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  102. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  103. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  104. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  105. package/src/components/velero/VeleroSchedules.tsx +255 -0
  106. package/src/components/velero/VeleroView.tsx +59 -0
  107. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  108. package/src/components/velero/attention.test.ts +178 -0
  109. package/src/components/velero/attention.ts +281 -0
  110. package/src/components/velero/backupDelete.test.tsx +91 -0
  111. package/src/components/velero/backupDelete.tsx +182 -0
  112. package/src/components/velero/coverage.test.ts +87 -0
  113. package/src/components/velero/coverage.ts +150 -0
  114. package/src/components/velero/host.tsx +86 -0
  115. package/src/components/velero/routes.ts +78 -0
  116. package/src/components/velero/runs.tsx +121 -0
  117. package/src/components/velero/shared.test.ts +84 -0
  118. package/src/components/velero/shared.tsx +423 -0
  119. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  120. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  121. package/src/components/velero/velero.fixtures.ts +61 -0
  122. package/src/components/velero/workspaceRoute.ts +21 -0
  123. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
  124. package/src/components/vulnerabilities/parts.test.ts +72 -0
  125. package/src/components/vulnerabilities/parts.tsx +291 -0
  126. package/src/components/workload/WorkloadView.tsx +64 -27
  127. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  128. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  129. package/src/components/workspace/coverage.ts +61 -0
  130. package/src/components/workspace/layout.test.tsx +29 -1
  131. package/src/components/workspace/layout.tsx +15 -5
  132. package/src/components/workspace/sidebar.ts +9 -0
  133. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  134. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  135. package/src/desktop/AboutDialog.test.ts +12 -0
  136. package/src/desktop/AboutDialog.tsx +151 -0
  137. package/src/desktop/WindowsTitleBar.tsx +359 -0
  138. package/src/desktop/titleBar.test.ts +61 -0
  139. package/src/desktop/titleBar.ts +45 -0
  140. package/src/index.css +19 -0
  141. package/src/integrations/resourceHost.ts +5 -1
  142. package/src/integrations/resourceHosts.test.tsx +14 -2
  143. package/src/integrations/resourceHosts.tsx +22 -6
  144. package/src/integrations/workspaceRoute.ts +1 -1
  145. package/src/integrations/workspaceRoutes.test.ts +11 -0
  146. package/src/integrations/workspaceRoutes.ts +3 -1
  147. package/src/integrations/workspaceScreens.tsx +2 -0
  148. package/src/main.tsx +8 -0
  149. package/src/utils/desktop-zoom.test.ts +53 -0
  150. package/src/utils/desktop-zoom.ts +30 -0
  151. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  152. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -1,5 +1,5 @@
1
1
  import { RelatedFindingsSection } from './RelatedFindingsSection'
2
- import { decorateResourceDiagnose, resourceDetailRedirect, resourceDetailSlots, resourceLogs, resourceRendererOverrides } from '../../integrations/resourceHosts'
2
+ import { decorateResourceDiagnose, resourceDetailRedirect, resourceDetailSlots, resourceIssueDetail, resourceLogs, resourceRendererOverrides } from '../../integrations/resourceHosts'
3
3
  import { ApplicationEvidenceAction } from '../application-evidence/ApplicationEvidenceAction'
4
4
  import { useMemo, useEffect, useCallback, useRef, useState, type ReactNode } from 'react'
5
5
  import { useQueries, useQueryClient } from '@tanstack/react-query'
@@ -37,6 +37,7 @@ import {
37
37
  } from '@skyhook-io/k8s-ui'
38
38
  import type { ServicePortRenderProps } from '@skyhook-io/k8s-ui/components/resources/renderers/ServiceRenderer'
39
39
  import { isJobSetV1Alpha2 } from '@skyhook-io/k8s-ui/components/resources/resource-utils-jobset-lws'
40
+ import { SUBSTRATE_GROUP } from '@skyhook-io/k8s-ui/components/resources/resource-utils-agent-runtimes'
40
41
  import type { SelectedResource, ResourceRef, Relationships, ResourceWithRelationships } from '../../types'
41
42
  import { CronJobSchedulingContext, CronJobSchedulingDetails } from './CronJobSchedulingEvidence'
42
43
  import { NodeCertificateContext, NodeCertificateDetails, nodeCertificateContextVisible } from './NodeCertificateEvidence'
@@ -107,7 +108,7 @@ import { isOpenCostWorkloadKind } from '../cost/kinds'
107
108
  import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
108
109
  import { useTrafficAvailable } from '../../api/traffic'
109
110
  import { isNotFoundError, useResourceAudit, useResourceIssues, useSubjectIssues, useRadarFeature, useTrace, fetchTraceWithProbes, fetchInClusterCapability, runInClusterMerged } from '../../api/client'
110
- import { AuditAlerts, getRadarUpgradeRequirement, ResourceIssuesSection, ReachabilityView, TraceSummary, InClusterConsentDialog, traceFingerprint, staticPollUnreliable, summarizeInClusterTests, type Trace as NetworkTrace, type InClusterCapability, inClusterConsentGiven, consentRequestRows } from '@skyhook-io/k8s-ui'
111
+ import { AuditAlerts, getRadarUpgradeRequirement, ResourceIssuesSection, ReachabilityView, TraceSummary, InClusterConsentDialog, traceFingerprint, staticPollUnreliable, summarizeInClusterTests, type Trace as NetworkTrace, type InClusterCapability, inClusterConsentGiven, consentRequestRows, getDefaultLogContainerName, getLogContainerNames, getInitContainerNames } from '@skyhook-io/k8s-ui'
111
112
  import { WorkloadLogsViewer } from '../logs/WorkloadLogsViewer'
112
113
  import { ScheduledWorkloadLogsViewer } from '../logs/ScheduledWorkloadLogsViewer'
113
114
  import { LogsViewer } from '../logs/LogsViewer'
@@ -139,8 +140,12 @@ import { useDesktopDownload } from '../../hooks/useDesktopDownload'
139
140
  import { useCompareLauncher } from '../compare/useCompareLauncher'
140
141
  import { useDiagnoseCustomization } from '../../context/DiagnoseCustomization'
141
142
  import { NodeDrainStatus } from './NodeDrainStatus'
143
+ import { SubstrateHealthCharts } from '../resource/SubstrateHealthCharts'
144
+ import { SubstrateVerdictLine } from '../resource/SubstrateVerdictLine'
145
+ import { useAPIResources } from '../../api/apiResources'
142
146
  import { recordUsageEvent } from '../../api/usage-data'
143
147
  import { issueResourceOpener } from './issueResourceOpener'
148
+ import { isVeleroBackupKind } from '../velero/routes'
144
149
 
145
150
  type TabType = WorkloadTabType
146
151
 
@@ -295,6 +300,7 @@ interface WorkloadViewProps {
295
300
  statusNote?: ReactNode
296
301
  onRefresh?: () => Promise<unknown>
297
302
  hideKindBadge?: boolean
303
+ truncateName?: boolean
298
304
  }
299
305
 
300
306
  interface ImageTargetOwnershipContext {
@@ -428,10 +434,14 @@ function useActionsBarProps(
428
434
  className?: string
429
435
  }) => <PortForwardButton type={type} namespace={ns} name={n} className={className} />,
430
436
  renderDiagnose: decorateResourceDiagnose(renderDiagnose),
431
- onDelete: (
432
- params: Parameters<typeof deleteMutation.mutate>[0],
433
- callbacks?: { onSuccess?: () => void },
434
- ) => deleteMutation.mutate(params, { onSuccess: result => { if (!result.outcomeUnknown) callbacks?.onSuccess?.() } }),
437
+ // Deleting a Velero Backup object leaves the backup in storage and Velero
438
+ // recreates the object; the Velero host offers Delete backup instead.
439
+ onDelete: isVeleroBackupKind(kind, group)
440
+ ? undefined
441
+ : (
442
+ params: Parameters<typeof deleteMutation.mutate>[0],
443
+ callbacks?: { onSuccess?: () => void },
444
+ ) => deleteMutation.mutate(params, { onSuccess: result => { if (!result.outcomeUnknown) callbacks?.onSuccess?.() } }),
435
445
  isDeleting: deleteMutation.isPending,
436
446
  onDeletePreviewOpenChange: setDeletePreviewOpen,
437
447
  cascadeDetail: cascadePreview,
@@ -628,6 +638,14 @@ export function WorkloadView({
628
638
  // of itself. Fall back to the group derived from the fetched resource, then
629
639
  // to undefined (which the gate treats as "group unknown → allow").
630
640
  const effectiveGroup = rest.group || resourceGroup || undefined
641
+ // The fetched resource's own group, once it has loaded: the route's group is
642
+ // '' whenever a link left ?apiGroup out.
643
+ const identityGroup = resource?.apiVersion ? resourceGroup : effectiveGroup
644
+ const isNode = apiKind === 'nodes' && !effectiveGroup
645
+ const isSubstrateWorkerPool = apiKind === 'workerpools' && effectiveGroup === SUBSTRATE_GROUP
646
+ // Substrate's node charts are asked of Prometheus only on a cluster that serves it.
647
+ const { data: apiResources } = useAPIResources()
648
+ const servesSubstrate = isNode && apiResources?.some(r => r.group === SUBSTRATE_GROUP && r.name === 'workerpools') === true
631
649
  const batchKind = pluralToKind(apiKind)
632
650
  const batchExecution = supportsBatchExecution(batchKind, apiKind, effectiveGroup, resource?.apiVersion)
633
651
  const batchRunsQuery = useWorkloadRuns(apiKind, namespace, name, expanded && batchExecution, {
@@ -1286,7 +1304,7 @@ export function WorkloadView({
1286
1304
  viewNamespaces={viewNamespaces}
1287
1305
  />
1288
1306
  )}
1289
- {...resourceDetailSlots({ kind: apiKind, group: resource?.apiVersion ? resourceGroup : effectiveGroup, namespace, name }, rest.extraTabs)}
1307
+ {...resourceDetailSlots({ kind: apiKind, group: identityGroup, namespace, name }, rest.extraTabs)}
1290
1308
  onSelectTopologyMember={batchExecution && batchKind === 'JobSet' ? handleSelectTopologyMember : undefined}
1291
1309
  renderExpandedOverview={({ kind: k, apiKind, namespace: ns, name: n, resource: res, leadContent }) =>
1292
1310
  supportsBatchExecution(k, apiKind, effectiveGroup, res?.apiVersion) &&
@@ -1311,14 +1329,25 @@ export function WorkloadView({
1311
1329
  renderRelatedYaml={(ref) => (
1312
1330
  <RelatedResourceYaml key={`${ref.kind}/${ref.namespace}/${ref.name}`} target={ref} />
1313
1331
  )}
1314
- renderMetricsTab={({ kind, namespace: ns, name: n }) => (
1315
- <MetricsTabContent
1316
- kind={kind}
1317
- namespace={ns}
1318
- name={n}
1319
- resource={resource}
1320
- expanded={expanded}
1332
+ renderMetricsTab={({ kind, namespace: ns, name: n }) => isSubstrateWorkerPool ? (
1333
+ <SubstrateHealthCharts
1334
+ target={{ kind: 'workerpool', namespace: ns, name: n }}
1335
+ standalone
1336
+ collapsible={!expanded}
1337
+ workerPods={typeof resource?.status?.replicas === 'number' ? resource.status.replicas : undefined}
1321
1338
  />
1339
+ ) : (
1340
+ <>
1341
+ <MetricsTabContent
1342
+ kind={kind}
1343
+ namespace={ns}
1344
+ name={n}
1345
+ resource={resource}
1346
+ expanded={expanded}
1347
+ fill={!(isNode && servesSubstrate)}
1348
+ />
1349
+ {isNode && servesSubstrate && <div className="pt-4"><SubstrateHealthCharts target={{ kind: 'node', name: n }} collapsible={!expanded} /></div>}
1350
+ </>
1322
1351
  )}
1323
1352
  renderCostTab={({ kind, namespace: ns, name: n }) => (
1324
1353
  <div className="space-y-4">
@@ -1348,16 +1377,23 @@ export function WorkloadView({
1348
1377
  />
1349
1378
  )}
1350
1379
  isMetricsAvailable={(kind, res) =>
1351
- isPrometheusSupported(kind) && !(kind === 'Pod' && res?.status?.phase === 'Pending')
1380
+ isSubstrateWorkerPool || (isPrometheusSupported(kind) && !(kind === 'Pod' && res?.status?.phase === 'Pending'))
1352
1381
  }
1353
1382
  isCostAvailable={(kind) => isOpenCostWorkloadKind(kind)}
1354
1383
  onDuplicate={handleDuplicate}
1355
1384
  onDownload={desktopDownload}
1356
1385
  actionsBarProps={actionsBarProps}
1357
1386
  rendererOverrides={resourceRendererOverrides}
1358
- renderOverviewIntro={apiKind === 'nodes' && !effectiveGroup && resource?.metadata?.uid
1359
- ? () => <NodeDrainStatus name={name} nodeUID={resource.metadata.uid} />
1360
- : undefined}
1387
+ renderOverviewIntro={isSubstrateWorkerPool
1388
+ ? ({ namespace: ns, name: n }) => <SubstrateVerdictLine target={{ kind: 'workerpool', namespace: ns, name: n }} onOpenMetrics={expanded ? () => handleTabChange('metrics') : undefined} />
1389
+ : isNode && resource?.metadata?.uid
1390
+ ? () => (
1391
+ <div className="space-y-3">
1392
+ <NodeDrainStatus name={name} nodeUID={resource.metadata.uid} />
1393
+ {servesSubstrate && <SubstrateVerdictLine target={{ kind: 'node', name }} onOpenMetrics={expanded ? () => handleTabChange('metrics') : undefined} />}
1394
+ </div>
1395
+ )
1396
+ : undefined}
1361
1397
  renderOverviewExtra={({ kind: k, namespace: ns, name: n, group: g, context }) => {
1362
1398
  // Network entry kinds (Service/Ingress/Route/Gateway) ARE the diagnosis
1363
1399
  // target: DiagnoseInlineSection renders in the drawer, no hint. Workload
@@ -1396,10 +1432,10 @@ export function WorkloadView({
1396
1432
  renderDetailSection={({ issue }) => {
1397
1433
  if (schedulingEvidence?.state === 'reported' && issue.kind === 'CronJob' && issue.reason === schedulingEvidence.reason) return <CronJobSchedulingDetails evidence={schedulingEvidence} onViewTimeline={viewSchedulingReport} />
1398
1434
  if (certificateEvidence && issue.kind === 'Node' && issue.reason === 'NodeCertificateExpiry') return <NodeCertificateDetails evidence={certificateEvidence} onViewTimeline={viewCertificateReport} includeOriginalReport={false} />
1399
- return null
1435
+ return resourceIssueDetail({ kind: apiKind, group: resource?.apiVersion ? resourceGroup : effectiveGroup, namespace, name }, { issue, resource })
1400
1436
  }}
1401
1437
  compact={!expanded}
1402
- subjectResource={{ kind: apiKind, namespace, name, group: rest.group }}
1438
+ subjectResource={{ kind: apiKind, namespace, name, group: identityGroup }}
1403
1439
  onResourceClick={openIssueResource}
1404
1440
  />
1405
1441
  </div>
@@ -1687,12 +1723,8 @@ function PodLogsTab({
1687
1723
  initialContainer?: string | null
1688
1724
  onConsumeInitialContainer?: () => void
1689
1725
  }) {
1690
- const containers = useMemo(() => {
1691
- const names: string[] = []
1692
- for (const c of resource?.spec?.initContainers || []) if (c.name) names.push(c.name)
1693
- for (const c of resource?.spec?.containers || []) if (c.name) names.push(c.name)
1694
- return names
1695
- }, [resource])
1726
+ const containers = useMemo(() => getLogContainerNames(resource), [resource])
1727
+ const initContainers = useMemo(() => getInitContainerNames(resource), [resource])
1696
1728
 
1697
1729
  // A terminated pod has nothing to follow — only stream live ones. Wait for
1698
1730
  // the phase to be known so a completed pod isn't briefly streamed while the
@@ -1712,7 +1744,8 @@ function PodLogsTab({
1712
1744
  namespace={namespace}
1713
1745
  podName={name}
1714
1746
  containers={containers}
1715
- initialContainer={initialContainer || undefined}
1747
+ initialContainer={initialContainer || getDefaultLogContainerName(resource)}
1748
+ initContainers={initContainers}
1716
1749
  autoStream={autoStream}
1717
1750
  />
1718
1751
  </div>
@@ -2228,14 +2261,18 @@ function MetricsTabContent({
2228
2261
  name,
2229
2262
  resource,
2230
2263
  expanded,
2264
+ fill = true,
2231
2265
  }: {
2232
2266
  kind: string
2233
2267
  namespace: string
2234
2268
  name: string
2235
2269
  resource: any
2236
2270
  expanded: boolean
2271
+ /** False when content follows, so the tab scrolls everything as one. */
2272
+ fill?: boolean
2237
2273
  }) {
2238
2274
  if (expanded) {
2275
+ if (!fill) return <PrometheusChartsGrid kind={kind} namespace={namespace} name={name} resource={resource} fill={false} />
2239
2276
  return (
2240
2277
  <div className="flex flex-col h-full">
2241
2278
  <div className="flex-1 min-h-0">
@@ -0,0 +1,32 @@
1
+ import { useLocation, useSearchParams } from 'react-router-dom'
2
+ import { ArrowLeft } from 'lucide-react'
3
+ import type { SelectedResource } from '../../types'
4
+ import { decodeDrawerTrail, encodeDrawerTrail, sameSelectedResource } from '../../utils/drawer-trail'
5
+
6
+ /**
7
+ * On a workspace screen the drawer URL carries the chain of objects opened
8
+ * from inside the drawer. This is the step back to the previous one, shown for
9
+ * whatever kind is open. `kindLabel` names the previous object's kind from its
10
+ * plural; unnamed plurals show as they are.
11
+ */
12
+ export function DrawerTrailBack({ resource, pathPrefix, kindLabel }: { resource: SelectedResource; pathPrefix: string; kindLabel: (plural: string) => string | undefined }) {
13
+ const location = useLocation()
14
+ const [searchParams, setSearchParams] = useSearchParams()
15
+ if (location.pathname !== pathPrefix && !location.pathname.startsWith(`${pathPrefix}/`)) return null
16
+ const trail = decodeDrawerTrail(searchParams.get('drawer'))
17
+ if (trail.length < 2 || !sameSelectedResource(trail[trail.length - 1], resource)) return null
18
+ const prev = trail[trail.length - 2]
19
+ const back = () => {
20
+ const params = new URLSearchParams(searchParams)
21
+ params.set('drawer', encodeDrawerTrail(trail.slice(0, -1)))
22
+ setSearchParams(params, { replace: true, state: location.state })
23
+ }
24
+ return (
25
+ <div className="shrink-0 border-b border-theme-border px-4 py-2">
26
+ <button type="button" onClick={back} className="inline-flex items-center gap-1 text-xs font-medium text-accent-text hover:underline">
27
+ <ArrowLeft className="h-3.5 w-3.5" />
28
+ {kindLabel(prev.kind) ?? prev.kind} {prev.name}
29
+ </button>
30
+ </div>
31
+ )
32
+ }
@@ -0,0 +1,71 @@
1
+ import { useCallback, useEffect, useState, type ReactNode } from 'react'
2
+ import { useLocation } from 'react-router-dom'
3
+ import { DialogPortal, ResourcesSidebar, type SelectedKindInfo, type SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
4
+ import { PanelLeft, X } from 'lucide-react'
5
+ import { useAPIResources } from '../../api/apiResources'
6
+ import { usePinnedKinds } from '../../hooks/useFavorites'
7
+ import { useResourceCounts } from '../../hooks/useResourceCounts'
8
+ import { useWorkspaceNavigate } from './useWorkspaceNavigate'
9
+
10
+ /**
11
+ * A workspace inside Resources: the same Resources sidebar, with the
12
+ * workspaces' destinations above their exact kinds, and the screen beside it.
13
+ * On narrow windows the sidebar moves into a dialog behind a button.
14
+ */
15
+ export function WorkspaceFrame({
16
+ namespaces,
17
+ categoryWorkspaces,
18
+ selectedKind = null,
19
+ compactNavigation,
20
+ children,
21
+ }: {
22
+ namespaces: string[]
23
+ categoryWorkspaces: Record<string, SidebarCategoryWorkspace> | undefined
24
+ /** The kind whose row is highlighted, when the screen is one object of it rather than a destination. */
25
+ selectedKind?: SelectedKindInfo | null
26
+ compactNavigation: boolean
27
+ children: ReactNode
28
+ }) {
29
+ const location = useLocation()
30
+ const navigate = useWorkspaceNavigate()
31
+ const [navigationOpen, setNavigationOpen] = useState(false)
32
+ useEffect(() => setNavigationOpen(false), [location.pathname, location.search, compactNavigation])
33
+ const { data: apiResources } = useAPIResources()
34
+ const { data: counts } = useResourceCounts(namespaces)
35
+ const { pinned, togglePin, isPinned } = usePinnedKinds()
36
+
37
+ const selectKind = useCallback(
38
+ (kind: SelectedKindInfo) => {
39
+ navigate(`/resources/${kind.name}${kind.group ? `?apiGroup=${encodeURIComponent(kind.group)}` : ''}`)
40
+ },
41
+ [navigate],
42
+ )
43
+
44
+ const sidebar = <ResourcesSidebar
45
+ selectedKind={selectedKind}
46
+ onSelectedKindChange={selectKind}
47
+ apiResources={apiResources}
48
+ resourceCounts={counts?.counts}
49
+ resourceCoverage={counts?.coverage}
50
+ resourceForbidden={counts?.forbidden}
51
+ resourceUnavailable={counts?.unavailable}
52
+ pinned={pinned}
53
+ togglePin={togglePin}
54
+ isPinned={(kind: string, group?: string) => isPinned(kind, group ?? '')}
55
+ categoryWorkspaces={categoryWorkspaces}
56
+ className={compactNavigation ? '!w-full !border-r-0' : undefined}
57
+ />
58
+ return (
59
+ <div className="flex h-full min-h-0 w-full">
60
+ {!compactNavigation && sidebar}
61
+ <DialogPortal open={navigationOpen && compactNavigation} onClose={() => setNavigationOpen(false)} ariaLabel="Resource navigation" className="flex h-[min(80vh,44rem)] w-full max-w-md flex-col overflow-hidden">
62
+ <div className="flex items-center justify-between border-b border-theme-border px-4 py-3"><h2 className="font-medium text-theme-text-primary">Resources</h2><button type="button" aria-label="Close resource navigation" onClick={() => setNavigationOpen(false)} className="rounded p-1 text-theme-text-secondary hover:bg-theme-hover"><X className="h-4 w-4" /></button></div>
63
+ <div className="flex min-h-0 flex-1">{sidebar}</div>
64
+ </DialogPortal>
65
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-theme-base">
66
+ {compactNavigation && <div className="border-b border-theme-border px-5 py-2"><button type="button" aria-haspopup="dialog" aria-expanded={navigationOpen} onClick={() => setNavigationOpen(true)} className="btn-secondary inline-flex items-center gap-1.5 px-2.5 py-1 text-xs"><PanelLeft className="h-3.5 w-3.5" />Resources</button></div>}
67
+ {children}
68
+ </div>
69
+ </div>
70
+ )
71
+ }
@@ -0,0 +1,61 @@
1
+ // How much of one kind a workspace read, worded for people. The shape is
2
+ // integration.KindCoverage, which every workspace endpoint serves per kind.
3
+
4
+ export interface WorkspaceKindCoverage {
5
+ state: string
6
+ deniedNamespaces?: string[]
7
+ uncachedNamespaces?: string[]
8
+ allowedNamespaces?: string[]
9
+ }
10
+
11
+ const COVERAGE_LABEL: Record<string, string> = {
12
+ denied: 'no access',
13
+ partial: 'not read in some namespaces',
14
+ uncached: 'not cached by Radar',
15
+ syncing: 'still loading',
16
+ error: 'could not be read',
17
+ }
18
+
19
+ /** Coverage states that leave some of a kind unread. */
20
+ export const INCOMPLETE_COVERAGE_STATES = new Set(['partial', 'denied', 'syncing', 'error', 'uncached'])
21
+
22
+ // The causes the server named for the namespaces it left unread. A partial or
23
+ // uncached read can name both kinds of namespace at once.
24
+ function namedCauses(cov: WorkspaceKindCoverage | undefined, uncachedNoun: string): { denied?: string; uncached?: string } {
25
+ return {
26
+ denied: cov?.deniedNamespaces?.length ? cov.deniedNamespaces.join(', ') : undefined,
27
+ uncached: cov?.uncachedNamespaces?.length ? `${uncachedNoun} in ${cov.uncachedNamespaces.join(', ')}` : undefined,
28
+ }
29
+ }
30
+
31
+ /** How much of a kind was read, in a few words ("not cached by Radar in pg"). */
32
+ export function coverageLabel(cov: WorkspaceKindCoverage | undefined): string {
33
+ if (!cov) return 'not read by this Radar'
34
+ const { denied, uncached } = namedCauses(cov, 'not cached by Radar')
35
+ const named = [denied && `no access in ${denied}`, uncached].filter(Boolean)
36
+ if (named.length > 0) return named.join('; ')
37
+ return COVERAGE_LABEL[cov?.state ?? ''] ?? cov?.state ?? 'unknown'
38
+ }
39
+
40
+ /** Empty-state text for a collection, derived from how much of it was readable. */
41
+ export function coverageEmpty(cov: WorkspaceKindCoverage | undefined, noun: string): string {
42
+ switch (cov?.state) {
43
+ case 'full':
44
+ return `No ${noun} in this scope.`
45
+ case 'partial':
46
+ case 'uncached': {
47
+ const { denied, uncached } = namedCauses(cov, `Radar does not cache ${noun}`)
48
+ const causes = [denied && `no access in ${denied}`, uncached].filter(Boolean)
49
+ if (causes.length > 0) return `No ${noun} visible: ${causes.join('; ')}.`
50
+ return cov.state === 'uncached' ? `Radar does not cache ${noun} in this scope.` : `No ${noun} visible. Some namespaces were not read.`
51
+ }
52
+ case 'denied':
53
+ return `No access to ${noun}.`
54
+ case 'syncing':
55
+ return `${noun[0].toUpperCase()}${noun.slice(1)} are still loading.`
56
+ case 'error':
57
+ return `${noun[0].toUpperCase()}${noun.slice(1)} could not be read.`
58
+ default:
59
+ return `This kind is not installed.`
60
+ }
61
+ }
@@ -2,7 +2,7 @@
2
2
  import { act } from 'react'
3
3
  import { createRoot } from 'react-dom/client'
4
4
  import { expect, it, vi } from 'vitest'
5
- import { Mono } from './layout'
5
+ import { Mono, SectionTable } from './layout'
6
6
 
7
7
  ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
8
8
 
@@ -27,3 +27,31 @@ it('uses normal word boundaries with overflow wrapping and keeps the complete va
27
27
  host.remove()
28
28
  vi.useRealTimers()
29
29
  })
30
+
31
+ it('opens a row from the keyboard the way a click does, and leaves keys on controls inside it alone', () => {
32
+ const host = document.createElement('div')
33
+ document.body.append(host)
34
+ const root = createRoot(host)
35
+ const onInspect = vi.fn()
36
+ const inner = vi.fn()
37
+ act(() => root.render(
38
+ <SectionTable
39
+ title="Things"
40
+ columns={[{ header: 'Name', cell: (r: { name: string }) => <button type="button" onClick={inner}>{r.name}</button> }]}
41
+ rows={[{ name: 'a' }]}
42
+ rowKey={(r) => r.name}
43
+ rowResource={(r) => ({ kind: 'Schedule', group: 'velero.io', namespace: 'velero', name: r.name })}
44
+ onInspect={onInspect}
45
+ inspected={null}
46
+ empty="none"
47
+ />,
48
+ ))
49
+ const row = host.querySelector('tbody tr') as HTMLTableRowElement
50
+ expect(row.tabIndex).toBe(0)
51
+ act(() => row.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })))
52
+ expect(onInspect).toHaveBeenCalledTimes(1)
53
+ act(() => host.querySelector('tbody button')!.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })))
54
+ expect(onInspect).toHaveBeenCalledTimes(1)
55
+ act(() => root.unmount())
56
+ host.remove()
57
+ })
@@ -78,7 +78,7 @@ export function Segments<T extends string>({
78
78
  label,
79
79
  }: {
80
80
  value: T
81
- options: { id: T; label: string; count?: number | string }[]
81
+ options: { id: T; label: string; count?: ReactNode }[]
82
82
  onChange: (id: T) => void
83
83
  label: string
84
84
  }) {
@@ -128,7 +128,8 @@ export function SectionTable<T>({
128
128
  minWidth = 760,
129
129
  footer,
130
130
  }: {
131
- title: ReactNode
131
+ /** Left out where the page heading already names the table. */
132
+ title?: ReactNode
132
133
  subtitle?: ReactNode
133
134
  columns: TableColumn<T>[]
134
135
  rows: T[]
@@ -143,7 +144,7 @@ export function SectionTable<T>({
143
144
  return (
144
145
  <section>
145
146
  <div className="mb-2 flex flex-wrap items-baseline gap-x-2.5 gap-y-1">
146
- <h2 className="text-sm font-semibold text-theme-text-primary">{title}</h2>
147
+ {title && <h2 className="text-sm font-semibold text-theme-text-primary">{title}</h2>}
147
148
  {subtitle && <span className="text-xs text-theme-text-tertiary">{subtitle}</span>}
148
149
  </div>
149
150
  <div className="overflow-hidden rounded-xl border border-theme-border bg-theme-surface shadow-theme-sm">
@@ -168,11 +169,20 @@ export function SectionTable<T>({
168
169
  {rows.map((row) => {
169
170
  const res = rowResource?.(row) ?? null
170
171
  const active = !!res && sameSelectedResource(inspected, res)
172
+ const open = res && onInspect ? () => onInspect(res) : undefined
171
173
  return (
172
174
  <tr
173
175
  key={rowKey(row)}
174
- onClick={res && onInspect ? () => onInspect(res) : undefined}
175
- className={clsx(res && onInspect && 'cursor-pointer', ROW_HOVER, active && 'selection')}
176
+ onClick={open}
177
+ // Keyboard users open a row the way a click does; keys on a
178
+ // control inside the row stay that control's.
179
+ tabIndex={open ? 0 : undefined}
180
+ onKeyDown={open ? (e) => {
181
+ if (e.target !== e.currentTarget || (e.key !== 'Enter' && e.key !== ' ')) return
182
+ e.preventDefault()
183
+ open()
184
+ } : undefined}
185
+ className={clsx(open && 'cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent', ROW_HOVER, active && 'selection')}
176
186
  aria-selected={res ? active : undefined}
177
187
  >
178
188
  {columns.map((c, i) => (
@@ -0,0 +1,9 @@
1
+ import { useMemo } from 'react'
2
+ import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
3
+
4
+ type Workspaces = Record<string, SidebarCategoryWorkspace>
5
+
6
+ /** Two integrations' sidebar workspaces as one map; undefined when neither applies. */
7
+ export function useMergedSidebarWorkspaces(a: Workspaces | undefined, b: Workspaces | undefined): Workspaces | undefined {
8
+ return useMemo(() => (a || b ? { ...a, ...b } : undefined), [a, b])
9
+ }
@@ -0,0 +1,63 @@
1
+ import { useCallback, useEffect, useMemo, useRef } from 'react'
2
+ import { useLocation, useSearchParams } from 'react-router-dom'
3
+ import type { SelectedResource } from '../../types'
4
+ import { decodeDrawerTrail, encodeDrawerTrail, sameSelectedResource } from '../../utils/drawer-trail'
5
+
6
+ /**
7
+ * A workspace's link to the app's single resource drawer. `?drawer=` backs it
8
+ * so a refresh, a shared link and browser Back restore the inspected object,
9
+ * and it carries the chain of objects opened from inside the drawer.
10
+ */
11
+ export function useWorkspaceDrawer({
12
+ selectedResource,
13
+ onOpenResource,
14
+ onCloseResource,
15
+ }: {
16
+ selectedResource: SelectedResource | null
17
+ onOpenResource: (resource: SelectedResource) => void
18
+ onCloseResource: () => void
19
+ }) {
20
+ const location = useLocation()
21
+ const [searchParams, setSearchParams] = useSearchParams()
22
+ const drawerParam = searchParams.get('drawer')
23
+ const trail = useMemo(() => decodeDrawerTrail(drawerParam), [drawerParam])
24
+ const drawerTarget = trail.length > 0 ? trail[trail.length - 1] : null
25
+
26
+ // Two-way sync between ?drawer= and the app drawer. Whichever side changed
27
+ // since the last sync wins, so URL navigation (Back, a pasted link) opens the
28
+ // drawer and drawer navigation (close, a link inside it) rewrites the URL.
29
+ const lastSynced = useRef<string | null>(null)
30
+ const selectedKey = selectedResource ? encodeDrawerTrail([selectedResource]) : ''
31
+ const targetKey = drawerTarget ? encodeDrawerTrail([drawerTarget]) : ''
32
+ useEffect(() => {
33
+ if (targetKey !== (lastSynced.current ?? '')) {
34
+ lastSynced.current = targetKey
35
+ if (drawerTarget && !sameSelectedResource(drawerTarget, selectedResource)) onOpenResource(drawerTarget)
36
+ else if (!drawerTarget && selectedResource) onCloseResource()
37
+ return
38
+ }
39
+ if (selectedKey !== targetKey) {
40
+ lastSynced.current = selectedKey
41
+ const params = new URLSearchParams(searchParams)
42
+ if (!selectedResource) {
43
+ params.delete('drawer')
44
+ } else {
45
+ const idx = trail.findIndex((r) => sameSelectedResource(r, selectedResource))
46
+ const next = idx >= 0 ? trail.slice(0, idx + 1) : [...trail, selectedResource]
47
+ params.set('drawer', encodeDrawerTrail(next))
48
+ }
49
+ setSearchParams(params, { replace: true, state: location.state })
50
+ }
51
+ }, [targetKey, selectedKey]) // eslint-disable-line react-hooks/exhaustive-deps
52
+
53
+ const inspect = useCallback(
54
+ (resource: SelectedResource) => {
55
+ const params = new URLSearchParams(searchParams)
56
+ params.set('drawer', encodeDrawerTrail([resource]))
57
+ setSearchParams(params, { replace: true, state: location.state })
58
+ },
59
+ [searchParams, setSearchParams, location.state],
60
+ )
61
+
62
+ return { drawerTarget, inspect, searchParams }
63
+ }
@@ -0,0 +1,21 @@
1
+ import { useCallback } from 'react'
2
+ import { useLocation, useNavigate, type NavigateOptions, type To } from 'react-router-dom'
3
+ import { withCrossViewParams } from '../../utils/navigation'
4
+
5
+ /**
6
+ * navigate() for the workspace screens: a string path keeps the current
7
+ * cross-view params (the namespace filter, an open investigation), as the
8
+ * app's own navigation does. Without them the app reads the missing
9
+ * ?namespaces= as "All namespaces" and saves that as the user's choice.
10
+ */
11
+ export function useWorkspaceNavigate() {
12
+ const navigate = useNavigate()
13
+ const { search } = useLocation()
14
+ return useCallback(
15
+ (to: To | number, options?: NavigateOptions) => {
16
+ if (typeof to === 'number') return navigate(to)
17
+ return navigate(typeof to === 'string' ? withCrossViewParams(to, search) : to, options)
18
+ },
19
+ [navigate, search],
20
+ )
21
+ }
@@ -0,0 +1,12 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { aboutVersionText } from './AboutDialog'
4
+
5
+ describe('aboutVersionText', () => {
6
+ const info = { version: 'v1.20.4', platform: 'Windows · amd64' }
7
+ it('names the version, channel and platform for bug reports', () => {
8
+ expect(aboutVersionText(info, 'stable')).toBe('Radar 1.20.4\nWindows · amd64 · desktop app')
9
+ expect(aboutVersionText(info, 'development')).toBe('Radar 1.20.4 (development build)\nWindows · amd64 · desktop app')
10
+ expect(aboutVersionText(info)).toBe('Radar 1.20.4\nWindows · amd64 · desktop app')
11
+ })
12
+ })