@skyhook-io/radar-app 1.20.1 → 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 (81) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +12 -7
  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 +218 -11
  9. package/src/api/networkAttachments.test.tsx +120 -0
  10. package/src/api/networkAttachments.ts +30 -0
  11. package/src/api/radarFeatures.test.ts +5 -0
  12. package/src/api/radarFeatures.ts +3 -0
  13. package/src/api/secretsStore.test.ts +33 -0
  14. package/src/api/secretsStore.ts +37 -0
  15. package/src/components/ConnectionErrorView.test.tsx +11 -0
  16. package/src/components/ConnectionErrorView.tsx +19 -0
  17. package/src/components/ContextSwitcher.tsx +9 -2
  18. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  19. package/src/components/applications/ApplicationsView.tsx +8 -11
  20. package/src/components/cost/CostView.tsx +27 -9
  21. package/src/components/diagnose/InvestigationView.tsx +12 -3
  22. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  23. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
  24. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  25. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  26. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  27. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  28. package/src/components/dock/TerminalPreferences.tsx +73 -0
  29. package/src/components/gitops/GitOpsView.tsx +1 -9
  30. package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
  31. package/src/components/helm/HelmView.tsx +5 -3
  32. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  33. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  34. package/src/components/helm/OwnedResources.test.tsx +86 -0
  35. package/src/components/helm/OwnedResources.tsx +65 -8
  36. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  37. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  38. package/src/components/home/ClusterHealthCard.tsx +22 -10
  39. package/src/components/home/HelmSummary.tsx +15 -15
  40. package/src/components/home/mcpToolCatalog.ts +2 -2
  41. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  42. package/src/components/resource/RightsizingStrip.tsx +53 -4
  43. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  44. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  45. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  46. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  47. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  48. package/src/components/resources/pod-file-upload.ts +266 -0
  49. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  50. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  51. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  52. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  53. package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
  54. package/src/components/rightsizing/model.test.ts +11 -0
  55. package/src/components/rightsizing/model.ts +3 -1
  56. package/src/components/rightsizing/presentation.test.ts +46 -0
  57. package/src/components/rightsizing/presentation.ts +17 -2
  58. package/src/components/traffic/TrafficView.tsx +27 -27
  59. package/src/components/traffic/trafficFilters.test.ts +18 -1
  60. package/src/components/traffic/trafficFilters.ts +30 -1
  61. package/src/components/ui/Omnibar.tsx +4 -1
  62. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  63. package/src/components/ui/RadarOmnibar.tsx +7 -1
  64. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  65. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  66. package/src/components/ui/UpdateNotification.test.tsx +23 -1
  67. package/src/components/ui/UpdateNotification.tsx +26 -2
  68. package/src/components/ui/omnibar-match.test.ts +7 -0
  69. package/src/components/ui/omnibar-match.ts +1 -0
  70. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  71. package/src/components/ui/searchCoverageNote.ts +31 -7
  72. package/src/components/useContextSwitchFlow.tsx +9 -1
  73. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  74. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  75. package/src/components/workload/WorkloadView.tsx +51 -11
  76. package/src/context/ConnectionContext.test.ts +1 -0
  77. package/src/context/ConnectionContext.tsx +2 -2
  78. package/src/integrations/resourceHosts.test.tsx +2 -2
  79. package/src/integrations/resourceHosts.tsx +4 -0
  80. package/src/utils/namespacePick.test.ts +87 -0
  81. package/src/utils/namespacePick.ts +88 -0
@@ -0,0 +1,68 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { expect, it, vi } from 'vitest'
5
+ import { useTerminalCopyOnSelect } from '../../../../packages/k8s-ui/src/components/dock/terminalPreferences'
6
+ import { TerminalPreferences } from './TerminalPreferences'
7
+
8
+ const { refetch } = vi.hoisted(() => ({ refetch: vi.fn() }))
9
+ vi.mock('../../api/client', () => ({ useAuthMe: () => ({ refetch }) }))
10
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
11
+
12
+ interface Result {
13
+ data?: { authEnabled: boolean; username?: string }
14
+ isSuccess: boolean
15
+ isError: boolean
16
+ fetchStatus: 'idle'
17
+ dataUpdatedAt: number
18
+ }
19
+
20
+ it('blocks an existing terminal immediately on focus or visibility changes until the fresh account scope is applied', async () => {
21
+ const responses: Array<(value: Result) => void> = []
22
+ refetch.mockImplementation(() => new Promise<Result>(resolve => responses.push(resolve)))
23
+ const root = createRoot(document.createElement('div'))
24
+ let preference: ReturnType<typeof useTerminalCopyOnSelect> | undefined
25
+ function Terminal() { preference = useTerminalCopyOnSelect(); return null }
26
+ localStorage.setItem('radar:terminal:copy-on-select:account:owned-a', 'true')
27
+ try {
28
+ await act(async () => root.render(<TerminalPreferences><Terminal /></TerminalPreferences>))
29
+ await act(async () => responses.shift()?.({ data: { authEnabled: true, username: 'owned-a' }, isSuccess: true, isError: false, fetchStatus: 'idle', dataUpdatedAt: Date.now() }))
30
+ const connectedGetter = preference?.getState
31
+ expect(connectedGetter?.()).toBe('on')
32
+ await act(async () => {
33
+ window.dispatchEvent(new Event('focus'))
34
+ expect(connectedGetter?.()).toBe('pending')
35
+ preference?.setEnabled(false)
36
+ expect(localStorage.getItem('radar:terminal:copy-on-select:account:owned-a')).toBe('true')
37
+ })
38
+ expect(preference?.available).toBe(false)
39
+ await act(async () => window.dispatchEvent(new Event('blur')))
40
+ await act(async () => responses.shift()?.({ data: { authEnabled: true, username: 'owned-a' }, isSuccess: true, isError: false, fetchStatus: 'idle', dataUpdatedAt: Date.now() }))
41
+ expect(connectedGetter?.()).toBe('pending')
42
+ expect(preference?.available).toBe(false)
43
+ await act(async () => window.dispatchEvent(new Event('focus')))
44
+ await act(async () => responses.shift()?.({ data: { authEnabled: true, username: 'owned-b' }, isSuccess: true, isError: false, fetchStatus: 'idle', dataUpdatedAt: Date.now() }))
45
+ expect(preference?.available).toBe(true)
46
+ expect(connectedGetter?.()).toBe('off')
47
+ await act(async () => preference?.setEnabled(true))
48
+ expect(connectedGetter?.()).toBe('on')
49
+ Object.defineProperty(document, 'visibilityState', { configurable: true, value: 'hidden' })
50
+ await act(async () => {
51
+ document.dispatchEvent(new Event('visibilitychange'))
52
+ expect(connectedGetter?.()).toBe('pending')
53
+ })
54
+ Object.defineProperty(document, 'visibilityState', { configurable: true, value: 'visible' })
55
+ await act(async () => document.dispatchEvent(new Event('visibilitychange')))
56
+ expect(connectedGetter?.()).toBe('pending')
57
+ await act(async () => responses.shift()?.({ isSuccess: false, isError: true, fetchStatus: 'idle', dataUpdatedAt: 0 }))
58
+ expect(preference?.available).toBe(false)
59
+ expect(connectedGetter?.()).toBe('pending')
60
+ expect(preference?.unavailableReason).toContain('Could not load account information')
61
+ expect(preference?.unavailableReason).toContain('Switch to another tab or window and back to retry')
62
+ } finally {
63
+ await act(async () => root.unmount())
64
+ refetch.mockReset()
65
+ localStorage.clear()
66
+ Reflect.deleteProperty(document, 'visibilityState')
67
+ }
68
+ })
@@ -0,0 +1,73 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
2
+ import { TerminalPreferencesProvider } from '@skyhook-io/k8s-ui'
3
+ import { useAuthMe } from '../../api/client'
4
+
5
+ interface Identity {
6
+ scope?: string
7
+ checking: boolean
8
+ failed?: boolean
9
+ }
10
+
11
+ export function TerminalPreferences({ children }: { children: ReactNode }) {
12
+ const { refetch } = useAuthMe()
13
+ const [identity, setIdentity] = useState<Identity>({ checking: true })
14
+ const current = useRef(false)
15
+ const isScopeCurrent = useCallback(() => current.current, [])
16
+
17
+ useLayoutEffect(() => {
18
+ current.current = !identity.checking && !identity.failed && identity.scope !== undefined
19
+ }, [identity])
20
+
21
+ useEffect(() => {
22
+ let generation = 0
23
+ let disposed = false
24
+ const invalidate = () => {
25
+ current.current = false
26
+ generation++
27
+ setIdentity(previous => ({ ...previous, checking: true, failed: false }))
28
+ }
29
+ const verify = async () => {
30
+ invalidate()
31
+ const request = generation
32
+ while (!disposed && generation === request) {
33
+ const startedAt = Date.now()
34
+ const result = await refetch()
35
+ if (disposed || generation !== request) return
36
+ if (result.isError && result.fetchStatus === 'idle') {
37
+ setIdentity(previous => ({ ...previous, checking: false, failed: true }))
38
+ return
39
+ }
40
+ if (!result.isSuccess || result.fetchStatus !== 'idle' || result.dataUpdatedAt < startedAt) continue
41
+ const auth = result.data
42
+ const scope = auth.authEnabled === false
43
+ ? 'standalone'
44
+ : auth.username ? `account:${auth.username}` : undefined
45
+ setIdentity({ scope, checking: false })
46
+ return
47
+ }
48
+ }
49
+ const onVisibility = () => {
50
+ if (document.visibilityState === 'visible') void verify()
51
+ else invalidate()
52
+ }
53
+ const onFocus = () => { void verify() }
54
+ window.addEventListener('blur', invalidate)
55
+ window.addEventListener('focus', onFocus)
56
+ document.addEventListener('visibilitychange', onVisibility)
57
+ void verify()
58
+ return () => {
59
+ disposed = true
60
+ generation++
61
+ current.current = false
62
+ window.removeEventListener('blur', invalidate)
63
+ window.removeEventListener('focus', onFocus)
64
+ document.removeEventListener('visibilitychange', onVisibility)
65
+ }
66
+ }, [refetch])
67
+
68
+ return <TerminalPreferencesProvider scope={identity.scope} scopePending={identity.checking || identity.failed} isScopeCurrent={isScopeCurrent} unavailableReason={identity.checking
69
+ ? 'Waiting for account information'
70
+ : identity.failed ? 'Could not load account information. Switch to another tab or window and back to retry.' : undefined}>
71
+ {children}
72
+ </TerminalPreferencesProvider>
73
+ }
@@ -1112,7 +1112,7 @@ function normalizeDetailResource(kind: string, group: string, tool: 'argo' | 'fl
1112
1112
  destination: 'in-cluster',
1113
1113
  destinationNamespace: resource.spec?.targetNamespace ?? resource.metadata?.namespace ?? '',
1114
1114
  createdAt: resource.metadata?.creationTimestamp ?? '',
1115
- lastSync: newestConditionTime(resource),
1115
+ lastSync: '',
1116
1116
  autoSync: !resource.spec?.suspend,
1117
1117
  terminating: isTerminating(resource),
1118
1118
  terminationStartedAt: terminationStartedAt(resource),
@@ -1167,14 +1167,6 @@ function terminationStartedAt(resource: any): string | undefined {
1167
1167
  return resource?.metadata?.deletionTimestamp || undefined
1168
1168
  }
1169
1169
 
1170
- function newestConditionTime(resource: any): string {
1171
- const times = (resource.status?.conditions ?? [])
1172
- .map((condition: any) => condition.lastTransitionTime)
1173
- .filter(Boolean)
1174
- .sort()
1175
- return times[times.length - 1] ?? ''
1176
- }
1177
-
1178
1170
 
1179
1171
  // Inline counts for the topology toolbar — answers "how many resources, how
1180
1172
  // many of them are healthy / drifted" at a glance, without making the user
@@ -591,11 +591,12 @@ function FullHelmRelease({ release, onClose, onNavigateToResource }: Pick<HelmRe
591
591
  upgrade check failed
592
592
  </span>
593
593
  </Tooltip>
594
- ) : upgradeInfo?.updateAvailable && releaseDetail?.managedByFluxHelmRelease ? (
594
+ ) : upgradeInfo?.updateAvailable && (releaseDetail?.managedByFlux || releaseDetail?.managedByFluxHelmRelease) ? (
595
595
  // Route-only for GitOps-managed releases: a direct `helm upgrade`
596
- // would be reverted at the next reconcile, so surface the available
597
- // version as info and point at GitOps rather than offer the upgrade.
598
- <Tooltip content={`${upgradeInfo.latestVersion} available — managed by Flux, upgrade via the GitOps view (a direct upgrade would be reverted at the next reconcile).`}>
596
+ // may be reconciled back, so surface the available version as info.
597
+ <Tooltip content={releaseDetail?.managedByFluxHelmRelease
598
+ ? `${upgradeInfo.latestVersion} available - managed by Flux. Upgrade its HelmRelease from the GitOps view; direct Helm changes may be reconciled back.`
599
+ : `${upgradeInfo.latestVersion} available - managed by Flux. Ask the HelmRelease owner to upgrade it; Radar cannot show you the owning HelmRelease.`}>
599
600
  <span className={clsx('badge', SEVERITY_BADGE.warning, 'opacity-90')}>
600
601
  <ArrowUpCircle className="w-3 h-3" />
601
602
  {upgradeInfo.latestVersion}
@@ -622,10 +623,11 @@ function FullHelmRelease({ release, onClose, onNavigateToResource }: Pick<HelmRe
622
623
  </span>
623
624
  </Tooltip>
624
625
  ) : upgradeInfo?.error ? (
625
- releaseDetail?.managedByFluxHelmRelease ? (
626
- // Managed by Flux — the "Managed by Flux" badge routes to GitOps,
627
- // where the chart source lives. Don't push a Helm source here.
628
- <Tooltip content="Chart source is managed by Flux — track upgrades from the GitOps view.">
626
+ (releaseDetail?.managedByFlux || releaseDetail?.managedByFluxHelmRelease) ? (
627
+ // Keep source changes with Flux even when its controller link is hidden.
628
+ <Tooltip content={releaseDetail?.managedByFluxHelmRelease
629
+ ? "Chart source is managed by Flux. Track upgrades from its HelmRelease in the GitOps view."
630
+ : "Chart source is managed by Flux. Ask the HelmRelease owner to manage upgrades; Radar cannot show you the owning HelmRelease."}>
629
631
  <span className="badge bg-theme-hover/50 text-theme-text-secondary">
630
632
  source via GitOps
631
633
  </span>
@@ -661,7 +663,7 @@ function FullHelmRelease({ release, onClose, onNavigateToResource }: Pick<HelmRe
661
663
  ) : null}
662
664
  </div>
663
665
  <div className="flex items-center gap-1">
664
- {sourceFeature.support === 'supported' && !releaseDetail?.managedByFluxHelmRelease && <Tooltip content="Choose chart source">
666
+ {sourceFeature.support === 'supported' && !releaseDetail?.managedByFlux && !releaseDetail?.managedByFluxHelmRelease && <Tooltip content="Choose chart source">
665
667
  <button type="button" aria-label="Choose chart source" disabled={!canHelmWrite} onClick={() => setShowTrackSource(true)} className="p-1.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded disabled:opacity-50"><Link2 className="w-4 h-4" /></button>
666
668
  </Tooltip>}
667
669
  <Tooltip content="Refresh">
@@ -710,8 +712,15 @@ function FullHelmRelease({ release, onClose, onNavigateToResource }: Pick<HelmRe
710
712
  </Tooltip>
711
713
  </div>
712
714
  <p className="text-sm text-theme-text-tertiary">{release.namespace}</p>
715
+ {releaseDetail?.managedByFlux && !releaseDetail.managedByFluxHelmRelease && (
716
+ <Tooltip content="The owning Flux HelmRelease's namespace isn't available in this view, or Radar couldn't check your access. Manage this release through Flux; direct Helm changes may be reconciled back." wrapperClassName="mt-1">
717
+ <span className="inline-flex items-center gap-1 mt-1 text-xs text-theme-text-secondary">
718
+ <GitBranch className="w-3 h-3" />Managed by Flux
719
+ </span>
720
+ </Tooltip>
721
+ )}
713
722
  {releaseDetail?.managedByFluxHelmRelease && (
714
- <Tooltip content={`Installed by Flux helm-controller via HelmRelease ${releaseDetail.managedByFluxHelmRelease}. Changes here would be reverted at the next reconcile.`} wrapperClassName="mt-1">
723
+ <Tooltip content={`Installed by Flux helm-controller via HelmRelease ${releaseDetail.managedByFluxHelmRelease}. Direct Helm changes may be reconciled back.`} wrapperClassName="mt-1">
715
724
  <button
716
725
  type="button"
717
726
  onClick={() => {
@@ -757,6 +766,7 @@ function FullHelmRelease({ release, onClose, onNavigateToResource }: Pick<HelmRe
757
766
  operation={releaseDetail.lastOperation}
758
767
  operationInsight={releaseDetail.operationInsight}
759
768
  releaseNamespace={releaseDetail.namespace}
769
+ managedByFlux={releaseDetail.managedByFlux}
760
770
  managedByFluxHelmRelease={releaseDetail.managedByFluxHelmRelease}
761
771
  hookDiagnostics={releaseDetail.hookDiagnostics}
762
772
  onCompare={handleCompareRevisions}
@@ -1129,6 +1139,7 @@ function HelmOperationBanner({
1129
1139
  operation,
1130
1140
  operationInsight,
1131
1141
  releaseNamespace,
1142
+ managedByFlux,
1132
1143
  managedByFluxHelmRelease,
1133
1144
  hookDiagnostics,
1134
1145
  onCompare,
@@ -1137,6 +1148,7 @@ function HelmOperationBanner({
1137
1148
  operation?: HelmOperation
1138
1149
  operationInsight?: HelmOperationInsight
1139
1150
  releaseNamespace: string
1151
+ managedByFlux?: boolean
1140
1152
  managedByFluxHelmRelease?: string
1141
1153
  hookDiagnostics?: HookDiagnostic[]
1142
1154
  onCompare?: (rev1: number, rev2: number) => void
@@ -1213,9 +1225,9 @@ function HelmOperationBanner({
1213
1225
  onNavigateToResource={onNavigateToResource}
1214
1226
  />
1215
1227
  {primaryHookDiagnostic && <HookSignal diagnostic={primaryHookDiagnostic} />}
1216
- {managedByFluxHelmRelease && (
1228
+ {(managedByFlux || managedByFluxHelmRelease) && (
1217
1229
  <p className="mt-1 text-xs text-theme-text-tertiary">
1218
- This release is managed by Flux HelmRelease {managedByFluxHelmRelease}; direct Helm changes may be reconciled back.
1230
+ Managed by Flux{managedByFluxHelmRelease ? ` HelmRelease ${managedByFluxHelmRelease}` : ''}. Direct Helm changes may be reconciled back.
1219
1231
  </p>
1220
1232
  )}
1221
1233
  </div>
@@ -12,6 +12,7 @@ import { Tooltip } from '../ui/Tooltip'
12
12
  import { ChartBrowser } from './ChartBrowser'
13
13
  import { InstallWizard } from './InstallWizard'
14
14
  import { ObservedHelmNotice } from './ObservedHelmNotice'
15
+ import { NotCheckedBadge } from './NotCheckedBadge'
15
16
 
16
17
  type ViewTab = 'releases' | 'charts'
17
18
 
@@ -665,9 +666,9 @@ const ObservedReleaseRow = forwardRef<HTMLTableRowElement, ObservedReleaseRowPro
665
666
  )
666
667
  })
667
668
 
668
- function FluxBadge({ release }: { release: string }) {
669
+ function FluxBadge({ release }: { release?: string }) {
669
670
  return (
670
- <Tooltip content={`Installed by Flux helm-controller via HelmRelease ${release}. Changes here will be reverted at the next reconcile — manage via the GitOps tab.`}>
671
+ <Tooltip content={release ? `Installed by Flux helm-controller via HelmRelease ${release}. Manage its source in GitOps.` : "The owning Flux HelmRelease's namespace isn't available in this view, or Radar couldn't check your access. Manage this release through Flux; direct Helm changes may be reconciled back."}>
671
672
  <span className="badge-sm shrink-0 border border-theme-border bg-theme-elevated text-theme-text-secondary">
672
673
  <GitBranch className="w-3 h-3" />
673
674
  Flux
@@ -699,8 +700,9 @@ const ReleaseRow = forwardRef<HTMLTableRowElement, ReleaseRowProps>(
699
700
  <Package className="w-4 h-4 text-theme-text-tertiary shrink-0" />
700
701
  <span className="min-w-0 truncate text-sm font-medium text-theme-text-primary phone:max-w-[calc(100%-1.5rem)] phone:shrink-0">{release.name}</span>
701
702
  <ReleaseHealthBadge release={release} />
703
+ <NotCheckedBadge count={release.statusUnreadCount} />
702
704
  {listOperation && <HelmOperationChip operation={listOperation} />}
703
- {release.managedByFluxHelmRelease && <FluxBadge release={release.managedByFluxHelmRelease} />}
705
+ {(release.managedByFlux || release.managedByFluxHelmRelease) && <FluxBadge release={release.managedByFluxHelmRelease} />}
704
706
  {upgradeInfo?.updateAvailable && (
705
707
  <Tooltip content={`Upgrade available: ${release.chartVersion} → ${upgradeInfo.latestVersion}`}>
706
708
  <span className={clsx('badge-sm shrink-0', SEVERITY_BADGE.warning)}>
@@ -0,0 +1,62 @@
1
+ import { describe, expect, it, vi } from 'vitest'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+ import { NotCheckedBadge, notCheckedTooltip } from './NotCheckedBadge'
4
+
5
+ vi.mock('../../api/client', () => ({
6
+ useRadarFeature: () => ({ support: 'supported' }),
7
+ }))
8
+
9
+ const { HelmSummary } = await import('../home/HelmSummary')
10
+
11
+ describe('the "not checked" mark on a release', () => {
12
+ it('shows the count when objects were left out', () => {
13
+ expect(renderToStaticMarkup(<NotCheckedBadge count={2} />)).toContain('2 objects not checked')
14
+ })
15
+
16
+ it('is absent when everything was checked', () => {
17
+ expect(renderToStaticMarkup(<NotCheckedBadge count={0} />)).toBe('')
18
+ expect(renderToStaticMarkup(<NotCheckedBadge />)).toBe('')
19
+ })
20
+
21
+ it('does not call an unanswered check a denial', () => {
22
+ expect(notCheckedTooltip(1, 'unconfirmed')).not.toMatch(/can’t read/)
23
+ expect(notCheckedTooltip(1, 'denied')).toMatch(/can’t read/)
24
+ expect(notCheckedTooltip(2, 'either')).toMatch(/can’t read them, or Radar couldn’t confirm/)
25
+ })
26
+
27
+ it('separates unchecked object status from release health', () => {
28
+ const reasons: Parameters<typeof notCheckedTooltip>[1][] = ['denied', 'either']
29
+ for (const reason of reasons) {
30
+ expect(notCheckedTooltip(2, reason)).toContain('Release health uses workload and Pod status.')
31
+ expect(notCheckedTooltip(2, reason)).toContain('This count can include other objects.')
32
+ expect(notCheckedTooltip(2, reason)).not.toContain('Health covers only')
33
+ }
34
+ })
35
+
36
+ it('explains that a release badge counts only health-relevant objects', () => {
37
+ expect(notCheckedTooltip(1, 'either', 'health')).toContain('workloads or Pods')
38
+ expect(notCheckedTooltip(1, 'either', 'health')).not.toContain('can include other objects')
39
+ })
40
+ })
41
+
42
+ describe('the Home Helm card', () => {
43
+ const row = { namespace: 'team-a', chart: 'platform-app', chartVersion: '0.1.0', status: 'deployed' }
44
+
45
+ it('marks only the release whose health left objects out', () => {
46
+ const html = renderToStaticMarkup(
47
+ <HelmSummary
48
+ onNavigate={() => {}}
49
+ data={{
50
+ total: 2,
51
+ releases: [
52
+ { ...row, name: 'payments', resourceHealth: 'unknown', statusUnreadCount: 1 },
53
+ { ...row, name: 'billing', resourceHealth: 'healthy' },
54
+ ],
55
+ }}
56
+ />,
57
+ )
58
+ expect(html.match(/not checked/g)).toHaveLength(1)
59
+ expect(html.indexOf('1 object not checked')).toBeGreaterThan(html.indexOf('payments'))
60
+ expect(html.indexOf('1 object not checked')).toBeLessThan(html.indexOf('billing'))
61
+ })
62
+ })
@@ -0,0 +1,39 @@
1
+ import { clsx } from 'clsx'
2
+ import { SEVERITY_BADGE } from '../../utils/badge-colors'
3
+ import { Tooltip } from '../ui/Tooltip'
4
+
5
+ /**
6
+ * Why some of a release's objects weren't checked. "denied": the caller can't
7
+ * read them. "unconfirmed": the access check went unanswered. "either": both,
8
+ * or not known which (a count alone doesn't say).
9
+ */
10
+ export type NotCheckedReason = 'denied' | 'unconfirmed' | 'either'
11
+
12
+ export function notCheckedTooltip(count: number, reason: NotCheckedReason = 'either', scope: 'objects' | 'health' = 'objects'): string {
13
+ const one = count === 1
14
+ const objects = `${count} of this release’s ${scope === 'health' ? 'workloads or Pods' : 'objects'}`
15
+ const coverage = scope === 'health'
16
+ ? 'Release health covers only the workloads and Pods that were checked.'
17
+ : 'Release health uses workload and Pod status. This count can include other objects.'
18
+ switch (reason) {
19
+ case 'denied':
20
+ return `You can’t read ${objects}, so ${one ? 'it wasn’t' : 'they weren’t'} checked. ${coverage}`
21
+ case 'unconfirmed':
22
+ return `Radar couldn’t confirm your access to ${objects}, so ${one ? 'it wasn’t' : 'they weren’t'} checked. Refresh to try again.`
23
+ default:
24
+ return `${objects.charAt(0).toUpperCase()}${objects.slice(1)} ${one ? 'wasn’t' : 'weren’t'} checked: you can’t read ${one ? 'it' : 'them'}, or Radar couldn’t confirm your access. ${coverage}`
25
+ }
26
+ }
27
+
28
+ /** Grey "N not checked" mark for a release whose health leaves objects out. */
29
+ export function NotCheckedBadge({ count }: { count?: number }) {
30
+ if (!count || count <= 0) return null
31
+ return (
32
+ <Tooltip content={<div className="max-w-xs">{notCheckedTooltip(count, 'either', 'health')}</div>}>
33
+ <span className={clsx('badge-sm shrink-0 whitespace-nowrap', SEVERITY_BADGE.neutral)}>
34
+ <span className="w-1.5 h-1.5 rounded-full bg-theme-text-tertiary" />
35
+ {count} {count === 1 ? 'object' : 'objects'} not checked
36
+ </span>
37
+ </Tooltip>
38
+ )
39
+ }
@@ -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,7 +13,9 @@ 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[]
@@ -38,10 +40,11 @@ function groupByKind(resources: HelmOwnedResource[]): Map<string, HelmOwnedResou
38
40
  }
39
41
 
40
42
  // Health status types
41
- type HealthFilter = 'all' | 'healthy' | 'warning' | 'error'
43
+ type HealthFilter = 'all' | 'healthy' | 'warning' | 'error' | 'unread'
42
44
 
43
45
  // Determine health status of a resource
44
- function getResourceHealth(resource: HelmOwnedResource): 'healthy' | 'warning' | 'error' | 'unknown' {
46
+ function getResourceHealth(resource: HelmOwnedResource): 'healthy' | 'warning' | 'error' | 'unread' | 'unknown' {
47
+ if (resource.statusUnread) return 'unread'
45
48
  // An issue field always indicates a problem regardless of status
46
49
  if (resource.issue) return 'error'
47
50
  const status = resource.status
@@ -58,17 +61,24 @@ function computeHealthSummary(resources: HelmOwnedResource[]) {
58
61
  let healthy = 0
59
62
  let warning = 0
60
63
  let error = 0
64
+ let unread = 0
61
65
  let unknown = 0
66
+ let denied = 0
62
67
 
63
68
  for (const r of resources) {
64
69
  const health = getResourceHealth(r)
65
70
  if (health === 'healthy') healthy++
66
71
  else if (health === 'warning') warning++
67
72
  else if (health === 'error') error++
73
+ else if (health === 'unread') {
74
+ unread++
75
+ if (readActionFor(r.statusUnread) !== 'retry') denied++
76
+ }
68
77
  else unknown++
69
78
  }
70
79
 
71
- 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 }
72
82
  }
73
83
 
74
84
  export function OwnedResources({ resources, onNavigate, summaryLabel = 'created by this release' }: OwnedResourcesProps) {
@@ -99,7 +109,7 @@ export function OwnedResources({ resources, onNavigate, summaryLabel = 'created
99
109
  return (
100
110
  <div className="p-4 space-y-4">
101
111
  {/* Health summary - clickable badges */}
102
- <div className="flex items-center justify-between">
112
+ <div className="flex flex-wrap items-center justify-between gap-2">
103
113
  <div className="text-sm text-theme-text-secondary">
104
114
  {healthFilter === 'all' ? (
105
115
  <>{pluralize(resources.length, 'resource')} {summaryLabel}</>
@@ -117,7 +127,7 @@ export function OwnedResources({ resources, onNavigate, summaryLabel = 'created
117
127
  </span>
118
128
  )}
119
129
  </div>
120
- <div className="flex items-center gap-2">
130
+ <div className="flex flex-wrap items-center gap-2">
121
131
  {health.healthy > 0 && (
122
132
  <button
123
133
  onClick={() => handleFilterClick('healthy')}
@@ -154,6 +164,20 @@ export function OwnedResources({ resources, onNavigate, summaryLabel = 'created
154
164
  {health.error} failed
155
165
  </button>
156
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
+ )}
157
181
  </div>
158
182
  </div>
159
183
 
@@ -201,8 +225,26 @@ interface ResourceItemProps {
201
225
  onNavigate?: NavigateToResource
202
226
  }
203
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
+
204
244
  function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
205
- 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
206
248
  const isPod = resource.kind.toLowerCase() === 'pod'
207
249
  const isService = resource.kind.toLowerCase() === 'service'
208
250
  const isRunning = resource.status?.toLowerCase() === 'running'
@@ -243,8 +285,16 @@ function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
243
285
  </div>
244
286
 
245
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
+
246
296
  {/* Quick actions for pods */}
247
- {isPod && (
297
+ {isPod && !unread && (
248
298
  <PodQuickActions
249
299
  namespace={resource.namespace}
250
300
  podName={resource.name}
@@ -253,7 +303,7 @@ function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
253
303
  )}
254
304
 
255
305
  {/* Quick actions for services */}
256
- {isService && (
306
+ {isService && !unread && (
257
307
  <ServiceQuickActions
258
308
  namespace={resource.namespace}
259
309
  serviceName={resource.name}
@@ -296,6 +346,13 @@ function ResourceItem({ resource, onNavigate }: ResourceItemProps) {
296
346
  </Tooltip>
297
347
  )}
298
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
+
299
356
  {canNavigate && (
300
357
  <Tooltip content="View details">
301
358
  <button