@skyhook-io/radar-app 1.22.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +128 -25
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { kindToPluralWithGroup } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
2
|
+
import { resourcePath } from '../../utils/navigation'
|
|
3
|
+
|
|
4
|
+
// Paths here are router-relative (no basename), the shape Radar's own links use.
|
|
5
|
+
export interface RouterLocation {
|
|
6
|
+
pathname: string
|
|
7
|
+
search: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ShareSubject {
|
|
11
|
+
kind: string
|
|
12
|
+
group?: string
|
|
13
|
+
namespace?: string
|
|
14
|
+
name: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function withSearch(pathname: string, params: URLSearchParams): string {
|
|
18
|
+
const query = params.toString()
|
|
19
|
+
return query ? `${pathname}?${query}` : pathname
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The link for a resource shown in the side drawer. On /resources the drawer is
|
|
24
|
+
* in the URL, so the address already names it and keeps the list's namespace and
|
|
25
|
+
* filters. Elsewhere (a drawer opened over Topology, a GitOps page) the drawer
|
|
26
|
+
* is not in the URL and the address names the page under it, so the link opens
|
|
27
|
+
* the resource itself.
|
|
28
|
+
*/
|
|
29
|
+
export function drawerSharePath(subject: ShareSubject, location: RouterLocation): string {
|
|
30
|
+
const params = new URLSearchParams(location.search)
|
|
31
|
+
const plural = kindToPluralWithGroup(subject.kind, subject.group ?? '')
|
|
32
|
+
const named = subject.namespace ? `${subject.namespace}/${subject.name}` : subject.name
|
|
33
|
+
if (
|
|
34
|
+
location.pathname === `/resources/${plural}` &&
|
|
35
|
+
params.get('resource') === named &&
|
|
36
|
+
(params.get('apiGroup') ?? '') === (subject.group ?? '')
|
|
37
|
+
) {
|
|
38
|
+
return withSearch(location.pathname, params)
|
|
39
|
+
}
|
|
40
|
+
return resourcePath({ kind: subject.kind, group: subject.group, namespace: subject.namespace ?? '', name: subject.name })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function issueSubjectParams(subject: ShareSubject) {
|
|
44
|
+
return {
|
|
45
|
+
kind: subject.kind,
|
|
46
|
+
apiGroup: subject.group ?? '',
|
|
47
|
+
resource: subject.namespace ? `${subject.namespace}/${subject.name}` : subject.name,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Share a workload issue with its resource identity and the current namespace selection. */
|
|
52
|
+
export function issueSharePath(issueId: string, location: RouterLocation, subject?: ShareSubject): string {
|
|
53
|
+
const current = new URLSearchParams(location.search)
|
|
54
|
+
const params = location.pathname === '/issues' ? current : new URLSearchParams()
|
|
55
|
+
const namespaces = current.get('namespaces')
|
|
56
|
+
if (namespaces) params.set('namespaces', namespaces)
|
|
57
|
+
if (subject) {
|
|
58
|
+
for (const [key, value] of Object.entries(issueSubjectParams(subject))) params.set(key, value)
|
|
59
|
+
}
|
|
60
|
+
params.set('issue', issueId)
|
|
61
|
+
return withSearch('/issues', params)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* True when the browser reached Radar on a loopback name, so a copied link opens
|
|
66
|
+
* only on this computer. This is the browser's view, not the listener's: a
|
|
67
|
+
* Radar bound to 0.0.0.0 but opened as localhost still hands out localhost links.
|
|
68
|
+
*/
|
|
69
|
+
export function isLoopbackHostname(hostname: string): boolean {
|
|
70
|
+
const host = hostname.toLowerCase().replace(/^\[|\]$/g, '')
|
|
71
|
+
if (host === 'localhost' || host.endsWith('.localhost')) return true
|
|
72
|
+
if (host === '::1' || host === '0:0:0:0:0:0:0:1') return true
|
|
73
|
+
return /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(host)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The same view in Radar Cloud. Radar Cloud mounts this app under the cluster's
|
|
78
|
+
* page (/c/<id>), so a Radar path maps onto it unchanged. Query parameters the
|
|
79
|
+
* cluster URL already carries are kept. Anything that isn't a cluster page gets
|
|
80
|
+
* no link.
|
|
81
|
+
*/
|
|
82
|
+
export function cloudViewUrl(clusterUrl: string, path: string): string | null {
|
|
83
|
+
let base: URL
|
|
84
|
+
try {
|
|
85
|
+
base = new URL(clusterUrl)
|
|
86
|
+
} catch {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
const cluster = base.pathname.match(/^\/c\/[A-Za-z0-9_-]{1,64}/)?.[0]
|
|
90
|
+
if (!cluster) return null
|
|
91
|
+
const target = new URL(path, 'http://radar.invalid')
|
|
92
|
+
const url = new URL(base.origin)
|
|
93
|
+
url.pathname = `${cluster}${target.pathname === '/' ? '' : target.pathname}`
|
|
94
|
+
const params = new URLSearchParams(base.search)
|
|
95
|
+
// ctx pins a view to the local kubeconfig context; the cluster in Radar
|
|
96
|
+
// Cloud reports its own context, and a page would refuse the local one.
|
|
97
|
+
target.searchParams.forEach((value, key) => {
|
|
98
|
+
if (key !== 'ctx') params.set(key, value)
|
|
99
|
+
})
|
|
100
|
+
url.search = params.toString()
|
|
101
|
+
return url.toString()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Hiding the Radar Cloud option is for good. When storage is blocked it still
|
|
105
|
+
// holds for as long as this page is open.
|
|
106
|
+
const HIDE_KEY = 'radar.share.cloudOption.hidden'
|
|
107
|
+
let hiddenInMemory = false
|
|
108
|
+
|
|
109
|
+
type StorageLike = Pick<Storage, 'getItem' | 'setItem'>
|
|
110
|
+
|
|
111
|
+
function defaultStorage(): StorageLike | undefined {
|
|
112
|
+
try {
|
|
113
|
+
return window.localStorage
|
|
114
|
+
} catch {
|
|
115
|
+
return undefined
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function isCloudShareHidden(storage: StorageLike | undefined = defaultStorage()): boolean {
|
|
120
|
+
if (hiddenInMemory) return true
|
|
121
|
+
try {
|
|
122
|
+
return storage?.getItem(HIDE_KEY) === 'true'
|
|
123
|
+
} catch {
|
|
124
|
+
return false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Every open share control drops the option at once, not on its next mount.
|
|
129
|
+
const listeners = new Set<() => void>()
|
|
130
|
+
|
|
131
|
+
export function subscribeCloudShareHidden(listener: () => void): () => void {
|
|
132
|
+
listeners.add(listener)
|
|
133
|
+
return () => listeners.delete(listener)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function hideCloudShare(storage: StorageLike | undefined = defaultStorage()): void {
|
|
137
|
+
hiddenInMemory = true
|
|
138
|
+
try {
|
|
139
|
+
storage?.setItem(HIDE_KEY, 'true')
|
|
140
|
+
} catch {
|
|
141
|
+
// Blocked storage: the in-memory flag above carries the choice.
|
|
142
|
+
}
|
|
143
|
+
listeners.forEach((listener) => listener())
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// The Radar Cloud option rides along with a copy only a few times, then the
|
|
147
|
+
// icon just copies. Counted per browser; held in memory when storage is blocked.
|
|
148
|
+
const SHOWN_KEY = 'radar.share.cloudOption.shown'
|
|
149
|
+
export const CLOUD_SHARE_SHOWS = 3
|
|
150
|
+
let shownInMemory: number | null = null
|
|
151
|
+
|
|
152
|
+
export function cloudShareShows(storage: StorageLike | undefined = defaultStorage()): number {
|
|
153
|
+
if (shownInMemory !== null) return shownInMemory
|
|
154
|
+
try {
|
|
155
|
+
const n = Number(storage?.getItem(SHOWN_KEY))
|
|
156
|
+
return Number.isFinite(n) && n > 0 ? n : 0
|
|
157
|
+
} catch {
|
|
158
|
+
return 0
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function noteCloudShareShown(storage: StorageLike | undefined = defaultStorage()): void {
|
|
163
|
+
const n = cloudShareShows(storage) + 1
|
|
164
|
+
shownInMemory = n
|
|
165
|
+
try {
|
|
166
|
+
storage?.setItem(SHOWN_KEY, String(n))
|
|
167
|
+
} catch {
|
|
168
|
+
// Blocked storage: the in-memory count above carries it.
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function resetCloudShareHiddenForTests(): void {
|
|
173
|
+
hiddenInMemory = false
|
|
174
|
+
shownInMemory = null
|
|
175
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { X } from 'lucide-react'
|
|
3
|
+
import { PaneLoader, ResourceDetailDrawer, Tooltip } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import { substrateErrorCode, useSubstrateActor, type SubstrateRef } from '../../api/substrateWorkspace'
|
|
5
|
+
import { RefreshFailedNotice } from '../workspace/layout'
|
|
6
|
+
import { definitiveFailure } from './readings'
|
|
7
|
+
import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
|
|
8
|
+
import { overlayExitMs } from '../../utils/animation'
|
|
9
|
+
import { actorRowResource } from './SubstrateActors'
|
|
10
|
+
import type { OpenSubject } from './SubstrateAttentionList'
|
|
11
|
+
import { ActorReadFailure } from './SubstrateActorPage'
|
|
12
|
+
import { SubstrateActorOverview } from './SubstrateActorOverview'
|
|
13
|
+
import { ActorStateBadge, Term } from './shared'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An actor's drawer: the Overview of its page, with Open full view. Actors
|
|
17
|
+
* are not Kubernetes objects, so they have this drawer rather than the
|
|
18
|
+
* resource drawer, which Kubernetes objects opened from here still use.
|
|
19
|
+
*/
|
|
20
|
+
export function SubstrateActorDrawer({
|
|
21
|
+
actor,
|
|
22
|
+
onClose,
|
|
23
|
+
onOpenFull,
|
|
24
|
+
onOpenSubject,
|
|
25
|
+
}: {
|
|
26
|
+
actor: SubstrateRef | null
|
|
27
|
+
onClose: () => void
|
|
28
|
+
onOpenFull: (actor: SubstrateRef, tab?: string) => void
|
|
29
|
+
onOpenSubject: OpenSubject
|
|
30
|
+
}) {
|
|
31
|
+
const presence = useAnimatedUnmount(!!actor, overlayExitMs('drawer'))
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!actor) return
|
|
34
|
+
const onKey = (e: KeyboardEvent) => {
|
|
35
|
+
if (e.key === 'Escape' && !e.defaultPrevented) onClose()
|
|
36
|
+
}
|
|
37
|
+
document.addEventListener('keydown', onKey)
|
|
38
|
+
return () => document.removeEventListener('keydown', onKey)
|
|
39
|
+
}, [actor, onClose])
|
|
40
|
+
if (!presence.shouldRender || !actor) return null
|
|
41
|
+
// The resource drawer's frame (position, width, resizing), with an actor's content.
|
|
42
|
+
return (
|
|
43
|
+
<ResourceDetailDrawer resource={actorRowResource(actor)} isOpen={presence.isOpen} onClose={onClose}>
|
|
44
|
+
{() => <ActorDrawerBody key={`${actor.atespace}/${actor.name}`} actor={actor} onClose={onClose} onOpenFull={onOpenFull} onOpenSubject={onOpenSubject} />}
|
|
45
|
+
</ResourceDetailDrawer>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function ActorDrawerBody({ actor, onClose, onOpenFull, onOpenSubject }: { actor: SubstrateRef; onClose: () => void; onOpenFull: (actor: SubstrateRef, tab?: string) => void; onOpenSubject: OpenSubject }) {
|
|
50
|
+
const query = useSubstrateActor(actor)
|
|
51
|
+
const detail = definitiveFailure(substrateErrorCode(query.error)) ? undefined : query.data
|
|
52
|
+
return (
|
|
53
|
+
<div role="dialog" aria-label={`Actor ${actor.name}`} className="flex min-h-0 flex-1 flex-col">
|
|
54
|
+
<div className="flex shrink-0 items-start gap-3 border-b border-theme-border px-4 py-3">
|
|
55
|
+
<div className="min-w-0 flex-1">
|
|
56
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
57
|
+
{detail && <ActorStateBadge state={detail.actor.state} impact={detail.row.workerImpact} updateTime={detail.actor.updateTime} />}
|
|
58
|
+
</div>
|
|
59
|
+
<h2 className="mt-1 truncate font-mono text-base font-semibold text-theme-text-primary">{actor.name}</h2>
|
|
60
|
+
<div className="text-xs text-theme-text-tertiary"><Term term="atespace">Atespace</Term>: <span className="font-mono">{actor.atespace}</span></div>
|
|
61
|
+
</div>
|
|
62
|
+
<Tooltip content="Close (Esc)" delay={150} position="bottom">
|
|
63
|
+
<button type="button" aria-label="Close" onClick={onClose} className="rounded-lg p-1.5 text-theme-text-secondary hover:bg-theme-elevated hover:text-theme-text-primary">
|
|
64
|
+
<X className="h-4 w-4" />
|
|
65
|
+
</button>
|
|
66
|
+
</Tooltip>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="min-h-0 flex-1 overflow-y-auto px-4 py-4">
|
|
69
|
+
<RefreshFailedNotice queries={[query]} className="mb-3" />
|
|
70
|
+
{!detail && query.isLoading ? (
|
|
71
|
+
<PaneLoader label={`Loading ${actor.name}…`} />
|
|
72
|
+
) : !detail ? (
|
|
73
|
+
<ActorReadFailure actor={actor} error={query.error} onBack={onClose} backLabel="Close" />
|
|
74
|
+
) : (
|
|
75
|
+
<SubstrateActorOverview detail={detail} framed={false} onOpenSubject={onOpenSubject}
|
|
76
|
+
onShowLogs={() => onOpenFull(actor, 'logs')} onShowSnapshots={() => onOpenFull(actor, 'snapshots')} onShowEgress={() => onOpenFull(actor, 'egress')}
|
|
77
|
+
actions={<div className="flex flex-wrap gap-2">
|
|
78
|
+
<button type="button" className="btn-brand px-3 py-1 text-sm" onClick={() => onOpenFull(actor)}>Open actor</button>
|
|
79
|
+
<button type="button" className="btn-secondary px-3 py-1 text-sm" onClick={() => onOpenFull(actor, 'snapshots')}>Snapshots</button>
|
|
80
|
+
<button type="button" className="btn-secondary px-3 py-1 text-sm" onClick={() => onOpenFull(actor, 'logs')}>Logs</button>
|
|
81
|
+
</div>}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|