@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,3 +1,4 @@
1
+ import { formatBytes } from '@skyhook-io/k8s-ui/utils/format'
1
2
  import type { AggregatedFlow, TrafficFlow, TrafficWarningKind } from '../../types'
2
3
  import type { TrafficEndpointPair, TrafficEndpointRef, TrafficMatch } from '../../api/traffic'
3
4
  import type { TrafficGraphSelection } from './TrafficGraph'
@@ -71,6 +72,96 @@ export function errorRateOf(flow: Pick<AggregatedFlow, 'errorRate' | 'errorCount
71
72
  return flow.errorRate ?? flow.errorCount ?? 0
72
73
  }
73
74
 
75
+ /**
76
+ * An edge's protocol as "application / transport", or one name when the two
77
+ * are the same: a mesh source reports HTTP as both, and "HTTP / HTTP" reads as
78
+ * two protocols.
79
+ */
80
+ export function protocolLabel(l7Protocol: string | undefined, protocol: string): string {
81
+ if (!l7Protocol || l7Protocol.toLowerCase() === protocol.toLowerCase()) return l7Protocol || protocol
82
+ return `${l7Protocol} / ${protocol}`
83
+ }
84
+
85
+ export function protocolName(protocol: string): string {
86
+ return protocol.toLowerCase() === 'grpc' ? 'gRPC' : protocol.toUpperCase() || 'Unknown'
87
+ }
88
+
89
+ export interface ProtocolData {
90
+ protocol: string | null
91
+ sent: number
92
+ recv: number
93
+ }
94
+
95
+ type ByteFigures = Pick<AggregatedFlow, 'bytesByProtocol' | 'bytesSent' | 'bytesRecv'>
96
+
97
+ const transportProtocols = new Set(['tcp', 'udp', 'icmp', 'icmpv6', 'sctp'])
98
+
99
+ export function isPayloadProtocol(protocol: string): boolean {
100
+ return !transportProtocols.has(protocol.toLowerCase())
101
+ }
102
+
103
+ /** The protocols an edge's traffic was observed on, payload protocols first,
104
+ * whether or not they carried byte figures. */
105
+ export function protocolsOf(flow: Pick<AggregatedFlow, 'bytesByProtocol'>): string[] {
106
+ return Object.keys(flow.bytesByProtocol ?? {})
107
+ .sort((a, b) => Number(isPayloadProtocol(b)) - Number(isPayloadProtocol(a)) || a.localeCompare(b))
108
+ }
109
+
110
+ /** An edge's Data per protocol, payload protocols first. Only protocols that
111
+ * carried bytes: a zero there usually means not measured (a failed byte query,
112
+ * a source that reports none), and "0 B" would read as a measurement. A Radar
113
+ * that predates the breakdown sends only the cross-protocol sum, which can
114
+ * already mix HTTP and gRPC under one protocol name, so it comes back as one
115
+ * figure with no protocol claimed. */
116
+ export function dataByProtocol(flow: ByteFigures): ProtocolData[] {
117
+ const buckets = flow.bytesByProtocol
118
+ if (!buckets) return [{ protocol: null, sent: flow.bytesSent, recv: flow.bytesRecv }]
119
+ return protocolsOf(flow)
120
+ .map(protocol => ({ protocol, sent: buckets[protocol].bytesSent, recv: buckets[protocol].bytesRecv }))
121
+ .filter(e => e.sent + e.recv > 0)
122
+ }
123
+
124
+ /** The span a rate-based source's byte totals cover, in seconds: the view's
125
+ * range, five minutes when it is under a minute, at most an hour — the same
126
+ * rule the server's rate window follows. */
127
+ export function rateWindowSeconds(timeRange: string): number {
128
+ const m = /^(\d+)([smh])$/.exec(timeRange)
129
+ const seconds = m ? Number(m[1]) * ({ s: 1, m: 60, h: 3600 } as const)[m[2] as 's' | 'm' | 'h'] : 0
130
+ return seconds < 60 ? 300 : Math.min(seconds, 3600)
131
+ }
132
+
133
+ /** Label for an edge a rate-based source measured only in bytes: its
134
+ * throughput per protocol over the window, never added across protocols.
135
+ * Empty without a per-protocol breakdown: an older Radar's byte sum can mix
136
+ * TCP and UDP under one protocol name, so no protocol can be claimed for it. */
137
+ export function throughputLabel(flow: ByteFigures, windowSeconds: number): string {
138
+ if (!flow.bytesByProtocol) return ''
139
+ return dataByProtocol(flow)
140
+ .map(e => {
141
+ const perSecond = (e.sent + e.recv) / windowSeconds
142
+ return `${protocolName(e.protocol!)} · ${perSecond < 1 ? '<1 B' : formatBytes(perSecond)}/s`
143
+ })
144
+ .join(' · ')
145
+ }
146
+
147
+ /** Data across several edges, added only within each protocol. */
148
+ export function totalDataByProtocol(flows: ByteFigures[]): ProtocolData[] {
149
+ if (!flows.some(f => f.bytesByProtocol)) {
150
+ return [{ protocol: null, sent: flows.reduce((n, f) => n + f.bytesSent, 0), recv: flows.reduce((n, f) => n + f.bytesRecv, 0) }]
151
+ }
152
+ return dataByProtocol({ bytesSent: 0, bytesRecv: 0, bytesByProtocol: flows.reduce<AggregatedFlow['bytesByProtocol']>((acc, f) => mergeProtocolBytes(acc, f.bytesByProtocol), undefined) })
153
+ }
154
+
155
+ function mergeProtocolBytes(a: AggregatedFlow['bytesByProtocol'], b: AggregatedFlow['bytesByProtocol']): AggregatedFlow['bytesByProtocol'] {
156
+ if (!b) return a
157
+ const merged = { ...a }
158
+ for (const [protocol, bytes] of Object.entries(b)) {
159
+ const prev = merged[protocol]
160
+ merged[protocol] = { bytesSent: (prev?.bytesSent ?? 0) + bytes.bytesSent, bytesRecv: (prev?.bytesRecv ?? 0) + bytes.bytesRecv }
161
+ }
162
+ return merged
163
+ }
164
+
74
165
  /**
75
166
  * The volume shown for an edge. For a rate-based source `connections` is its
76
167
  * request rate rounded with a floor of one — the graph sizes, sorts and filters
@@ -130,6 +221,7 @@ export function mergeFlowVolume(into: AggregatedFlow, flow: AggregatedFlow): voi
130
221
  }
131
222
  const weighted: LatencyWeighted = into
132
223
  weighted.latencyWeight = wInto + wFlow
224
+ into.bytesByProtocol = mergeProtocolBytes(into.bytesByProtocol, flow.bytesByProtocol)
133
225
  into.connections += flow.connections
134
226
  into.bytesSent += flow.bytesSent
135
227
  into.bytesRecv += flow.bytesRecv
@@ -372,6 +464,53 @@ export function mergeRawPairs(into: GraphFlow, from: GraphFlow): void {
372
464
  for (const pair of from.rawPairs ?? []) target.push(pair)
373
465
  }
374
466
 
467
+ export function groupAddonFlows(flows: GraphFlow[], isAddon: (name: string, namespace: string | undefined) => boolean): GraphFlow[] {
468
+ let internet: GraphFlow | undefined
469
+ let kubernetes: GraphFlow | undefined
470
+ const grouped: GraphFlow[] = []
471
+ for (const flow of flows) {
472
+ if (flow.source.kind === 'Internet' && isAddon(flow.destination.name, flow.destination.namespace)) {
473
+ if (!internet) {
474
+ internet = {
475
+ connections: 0, bytesSent: 0, bytesRecv: 0, flowCount: 0, lastSeen: flow.lastSeen,
476
+ source: { name: 'addon-internet', namespace: '', kind: 'AddonInternet' },
477
+ destination: { name: 'addon-group-target', namespace: '', kind: 'AddonGroupTarget' },
478
+ protocol: flow.protocol, port: flow.port, l7Protocol: flow.l7Protocol,
479
+ rawPairs: [],
480
+ }
481
+ }
482
+ internet.port = mergedEdgePort(internet.port, flow.port)
483
+ if (internet.protocol !== flow.protocol) internet.protocol = 'mixed'
484
+ if (internet.l7Protocol !== flow.l7Protocol) internet.l7Protocol = 'mixed'
485
+ mergeFlowVolume(internet, flow)
486
+ mergeRawPairs(internet, flow)
487
+ grouped.push({ ...flow, source: { name: 'addon-internet', namespace: '', kind: 'SkipEdge' } })
488
+ } else if (isAddon(flow.source.name, flow.source.namespace) && flow.destination.name === 'kubernetes' &&
489
+ (!flow.destination.namespace || flow.destination.namespace === 'default')) {
490
+ if (!kubernetes) {
491
+ kubernetes = {
492
+ connections: 0, bytesSent: 0, bytesRecv: 0, flowCount: 0, lastSeen: flow.lastSeen,
493
+ source: { name: 'addon-group-source', namespace: '', kind: 'AddonGroupSource' },
494
+ destination: { name: 'kubernetes', namespace: 'default', kind: 'Service' },
495
+ protocol: flow.protocol, port: flow.port, l7Protocol: flow.l7Protocol,
496
+ rawPairs: [],
497
+ }
498
+ }
499
+ kubernetes.port = mergedEdgePort(kubernetes.port, flow.port)
500
+ if (kubernetes.protocol !== flow.protocol) kubernetes.protocol = 'mixed'
501
+ if (kubernetes.l7Protocol !== flow.l7Protocol) kubernetes.l7Protocol = 'mixed'
502
+ mergeFlowVolume(kubernetes, flow)
503
+ mergeRawPairs(kubernetes, flow)
504
+ grouped.push({ ...flow, destination: { ...flow.destination, kind: 'SkipEdge' } })
505
+ } else {
506
+ grouped.push(flow)
507
+ }
508
+ }
509
+ if (internet) grouped.push(internet)
510
+ if (kubernetes) grouped.push(kubernetes)
511
+ return grouped
512
+ }
513
+
375
514
  // The renderer draws the addon group's virtual endpoints as one group node.
376
515
  function selectableId(e: { namespace?: string; name: string; kind?: string }): string {
377
516
  if (e.kind === 'AddonGroupTarget' || e.kind === 'AddonGroupSource') return 'addon-group'
@@ -6,6 +6,7 @@ import { openExternal } from '../../utils/navigation'
6
6
  import { useDiagnostics } from '../../api/client'
7
7
  import type { DiagnosticsSnapshot, DiagEnvVar, DiagMetricsSourceHealth, DiagDropRecord, DiagErrorEntry, DiagCacheSyncStatus, DiagInformerSyncStatus, DiagSyncPhase, DiagSampleWindow } from '../../api/client'
8
8
  import { getK8sUIPerfSnapshot, type K8sUIPerfSnapshot } from '@skyhook-io/k8s-ui'
9
+ import { SLACK_COLORS_ON_HOVER, SlackIcon } from '../community'
9
10
 
10
11
  export type DiagnosticsFocus = 'timeline'
11
12
 
@@ -14,9 +15,10 @@ interface DiagnosticsOverlayProps {
14
15
  isOpen?: boolean
15
16
  /** Section to scroll to on open, for callers linking to one specific problem. */
16
17
  focus?: DiagnosticsFocus
18
+ communityUrl?: string
17
19
  }
18
20
 
19
- export function DiagnosticsOverlay({ onClose, isOpen = true, focus }: DiagnosticsOverlayProps) {
21
+ export function DiagnosticsOverlay({ onClose, isOpen = true, focus, communityUrl }: DiagnosticsOverlayProps) {
20
22
  const { data, isLoading, error } = useDiagnostics(true)
21
23
  const [copied, setCopied] = useState<'json' | 'formatted' | null>(null)
22
24
  const [reportOpened, setReportOpened] = useState(false)
@@ -157,6 +159,17 @@ export function DiagnosticsOverlay({ onClose, isOpen = true, focus }: Diagnostic
157
159
  <CopyButton label="Copy as Markdown" onClick={() => copyToClipboard('formatted')} copied={copied === 'formatted'} />
158
160
  <CopyButton label="Copy Raw JSON" onClick={() => copyToClipboard('json')} copied={copied === 'json'} />
159
161
  <div className="flex-1" />
162
+ {communityUrl && (
163
+ <a
164
+ href={communityUrl}
165
+ target="_blank"
166
+ rel="noopener noreferrer"
167
+ className="group flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated"
168
+ >
169
+ <SlackIcon className={clsx('w-3.5 h-3.5', SLACK_COLORS_ON_HOVER)} />
170
+ Ask in Slack
171
+ </a>
172
+ )}
160
173
  <button
161
174
  onClick={openBugReport}
162
175
  disabled={!data}
@@ -66,13 +66,16 @@ describe('manual Desktop version checks', () => {
66
66
  expect(container.textContent).toContain('Radar 1.2.3')
67
67
  })
68
68
 
69
- it('publishes a fresh available update and clears its dismissal', () => {
69
+ it('publishes a fresh available update, clears its dismissal and leaves the announcement to the card', () => {
70
70
  localStorage.setItem('radar-update-dismissed', '1.3.0')
71
71
  const info = { ...current, updateAvailable: true, latestVersion: '1.3.0' }
72
+ act(() => { window.dispatchEvent(new Event('radar:check-for-updates')) })
72
73
  act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: info })) })
73
74
  expect(client.getQueryData(['version-check', '/desktop/api'])).toEqual(info)
74
75
  expect(localStorage.getItem('radar-update-dismissed')).toBeNull()
75
- expect(container.textContent).toContain('Radar 1.3.0 is available')
76
+ act(() => { vi.advanceTimersByTime(DURATION_TOAST_EXIT) })
77
+ // The card shares the toast's corner; a toast saying the same would cover it.
78
+ expect(container.querySelector('[role="status"]')).toBeNull()
76
79
  })
77
80
 
78
81
  it('reports failure without replacing known version data', () => {
@@ -5,6 +5,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
5
5
  let deploymentMode = 'local'
6
6
  let installMethod = 'direct'
7
7
  let manualUpdate: 'appimage' | 'package' | 'download' | undefined
8
+ let applied = false
8
9
 
9
10
  vi.mock('../../api/client', () => ({
10
11
  useCapabilities: () => ({ data: { deployment: { mode: deploymentMode } } }),
@@ -22,10 +23,11 @@ vi.mock('../../api/client', () => ({
22
23
  }),
23
24
  useStartDesktopUpdate: () => ({ mutate: vi.fn(), isPending: false }),
24
25
  useDesktopUpdateStatus: () => ({ data: undefined }),
25
- useApplyDesktopUpdate: () => ({ mutate: vi.fn() }),
26
+ useApplyDesktopUpdate: () => ({ mutate: vi.fn(), isPending: false, isSuccess: applied }),
26
27
  }))
27
28
 
28
- import { UpdateNotification } from './UpdateNotification'
29
+ import { UpdateNotification, manualCheckToast } from './UpdateNotification'
30
+ import type { VersionInfo } from '../../api/client'
29
31
  import { ToastProvider } from './Toast'
30
32
 
31
33
  function renderNotification() {
@@ -42,6 +44,7 @@ describe('UpdateNotification', () => {
42
44
  deploymentMode = 'local'
43
45
  installMethod = 'direct'
44
46
  manualUpdate = undefined
47
+ applied = false
45
48
  })
46
49
 
47
50
  it('keeps the update popup for local installations', () => {
@@ -67,8 +70,34 @@ describe('UpdateNotification', () => {
67
70
  expect(html.match(/<button/g)).toHaveLength(1)
68
71
  })
69
72
 
73
+ it('keeps showing the restart once the new version is in place', () => {
74
+ installMethod = 'desktop'
75
+ applied = true
76
+ const html = renderNotification()
77
+ expect(html).toContain('Applying Update...')
78
+ expect(html).not.toContain('Update Available')
79
+ })
80
+
70
81
  it('suppresses the update popup for shared in-cluster viewers', () => {
71
82
  deploymentMode = 'in-cluster'
72
83
  expect(renderNotification()).toBe('')
73
84
  })
74
85
  })
86
+
87
+ describe('manualCheckToast', () => {
88
+ const info = (over: Partial<VersionInfo>) => ({ currentVersion: '1.2.3', latestVersion: '1.3.0', updateAvailable: false, ...over }) as VersionInfo
89
+
90
+ it('leaves a found update to the card, which shares its corner', () => {
91
+ expect(manualCheckToast(info({ updateAvailable: true }), true)).toBeNull()
92
+ })
93
+
94
+ it('announces a found update when the card is held back', () => {
95
+ expect(manualCheckToast(info({ updateAvailable: true }), false)?.message).toBe('Radar 1.3.0 is available')
96
+ })
97
+
98
+ it('still answers when there is nothing to update to, or the check failed', () => {
99
+ expect(manualCheckToast(info({}), true)?.message).toBe("You're up to date")
100
+ expect(manualCheckToast(info({ buildChannel: 'development' }), true)?.message).toBe('Latest Radar release: 1.3.0')
101
+ expect(manualCheckToast(info({ error: 'offline' }), true)).toMatchObject({ type: 'error', detail: 'offline' })
102
+ })
103
+ })
@@ -32,6 +32,20 @@ export function isUpdateDismissed(latestVersion: string): boolean {
32
32
  }
33
33
  }
34
34
 
35
+ type ManualCheckToast = { message: string; type: 'info' | 'success' | 'error'; detail?: string }
36
+
37
+ // The answer to Help → Check for Updates. A found update is announced by the
38
+ // update card, which shares the toast's corner, so the toast only says so when
39
+ // something else holds that corner and the card waits.
40
+ export function manualCheckToast(info: VersionInfo, cardShows: boolean): ManualCheckToast | null {
41
+ if (info.error) return { message: 'Could not check for updates', type: 'error', detail: info.error }
42
+ if (info.updateAvailable) return cardShows ? null : { message: `Radar ${info.latestVersion} is available`, type: 'info' }
43
+ if (info.buildChannel === 'development') {
44
+ return { message: `Latest Radar release: ${info.latestVersion}`, type: 'info', detail: 'You are running a development build.' }
45
+ }
46
+ return { message: "You're up to date", type: 'success', detail: `Radar ${info.currentVersion}` }
47
+ }
48
+
35
49
  export function UpdateNotification({ placement = 'floating' }: { placement?: 'floating' | 'settings' }) {
36
50
  const inSettings = placement === 'settings'
37
51
  const [expanded, setExpanded] = useState(false)
@@ -39,7 +53,7 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
39
53
  const triggerRef = useRef<HTMLButtonElement>(null)
40
54
  const panelId = useId()
41
55
  const queryClient = useQueryClient()
42
- const { showToast } = useToast()
56
+ const { showToast, dismissToast } = useToast()
43
57
  const { data: capabilities } = useCapabilities()
44
58
  const deploymentMode = capabilities ? (capabilities.deployment?.mode ?? 'local') : undefined
45
59
  const { data: versionInfo } = useVersionCheck()
@@ -72,21 +86,15 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
72
86
  }
73
87
  const resultHandler = (event: Event) => {
74
88
  const info = (event as CustomEvent<VersionInfo>).detail
75
- if (info.error) {
76
- showToast('Could not check for updates', { id, type: 'error', detail: info.error })
77
- return
78
- }
79
- void queryClient.cancelQueries({ queryKey: ['version-check', getApiBase()], exact: true })
80
- setDismissed(false)
81
- try { localStorage.removeItem(DISMISSED_KEY) } catch { /* ignore */ }
82
- queryClient.setQueryData(['version-check', getApiBase()], info)
83
- if (info.updateAvailable) {
84
- showToast(`Radar ${info.latestVersion} is available`, { id, type: 'info' })
85
- } else if (info.buildChannel === 'development') {
86
- showToast(`Latest Radar release: ${info.latestVersion}`, { id, type: 'info', detail: 'You are running a development build.' })
87
- } else {
88
- showToast("You're up to date", { id, type: 'success', detail: `Radar ${info.currentVersion}` })
89
+ if (!info.error) {
90
+ void queryClient.cancelQueries({ queryKey: ['version-check', getApiBase()], exact: true })
91
+ setDismissed(false)
92
+ try { localStorage.removeItem(DISMISSED_KEY) } catch { /* ignore */ }
93
+ queryClient.setQueryData(['version-check', getApiBase()], info)
89
94
  }
95
+ const toast = manualCheckToast(info, cardCanShowRef.current)
96
+ if (toast) showToast(toast.message, { id, type: toast.type, detail: toast.detail })
97
+ else dismissToast(id)
90
98
  }
91
99
 
92
100
  window.addEventListener('radar:check-for-updates', handler)
@@ -95,7 +103,7 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
95
103
  window.removeEventListener('radar:check-for-updates', handler)
96
104
  window.removeEventListener('radar:update-check-result', resultHandler)
97
105
  }
98
- }, [queryClient, inSettings, showToast])
106
+ }, [queryClient, inSettings, showToast, dismissToast])
99
107
 
100
108
  // Runs until the launch window is over, so a notice already on screen when
101
109
  // the launch day starts steps aside too.
@@ -136,6 +144,12 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
136
144
  return () => window.removeEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
137
145
  }, [inSettings])
138
146
 
147
+ // Whether a found update would show the card now; read by the manual
148
+ // check's result, which clears the card's dismissal first.
149
+ const cardCanShow = deploymentMode !== undefined && deploymentMode !== 'cloud' && deploymentMode !== 'in-cluster' && !launchHoldsCorner && !usagePromptShowing
150
+ const cardCanShowRef = useRef(cardCanShow)
151
+ useEffect(() => { cardCanShowRef.current = cardCanShow }, [cardCanShow])
152
+
139
153
  // Stop polling when update reaches a terminal state
140
154
  useEffect(() => {
141
155
  if (updateStatus?.state === 'error' || updateStatus?.state === 'idle') {
@@ -186,7 +200,10 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
186
200
  }
187
201
 
188
202
  // Determine what the current effective state is
189
- const effectiveState: DesktopUpdateState = updateStatus?.state ?? 'idle'
203
+ // The updater is idle again once the new version is in place, before Radar
204
+ // restarts; the card keeps showing the restart rather than offering the
205
+ // update again.
206
+ const effectiveState: DesktopUpdateState = applyUpdate.isPending || applyUpdate.isSuccess ? 'applying' : updateStatus?.state ?? 'idle'
190
207
 
191
208
  const panel = shouldRender && (
192
209
  <div
@@ -18,10 +18,14 @@ import {
18
18
  Server,
19
19
  Megaphone,
20
20
  } from "lucide-react";
21
+ import { SlackIcon } from "../community";
21
22
  import { useNamespaces, useContexts } from "../../api/client";
22
23
  import { CORE_RESOURCES, useAPIResources } from "../../api/apiResources";
23
24
  import { getResourceIcon } from "../../utils/resource-icons";
24
- import { parseContextForSwitcher, parseContextName } from "../../utils/context-name";
25
+ import {
26
+ parseContextForSwitcher,
27
+ parseContextName,
28
+ } from "../../utils/context-name";
25
29
 
26
30
  export type MainView =
27
31
  | "home"
@@ -128,6 +132,7 @@ export interface CommandItemCallbacks {
128
132
  onShowDiagnostics?: () => void;
129
133
  // Present only when release notes exist for this version.
130
134
  onShowWhatsNew?: () => void;
135
+ onOpenCommunity?: () => void;
131
136
  }
132
137
 
133
138
  const VIEW_ENTRIES: {
@@ -276,6 +281,23 @@ export function useCommandItems(cb: CommandItemCallbacks): CommandItem[] {
276
281
  searchTerms: ["release notes", "changelog", "updates", "new features"],
277
282
  });
278
283
  }
284
+ if (cb.onOpenCommunity) {
285
+ result.push({
286
+ id: "action-community",
287
+ label: "Radar community on Slack",
288
+ category: "Actions",
289
+ icon: SlackIcon,
290
+ action: () => cb.onOpenCommunity?.(),
291
+ searchTerms: [
292
+ "slack",
293
+ "community",
294
+ "help",
295
+ "support",
296
+ "chat",
297
+ "question",
298
+ ],
299
+ });
300
+ }
279
301
  if (cb.onShowDiagnostics) {
280
302
  result.push({
281
303
  id: "action-diagnostics",
@@ -300,5 +322,6 @@ export function useCommandItems(cb: CommandItemCallbacks): CommandItem[] {
300
322
  cb.onToggleTheme,
301
323
  cb.onShowDiagnostics,
302
324
  cb.onShowWhatsNew,
325
+ cb.onOpenCommunity,
303
326
  ]);
304
327
  }
@@ -0,0 +1,165 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { afterEach, describe, expect, it, vi } from 'vitest'
5
+ import { schedule as reading } from './velero.fixtures'
6
+
7
+ ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
8
+
9
+ const state = vi.hoisted(() => ({ support: 'supported', mutate: vi.fn(), reading: undefined as unknown, serverStopped: false, backupsDisabled: false, toast: vi.fn() }))
10
+ vi.mock('../../api/client', () => ({ useRadarFeature: () => ({ support: state.support }) }))
11
+ vi.mock('../../api/velero', () => ({
12
+ useVeleroBackupNow: () => ({ mutate: state.mutate, reset: vi.fn(), isPending: false }),
13
+ useVeleroScheduleActivity: () => ({ data: state.reading ? { reading: state.reading, serverStopped: state.serverStopped } : undefined }),
14
+ useVeleroWorkspace: () => ({ data: { installations: [{ namespace: 'velero', server: { source: 'deployment', backupsDisabled: state.backupsDisabled } }] } }),
15
+ }))
16
+ vi.mock('../ui/Toast', () => ({ showApiSuccess: state.toast }))
17
+
18
+ const { VeleroBackupNow } = await import('./VeleroBackupNow')
19
+
20
+ const nightly = {
21
+ metadata: { namespace: 'velero', name: 'nightly', resourceVersion: '42' },
22
+ spec: { schedule: '0 1 * * *', template: { includedNamespaces: ['payments'], storageLocation: 'primary', ttl: '168h0m0s' } },
23
+ }
24
+
25
+ // Every root is unmounted after its test: a mounted dialog keeps scheduling
26
+ // its close animation, which would otherwise run after the environment is gone.
27
+ const roots: ReturnType<typeof createRoot>[] = []
28
+ function render(node: React.ReactNode) {
29
+ const host = document.createElement('div')
30
+ document.body.append(host)
31
+ const root = createRoot(host)
32
+ roots.push(root)
33
+ act(() => root.render(node))
34
+ return root
35
+ }
36
+ afterEach(() => {
37
+ act(() => roots.splice(0).forEach((r) => r.unmount()))
38
+ document.body.innerHTML = ''
39
+ state.support = 'supported'
40
+ state.reading = undefined
41
+ state.serverStopped = false
42
+ state.backupsDisabled = false
43
+ state.toast.mockReset()
44
+ state.mutate.mockReset()
45
+ })
46
+
47
+ const buttonNamed = (label: string) => [...document.querySelectorAll('button')].find((b) => b.textContent?.trim() === label)
48
+
49
+ describe('Back up now', () => {
50
+ it('says a wildcard exclusion narrows what is backed up', () => {
51
+ for (const field of ['excludedNamespaceScopedResources', 'excludedClusterScopedResources']) {
52
+ render(<VeleroBackupNow schedule={{ ...nightly, spec: { ...nightly.spec, template: { ...nightly.spec.template, [field]: ['*'] } } }} />)
53
+ act(() => buttonNamed('Back up now')!.click())
54
+ expect(document.body.textContent).toContain('narrowed by resource or label filters')
55
+ act(() => roots.splice(0).forEach((r) => r.unmount()))
56
+ document.body.innerHTML = ''
57
+ }
58
+ })
59
+
60
+ it('reads a zero retention as the server default, as Velero does', () => {
61
+ render(<VeleroBackupNow schedule={{ ...nightly, spec: { ...nightly.spec, template: { ...nightly.spec.template, ttl: '0s' } } }} />)
62
+ act(() => buttonNamed('Back up now')!.click())
63
+ expect(document.body.textContent).toContain('The Velero server’s default (30 days unless it was changed)')
64
+ expect(document.body.textContent).not.toContain('0 hours')
65
+ })
66
+
67
+ it('shows what will be backed up, and binds the backup to the schedule reviewed', () => {
68
+ render(<VeleroBackupNow schedule={nightly} />)
69
+ act(() => buttonNamed('Back up now')!.click())
70
+ const dialog = document.body.textContent ?? ''
71
+ expect(dialog).toContain('payments')
72
+ expect(dialog).toContain('primary')
73
+ expect(dialog).toContain('7 days')
74
+ expect(dialog).toContain("The schedule's next run waits while this backup is queued or running.")
75
+ const confirm = [...document.querySelectorAll('button')].filter((b) => b.textContent?.trim() === 'Back up now').at(-1)!
76
+ act(() => confirm.click())
77
+ expect(state.mutate).toHaveBeenCalledWith(
78
+ expect.objectContaining({ namespace: 'velero', name: 'nightly', resourceVersion: '42', backupName: expect.stringMatching(/^nightly-\d{14}$/), submission: expect.stringMatching(/^[A-Za-z0-9-]{8,64}$/) }),
79
+ expect.anything(),
80
+ )
81
+ })
82
+
83
+ it('keeps the schedule it showed, and refuses one that changed while it was open', () => {
84
+ const root = render(<VeleroBackupNow schedule={nightly} />)
85
+ act(() => buttonNamed('Back up now')!.click())
86
+ const edited = { ...nightly, metadata: { ...nightly.metadata, resourceVersion: '43' }, spec: { ...nightly.spec, template: { ...nightly.spec.template, storageLocation: 'elsewhere' } } }
87
+ act(() => root.render(<VeleroBackupNow schedule={edited} />))
88
+ const text = document.body.textContent ?? ''
89
+ expect(text).toContain('primary')
90
+ expect(text).not.toContain('elsewhere')
91
+ expect(text).toContain('This schedule changed while this was open')
92
+ const confirm = [...document.querySelectorAll('button')].filter((b) => b.textContent?.trim() === 'Back up now').at(-1)!
93
+ expect(confirm.disabled).toBe(true)
94
+ })
95
+
96
+ it('cannot start a backup that would fail', () => {
97
+ state.reading = reading({ name: 'nightly', state: 'cannotRun', attention: true })
98
+ render(<VeleroBackupNow schedule={nightly} />)
99
+ expect(buttonNamed('Back up now')!.disabled).toBe(true)
100
+ })
101
+
102
+ it('says the backup was created, with a way to open it', () => {
103
+ state.mutate.mockImplementation((_vars: unknown, opts: { onSuccess: (b: unknown) => void }) => opts.onSuccess({ namespace: 'velero', name: 'nightly-20261115210509' }))
104
+ const onNavigate = vi.fn()
105
+ render(<VeleroBackupNow schedule={nightly} onNavigate={onNavigate} />)
106
+ act(() => buttonNamed('Back up now')!.click())
107
+ const confirm = [...document.querySelectorAll('button')].filter((b) => b.textContent?.trim() === 'Back up now').at(-1)!
108
+ act(() => confirm.click())
109
+ expect(state.toast).toHaveBeenCalledWith('Backup nightly-20261115210509 created', undefined, expect.objectContaining({ label: 'Open' }))
110
+ state.toast.mock.calls[0][2].onClick()
111
+ expect(onNavigate).toHaveBeenCalledWith({ kind: 'Backup', group: 'velero.io', namespace: 'velero', name: 'nightly-20261115210509' })
112
+ })
113
+
114
+ // A stopped server would only queue it, so "now" would not be true.
115
+ it('is unavailable while the Velero server is stopped, whatever the schedule reads', () => {
116
+ state.reading = reading({ name: 'nightly', state: 'due' })
117
+ state.serverStopped = true
118
+ render(<VeleroBackupNow schedule={nightly} />)
119
+ expect(buttonNamed('Back up now')!.disabled).toBe(true)
120
+ })
121
+
122
+ it('says when resource or label filters narrow what it backs up', () => {
123
+ const filtered = { ...nightly, spec: { ...nightly.spec, template: { ...nightly.spec.template, excludedNamespaces: ['kube-system'], labelSelector: { matchLabels: { app: 'api' } } } } }
124
+ render(<VeleroBackupNow schedule={filtered} />)
125
+ act(() => buttonNamed('Back up now')!.click())
126
+ const dialog = document.body.textContent ?? ''
127
+ expect(dialog).toContain('payments, except kube-system')
128
+ expect(dialog).toContain('narrowed by resource or label filters')
129
+ })
130
+
131
+ it('is unavailable when Velero runs restore-only', () => {
132
+ state.backupsDisabled = true
133
+ render(<VeleroBackupNow schedule={nightly} />)
134
+ expect(buttonNamed('Back up now')!.disabled).toBe(true)
135
+ })
136
+
137
+ // Velero rejects a backup to a ReadOnly location; the attempt is still the user's to make.
138
+ it('warns, without refusing, when the schedule writes to a read-only location', () => {
139
+ state.reading = reading({ name: 'nightly', state: 'cannotRun', reason: 'locationReadOnly', attention: true, location: { name: 'primary', readOnly: true } })
140
+ render(<VeleroBackupNow schedule={nightly} />)
141
+ const button = buttonNamed('Back up now')!
142
+ expect(button.disabled).toBe(false)
143
+ act(() => button.click())
144
+ expect(document.body.textContent).toContain('Storage location primary is read-only, so Velero will reject this backup.')
145
+ })
146
+
147
+ it('is absent on a Radar without the action', () => {
148
+ state.support = 'unsupported'
149
+ render(<VeleroBackupNow schedule={nightly} />)
150
+ expect(buttonNamed('Back up now')).toBeUndefined()
151
+ })
152
+
153
+ // The server can stop while the confirmation is open.
154
+ it('refuses to confirm once the server has stopped', () => {
155
+ state.reading = reading({ name: 'nightly', state: 'onSchedule' })
156
+ const root = render(<VeleroBackupNow schedule={nightly} />)
157
+ act(() => buttonNamed('Back up now')!.click())
158
+ state.serverStopped = true
159
+ act(() => root.render(<VeleroBackupNow schedule={{ ...nightly }} />))
160
+ const confirm = [...document.querySelectorAll('button')].filter((b) => b.textContent?.trim() === 'Back up now').at(-1)!
161
+ expect(confirm.disabled).toBe(true)
162
+ expect(document.body.textContent).toContain('Start it first')
163
+ })
164
+ })
165
+