@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,88 @@
1
+ import type { NamespaceScope } from '../api/client'
2
+ import { createTabStorage } from './tabStorage'
3
+
4
+ // The namespace pick is view state owned by each tab. The server's remembered
5
+ // pick only seeds a tab that has none, so another tab or another person
6
+ // sharing the Kubernetes identity can't change what an open tab shows, on
7
+ // reload included.
8
+ //
9
+ // The tab keeps one pick per Radar address, tagged with the kubeconfig context
10
+ // it was made in. After a context switch the tab starts again from the
11
+ // server's pick for the new context.
12
+ //
13
+ // Under --namespace-scope the pick is the process-wide cache scope and stays
14
+ // server-owned. A server that doesn't report its context predates per-tab
15
+ // picks and keeps the shared behavior, since an older Radar may still apply
16
+ // its stored pick to reads that name no namespace.
17
+
18
+ const storage = createTabStorage()
19
+ // Picks whose sessionStorage write didn't stick (storage full). They win over
20
+ // the stored slot for the life of the page, so an accepted pick isn't undone
21
+ // by the next fetch; a reload then falls back to the stored one.
22
+ const unsaved = new Map<string, string>()
23
+
24
+ function slotKey(apiBase: string): string {
25
+ return `radar:namespace-pick:${apiBase}`
26
+ }
27
+
28
+ export function readTabPick(apiBase: string, context: string): string[] | undefined {
29
+ const key = slotKey(apiBase)
30
+ const raw = unsaved.get(key) ?? storage.get(key)
31
+ if (raw === undefined) return undefined
32
+ try {
33
+ const parsed: unknown = JSON.parse(raw)
34
+ if (typeof parsed !== 'object' || parsed === null || !('context' in parsed) || !('namespaces' in parsed)) return undefined
35
+ const { context: pickedIn, namespaces } = parsed
36
+ if (pickedIn !== context || !Array.isArray(namespaces)) return undefined
37
+ if (namespaces.every((ns): ns is string => typeof ns === 'string')) return namespaces
38
+ } catch { /* unreadable slot: treat as absent */ }
39
+ return undefined
40
+ }
41
+
42
+ export function writeTabPick(apiBase: string, context: string, namespaces: string[]): void {
43
+ const key = slotKey(apiBase)
44
+ const value = JSON.stringify({ context, namespaces })
45
+ storage.set(key, value)
46
+ if (storage.get(key) === value) unsaved.delete(key)
47
+ else unsaved.set(key, value)
48
+ }
49
+
50
+ /** Same cleaning the server applies to a submitted pick. */
51
+ export function cleanPick(namespaces: string[]): string[] {
52
+ return [...new Set(namespaces.filter(ns => ns !== ''))]
53
+ }
54
+
55
+ export function ownsTabPick(scope: Pick<NamespaceScope, 'cacheScoped' | 'context'>): scope is NamespaceScope & { context: string } {
56
+ return !scope.cacheScoped && !!scope.context
57
+ }
58
+
59
+ export function withActives(scope: NamespaceScope, actives: string[]): NamespaceScope {
60
+ const mode = actives.length > 0 ? 'namespace' : scope.authoritative ? 'cluster-wide' : 'restricted'
61
+ return { ...scope, actives, mode }
62
+ }
63
+
64
+ /**
65
+ * Drops picked namespaces missing from the scope's list where the server drops
66
+ * its own pick: when it says so (`accessChecked`), or on a complete non-empty
67
+ * list. After a failed lookup, or with no list at all, the pick stays.
68
+ */
69
+ export function pruneTabPick(scope: NamespaceScope, pick: string[]): string[] {
70
+ const proves = scope.accessChecked || (scope.authoritative && scope.accessibleNamespaces.length > 0)
71
+ if (!proves) return pick
72
+ const accessible = new Set(scope.accessibleNamespaces)
73
+ return pick.filter(ns => accessible.has(ns))
74
+ }
75
+
76
+ /**
77
+ * Returns the server scope as this tab sees it: its own pick when it has one
78
+ * for this context, else the server's pick, which becomes the tab's.
79
+ */
80
+ export function applyTabPick(scope: NamespaceScope, apiBase: string): NamespaceScope {
81
+ if (!ownsTabPick(scope)) return scope
82
+ const stored = readTabPick(apiBase, scope.context)
83
+ const pick = pruneTabPick(scope, stored ?? scope.actives)
84
+ if (stored === undefined || pick.length !== stored.length) {
85
+ writeTabPick(apiBase, scope.context, pick)
86
+ }
87
+ return withActives(scope, pick)
88
+ }