@skyhook-io/radar-app 1.21.5 → 1.21.7

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 (107) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +19 -1
  4. package/src/RadarApp.tsx +8 -2
  5. package/src/api/client.discoverMetrics.test.tsx +69 -0
  6. package/src/api/client.issueCorrelation.test.tsx +244 -0
  7. package/src/api/client.issueRowChanges.test.tsx +129 -0
  8. package/src/api/client.pendingOwnership.test.tsx +197 -0
  9. package/src/api/client.prometheusStatus.test.ts +4 -0
  10. package/src/api/client.restartError.test.ts +36 -1
  11. package/src/api/client.stopWorkflow.test.tsx +133 -0
  12. package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
  13. package/src/api/client.ts +572 -111
  14. package/src/api/connectionBinding.test.tsx +3 -1
  15. package/src/api/connectionBinding.ts +14 -2
  16. package/src/api/gitOpsPermissions.render.test.tsx +155 -0
  17. package/src/api/gitOpsPermissions.test.ts +90 -0
  18. package/src/api/gitOpsPermissions.ts +51 -0
  19. package/src/api/httpErrors.test.ts +30 -1
  20. package/src/api/httpErrors.ts +17 -0
  21. package/src/api/openobserveSetup.ts +85 -0
  22. package/src/api/podDebug.test.tsx +137 -0
  23. package/src/api/podDebug.ts +82 -0
  24. package/src/api/prometheusCharts.test.ts +23 -0
  25. package/src/api/prometheusCharts.ts +25 -0
  26. package/src/api/radarFeatures.render.test.tsx +43 -2
  27. package/src/api/radarFeatures.test.ts +18 -1
  28. package/src/api/radarFeatures.ts +17 -4
  29. package/src/api/reviewedActionMutation.ts +9 -2
  30. package/src/api/workloadMetrics.ts +2 -0
  31. package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
  32. package/src/components/applications/ApplicationsView.tsx +56 -31
  33. package/src/components/cnpg/host.test.tsx +1 -1
  34. package/src/components/cnpg/host.tsx +0 -2
  35. package/src/components/dock/BottomDock.tsx +7 -3
  36. package/src/components/dock/MissingShellDebug.test.tsx +193 -0
  37. package/src/components/dock/MissingShellDebug.tsx +114 -0
  38. package/src/components/dock/PodDebugSession.test.tsx +60 -0
  39. package/src/components/dock/PodDebugSession.tsx +96 -0
  40. package/src/components/dock/TerminalTab.test.tsx +48 -4
  41. package/src/components/dock/TerminalTab.tsx +47 -25
  42. package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
  43. package/src/components/dock/WorkloadLogsTab.tsx +16 -0
  44. package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
  45. package/src/components/execution/BatchExecutionView.tsx +88 -5
  46. package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
  47. package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
  48. package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
  49. package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
  50. package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
  51. package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
  52. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
  53. package/src/components/gitops/GitOpsView.tsx +93 -32
  54. package/src/components/helm/OwnedResources.tsx +1 -0
  55. package/src/components/home/mcpToolCatalog.ts +1 -0
  56. package/src/components/issues/IssuesPane.render.test.tsx +1 -1
  57. package/src/components/issues/IssuesPane.tsx +11 -0
  58. package/src/components/issues/useIssueExpansion.ts +91 -0
  59. package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
  60. package/src/components/resource/MetricsNotConnected.tsx +114 -0
  61. package/src/components/resource/PVCUsageBar.tsx +2 -1
  62. package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
  63. package/src/components/resource/PrometheusCharts.tsx +14 -2
  64. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
  65. package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
  66. package/src/components/resource/RestartChart.tsx +4 -3
  67. package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
  68. package/src/components/resource/RightsizingStrip.tsx +5 -3
  69. package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
  70. package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
  71. package/src/components/resource/nameMatchedScope.ts +9 -3
  72. package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
  73. package/src/components/resources/PodDebugAction.test.tsx +157 -0
  74. package/src/components/resources/PodDebugAction.tsx +207 -0
  75. package/src/components/resources/PodDebugPermission.tsx +21 -0
  76. package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
  77. package/src/components/resources/ResourcesView.tsx +39 -5
  78. package/src/components/resources/namespaceHint.test.ts +34 -0
  79. package/src/components/resources/namespaceHint.ts +19 -0
  80. package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
  81. package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
  82. package/src/components/resources/renderers/PodRenderer.tsx +12 -5
  83. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
  84. package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
  85. package/src/components/settings/MetricsBackendSwitch.tsx +167 -0
  86. package/src/components/settings/OpenObserveSetup.test.tsx +343 -0
  87. package/src/components/settings/OpenObserveSetup.tsx +358 -0
  88. package/src/components/settings/SettingsDialog.tsx +21 -7
  89. package/src/components/settings/openobserveStatus.test.ts +34 -0
  90. package/src/components/settings/openobserveStatus.ts +55 -0
  91. package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
  92. package/src/components/timeline/TimelineList.test.ts +18 -0
  93. package/src/components/timeline/TimelineList.tsx +19 -5
  94. package/src/components/timeline/TimelineView.tsx +2 -0
  95. package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
  96. package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
  97. package/src/components/workload/WorkloadView.tsx +95 -10
  98. package/src/context/TimelineNavigation.test.ts +59 -0
  99. package/src/context/TimelineNavigation.tsx +86 -0
  100. package/src/contexts/CapabilitiesContext.tsx +3 -1
  101. package/src/hooks/useResourceCounts.ts +2 -1
  102. package/src/hooks/useWorkflowStopAction.ts +31 -0
  103. package/src/index.css +1 -0
  104. package/src/integrations/resourceHosts.test.tsx +2 -2
  105. package/src/integrations/resourceHosts.tsx +4 -2
  106. package/src/k8s-ui-exports.test.ts +10 -0
  107. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
@@ -0,0 +1,132 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { MemoryRouter } from 'react-router-dom'
5
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
6
+ import { afterEach, beforeEach, expect, it, vi } from 'vitest'
7
+ import { ResourcesView } from './ResourcesView'
8
+
9
+ vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected', context: 'test' } }) }))
10
+ vi.mock('../dock', () => ({ useOpenLogs: () => () => {}, useOpenWorkloadLogs: () => () => {} }))
11
+ vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
12
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
13
+
14
+ const completeAll = { status: 'complete', scope: { type: 'all_namespaces' }, gaps: [] }
15
+ const narrowedAll = { status: 'complete', scope: { type: 'all_namespaces' }, narrowedBy: ['user_access'], gaps: [] }
16
+ const completeScoped = (ns: string) => ({ status: 'complete', scope: { type: 'namespaces', namespaces: { names: [ns], count: 1 } }, gaps: [] })
17
+
18
+ const apiResourcesFixture = [
19
+ { name: 'pods', kind: 'Pod', group: '', version: 'v1', namespaced: true, verbs: ['get', 'list'], isCrd: false },
20
+ { name: 'certificates', kind: 'Certificate', group: 'cert-manager.io', version: 'v1', namespaced: true, verbs: ['get', 'list'], isCrd: true },
21
+ ]
22
+
23
+ function jsonResponse(body: unknown) {
24
+ return Promise.resolve(new Response(JSON.stringify(body), { status: 200, headers: { 'Content-Type': 'application/json' } }))
25
+ }
26
+
27
+ let host: HTMLDivElement
28
+ let root: ReturnType<typeof createRoot>
29
+ let client: QueryClient
30
+
31
+ beforeEach(() => {
32
+ vi.stubGlobal('matchMedia', () => ({ matches: false, addEventListener: () => {}, removeEventListener: () => {} }))
33
+ Element.prototype.scrollIntoView = vi.fn()
34
+ host = document.createElement('div')
35
+ document.body.append(host)
36
+ root = createRoot(host)
37
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
38
+ })
39
+
40
+ afterEach(async () => {
41
+ await act(async () => root.unmount())
42
+ host.remove()
43
+ client.clear()
44
+ vi.unstubAllGlobals()
45
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
46
+ })
47
+
48
+ async function flush() {
49
+ for (let i = 0; i < 6; i++) {
50
+ await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)) })
51
+ }
52
+ }
53
+
54
+ function setupFetch(options: {
55
+ scope?: 'pending' | Record<string, unknown>
56
+ listCoverage?: Record<string, unknown>
57
+ allCounts?: Record<string, unknown>
58
+ }) {
59
+ const requested: URL[] = []
60
+ vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL) => {
61
+ const url = new URL(String(input), 'http://radar.invalid')
62
+ requested.push(url)
63
+ if (url.pathname.endsWith('/api-resources')) return jsonResponse(apiResourcesFixture)
64
+ if (url.pathname.endsWith('/capabilities')) return jsonResponse({ workloadWrites: {} })
65
+ if (url.pathname.endsWith('/cluster/namespace-scope')) {
66
+ if (options.scope === 'pending') return new Promise<Response>(() => {})
67
+ return jsonResponse(options.scope)
68
+ }
69
+ if (url.pathname.endsWith('/resource-counts')) {
70
+ const ns = url.searchParams.get('namespaces')
71
+ if (!ns) return jsonResponse(options.allCounts ?? { counts: { Pod: 15, 'cert-manager.io/Certificate': 12 }, coverage: { Pod: completeAll, 'cert-manager.io/Certificate': completeAll } })
72
+ return jsonResponse({ counts: { Pod: 0, 'cert-manager.io/Certificate': 0 }, coverage: { Pod: completeScoped(ns), 'cert-manager.io/Certificate': completeScoped(ns) } })
73
+ }
74
+ if (url.pathname.includes('/metrics/')) return jsonResponse([])
75
+ if (url.pathname.includes('/resources/')) {
76
+ return jsonResponse({ items: [], coverage: options.listCoverage ?? completeScoped('staging') })
77
+ }
78
+ return jsonResponse({})
79
+ }))
80
+ return requested
81
+ }
82
+
83
+ async function renderView(initialEntry: string, namespaces: string[]) {
84
+ await act(async () => {
85
+ root.render(
86
+ <QueryClientProvider client={client}>
87
+ <MemoryRouter initialEntries={[initialEntry]}>
88
+ <ResourcesView namespaces={namespaces} selectedResource={null} onResourceClick={() => {}} onClearNamespaces={() => {}} />
89
+ </MemoryRouter>
90
+ </QueryClientProvider>,
91
+ )
92
+ })
93
+ await flush()
94
+ }
95
+
96
+ it('resolves canonical CRD count keys on direct URL load', async () => {
97
+ setupFetch({
98
+ scope: { actives: ['staging'], context: 'test', accessChecked: true, kubeconfigNamespace: '', mode: 'namespace', accessibleNamespaces: ['default', 'staging'], deniedNamespaces: [], authoritative: true, canClearNamespace: true, cacheScoped: false, namespaceRescope: false },
99
+ })
100
+ await renderView('/resources/certificates?apiGroup=cert-manager.io', ['staging'])
101
+ expect(host.textContent).toContain('Filtered to staging. 12 Certificates are in other namespaces.')
102
+ expect(host.textContent).toContain('Show all namespaces')
103
+ })
104
+
105
+ it('waits for namespaceScope before requesting unfiltered counts (prevents --namespace-scope load race)', async () => {
106
+ const requested = setupFetch({ scope: 'pending' })
107
+ await renderView('/resources/pods', ['other-ns'])
108
+ const unfilteredCounts = requested.filter(u => u.pathname.endsWith('/resource-counts') && !u.searchParams.get('namespaces'))
109
+ expect(unfilteredCounts).toHaveLength(0)
110
+ expect(host.textContent).not.toContain('are in other namespaces')
111
+ })
112
+
113
+ it('hides Show all namespaces when canClearNamespace is false', async () => {
114
+ setupFetch({
115
+ scope: { actives: ['team-a'], context: 'test', accessChecked: true, kubeconfigNamespace: '', mode: 'namespace', accessibleNamespaces: ['team-a'], deniedNamespaces: [], authoritative: false, canClearNamespace: false, cacheScoped: false, namespaceRescope: false },
116
+ allCounts: { counts: { Pod: 8 }, coverage: { Pod: narrowedAll } },
117
+ })
118
+ await renderView('/resources/pods', ['team-a'])
119
+ expect(host.textContent).toContain('Filtered to team-a. At least 8 Pods are in other namespaces.')
120
+ expect(host.textContent).not.toContain('Show all namespaces')
121
+ })
122
+
123
+ it('skips unfiltered counts while a selected namespace is still syncing', async () => {
124
+ const requested = setupFetch({
125
+ scope: { actives: ['staging', 'syncing'], context: 'test', accessChecked: true, kubeconfigNamespace: '', mode: 'namespace', accessibleNamespaces: ['staging', 'syncing', 'prod'], deniedNamespaces: [], authoritative: true, canClearNamespace: true, cacheScoped: false, namespaceRescope: false },
126
+ listCoverage: { status: 'partial', scope: { type: 'namespaces', namespaces: { names: ['staging', 'syncing'], count: 2 } }, gaps: [{ code: 'kind_sync_pending', namespaces: { names: ['syncing'], count: 1 } }] },
127
+ })
128
+ await renderView('/resources/pods', ['staging', 'syncing'])
129
+ const unfilteredCounts = requested.filter(u => u.pathname.endsWith('/resource-counts') && !u.searchParams.get('namespaces'))
130
+ expect(unfilteredCounts).toHaveLength(0)
131
+ expect(host.textContent).not.toContain('are in other namespaces')
132
+ })
@@ -1,12 +1,12 @@
1
1
  import { useState, useMemo, useCallback } from 'react'
2
2
  import { useLocation, useNavigate } from 'react-router-dom'
3
3
  import { useQuery } from '@tanstack/react-query'
4
- import { fetchJSON, isForbiddenError, isKindSyncFailed, isStillLoadingError, useCapabilities, useNamespaceCapabilities, useResources, useSecretCertExpiry, useTopPodMetrics, useTopNodeMetrics, useBulkDeleteResources, useBulkRestartWorkloads, useBulkScaleWorkloads, useAuditBadges, useIssues, fetchResourceList, isListTooLargeError, isUnretryableReadError } from '../../api/client'
4
+ import { fetchJSON, useNamespaceScope, isForbiddenError, isKindSyncFailed, isStillLoadingError, useCapabilities, useNamespaceCapabilities, useResources, useSecretCertExpiry, useTopPodMetrics, useTopNodeMetrics, useBulkDeleteResources, useBulkRestartWorkloads, useBulkScaleWorkloads, useAuditBadges, useIssues, fetchResourceList, isListTooLargeError, isUnretryableReadError, useRadarFeature } from '../../api/client'
5
5
  import { isBadgeWorthy } from '../../utils/auditBadges'
6
6
  import { ISSUE_SEVERITY_RANK } from '@skyhook-io/k8s-ui'
7
7
  import type { Issue, AuditBadgeMessage } from '@skyhook-io/k8s-ui'
8
8
  import { stripBasename } from '../../api/config'
9
- import { createListRefetchInterval, type ResourceListResult } from '../../api/resourceLists'
9
+ import { createListRefetchInterval, listSyncPending, type ResourceListResult } from '../../api/resourceLists'
10
10
  import { useAPIResources } from '../../api/apiResources'
11
11
  import { useConnection } from '../../context/ConnectionContext'
12
12
  import { getSecretStoreProviderType } from '@skyhook-io/k8s-ui'
@@ -26,11 +26,13 @@ import {
26
26
  intersectWorkloadWrites,
27
27
  hasCuratedColumns,
28
28
  } from '@skyhook-io/k8s-ui'
29
- import type { Capabilities, ResourceQueryResult, WorkloadWritePermissions } from '@skyhook-io/k8s-ui'
29
+ import type { APIResource, Capabilities, ResourceQueryResult, WorkloadWritePermissions } from '@skyhook-io/k8s-ui'
30
30
  import type { SelectedResource } from '../../types'
31
31
  import { apiVersionToGroup, kindToPluralWithGroup, type NavigateToResource } from '../../utils/navigation'
32
32
  import { CreateResourceDialog } from '../shared/CreateResourceDialog'
33
33
  import { getSkeletonYaml } from '../../utils/skeleton-yaml'
34
+ import { EmptyNamespaceHint } from './EmptyNamespaceHint'
35
+ import { emptyNamespaceHint } from './namespaceHint'
34
36
 
35
37
  interface ResourcesViewProps {
36
38
  namespaces: string[]
@@ -73,6 +75,13 @@ function resourceCountKey(kind: NonNullable<SelectedKindInfo>): string {
73
75
  return kind.group ? `${kind.group}/${kind.kind}` : kind.kind
74
76
  }
75
77
 
78
+ function namespacedKind(apiResources: APIResource[] | undefined, kind: SelectedKindInfo): boolean {
79
+ if (!kind) return false
80
+ const match = apiResources?.find(r => r.name === kind.name && r.group === kind.group)
81
+ ?? CORE_RESOURCES.find(r => r.name === kind.name && r.group === kind.group)
82
+ return match?.namespaced ?? false
83
+ }
84
+
76
85
  function hasResourceCount(counts: Record<string, number> | undefined, key: string): boolean {
77
86
  return Object.prototype.hasOwnProperty.call(counts ?? {}, key)
78
87
  }
@@ -81,6 +90,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
81
90
  const location = useLocation()
82
91
  const navigate = useNavigate()
83
92
  const { connection } = useConnection()
93
+ const { data: namespaceScope } = useNamespaceScope()
84
94
 
85
95
  const { data: capabilities, isPending: capabilitiesPending } = useCapabilities()
86
96
  const hostFeatures = useResourceHostFeatures()
@@ -187,7 +197,9 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
187
197
  return map
188
198
  }, [audit.data?.findings, audit.data?.checks, selectedKind, selectedKindCanonical])
189
199
 
190
- const selectedCountKey = selectedKind ? resourceCountKey(selectedKind) : ''
200
+ const selectedCountKey = selectedKind && selectedKindCanonical
201
+ ? resourceCountKey({ ...selectedKind, kind: selectedKindCanonical })
202
+ : ''
191
203
  const selectedCount = selectedCountKey ? countsData?.counts[selectedCountKey] : undefined
192
204
  const selectedCountKnown = selectedCountKey ? hasResourceCount(countsData?.counts, selectedCountKey) : false
193
205
  const selectedCountUnavailable = selectedCountKey ? countsData?.unavailable?.includes(selectedCountKey) ?? false : false
@@ -239,6 +251,8 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
239
251
 
240
252
  const loadingInterval = useMemo(() => createListRefetchInterval(120000), [])
241
253
 
254
+ const selectedKindListsAsTable = resourceKindListMode(selectedKind, hostFeatures, capabilitiesPending) === 'table'
255
+
242
256
  // Fetch full data only for the selected kind
243
257
  const selectedKindQuery = useQuery({
244
258
  queryKey: ['resources', selectedKind?.name, isSelectedCrd ? selectedKind?.group : '', namespaces],
@@ -254,7 +268,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
254
268
  summary: selectedKindSummaryServed, table: wantsTable, signal,
255
269
  })
256
270
  },
257
- enabled: !!selectedKind && !selectedKindQueryBlocked && resourceKindListMode(selectedKind, hostFeatures, capabilitiesPending) === 'table',
271
+ enabled: !!selectedKind && !selectedKindQueryBlocked && selectedKindListsAsTable,
258
272
  staleTime: 30000,
259
273
  // Safety net — SSE k8s_event drives near-real-time invalidation. A list
260
274
  // whose namespaces are still loading is re-read until they finish.
@@ -286,6 +300,21 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
286
300
  }
287
301
  }, [selectedKind, selectedKindQueryBlocked, waitingForGuardCount, selectedKindQuery.data?.items, selectedKindQuery.data?.coverage, selectedKindQuery.isLoading, selectedKindQuery.error, selectedKindQuery.refetch, selectedKindQuery.dataUpdatedAt])
288
302
 
303
+ // An empty filtered list reads as "there are none" unless it says what the
304
+ // filter hides. Under --namespace-scope the cache holds no other namespace,
305
+ // so there is nothing to count. The All-namespaces counts are the query the
306
+ // sidebar runs at All, and it runs only while a filtered list is empty.
307
+ const selectedKindRows = selectedKindQueryResult && !selectedKindQueryResult.isLoading && !largeListGuard ? selectedKindQueryResult.data?.length : undefined
308
+ const selectedKindNamespaced = namespacedKind(apiResources, selectedKind)
309
+ const wantsEmptyHint = namespaces.length > 0 && selectedKindRows === 0 && selectedKindNamespaced &&
310
+ namespaceScope?.cacheScoped === false && !listSyncPending(selectedKindQueryResult?.coverage) && selectedKindListsAsTable
311
+ const { data: allNamespaceCounts } = useResourceCounts([], { enabled: wantsEmptyHint })
312
+ const emptyHint = useMemo(() => {
313
+ if (!wantsEmptyHint || !selectedCountKey) return null
314
+ const total = hasResourceCount(allNamespaceCounts?.counts, selectedCountKey) ? allNamespaceCounts?.counts[selectedCountKey] : undefined
315
+ return emptyNamespaceHint(total, allNamespaceCounts?.coverage?.[selectedCountKey])
316
+ }, [wantsEmptyHint, selectedCountKey, allNamespaceCounts])
317
+
289
318
  // Metrics
290
319
  const { data: topPodMetrics } = useTopPodMetrics({ enabled: topPodMetricsEnabled, namespaces })
291
320
  const { data: topNodeMetrics } = useTopNodeMetrics({ enabled: topNodeMetricsEnabled })
@@ -323,6 +352,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
323
352
  // Dock actions
324
353
  const openLogs = useOpenLogs()
325
354
  const openWorkloadLogs = useOpenWorkloadLogs()
355
+ const { support: replicaSetLogSupport } = useRadarFeature('replicaSetLogs')
326
356
 
327
357
  // Bulk delete
328
358
  const bulkDeleteMutation = useBulkDeleteResources()
@@ -385,6 +415,9 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
385
415
  rememberedKindSearch={rememberedKindSearch}
386
416
  onKindFiltersChange={onKindFiltersChange}
387
417
  onApplyNamespacesToAllSections={onApplyNamespacesToAllSections}
418
+ emptyScopeHint={emptyHint && selectedKindCanonical
419
+ ? <EmptyNamespaceHint hint={emptyHint} namespaces={namespaces} kind={selectedKindCanonical} onShowAll={namespaceScope?.canClearNamespace ? onClearNamespaces : undefined} />
420
+ : undefined}
388
421
  // Injected data
389
422
  apiResources={apiResources}
390
423
  // Lightweight counts for sidebar (replaces 233 parallel queries)
@@ -427,6 +460,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
427
460
  // Dock actions
428
461
  onOpenLogs={openLogs}
429
462
  onOpenWorkloadLogs={openWorkloadLogs}
463
+ replicaSetLogs={replicaSetLogSupport === 'supported'}
430
464
  // Create resource
431
465
  onCreateResource={handleCreateResource}
432
466
  renderKindView={renderKindView}
@@ -0,0 +1,34 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import type { ResourceCoverage } from '@skyhook-io/k8s-ui'
3
+ import { emptyNamespaceHint } from './namespaceHint'
4
+
5
+ const complete: ResourceCoverage = { status: 'complete', scope: { type: 'all_namespaces' }, gaps: [] }
6
+ const partial: ResourceCoverage = { status: 'partial', scope: { type: 'all_namespaces' }, gaps: [] }
7
+ const narrowed: ResourceCoverage = {
8
+ status: 'complete',
9
+ scope: { type: 'all_namespaces' },
10
+ narrowedBy: ['user_access'],
11
+ gaps: [],
12
+ }
13
+
14
+ describe('emptyNamespaceHint', () => {
15
+ it('counts what exists in other namespaces', () => {
16
+ expect(emptyNamespaceHint(15, complete)).toEqual({ type: 'elsewhere', count: 15, atLeast: false })
17
+ })
18
+
19
+ it('treats a partial or access-narrowed count as a lower bound', () => {
20
+ expect(emptyNamespaceHint(15, partial)).toEqual({ type: 'elsewhere', count: 15, atLeast: true })
21
+ expect(emptyNamespaceHint(15, narrowed)).toEqual({ type: 'elsewhere', count: 15, atLeast: true })
22
+ expect(emptyNamespaceHint(15, undefined)).toEqual({ type: 'elsewhere', count: 15, atLeast: true })
23
+ })
24
+
25
+ it('says none elsewhere only when the count covers every namespace', () => {
26
+ expect(emptyNamespaceHint(0, complete)).toEqual({ type: 'none-elsewhere' })
27
+ expect(emptyNamespaceHint(0, partial)).toBeNull()
28
+ expect(emptyNamespaceHint(0, narrowed)).toBeNull()
29
+ })
30
+
31
+ it('says nothing without a count', () => {
32
+ expect(emptyNamespaceHint(undefined, complete)).toBeNull()
33
+ })
34
+ })
@@ -0,0 +1,19 @@
1
+ import type { ResourceCoverage } from '@skyhook-io/k8s-ui'
2
+
3
+ export type EmptyNamespaceHint =
4
+ | { type: 'elsewhere'; count: number; atLeast: boolean }
5
+ | { type: 'none-elsewhere' }
6
+
7
+ /**
8
+ * What an empty, namespace-filtered list says about the rest of the cluster,
9
+ * from the kind's count across every namespace the caller can read.
10
+ *
11
+ * A count Radar couldn't fully read, or one narrowed by the caller's access,
12
+ * is a lower bound, so it can't back "none in other namespaces".
13
+ */
14
+ export function emptyNamespaceHint(total: number | undefined, coverage: ResourceCoverage | undefined): EmptyNamespaceHint | null {
15
+ if (total === undefined) return null
16
+ const complete = coverage?.status === 'complete' && !coverage.narrowedBy?.length
17
+ if (total > 0) return { type: 'elsewhere', count: total, atLeast: !complete }
18
+ return complete ? { type: 'none-elsewhere' } : null
19
+ }
@@ -0,0 +1,135 @@
1
+ import { Link2 } from 'lucide-react'
2
+ import {
3
+ RelationshipGroup,
4
+ ResourceLink,
5
+ Section,
6
+ type ResourceRef,
7
+ } from '@skyhook-io/k8s-ui'
8
+ import { isFetchError, isForbiddenError } from '@skyhook-io/k8s-ui/types/fetch-error'
9
+ import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
10
+ import {
11
+ ValidatingAdmissionPolicyBindingRenderer as BaseBindingRenderer,
12
+ ValidatingAdmissionPolicyRenderer as BasePolicyRenderer,
13
+ } from '@skyhook-io/k8s-ui/components/resources/renderers/ValidatingAdmissionPolicyRenderers'
14
+ import {
15
+ MutatingAdmissionPolicyBindingRenderer as BaseMutatingBinding,
16
+ MutatingAdmissionPolicyRenderer as BaseMutatingPolicy,
17
+ } from '@skyhook-io/k8s-ui/components/resources/renderers/MutatingAdmissionPolicyRenderers'
18
+ import { useResources, useResourceWithRelationships } from '../../../api/client'
19
+
20
+ const ADMISSION_REGISTRATION_GROUP = 'admissionregistration.k8s.io'
21
+
22
+ interface AdmissionProps {
23
+ data: any
24
+ onNavigate?: (ref: ResourceRef) => void
25
+ }
26
+
27
+ export function ValidatingAdmissionPolicyRenderer(props: AdmissionProps) {
28
+ return <BasePolicyRenderer {...props} bindings={<PolicyBindings {...props} mutating={false} />} />
29
+ }
30
+
31
+ export function MutatingAdmissionPolicyRenderer(props: AdmissionProps) {
32
+ return <BaseMutatingPolicy {...props} bindings={<PolicyBindings {...props} mutating />} />
33
+ }
34
+
35
+ function PolicyBindings({ data, onNavigate, mutating }: AdmissionProps & { mutating: boolean }) {
36
+ const name = data?.metadata?.name
37
+ const query = useResources<any>(
38
+ mutating ? 'mutatingadmissionpolicybindings' : 'validatingadmissionpolicybindings',
39
+ undefined,
40
+ ADMISSION_REGISTRATION_GROUP,
41
+ { enabled: Boolean(name), refetchInterval: 30000 },
42
+ )
43
+ const denied = isForbiddenError(query.error)
44
+ const bindings = denied ? [] : (query.data ?? []).filter(binding => binding?.spec?.policyName === name)
45
+ const bindingLookupComplete = query.coverage?.status === 'complete' && !query.error
46
+ const bindingTitle = bindingLookupComplete
47
+ ? `Bindings (${bindings.length})`
48
+ : bindings.length > 0 ? `Bindings (${bindings.length}+)` : 'Bindings'
49
+ const refs = bindings.map(binding => ({
50
+ kind: mutating ? 'MutatingAdmissionPolicyBinding' : 'ValidatingAdmissionPolicyBinding',
51
+ namespace: '',
52
+ name: binding?.metadata?.name ?? '',
53
+ group: ADMISSION_REGISTRATION_GROUP,
54
+ }))
55
+
56
+ return (
57
+ <Section title={bindingTitle} icon={Link2} defaultExpanded>
58
+ {query.isLoading ? (
59
+ <div className="text-sm text-theme-text-tertiary">Looking for readable bindings…</div>
60
+ ) : query.error && bindings.length === 0 ? (
61
+ <LookupFailureNote errors={[query.error]} what="which bindings select this policy" />
62
+ ) : bindings.length === 0 && bindingLookupComplete ? (
63
+ <div className="text-sm text-theme-text-tertiary">
64
+ No readable bindings select this policy; this policy has no effect.
65
+ </div>
66
+ ) : bindings.length === 0 ? (
67
+ <div className="text-sm text-theme-text-tertiary">
68
+ Binding availability could not be established; this policy may still have readable bindings.
69
+ </div>
70
+ ) : (
71
+ <div className="space-y-2">
72
+ {!bindingLookupComplete && !query.error && (
73
+ <div className="text-sm text-theme-text-tertiary">
74
+ This list may be incomplete; binding coverage could not be confirmed.
75
+ </div>
76
+ )}
77
+ <LookupFailureNote
78
+ errors={[query.error]}
79
+ what="which bindings select this policy"
80
+ incomplete
81
+ />
82
+ <RelationshipGroup label="Select this policy" refs={refs} onNavigate={onNavigate} />
83
+ </div>
84
+ )}
85
+ </Section>
86
+ )
87
+ }
88
+
89
+ export function ValidatingAdmissionPolicyBindingRenderer(props: AdmissionProps) {
90
+ return <BaseBindingRenderer {...props} policyReference={<PolicyReference {...props} kind="validatingadmissionpolicies" />} />
91
+ }
92
+
93
+ export function MutatingAdmissionPolicyBindingRenderer(props: AdmissionProps) {
94
+ return <BaseMutatingBinding {...props} policyReference={<PolicyReference {...props} kind="mutatingadmissionpolicies" />} />
95
+ }
96
+
97
+ function PolicyReference({ data, onNavigate, kind }: AdmissionProps & { kind: string }) {
98
+ const policyName = data?.spec?.policyName ?? ''
99
+ const query = useResourceWithRelationships<any>(
100
+ kind,
101
+ '',
102
+ policyName,
103
+ ADMISSION_REGISTRATION_GROUP,
104
+ )
105
+ const status = isFetchError(query.error) ? query.error.status : undefined
106
+ if (!policyName) return <>Not specified</>
107
+ return query.isLoading ? (
108
+ <ReferenceState name={policyName} note="Checking policy availability…" />
109
+ ) : status === 404 ? (
110
+ <ReferenceState name={policyName} note="Referenced policy was not found." />
111
+ ) : status === 403 ? (
112
+ <ReferenceState name={policyName} note="Not permitted to check policy availability." />
113
+ ) : query.error ? (
114
+ <ReferenceState name={policyName} note="Could not check policy availability." />
115
+ ) : query.data ? (
116
+ <ResourceLink
117
+ name={policyName}
118
+ kind={kind}
119
+ namespace=""
120
+ group={ADMISSION_REGISTRATION_GROUP}
121
+ onNavigate={onNavigate}
122
+ />
123
+ ) : (
124
+ <ReferenceState name={policyName} note="Policy availability was not checked." />
125
+ )
126
+ }
127
+
128
+ function ReferenceState({ name, note }: { name: string; note: string }) {
129
+ return (
130
+ <span className="space-y-0.5">
131
+ <span className="block">{name || 'Not specified'}</span>
132
+ <span className="block text-xs text-theme-text-tertiary">{note}</span>
133
+ </span>
134
+ )
135
+ }
@@ -1,3 +1,4 @@
1
+ import { hasPrometheusCharts } from '../../../api/prometheusCharts'
1
2
  import { NodeRenderer as BaseNodeRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/NodeRenderer'
2
3
  import { useNavigate } from 'react-router-dom'
3
4
  import { getVisibleLiveMetrics, isLiveMetricsUnavailable, shouldFetchLiveMetrics, useNodeRemovalPlan, useNodeMetrics, useNodeMetricsHistory, usePrometheusResourceMetrics, usePrometheusStatus } from '../../../api/client'
@@ -26,7 +27,7 @@ export function NodeRenderer({ data, relationships }: NodeRendererProps) {
26
27
 
27
28
  // Determine whether to hide metrics-server section (Prometheus has data)
28
29
  const { data: prometheusStatus } = usePrometheusStatus()
29
- const prometheusConnected = prometheusStatus?.connected === true
30
+ const prometheusConnected = hasPrometheusCharts(prometheusStatus)
30
31
  const { data: prometheusCPU, isLoading: prometheusCPULoading, error: prometheusCPUError } = usePrometheusResourceMetrics(
31
32
  'Node', '', nodeName ?? '', 'cpu', '1h', prometheusConnected,
32
33
  )
@@ -1,3 +1,7 @@
1
+ import { connectionHeaderValue } from '../../../api/connectionBinding'
2
+ import { usePodDetailAccess } from '../PodDebugAction'
3
+ import { getApiBase } from '../../../api/config'
4
+ import { hasPrometheusCharts } from '../../../api/prometheusCharts'
1
5
  import { PodRenderer as BasePodRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/PodRenderer'
2
6
  import type { CopyHandler } from '@skyhook-io/k8s-ui/components/ui/drawer-components'
3
7
  import { getPodNetworks, uniqueNetworkAttachmentRefs } from '@skyhook-io/k8s-ui/utils/multus'
@@ -48,10 +52,9 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
48
52
  const awaitsScheduling = podAwaitsScheduling(data)
49
53
 
50
54
  // Capabilities (namespace-scoped: re-checks RBAC if globally denied)
51
- const { canExec, canViewLogs, canPortForward } = useNamespacedCapabilities(namespace)
52
- // Show the port-forward affordance for a live forward (local + RBAC) OR when
53
- // not local — in-cluster/Cloud surfaces a copy-paste kubectl command instead.
54
- // The button itself picks live vs. copy-command based on deployment mode.
55
+ const nsCaps = useNamespacedCapabilities(namespace)
56
+ const { canViewLogs, canPortForward } = nsCaps
57
+ const { canExec, canOpenEphemeralTerminal } = usePodDetailAccess(data, nsCaps)
55
58
  const isLocal = useIsLocalDeployment()
56
59
  const showPortForward = canPortForward || !isLocal
57
60
 
@@ -66,7 +69,7 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
66
69
 
67
70
  // Hide metrics-server section when Prometheus has CPU data
68
71
  const { data: prometheusStatus } = usePrometheusStatus()
69
- const prometheusConnected = prometheusStatus?.connected === true
72
+ const prometheusConnected = hasPrometheusCharts(prometheusStatus)
70
73
  const { data: prometheusCPU, isLoading: prometheusCPULoading, error: prometheusCPUError } = usePrometheusResourceMetrics(
71
74
  'Pod', namespace ?? '', podName ?? '', 'cpu', '1h', prometheusConnected,
72
75
  )
@@ -143,6 +146,10 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
143
146
  canViewLogs={canViewLogs}
144
147
  canPortForward={showPortForward}
145
148
  onOpenTerminal={(params) => openTerminal(params)}
149
+ onOpenEphemeralTerminal={canOpenEphemeralTerminal ? (name, image) => openTerminal({
150
+ namespace, podName, containerName: name, containers: [name],
151
+ debugSession: { podUID: data.metadata.uid, image, connectionId: connectionHeaderValue(), apiBase: getApiBase() },
152
+ }) : undefined}
146
153
  onOpenLogsPanel={(params) => openLogsPanel(params)}
147
154
  renderPortAction={({ namespace: ns, podName: pod, port, protocol, disabled }) => (
148
155
  <PortForwardInlineButton
@@ -1,9 +1,11 @@
1
1
  import { renderToStaticMarkup } from 'react-dom/server'
2
2
  import { beforeEach, describe, expect, it, vi } from 'vitest'
3
3
  import {
4
+ MutatingAdmissionPolicyBindingRenderer,
5
+ MutatingAdmissionPolicyRenderer,
4
6
  ValidatingAdmissionPolicyBindingRenderer,
5
7
  ValidatingAdmissionPolicyRenderer,
6
- } from './ValidatingAdmissionPolicyRenderer'
8
+ } from './AdmissionPolicyRenderers'
7
9
 
8
10
  const mock = vi.hoisted(() => ({
9
11
  query: {} as any,
@@ -158,3 +160,24 @@ describe('ValidatingAdmissionPolicy reverse binding lookup', () => {
158
160
  expect(present).toContain('>require-owner</button>')
159
161
  })
160
162
  })
163
+
164
+ describe('mutating admission policy relationships', () => {
165
+ it('reads the mutating binding kind and withholds cached rows after permission loss', () => {
166
+ mock.query = { data: [binding('owner-prod', 'require-owner')], coverage: { status: 'complete' }, isLoading: false }
167
+ const renderMutating = () => renderToStaticMarkup(<MutatingAdmissionPolicyRenderer data={policy} />)
168
+ expect(renderMutating()).toContain('owner-prod')
169
+ expect(mock.reads[0][0]).toBe('mutatingadmissionpolicybindings')
170
+ mock.query.error = { status: 403, message: 'Forbidden' }
171
+ const html = renderMutating()
172
+ expect(html).not.toContain('owner-prod')
173
+ expect(html).toContain('permission')
174
+ })
175
+
176
+ it('looks up its policy in the mutating API without requesting parameters', () => {
177
+ mock.policyQuery = { data: { resource: policy } }
178
+ const html = renderToStaticMarkup(<MutatingAdmissionPolicyBindingRenderer data={binding('team', 'require-owner')} onNavigate={() => {}} />)
179
+ expect(html).toContain('>require-owner</button>')
180
+ expect(mock.policyReads[0]).toEqual(['mutatingadmissionpolicies', '', 'require-owner', 'admissionregistration.k8s.io'])
181
+ expect(mock.reads).toHaveLength(0)
182
+ })
183
+ })
@@ -1,5 +1,6 @@
1
1
  import { useOpenCostSummary, usePrometheusStatus, type useArgoStatus } from '../../api/client'
2
2
  import { costIntegrationUnavailableMessage, costSourceLabel } from '../cost/source'
3
+ import { metricsSourceLine, sourceNote } from './openobserveStatus'
3
4
  import type { IntegrationKind, IntegrationProfile } from './LocalConnectionSettings'
4
5
  import { Badge, Collapse } from '@skyhook-io/k8s-ui'
5
6
  import { useRef } from 'react'
@@ -20,11 +21,21 @@ export function LocalIntegrationStatus({ kind, profile, argo, busy, changedAt }:
20
21
  Math.max(query.dataUpdatedAt, query.errorUpdatedAt) < changedAt
21
22
  let status = 'Checking…'
22
23
  let detail: string | undefined
24
+ let sourceTone: 'success' | 'warning' | 'neutral' | undefined
23
25
  if (!checking) {
24
26
  if (query.isError) status = 'Status unavailable'
25
27
  else if (kind === 'metrics' && prom.data) {
26
- status = prom.data.connected ? 'Connected' : prom.data.discovering ? 'Discovering…' : 'Not connected'
27
- detail = prom.data.connected ? !profile.url ? `Discovered: ${prom.data.address}` : undefined : prom.data.error
28
+ const line = metricsSourceLine(prom.data.source)
29
+ if (line) {
30
+ status = line.status
31
+ detail = line.detail
32
+ sourceTone = line.tone
33
+ } else {
34
+ status = prom.data.connected ? 'Connected' : prom.data.gkeSystemMetrics ? 'GKE system metrics' : prom.data.discovering ? 'Discovering…' : 'Not connected'
35
+ detail = prom.data.connected ? !profile.url ? `Discovered: ${prom.data.address}` : undefined : prom.data.gkeSystemMetrics ? undefined : prom.data.error
36
+ const note = sourceNote(prom.data.source)
37
+ if (note) detail = detail ? `${detail} · ${note}` : note
38
+ }
28
39
  } else if (kind === 'argocd' && argo.data) {
29
40
  status = argo.data.connected ? argo.data.anonymous ? 'Connected · no token needed' : 'Connected' : argo.data.connecting ? 'Connecting…' : 'Not connected'
30
41
  detail = argo.data.reason ?? (argo.data.connected && !profile.url ? `Discovered: ${argo.data.address}` : undefined)
@@ -40,7 +51,7 @@ export function LocalIntegrationStatus({ kind, profile, argo, busy, changedAt }:
40
51
  const failed = !checking && (query.isError || configured && ['Not connected', 'Unavailable', 'No cost data'].includes(status))
41
52
  return (
42
53
  <div role="group" className="contents text-xs text-theme-text-secondary" aria-label="Current connection">
43
- <Badge severity={status.startsWith('Connected') || status.startsWith('Available') ? 'success' : failed ? 'warning' : 'neutral'}>{status}</Badge>
54
+ <Badge severity={sourceTone ?? (status.startsWith('Connected') || status.startsWith('Available') ? 'success' : failed ? 'warning' : 'neutral')}>{status}</Badge>
44
55
  <Collapse open={lastDetail.current.visible} className="basis-full min-w-0">
45
56
  <p className={`break-words text-theme-text-tertiary ${checking ? 'invisible' : ''}`}>{lastDetail.current.text}</p>
46
57
  </Collapse>