@skyhook-io/radar-app 1.20.0 → 1.20.3

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 (109) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +18 -11
  3. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  4. package/src/api/client.pauseDeployment.test.tsx +77 -0
  5. package/src/api/client.restartError.test.ts +14 -0
  6. package/src/api/client.revisionRefresh.test.tsx +44 -0
  7. package/src/api/client.rollbackError.test.ts +14 -0
  8. package/src/api/client.ts +287 -21
  9. package/src/api/helmInventory.test.tsx +108 -0
  10. package/src/api/networkAttachments.test.tsx +120 -0
  11. package/src/api/networkAttachments.ts +30 -0
  12. package/src/api/radarFeatures.test.ts +5 -0
  13. package/src/api/radarFeatures.ts +5 -0
  14. package/src/api/secretsStore.test.ts +33 -0
  15. package/src/api/secretsStore.ts +37 -0
  16. package/src/components/ConnectionErrorView.test.tsx +11 -0
  17. package/src/components/ConnectionErrorView.tsx +19 -0
  18. package/src/components/ContextSwitcher.tsx +9 -2
  19. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  20. package/src/components/applications/ApplicationsView.tsx +8 -11
  21. package/src/components/cost/CostView.tsx +27 -9
  22. package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
  23. package/src/components/curl/ServiceCurlButton.tsx +2 -2
  24. package/src/components/diagnose/InvestigationView.tsx +12 -3
  25. package/src/components/diagnose/investigationCase.test.tsx +41 -0
  26. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
  27. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  28. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +61 -16
  29. package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
  30. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
  31. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  32. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  33. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  34. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  35. package/src/components/dock/TerminalPreferences.tsx +73 -0
  36. package/src/components/gitops/GitOpsView.tsx +1 -9
  37. package/src/components/helm/HelmDrawerFrame.tsx +101 -0
  38. package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
  39. package/src/components/helm/HelmReleaseDrawer.tsx +47 -98
  40. package/src/components/helm/HelmView.tsx +215 -71
  41. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  42. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  43. package/src/components/helm/ObservedHelmNotice.tsx +146 -0
  44. package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
  45. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
  46. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
  47. package/src/components/helm/OwnedResources.test.tsx +86 -0
  48. package/src/components/helm/OwnedResources.tsx +69 -10
  49. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  50. package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
  51. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  52. package/src/components/home/ClusterHealthCard.tsx +49 -14
  53. package/src/components/home/HelmSummary.tsx +38 -19
  54. package/src/components/home/HelmSummary.unread.test.ts +16 -0
  55. package/src/components/home/HomeAgentBlock.tsx +7 -0
  56. package/src/components/home/MCPSetupDialog.test.tsx +38 -12
  57. package/src/components/home/MCPSetupDialog.tsx +5 -2
  58. package/src/components/home/mcpToolCatalog.ts +45 -5
  59. package/src/components/issues/uncheckedSources.test.ts +2 -0
  60. package/src/components/issues/uncheckedSources.ts +3 -0
  61. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  62. package/src/components/resource/RightsizingStrip.tsx +53 -4
  63. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  64. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  65. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  66. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  67. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  68. package/src/components/resources/pod-file-upload.ts +266 -0
  69. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  70. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  71. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  72. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  73. package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
  74. package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
  75. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
  76. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
  77. package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
  78. package/src/components/rightsizing/model.test.ts +11 -0
  79. package/src/components/rightsizing/model.ts +3 -1
  80. package/src/components/rightsizing/presentation.test.ts +46 -0
  81. package/src/components/rightsizing/presentation.ts +17 -2
  82. package/src/components/traffic/TrafficView.tsx +27 -27
  83. package/src/components/traffic/trafficFilters.test.ts +18 -1
  84. package/src/components/traffic/trafficFilters.ts +30 -1
  85. package/src/components/ui/Omnibar.tsx +4 -1
  86. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  87. package/src/components/ui/RadarOmnibar.tsx +7 -1
  88. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  89. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  90. package/src/components/ui/UpdateNotification.test.tsx +23 -1
  91. package/src/components/ui/UpdateNotification.tsx +26 -2
  92. package/src/components/ui/omnibar-match.test.ts +7 -0
  93. package/src/components/ui/omnibar-match.ts +1 -0
  94. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  95. package/src/components/ui/searchCoverageNote.ts +31 -7
  96. package/src/components/useContextSwitchFlow.tsx +9 -1
  97. package/src/components/whats-new/releaseNotes.ts +1 -1
  98. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  99. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  100. package/src/components/workload/WorkloadView.tsx +51 -11
  101. package/src/context/ConnectionContext.test.ts +1 -0
  102. package/src/context/ConnectionContext.tsx +2 -2
  103. package/src/contexts/CapabilitiesContext.tsx +2 -0
  104. package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
  105. package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
  106. package/src/integrations/resourceHosts.test.tsx +2 -2
  107. package/src/integrations/resourceHosts.tsx +9 -0
  108. package/src/utils/namespacePick.test.ts +87 -0
  109. package/src/utils/namespacePick.ts +88 -0
@@ -0,0 +1,228 @@
1
+ import { useEffect, useState, type ComponentType } from 'react'
2
+ import { useNavigate } from 'react-router-dom'
3
+ import { clsx } from 'clsx'
4
+ import { GitBranch, History, Link2, Package, RefreshCw, X } from 'lucide-react'
5
+ import { FactGrid, FactRow, FactValue, FetchResult, type Fact } from '@skyhook-io/k8s-ui'
6
+ import { isStableClientError, useObservedHelmRelease } from '../../api/client'
7
+ import { useRefreshAnimation } from '../../hooks/useRefreshAnimation'
8
+ import { getHelmStatusColor, SEVERITY_BADGE } from '../../utils/badge-colors'
9
+ import type { NavigateToResource } from '../../utils/navigation'
10
+ import type { FluxHelmRevision, ObservedHelmReleaseDetail, SelectedHelmRelease } from '../../types'
11
+ import { Tooltip } from '../ui/Tooltip'
12
+ import { formatDate } from './helm-utils'
13
+ import { ObservedHelmDrawerNote } from './ObservedHelmNotice'
14
+ import { OwnedResources } from './OwnedResources'
15
+
16
+ type TabId = 'overview' | 'history' | 'resources'
17
+
18
+ // Only what can hold data here: Helm's own tabs would all say the same thing,
19
+ // and the note above says it once. History is what Flux recorded, if anything.
20
+ const TABS: { id: TabId; label: string; icon: ComponentType<{ className?: string }> }[] = [
21
+ { id: 'overview', label: 'Overview', icon: Package },
22
+ { id: 'history', label: 'History', icon: History },
23
+ { id: 'resources', label: 'Resources', icon: Link2 },
24
+ ]
25
+
26
+ const UNREAD = 'Helm keeps this in its release Secret, which Radar can’t read here.'
27
+ const unknownFact = (source: string): Fact => ({ text: 'Unknown', tone: 'unknown', detail: source })
28
+ // found lists the values when objects disagree, as an interrupted upgrade
29
+ // leaves them; showing them is more use than "Unknown".
30
+ const stampedFact = (value: string | undefined, label: string, whenMissing: string, found?: string[]): Fact => {
31
+ if (value) return { text: value, tone: 'neutral', source: `From ${label}` }
32
+ if (found?.length) {
33
+ return { text: `Mixed: ${found.join(', ')}`, tone: 'neutral', source: `From ${label}`, detail: 'Its objects carry different values, as an interrupted upgrade can leave them.' }
34
+ }
35
+ return unknownFact(whenMissing)
36
+ }
37
+
38
+ interface ObservedHelmReleaseDrawerProps {
39
+ release: SelectedHelmRelease
40
+ onClose: () => void
41
+ onNavigateToResource?: NavigateToResource
42
+ }
43
+
44
+ /**
45
+ * A release as its deployed objects describe it, for someone who can't read
46
+ * Helm's storage. It issues no read of Helm's release routes, and what only
47
+ * those routes know stays visibly unknown.
48
+ */
49
+ export function ObservedHelmReleaseDrawer({ release, onClose, onNavigateToResource }: ObservedHelmReleaseDrawerProps) {
50
+ const navigate = useNavigate()
51
+ const [activeTab, setActiveTab] = useState<TabId>('overview')
52
+ const { data, isLoading, error, refetch: refetchRelease } = useObservedHelmRelease(release.namespace, release.name)
53
+ const [refetch, isRefreshAnimating] = useRefreshAnimation(refetchRelease)
54
+ useEffect(() => setActiveTab('overview'), [release.namespace, release.name])
55
+
56
+ const flux = data?.managedByFluxHelmRelease
57
+ const tabs = TABS.filter((tab) => tab.id !== 'history' || data?.fluxHistory?.length)
58
+ const shownTab = tabs.some((tab) => tab.id === activeTab) ? activeTab : 'overview'
59
+
60
+ return (
61
+ <>
62
+ <div className="border-b border-theme-border shrink-0">
63
+ <div className="flex items-center justify-between px-4 pt-3 pb-2">
64
+ <div className="flex items-center gap-2 flex-wrap">
65
+ <span className={clsx('badge', SEVERITY_BADGE.info)}>Helm Release</span>
66
+ <Tooltip content={UNREAD}>
67
+ <span className={clsx('badge', SEVERITY_BADGE.neutral)}>Status unknown</span>
68
+ </Tooltip>
69
+ </div>
70
+ <div className="flex items-center gap-1">
71
+ <Tooltip content="Refresh">
72
+ <button
73
+ onClick={refetch}
74
+ disabled={isRefreshAnimating}
75
+ className="p-1.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded disabled:opacity-50 disabled:pointer-events-none"
76
+ >
77
+ <RefreshCw className={clsx('w-4 h-4', isRefreshAnimating && 'animate-spin')} />
78
+ </button>
79
+ </Tooltip>
80
+ <Tooltip content="Close (Esc)">
81
+ <button onClick={onClose} className="p-1.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded">
82
+ <X className="w-4 h-4" />
83
+ </button>
84
+ </Tooltip>
85
+ </div>
86
+ </div>
87
+
88
+ <div className="px-4 pb-3">
89
+ <div className="flex items-center gap-2">
90
+ <Package className="w-5 h-5 text-purple-400" />
91
+ <h2 className="text-lg font-semibold text-theme-text-primary truncate">{release.name}</h2>
92
+ </div>
93
+ <p className="text-sm text-theme-text-tertiary">{release.namespace}</p>
94
+ {flux && (
95
+ <Tooltip content={`Installed by Flux helm-controller via HelmRelease ${flux}.`} wrapperClassName="mt-1">
96
+ <button
97
+ type="button"
98
+ onClick={() => {
99
+ const [ns, name] = flux.split('/')
100
+ navigate(`/gitops/detail/helmreleases/${encodeURIComponent(ns || '_')}/${encodeURIComponent(name)}`)
101
+ }}
102
+ className="inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[11px] text-amber-700 dark:text-amber-400 hover:bg-amber-500/20 transition-colors"
103
+ >
104
+ <GitBranch className="w-3 h-3" />
105
+ Managed by Flux · {flux}
106
+ </button>
107
+ </Tooltip>
108
+ )}
109
+ </div>
110
+
111
+ <div className="flex items-center gap-1 px-4 pb-2 overflow-x-auto">
112
+ {tabs.map((tab) => (
113
+ <button
114
+ key={tab.id}
115
+ onClick={() => setActiveTab(tab.id)}
116
+ className={clsx(
117
+ 'flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors whitespace-nowrap',
118
+ shownTab === tab.id
119
+ ? 'bg-theme-elevated text-theme-text-primary'
120
+ : 'text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated/50'
121
+ )}
122
+ >
123
+ <tab.icon className="w-3.5 h-3.5" />
124
+ {tab.label}
125
+ </button>
126
+ ))}
127
+ </div>
128
+ </div>
129
+
130
+ <div className="flex-1 overflow-y-auto">
131
+ <ObservedHelmDrawerNote coverage={data?.objectCoverage} refreshFailed={Boolean(data && error && !isStableClientError(error))} />
132
+ {!data || isStableClientError(error) ? (
133
+ <FetchResult loading={isLoading} error={error} notFoundMessage="No release found on the objects you can read" className="h-32" />
134
+ ) : shownTab === 'overview' ? (
135
+ <OverviewTab release={data} />
136
+ ) : shownTab === 'history' ? (
137
+ <FluxHistory release={data} />
138
+ ) : (
139
+ <OwnedResources resources={data.resources ?? []} onNavigate={onNavigateToResource} summaryLabel="with this release’s Helm metadata" />
140
+ )}
141
+ </div>
142
+ </>
143
+ )
144
+ }
145
+
146
+ function OverviewTab({ release }: { release: ObservedHelmReleaseDetail }) {
147
+ const health = release.resourceHealth
148
+ const lastRecord = release.fluxHistory?.[0]
149
+ const chartWhenMissing = release.otherCharts?.length
150
+ ? `Its objects name several charts, and none matches the release name: ${release.otherCharts.join(', ')}.`
151
+ : 'Its objects have no helm.sh/chart label.'
152
+ // When Flux recorded the release, these three values are Flux's, not labels.
153
+ const fact = (value: string | undefined, label: string, whenMissing: string, found?: string[]): Fact =>
154
+ lastRecord?.chartName ? (value ? { text: value, tone: 'neutral', source: 'Recorded by Flux' } : unknownFact('Flux didn’t record this.')) : stampedFact(value, label, whenMissing, found)
155
+ return (
156
+ <div className="p-4 space-y-4">
157
+ <div className="bg-theme-elevated/30 rounded-lg p-4">
158
+ <FactGrid>
159
+ <FactRow label="Chart"><FactValue fact={fact(release.chart, 'helm.sh/chart', chartWhenMissing)} /></FactRow>
160
+ <FactRow label="Chart version"><FactValue fact={fact(release.chartVersion, 'helm.sh/chart', 'No version could be read from its objects.', release.chartVersions)} /></FactRow>
161
+ <FactRow label="App version"><FactValue fact={fact(release.appVersion, 'app.kubernetes.io/version', 'No app version could be read from its objects.', release.appVersions)} /></FactRow>
162
+ {release.otherCharts && release.otherCharts.length > 0 && (
163
+ <FactRow label={release.chart ? 'Other charts' : 'Charts found'}>
164
+ <span className="text-theme-text-secondary">{release.otherCharts.join(', ')}</span>
165
+ </FactRow>
166
+ )}
167
+ <FactRow label="Objects">
168
+ <FactValue fact={{ text: `${release.resourceCount} you can read`, tone: 'neutral', detail: 'The release may have more. Secrets and kinds Radar isn’t watching aren’t counted.' }} />
169
+ </FactRow>
170
+ <FactRow label="Object health">
171
+ <FactValue fact={health && health !== 'unknown'
172
+ ? { text: release.healthSummary ? `${health}, ${release.healthSummary}` : health, tone: health === 'healthy' ? 'healthy' : health === 'degraded' ? 'degraded' : health === 'unhealthy' ? 'unhealthy' : 'unknown', detail: 'From the objects you can read, not from Helm.' }
173
+ : unknownFact('Radar can’t tell from the objects you can read.')} />
174
+ </FactRow>
175
+ <FactRow label="Status"><FactValue fact={unknownFact(UNREAD)} /></FactRow>
176
+ {lastRecord && (
177
+ <FactRow label="Flux’s last record">
178
+ <FactValue fact={{ text: `${lastRecord.status ?? 'No status'}, revision ${lastRecord.revision}`, tone: 'neutral', at: lastRecord.lastDeployed, detail: 'Recorded by Flux, which may not match Helm now.' }} />
179
+ </FactRow>
180
+ )}
181
+ <FactRow label="Revision"><FactValue fact={unknownFact(UNREAD)} /></FactRow>
182
+ <FactRow label="Last updated"><FactValue fact={unknownFact(UNREAD)} /></FactRow>
183
+ </FactGrid>
184
+ </div>
185
+ </div>
186
+ )
187
+ }
188
+
189
+ function FluxHistory({ release }: { release: ObservedHelmReleaseDetail }) {
190
+ const history = release.fluxHistory ?? []
191
+ return (
192
+ <div className="p-4 space-y-2">
193
+ <p className="text-sm text-theme-text-secondary">
194
+ As recorded by Flux in HelmRelease {release.managedByFluxHelmRelease}, not read from Helm.
195
+ </p>
196
+ <table className="w-full text-sm">
197
+ <thead>
198
+ <tr className="text-left text-theme-text-tertiary">
199
+ <th className="py-1.5 pr-3 font-normal">Revision</th>
200
+ <th className="py-1.5 pr-3 font-normal">Status</th>
201
+ <th className="py-1.5 pr-3 font-normal">Chart</th>
202
+ <th className="py-1.5 pr-3 font-normal">App version</th>
203
+ <th className="py-1.5 pr-3 font-normal">Last deployed</th>
204
+ <th className="py-1.5 font-normal">Release digest</th>
205
+ </tr>
206
+ </thead>
207
+ <tbody className="table-divide-subtle">
208
+ {history.map((entry) => <FluxHistoryRow key={entry.revision} entry={entry} />)}
209
+ </tbody>
210
+ </table>
211
+ </div>
212
+ )
213
+ }
214
+
215
+ function FluxHistoryRow({ entry }: { entry: FluxHelmRevision }) {
216
+ return (
217
+ <tr className="text-theme-text-secondary">
218
+ <td className="py-1.5 pr-3">{entry.revision}</td>
219
+ <td className="py-1.5 pr-3">{entry.status ? <span className={clsx('badge', getHelmStatusColor(entry.status))}>{entry.status}</span> : '—'}</td>
220
+ <td className="py-1.5 pr-3">{[entry.chartName, entry.chartVersion].filter(Boolean).join('-') || '—'}</td>
221
+ <td className="py-1.5 pr-3">{entry.appVersion || '—'}</td>
222
+ <td className="py-1.5 pr-3">{entry.lastDeployed ? formatDate(entry.lastDeployed) : '—'}</td>
223
+ <td className="py-1.5 font-mono text-xs">
224
+ {entry.digest ? <Tooltip content={entry.digest}><span>{entry.digest.replace('sha256:', '').slice(0, 12)}</span></Tooltip> : '—'}
225
+ </td>
226
+ </tr>
227
+ )
228
+ }
@@ -0,0 +1,86 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { afterEach, describe, expect, it, vi } from 'vitest'
5
+ import type { HelmOwnedResource } from '../../types'
6
+ import { OwnedResources } from './OwnedResources'
7
+
8
+ ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
9
+
10
+ let root: Root | undefined
11
+
12
+ afterEach(() => {
13
+ act(() => root?.unmount())
14
+ root = undefined
15
+ document.body.innerHTML = ''
16
+ })
17
+
18
+ function mount(resources: HelmOwnedResource[], onNavigate = vi.fn()) {
19
+ const container = document.createElement('div')
20
+ document.body.appendChild(container)
21
+ root = createRoot(container)
22
+ act(() => root!.render(<OwnedResources resources={resources} onNavigate={onNavigate} />))
23
+ return { container, onNavigate }
24
+ }
25
+
26
+ function row(container: HTMLElement, name: string): HTMLElement {
27
+ const label = Array.from(container.querySelectorAll('span')).find((el) => el.textContent === name)
28
+ if (!label?.parentElement) throw new Error(`no row for ${name}`)
29
+ return label.parentElement
30
+ }
31
+
32
+ const readable: HelmOwnedResource = { kind: 'ConfigMap', apiVersion: 'v1', name: 'settings', namespace: 'team-a', status: 'Active' }
33
+
34
+ describe('OwnedResources rows whose status the caller is not shown', () => {
35
+ it('marks a denied object and does not open it', () => {
36
+ const { container, onNavigate } = mount([
37
+ readable,
38
+ { kind: 'Deployment', apiVersion: 'apps/v1', name: 'worker', namespace: 'shared', statusUnread: 'user_namespace_not_visible' },
39
+ ])
40
+ expect(row(container, 'worker').parentElement?.textContent).toContain('No access')
41
+ act(() => row(container, 'worker').click())
42
+ expect(onNavigate).not.toHaveBeenCalled()
43
+ act(() => row(container, 'settings').click())
44
+ expect(onNavigate).toHaveBeenCalledTimes(1)
45
+ })
46
+
47
+ it('does not call an unanswered check a denial', () => {
48
+ const { container } = mount([
49
+ { kind: 'Deployment', apiVersion: 'apps/v1', name: 'worker', namespace: 'shared', statusUnread: 'user_permission_check_failed' },
50
+ ])
51
+ const text = row(container, 'worker').parentElement?.textContent ?? ''
52
+ expect(text).not.toContain('No access')
53
+ expect(text).toContain('Not checked')
54
+ expect(text).not.toContain('Unknown')
55
+ })
56
+
57
+ it('does not count a withheld object as healthy or failed', () => {
58
+ const { container } = mount([
59
+ readable,
60
+ { kind: 'Deployment', apiVersion: 'apps/v1', name: 'worker', namespace: 'shared', statusUnread: 'user_forbidden' },
61
+ ])
62
+ const summary = container.querySelector('.p-4 > div')?.textContent ?? ''
63
+ expect(summary).toContain('1 healthy')
64
+ expect(summary).not.toContain('failed')
65
+ })
66
+
67
+ it('counts withheld objects as not checked beside the healthy ones, and filters to them', () => {
68
+ const { container } = mount([
69
+ readable,
70
+ { kind: 'ConfigMap', apiVersion: 'v1', name: 'flags', namespace: 'team-a', status: 'Active' },
71
+ { kind: 'Deployment', apiVersion: 'apps/v1', name: 'worker', namespace: 'shared', statusUnread: 'user_namespace_not_visible' },
72
+ ])
73
+ const summary = container.querySelector('.p-4 > div')
74
+ expect(summary?.textContent).toContain('2 healthy')
75
+ const notChecked = Array.from(summary?.querySelectorAll('button') ?? []).find((b) => b.textContent === '1 not checked')
76
+ expect(notChecked).toBeDefined()
77
+ act(() => notChecked!.click())
78
+ expect(container.textContent).toContain('worker')
79
+ expect(container.textContent).not.toContain('settings')
80
+ })
81
+
82
+ it('shows no not-checked count when every object was read', () => {
83
+ const { container } = mount([readable])
84
+ expect(container.textContent).not.toContain('not checked')
85
+ })
86
+ })
@@ -13,11 +13,15 @@ import { useAvailablePorts } from '../../api/client'
13
13
  import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
14
14
  import { useNamespacedCapabilities, useIsLocalDeployment } from '../../contexts/CapabilitiesContext'
15
15
  import { pluralize, getExecContainerNames } from '@skyhook-io/k8s-ui'
16
+ import { readActionFor } from '@skyhook-io/k8s-ui/utils/read-actions'
16
17
  import { Tooltip } from '../ui/Tooltip'
18
+ import { notCheckedTooltip, type NotCheckedReason } from './NotCheckedBadge'
17
19
 
18
20
  interface OwnedResourcesProps {
19
21
  resources: HelmOwnedResource[]
20
22
  onNavigate?: NavigateToResource
23
+ /** Follows the count, saying what the list claims about these resources. */
24
+ summaryLabel?: string
21
25
  }
22
26
 
23
27
  function getIconForKind(kind: string) {
@@ -36,10 +40,11 @@ function groupByKind(resources: HelmOwnedResource[]): Map<string, HelmOwnedResou
36
40
  }
37
41
 
38
42
  // Health status types
39
- type HealthFilter = 'all' | 'healthy' | 'warning' | 'error'
43
+ type HealthFilter = 'all' | 'healthy' | 'warning' | 'error' | 'unread'
40
44
 
41
45
  // Determine health status of a resource
42
- function getResourceHealth(resource: HelmOwnedResource): 'healthy' | 'warning' | 'error' | 'unknown' {
46
+ function getResourceHealth(resource: HelmOwnedResource): 'healthy' | 'warning' | 'error' | 'unread' | 'unknown' {
47
+ if (resource.statusUnread) return 'unread'
43
48
  // An issue field always indicates a problem regardless of status
44
49
  if (resource.issue) return 'error'
45
50
  const status = resource.status
@@ -56,20 +61,27 @@ function computeHealthSummary(resources: HelmOwnedResource[]) {
56
61
  let healthy = 0
57
62
  let warning = 0
58
63
  let error = 0
64
+ let unread = 0
59
65
  let unknown = 0
66
+ let denied = 0
60
67
 
61
68
  for (const r of resources) {
62
69
  const health = getResourceHealth(r)
63
70
  if (health === 'healthy') healthy++
64
71
  else if (health === 'warning') warning++
65
72
  else if (health === 'error') error++
73
+ else if (health === 'unread') {
74
+ unread++
75
+ if (readActionFor(r.statusUnread) !== 'retry') denied++
76
+ }
66
77
  else unknown++
67
78
  }
68
79
 
69
- return { healthy, warning, error, unknown, total: resources.length }
80
+ const unreadReason: NotCheckedReason = denied === unread ? 'denied' : denied === 0 ? 'unconfirmed' : 'either'
81
+ return { healthy, warning, error, unread, unreadReason, unknown, total: resources.length }
70
82
  }
71
83
 
72
- export function OwnedResources({ resources, onNavigate }: OwnedResourcesProps) {
84
+ export function OwnedResources({ resources, onNavigate, summaryLabel = 'created by this release' }: OwnedResourcesProps) {
73
85
  const [healthFilter, setHealthFilter] = useState<HealthFilter>('all')
74
86
 
75
87
  if (!resources || resources.length === 0) {
@@ -97,10 +109,10 @@ export function OwnedResources({ resources, onNavigate }: OwnedResourcesProps) {
97
109
  return (
98
110
  <div className="p-4 space-y-4">
99
111
  {/* Health summary - clickable badges */}
100
- <div className="flex items-center justify-between">
112
+ <div className="flex flex-wrap items-center justify-between gap-2">
101
113
  <div className="text-sm text-theme-text-secondary">
102
114
  {healthFilter === 'all' ? (
103
- <>{pluralize(resources.length, 'resource')} created by this release</>
115
+ <>{pluralize(resources.length, 'resource')} {summaryLabel}</>
104
116
  ) : (
105
117
  <span className="flex items-center gap-2">
106
118
  Showing {filteredResources.length} of {resources.length} resources
@@ -115,7 +127,7 @@ export function OwnedResources({ resources, onNavigate }: OwnedResourcesProps) {
115
127
  </span>
116
128
  )}
117
129
  </div>
118
- <div className="flex items-center gap-2">
130
+ <div className="flex flex-wrap items-center gap-2">
119
131
  {health.healthy > 0 && (
120
132
  <button
121
133
  onClick={() => handleFilterClick('healthy')}
@@ -152,6 +164,20 @@ export function OwnedResources({ resources, onNavigate }: OwnedResourcesProps) {
152
164
  {health.error} failed
153
165
  </button>
154
166
  )}
167
+ {health.unread > 0 && (
168
+ <Tooltip content={<div className="max-w-xs">{notCheckedTooltip(health.unread, health.unreadReason)}</div>}>
169
+ <button
170
+ onClick={() => handleFilterClick('unread')}
171
+ className={clsx(
172
+ 'flex items-center gap-1 px-2 py-0.5 text-xs rounded transition-all',
173
+ SEVERITY_BADGE.neutral,
174
+ healthFilter === 'unread' && 'ring-2 ring-theme-border ring-offset-1 ring-offset-theme-surface'
175
+ )}
176
+ >
177
+ {health.unread} not checked
178
+ </button>
179
+ </Tooltip>
180
+ )}
155
181
  </div>
156
182
  </div>
157
183
 
@@ -199,8 +225,26 @@ interface ResourceItemProps {
199
225
  onNavigate?: NavigateToResource
200
226
  }
201
227
 
228
+ // The badge and tooltip for an object whose status the caller isn't shown.
229
+ // A check that went unanswered isn't a denial, so it doesn't say "No access".
230
+ function unreadStatusText(resource: HelmOwnedResource): { badge: string; tooltip: string } | null {
231
+ if (!resource.statusUnread) return null
232
+ if (readActionFor(resource.statusUnread) === 'retry') {
233
+ return {
234
+ badge: 'Not checked',
235
+ tooltip: `Radar couldn't check your access to this ${resource.kind}, so its status isn't shown. Refresh to try again.`,
236
+ }
237
+ }
238
+ return {
239
+ badge: 'No access',
240
+ tooltip: `You can't read this ${resource.kind}, so its status isn't shown and release health doesn't count it.`,
241
+ }
242
+ }
243
+
202
244
  function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
203
- const canNavigate = !!onNavigate
245
+ const unread = unreadStatusText(resource)
246
+ // Opening it, or its logs and ports, would only be refused.
247
+ const canNavigate = !!onNavigate && !unread
204
248
  const isPod = resource.kind.toLowerCase() === 'pod'
205
249
  const isService = resource.kind.toLowerCase() === 'service'
206
250
  const isRunning = resource.status?.toLowerCase() === 'running'
@@ -241,8 +285,16 @@ function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
241
285
  </div>
242
286
 
243
287
  <div className="flex items-center gap-2 shrink-0">
288
+ {unread && (
289
+ <Tooltip content={unread.tooltip}>
290
+ <span className={clsx('badge-sm', SEVERITY_BADGE.neutral)}>
291
+ {unread.badge}
292
+ </span>
293
+ </Tooltip>
294
+ )}
295
+
244
296
  {/* Quick actions for pods */}
245
- {isPod && (
297
+ {isPod && !unread && (
246
298
  <PodQuickActions
247
299
  namespace={resource.namespace}
248
300
  podName={resource.name}
@@ -251,7 +303,7 @@ function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
251
303
  )}
252
304
 
253
305
  {/* Quick actions for services */}
254
- {isService && (
306
+ {isService && !unread && (
255
307
  <ServiceQuickActions
256
308
  namespace={resource.namespace}
257
309
  serviceName={resource.name}
@@ -294,6 +346,13 @@ function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
294
346
  </Tooltip>
295
347
  )}
296
348
 
349
+ {/* Holds the details button's place so this row's badge lines up with the rest. */}
350
+ {onNavigate && !canNavigate && (
351
+ <span aria-hidden className="invisible p-1">
352
+ <ExternalLink className="w-3.5 h-3.5" />
353
+ </span>
354
+ )}
355
+
297
356
  {canNavigate && (
298
357
  <Tooltip content="View details">
299
358
  <button
@@ -0,0 +1,72 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { afterEach, expect, it, vi } from 'vitest'
5
+ import { ClusterHealthCard } from './ClusterHealthCard'
6
+ import type { DashboardResponse } from '../../api/client'
7
+
8
+ vi.mock('./HomeAgentBlock', () => ({ HomeAgentBlock: () => null }))
9
+
10
+ const counts: DashboardResponse['resourceCounts'] = {
11
+ pods: { total: 0, running: 0, pending: 0, failed: 0, succeeded: 0 },
12
+ deployments: { total: 0, available: 0, unavailable: 0 },
13
+ statefulSets: { total: 0, ready: 0, unready: 0 },
14
+ daemonSets: { total: 0, ready: 0, unready: 0 },
15
+ services: 0,
16
+ ingresses: 0,
17
+ nodes: { total: 0, ready: 0, notReady: 0, cordoned: 0 },
18
+ namespaces: 0,
19
+ jobs: { total: 0, active: 0, succeeded: 0, failed: 0 },
20
+ cronJobs: { total: 0, active: 0, suspended: 0 },
21
+ configMaps: 0,
22
+ secrets: 0,
23
+ pvcs: { total: 0, bound: 0, pending: 0, unbound: 0 },
24
+ }
25
+
26
+ let root: Root | undefined
27
+ let host: HTMLDivElement | undefined
28
+ afterEach(() => {
29
+ act(() => root?.unmount())
30
+ host?.remove()
31
+ })
32
+
33
+ function render(context: string) {
34
+ const cluster: DashboardResponse['cluster'] = { name: context, kubeconfigCluster: 'gitlab_com', platform: 'kind', version: '', connected: true }
35
+ act(() => {
36
+ root!.render(
37
+ <ClusterHealthCard
38
+ health={{ healthy: 0, warning: 0, error: 0, warningEvents: 0 }}
39
+ counts={counts}
40
+ cluster={cluster}
41
+ metrics={null}
42
+ metricsServerAvailable={false}
43
+ issueCount={0}
44
+ hasCriticalIssues={false}
45
+ nodeVersionSkew={null}
46
+ onNavigateToKind={() => {}}
47
+ onNavigateToView={() => {}}
48
+ />,
49
+ )
50
+ })
51
+ return host!.querySelector('h2')!
52
+ }
53
+
54
+ it('names the heading with the full context, which the middle cut hides from screen readers', () => {
55
+ host = document.createElement('div')
56
+ document.body.append(host)
57
+ root = createRoot(host)
58
+ const a = 'gitlab-org/infra/platform/k8s-agents:production-eu-west-agent'
59
+ expect(render(a).getAttribute('aria-label')).toBe(a)
60
+ const b = 'gitlab-org/infra/platform/k8s-agents:staging-us-east-agent'
61
+ expect(render(b).getAttribute('aria-label')).toBe(b)
62
+ })
63
+
64
+ it('names an OpenShift heading with the full context, so two projects on one server stay apart', () => {
65
+ host = document.createElement('div')
66
+ document.body.append(host)
67
+ root = createRoot(host)
68
+ const a = 'proj-a/api-prod-example-com:6443/alice'
69
+ const heading = render(a)
70
+ expect(heading.getAttribute('aria-label')).toBe(a)
71
+ expect(heading.textContent).not.toBe(a)
72
+ })
@@ -0,0 +1,76 @@
1
+ // @vitest-environment jsdom
2
+ import { describe, expect, it, vi } from "vitest";
3
+ import { renderToString } from "react-dom/server";
4
+ import type { DashboardResourceCounts } from "../../api/client";
5
+ import { ClusterHealthCard } from "./ClusterHealthCard";
6
+
7
+ // The MCP block needs the Diagnose provider and is unrelated to the counts.
8
+ vi.mock("./HomeAgentBlock", () => ({ HomeAgentBlock: () => null }));
9
+
10
+ function counts(overrides: Partial<DashboardResourceCounts>): DashboardResourceCounts {
11
+ return {
12
+ pods: { total: 0, running: 0, pending: 0, failed: 0, succeeded: 0 },
13
+ deployments: { total: 0, available: 0, unavailable: 0 },
14
+ statefulSets: { total: 0, ready: 0, unready: 0 },
15
+ daemonSets: { total: 0, ready: 0, unready: 0 },
16
+ services: 0,
17
+ ingresses: 0,
18
+ nodes: { total: 0, ready: 0, notReady: 0, cordoned: 0 },
19
+ namespaces: 0,
20
+ jobs: { total: 0, active: 0, succeeded: 0, failed: 0 },
21
+ cronJobs: { total: 0, active: 0, suspended: 0 },
22
+ configMaps: 0,
23
+ secrets: 0,
24
+ pvcs: { total: 0, bound: 0, pending: 0, unbound: 0 },
25
+ ...overrides,
26
+ };
27
+ }
28
+
29
+ function render(c: DashboardResourceCounts): string {
30
+ return renderToString(
31
+ <ClusterHealthCard
32
+ health={{ healthy: 0, warning: 0, error: 0, warningEvents: 0 }}
33
+ counts={c}
34
+ cluster={{ name: "test", platform: "", version: "", connected: true }}
35
+ metrics={null}
36
+ metricsServerAvailable={false}
37
+ issueCount={0}
38
+ hasCriticalIssues={false}
39
+ nodeVersionSkew={null}
40
+ onNavigateToKind={() => {}}
41
+ onNavigateToView={() => {}}
42
+ />,
43
+ );
44
+ }
45
+
46
+ describe("ClusterHealthCard restricted counts", () => {
47
+ it("shows the restricted Nodes ring instead of a zero ring", () => {
48
+ const html = render(counts({ restricted: ["nodes"] }));
49
+ expect(html).toMatch(/Nodes<\/span><span[^>]*>Restricted/);
50
+ expect(html).not.toContain("0 ready");
51
+ });
52
+
53
+ it("blames Node access, not metrics-server, for missing CPU and memory", () => {
54
+ expect(render(counts({ restricted: ["nodes"] }))).toContain("CPU and memory need permission to list Nodes");
55
+ expect(render(counts({ restricted: ["nodes"] }))).not.toContain("metrics-server");
56
+ expect(render(counts({}))).toContain("metrics-server");
57
+ });
58
+
59
+ it("marks a namespace count Radar could not list as a lower bound", () => {
60
+ const html = render(counts({ namespaces: 15, restricted: ["namespaces"] }));
61
+ expect(html).toContain("≥");
62
+ expect(html).toMatch(/>15<\/span> (<!-- -->)?namespaces/);
63
+ });
64
+
65
+ it("says restricted rather than zero when no namespace is known", () => {
66
+ const html = render(counts({ restricted: ["namespaces"] }));
67
+ expect(html).toContain("Namespaces restricted");
68
+ expect(html).not.toMatch(/>0<\/span> (<!-- -->)?namespaces/);
69
+ });
70
+
71
+ it("keeps an exact namespace count unmarked", () => {
72
+ const html = render(counts({ namespaces: 111 }));
73
+ expect(html).toMatch(/>111<\/span> namespaces/);
74
+ expect(html).not.toContain("≥");
75
+ });
76
+ });