@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,65 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { SeeTrafficLink, liveTrafficSearch } from './traffic'
|
|
7
|
+
|
|
8
|
+
const traffic = vi.hoisted(() => ({ available: true }))
|
|
9
|
+
vi.mock('../../api/traffic', () => ({ useTrafficAvailable: (enabled = true) => enabled && traffic.available }))
|
|
10
|
+
|
|
11
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
12
|
+
|
|
13
|
+
let container: HTMLDivElement
|
|
14
|
+
let root: Root
|
|
15
|
+
function Where() {
|
|
16
|
+
const location = useLocation()
|
|
17
|
+
return <output data-testid="location">{location.pathname + location.search}</output>
|
|
18
|
+
}
|
|
19
|
+
const at = () => container.querySelector('[data-testid="location"]')!.textContent
|
|
20
|
+
|
|
21
|
+
function render(kind: string, container_?: string) {
|
|
22
|
+
act(() => root.render(
|
|
23
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=workload&namespaces=shop']}>
|
|
24
|
+
<Routes><Route path="*" element={<><Where /><SeeTrafficLink workload={{ kind, group: 'apps', namespace: 'shop', name: 'web', container: container_ }} /></>} /></Routes>
|
|
25
|
+
</MemoryRouter>,
|
|
26
|
+
))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
traffic.available = true
|
|
31
|
+
container = document.createElement('div')
|
|
32
|
+
document.body.appendChild(container)
|
|
33
|
+
root = createRoot(container)
|
|
34
|
+
})
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
act(() => root.unmount())
|
|
37
|
+
container.remove()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
describe('See traffic', () => {
|
|
41
|
+
it('opens Live Traffic focused on the workload, keeping the namespace scope', () => {
|
|
42
|
+
render('Deployment')
|
|
43
|
+
const link = container.querySelector('button')!
|
|
44
|
+
expect(link.textContent).toBe('See traffic')
|
|
45
|
+
act(() => link.click())
|
|
46
|
+
expect(at()).toBe('/traffic?namespaces=shop&focus=shop%2Fweb')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('is not offered without an available traffic source', () => {
|
|
50
|
+
traffic.available = false
|
|
51
|
+
render('Deployment')
|
|
52
|
+
expect(container.querySelector('button')).toBeNull()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('is not offered for a kind the map does not draw as one node, or for a container', () => {
|
|
56
|
+
render('Job')
|
|
57
|
+
expect(container.querySelector('button')).toBeNull()
|
|
58
|
+
render('Deployment', 'app')
|
|
59
|
+
expect(container.querySelector('button')).toBeNull()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('builds the focus without a scope when the page has none', () => {
|
|
63
|
+
expect(liveTrafficSearch({ kind: 'Deployment', group: 'apps', namespace: 'a', name: 'b' }, null)).toBe('focus=a%2Fb')
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useNavigate, useSearchParams } from 'react-router-dom'
|
|
2
|
+
import { useTrafficAvailable } from '../../api/traffic'
|
|
3
|
+
import type { VulnerabilityWorkloadRef } from '../../api/vulnerabilities'
|
|
4
|
+
|
|
5
|
+
// The kinds Live Traffic draws as one node, so a focus on one of them finds
|
|
6
|
+
// it. A Job is left out: the map groups a controlled Job's pods under its
|
|
7
|
+
// owner, and the row can't tell whether something controls it.
|
|
8
|
+
const TRAFFIC_KINDS = new Set(['Deployment', 'StatefulSet', 'DaemonSet', 'CronJob', 'Rollout'])
|
|
9
|
+
|
|
10
|
+
export function liveTrafficSearch(w: VulnerabilityWorkloadRef, namespaces: string | null): string {
|
|
11
|
+
const params = new URLSearchParams()
|
|
12
|
+
if (namespaces) params.set('namespaces', namespaces)
|
|
13
|
+
params.set('focus', `${w.namespace}/${w.name}`)
|
|
14
|
+
return params.toString()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* "See traffic": opens Live Traffic focused on an exposed workload. Offered
|
|
19
|
+
* only once a traffic source is known to be available, so the page never
|
|
20
|
+
* links to an empty map. It makes no claim about who reached the workload.
|
|
21
|
+
*/
|
|
22
|
+
export function SeeTrafficLink({ workload }: { workload: VulnerabilityWorkloadRef }) {
|
|
23
|
+
const offered = TRAFFIC_KINDS.has(workload.kind) && !workload.container
|
|
24
|
+
const available = useTrafficAvailable(offered)
|
|
25
|
+
const navigate = useNavigate()
|
|
26
|
+
const [searchParams] = useSearchParams()
|
|
27
|
+
if (!offered || !available) return null
|
|
28
|
+
return (
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
onClick={(e) => {
|
|
32
|
+
e.stopPropagation()
|
|
33
|
+
navigate({ pathname: '/traffic', search: liveTrafficSearch(workload, searchParams.get('namespaces')) })
|
|
34
|
+
}}
|
|
35
|
+
className="text-accent-text hover:underline"
|
|
36
|
+
>
|
|
37
|
+
See traffic
|
|
38
|
+
</button>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { onlineManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { DockProvider, ToastProvider } from '@skyhook-io/k8s-ui'
|
|
7
|
+
import { expect, it, vi } from 'vitest'
|
|
8
|
+
import { getApiBase } from '../../api/config'
|
|
9
|
+
import { ConnectionProvider } from '../../context/ConnectionContext'
|
|
10
|
+
import { KeyboardShortcutProvider } from '../../hooks/useKeyboardShortcuts'
|
|
11
|
+
import { NavCustomizationProvider } from '../../context/NavCustomization'
|
|
12
|
+
import { WorkloadView } from './WorkloadView'
|
|
13
|
+
|
|
14
|
+
vi.mock('../logs/LogsViewer', () => ({ LogsViewer: () => <div>Pod logs</div> }))
|
|
15
|
+
|
|
16
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
17
|
+
|
|
18
|
+
const pool = {
|
|
19
|
+
apiVersion: 'ate.dev/v1alpha1',
|
|
20
|
+
kind: 'WorkerPool',
|
|
21
|
+
metadata: { namespace: 'agents', name: 'pool' },
|
|
22
|
+
}
|
|
23
|
+
const pod = {
|
|
24
|
+
apiVersion: 'v1',
|
|
25
|
+
kind: 'Pod',
|
|
26
|
+
metadata: { namespace: 'agents', name: 'worker', labels: { 'ate.dev/worker-pool': 'pool' } },
|
|
27
|
+
spec: { containers: [{ name: 'worker' }] },
|
|
28
|
+
status: { phase: 'Succeeded' },
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
it.each([false, true])('renders worker resources for a Radar advertising substrateWorkspace=%s', async (workspace) => {
|
|
32
|
+
const client = new QueryClient()
|
|
33
|
+
client.setQueryData(['capabilities'], { features: {
|
|
34
|
+
substrateHealthMetrics: true,
|
|
35
|
+
...(workspace ? { substrateWorkspace: true } : {}),
|
|
36
|
+
} })
|
|
37
|
+
client.setQueryData(['prometheus-status'], { connected: true })
|
|
38
|
+
client.setQueryData(['substrate-health', getApiBase(), undefined, 'workerpool', 'agents', 'pool', '1h'], {
|
|
39
|
+
status: 'available', verdict: { state: 'freeActorSlots', facts: [] }, charts: [],
|
|
40
|
+
})
|
|
41
|
+
client.setQueryData(['resource', 'workerpools', 'agents', 'pool', 'ate.dev'], { resource: pool })
|
|
42
|
+
client.setQueryData(['resource', 'pods', 'agents', 'worker', undefined], {
|
|
43
|
+
resource: pod,
|
|
44
|
+
relationships: { pods: [{ kind: 'Pod', namespace: 'agents', name: 'worker' }] },
|
|
45
|
+
})
|
|
46
|
+
const host = document.createElement('div')
|
|
47
|
+
const root = createRoot(host)
|
|
48
|
+
const wasOnline = onlineManager.isOnline()
|
|
49
|
+
onlineManager.setOnline(false)
|
|
50
|
+
|
|
51
|
+
async function render(kind: 'workerpools' | 'pods', tab: 'detail' | 'metrics' | 'logs') {
|
|
52
|
+
const group = kind === 'workerpools' ? 'ate.dev' : undefined
|
|
53
|
+
const name = kind === 'workerpools' ? 'pool' : 'worker'
|
|
54
|
+
const path = `/workload/${kind}/agents/${name}${tab === 'detail' ? '' : `?tab=${tab}`}`
|
|
55
|
+
await act(async () => root.render(
|
|
56
|
+
<QueryClientProvider client={client}>
|
|
57
|
+
<MemoryRouter key={path} initialEntries={[path]}>
|
|
58
|
+
<NavCustomizationProvider value={{ embedded: true }}>
|
|
59
|
+
<ConnectionProvider><ToastProvider><DockProvider><KeyboardShortcutProvider>
|
|
60
|
+
<WorkloadView kind={kind} group={group} namespace="agents" name={name} expanded onBack={() => {}} />
|
|
61
|
+
</KeyboardShortcutProvider></DockProvider></ToastProvider></ConnectionProvider>
|
|
62
|
+
</NavCustomizationProvider>
|
|
63
|
+
</MemoryRouter>
|
|
64
|
+
</QueryClientProvider>,
|
|
65
|
+
))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
await render('workerpools', 'detail')
|
|
70
|
+
expect(Boolean(host.querySelector('[aria-label="Agent Substrate capacity"]'))).toBe(!workspace)
|
|
71
|
+
expect(host.textContent?.includes('Placement capacity')).toBe(workspace)
|
|
72
|
+
|
|
73
|
+
await render('pods', 'detail')
|
|
74
|
+
expect(host.textContent?.includes('Pod logs, metrics and restarts cover the shared worker process.')).toBe(workspace)
|
|
75
|
+
expect(host.textContent?.includes('Substrate places actors on this Pod in turn')).toBe(!workspace)
|
|
76
|
+
|
|
77
|
+
for (const tab of ['metrics', 'logs'] as const) {
|
|
78
|
+
await render('pods', tab)
|
|
79
|
+
expect(host.querySelector('[role="tab"][aria-selected="true"]')?.textContent?.toLowerCase()).toBe(tab)
|
|
80
|
+
expect(host.textContent?.includes(`These ${tab} cover the shared worker Pod`)).toBe(workspace)
|
|
81
|
+
expect(host.textContent?.includes('View assigned actors')).toBe(workspace)
|
|
82
|
+
}
|
|
83
|
+
} finally {
|
|
84
|
+
act(() => root.unmount())
|
|
85
|
+
client.clear()
|
|
86
|
+
onlineManager.setOnline(wasOnline)
|
|
87
|
+
}
|
|
88
|
+
})
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { podDebugAccessKey } from '../../api/podDebug'
|
|
2
|
+
import { SUBSTRATE_WORKER_POOL_LABEL } from '@skyhook-io/k8s-ui/components/resources/resource-utils-agent-runtimes'
|
|
3
|
+
import { SubstrateWorkerPodScope } from '../substrate/SubstrateWorkerPodContext'
|
|
4
|
+
import { PoolSpecStatus } from '../substrate/SubstratePoolSummary'
|
|
2
5
|
import { supportsWorkloadRevisions, WorkloadRevisionsButton } from './WorkloadRevisionsButton'
|
|
3
6
|
import { RelatedFindingsSection } from './RelatedFindingsSection'
|
|
4
7
|
import { decorateResourceDiagnose, resourceDetailRedirect, resourceDetailSlots, resourceIssueDetail, resourceLogs, resourceRendererOverrides } from '../../integrations/resourceHosts'
|
|
@@ -10,6 +13,7 @@ import { workloadPodAwaitsScheduling } from '../capacity/podDemandGate'
|
|
|
10
13
|
import { Stethoscope } from 'lucide-react'
|
|
11
14
|
import {
|
|
12
15
|
WorkloadView as BaseWorkloadView,
|
|
16
|
+
WorkloadSourceSection,
|
|
13
17
|
EditableYamlView,
|
|
14
18
|
FetchResult,
|
|
15
19
|
Section,
|
|
@@ -120,6 +124,12 @@ import { WorkloadCostTab } from '../cost/WorkloadCostTab'
|
|
|
120
124
|
import { isOpenCostWorkloadKind } from '../cost/kinds'
|
|
121
125
|
import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
|
|
122
126
|
import { useResourceActionAdapter } from '../../api/resourceActions'
|
|
127
|
+
import { getApiBase } from '../../api/config'
|
|
128
|
+
import {
|
|
129
|
+
supportsWorkloadSource,
|
|
130
|
+
toWorkloadSourceState,
|
|
131
|
+
useWorkloadSource,
|
|
132
|
+
} from '../../api/workloadSource'
|
|
123
133
|
import { useTrafficAvailable } from '../../api/traffic'
|
|
124
134
|
import { useIssueExpansion, useIssueRowNotes } from '../issues/useIssueExpansion'
|
|
125
135
|
import { isNotFoundError, useResourceAudit, useResourceIssues, useSubjectIssues, useRadarFeature, useTrace, fetchTraceWithProbes, fetchInClusterCapability, runInClusterMerged } from '../../api/client'
|
|
@@ -157,6 +167,8 @@ import { useDesktopDownload } from '../../hooks/useDesktopDownload'
|
|
|
157
167
|
import { useCompareLauncher } from '../compare/useCompareLauncher'
|
|
158
168
|
import { useDiagnoseCustomization } from '../../context/DiagnoseCustomization'
|
|
159
169
|
import { NodeDrainStatus } from './NodeDrainStatus'
|
|
170
|
+
import { ShareLinkButton } from '../share/ShareLinkButton'
|
|
171
|
+
import { drawerSharePath } from '../share/shareLink'
|
|
160
172
|
import { SubstrateHealthCharts } from '../resource/SubstrateHealthCharts'
|
|
161
173
|
import { SubstrateVerdictLine } from '../resource/SubstrateVerdictLine'
|
|
162
174
|
import { useAPIResources } from '../../api/apiResources'
|
|
@@ -212,6 +224,8 @@ interface WorkloadViewRouteProps {
|
|
|
212
224
|
}
|
|
213
225
|
|
|
214
226
|
export function WorkloadViewRoute({ onNavigateToResource }: WorkloadViewRouteProps) {
|
|
227
|
+
const { support: substrateWorkspace } = useRadarFeature('substrateWorkspace')
|
|
228
|
+
const { support: kagentWorkspace } = useRadarFeature('kagentWorkspace')
|
|
215
229
|
const location = useLocation()
|
|
216
230
|
const navigate = useNavigate()
|
|
217
231
|
const [searchParams] = useSearchParams()
|
|
@@ -271,7 +285,7 @@ export function WorkloadViewRoute({ onNavigateToResource }: WorkloadViewRoutePro
|
|
|
271
285
|
)
|
|
272
286
|
}
|
|
273
287
|
|
|
274
|
-
const detailPath = resourceDetailRedirect({ kind, group, namespace, name }, searchParams)
|
|
288
|
+
const detailPath = resourceDetailRedirect({ kind, group, namespace, name }, searchParams, { substrateWorkspace, kagentWorkspace })
|
|
275
289
|
if (detailPath) return <Navigate replace to={detailPath} state={location.state} />
|
|
276
290
|
|
|
277
291
|
return (
|
|
@@ -315,6 +329,9 @@ interface WorkloadViewProps {
|
|
|
315
329
|
pushTabHistory?: boolean
|
|
316
330
|
breadcrumb?: ReactNode
|
|
317
331
|
extraTabs?: WorkloadExtraTab[]
|
|
332
|
+
/** Shown at the top of the Overview tab, after operational issues (an
|
|
333
|
+
* application's Environments panel). */
|
|
334
|
+
overviewLead?: ReactNode
|
|
318
335
|
tabOrder?: string[]
|
|
319
336
|
subheader?: ReactNode
|
|
320
337
|
specTab?: { label?: string; icon?: ReactNode; lead?: ReactNode; render?: () => ReactNode }
|
|
@@ -326,6 +343,9 @@ interface WorkloadViewProps {
|
|
|
326
343
|
onRefresh?: () => Promise<unknown>
|
|
327
344
|
hideKindBadge?: boolean
|
|
328
345
|
truncateName?: boolean
|
|
346
|
+
/** 'page' (default): the address names this resource, so Copy link copies it.
|
|
347
|
+
* 'drawer': the resource drawer, which is in the address only on /resources. */
|
|
348
|
+
shareLink?: 'page' | 'drawer'
|
|
329
349
|
}
|
|
330
350
|
|
|
331
351
|
interface ImageTargetOwnershipContext {
|
|
@@ -613,10 +633,16 @@ export function WorkloadView({
|
|
|
613
633
|
name,
|
|
614
634
|
expanded = true,
|
|
615
635
|
pushTabHistory = false,
|
|
636
|
+
overviewLead,
|
|
637
|
+
shareLink = 'page',
|
|
616
638
|
...rest
|
|
617
639
|
}: WorkloadViewProps) {
|
|
618
640
|
const [searchParams, setSearchParams] = useSearchParams()
|
|
619
641
|
const location = useLocation()
|
|
642
|
+
const sharePath =
|
|
643
|
+
shareLink === 'drawer'
|
|
644
|
+
? drawerSharePath({ kind: kindProp, group: rest.group, namespace, name }, location)
|
|
645
|
+
: `${location.pathname}${location.search}`
|
|
620
646
|
const viewNamespacesKey = namespacesFromSearch(searchParams).join(',')
|
|
621
647
|
const viewNamespaces = useMemo(() => (viewNamespacesKey ? viewNamespacesKey.split(',') : []), [viewNamespacesKey])
|
|
622
648
|
const apiKind = kindToPluralWithGroup(kindProp, rest.group ?? '')
|
|
@@ -707,6 +733,8 @@ export function WorkloadView({
|
|
|
707
733
|
// '' whenever a link left ?apiGroup out.
|
|
708
734
|
const identityGroup = resource?.apiVersion ? resourceGroup : effectiveGroup
|
|
709
735
|
const isNode = apiKind === 'nodes' && !effectiveGroup
|
|
736
|
+
const { support: substrateWorkspace } = useRadarFeature('substrateWorkspace')
|
|
737
|
+
const substratePodPool = apiKind === 'pods' && substrateWorkspace !== 'unsupported' ? resource?.metadata?.labels?.[SUBSTRATE_WORKER_POOL_LABEL] : undefined
|
|
710
738
|
const isSubstrateWorkerPool = apiKind === 'workerpools' && effectiveGroup === SUBSTRATE_GROUP
|
|
711
739
|
// Substrate's node charts are asked of Prometheus only on a cluster that serves it.
|
|
712
740
|
const { data: apiResources } = useAPIResources()
|
|
@@ -753,6 +781,10 @@ export function WorkloadView({
|
|
|
753
781
|
queryKey: ['workload-pods', apiKind, namespace, name],
|
|
754
782
|
...(apiKind === 'rayclusters' ? { type: 'active' as const } : {}),
|
|
755
783
|
}),
|
|
784
|
+
queryClient.refetchQueries({
|
|
785
|
+
queryKey: ['workload-source', getApiBase(), apiKind.toLowerCase(), namespace, name],
|
|
786
|
+
type: 'active',
|
|
787
|
+
}),
|
|
756
788
|
])
|
|
757
789
|
}, [apiKind, effectiveGroup, name, namespace, queryClient, refetchResource, resource?.metadata?.uid, resource?.spec?.clusterSelector, onRefresh])
|
|
758
790
|
const podWorkloadOwner = useMemo(
|
|
@@ -867,6 +899,7 @@ export function WorkloadView({
|
|
|
867
899
|
// RBAC
|
|
868
900
|
const canUpdateSecrets = useCanUpdateSecrets()
|
|
869
901
|
const { features, karpenter } = useCapabilitiesContext()
|
|
902
|
+
const { support: kagentWorkspace } = useRadarFeature('kagentWorkspace')
|
|
870
903
|
const { canPortForward } = useNamespacedCapabilities(namespace)
|
|
871
904
|
const isLocalDeployment = useIsLocalDeployment()
|
|
872
905
|
const showServingPortForward = canPortForward || !isLocalDeployment
|
|
@@ -1289,8 +1322,52 @@ export function WorkloadView({
|
|
|
1289
1322
|
[],
|
|
1290
1323
|
)
|
|
1291
1324
|
|
|
1325
|
+
const drawerScopeKey = `${apiKind}|${namespace}|${name}|${rest.initialTab ?? 'detail'}`
|
|
1326
|
+
const [drawerViewState, setDrawerViewState] = useState<{
|
|
1327
|
+
scope: string
|
|
1328
|
+
view: 'overview' | 'yaml' | 'spec'
|
|
1329
|
+
}>(() => ({
|
|
1330
|
+
scope: drawerScopeKey,
|
|
1331
|
+
view: rest.initialTab === 'yaml' ? 'yaml' : 'overview',
|
|
1332
|
+
}))
|
|
1333
|
+
const drawerView: 'overview' | 'yaml' | 'spec' =
|
|
1334
|
+
drawerViewState.scope === drawerScopeKey
|
|
1335
|
+
? drawerViewState.view
|
|
1336
|
+
: rest.initialTab === 'yaml'
|
|
1337
|
+
? 'yaml'
|
|
1338
|
+
: 'overview'
|
|
1339
|
+
const handleDrawerViewChange = useCallback(
|
|
1340
|
+
(view: 'overview' | 'yaml' | 'spec') => {
|
|
1341
|
+
setDrawerViewState({ scope: drawerScopeKey, view })
|
|
1342
|
+
},
|
|
1343
|
+
[drawerScopeKey],
|
|
1344
|
+
)
|
|
1345
|
+
|
|
1292
1346
|
const supportsWorkloadPods = ['deployments', 'statefulsets', 'daemonsets', 'rollouts'].includes(apiKind)
|
|
1293
1347
|
const workloadPodsQuery = useWorkloadPods(supportsWorkloadPods ? apiKind : '', namespace, name)
|
|
1348
|
+
const workloadSourceSupported = Boolean(namespace) && supportsWorkloadSource(apiKind, effectiveGroup)
|
|
1349
|
+
const workloadSourceVisible = expanded ? migratedTab === 'overview' : drawerView === 'overview'
|
|
1350
|
+
const workloadSourceEnabled =
|
|
1351
|
+
workloadSourceSupported &&
|
|
1352
|
+
Boolean(resource) &&
|
|
1353
|
+
rest.active !== false &&
|
|
1354
|
+
!isNotFoundError(resourceError) &&
|
|
1355
|
+
workloadSourceVisible
|
|
1356
|
+
const workloadSourceUid =
|
|
1357
|
+
typeof resource?.metadata?.uid === 'string' && resource.metadata.uid ? resource.metadata.uid : undefined
|
|
1358
|
+
const workloadSourceQuery = useWorkloadSource(
|
|
1359
|
+
apiKind,
|
|
1360
|
+
namespace,
|
|
1361
|
+
name,
|
|
1362
|
+
workloadSourceEnabled,
|
|
1363
|
+
workloadSourceUid,
|
|
1364
|
+
)
|
|
1365
|
+
const workloadSource =
|
|
1366
|
+
workloadSourceSupported &&
|
|
1367
|
+
!isNotFoundError(resourceError) &&
|
|
1368
|
+
(workloadSourceEnabled || workloadSourceQuery.data || workloadSourceQuery.cachedData)
|
|
1369
|
+
? toWorkloadSourceState(workloadSourceQuery)
|
|
1370
|
+
: undefined
|
|
1294
1371
|
const workloadAwaitsCapacity =
|
|
1295
1372
|
karpenter?.state === 'available' &&
|
|
1296
1373
|
(workloadPodsQuery.data?.pods ?? []).some(workloadPodAwaitsScheduling)
|
|
@@ -1328,6 +1405,7 @@ export function WorkloadView({
|
|
|
1328
1405
|
[servingRefs, servingQueries],
|
|
1329
1406
|
)
|
|
1330
1407
|
|
|
1408
|
+
const detailSlots = resourceDetailSlots({ kind: apiKind, group: identityGroup, namespace, name }, rest.extraTabs, { substrateWorkspace, kagentWorkspace })
|
|
1331
1409
|
return (
|
|
1332
1410
|
<>
|
|
1333
1411
|
<BaseWorkloadView
|
|
@@ -1336,6 +1414,9 @@ export function WorkloadView({
|
|
|
1336
1414
|
name={name}
|
|
1337
1415
|
expanded={expanded}
|
|
1338
1416
|
{...rest}
|
|
1417
|
+
renderShareAction={() => (
|
|
1418
|
+
<ShareLinkButton path={sharePath} subject={{ kind: resource?.kind ?? pluralToKind(apiKind), group: effectiveGroup, namespace, name }} />
|
|
1419
|
+
)}
|
|
1339
1420
|
group={effectiveGroup}
|
|
1340
1421
|
// Data
|
|
1341
1422
|
resource={resource}
|
|
@@ -1356,6 +1437,7 @@ export function WorkloadView({
|
|
|
1356
1437
|
}
|
|
1357
1438
|
workloadPodsLoading={supportsWorkloadPods ? workloadPodsQuery.isLoading : false}
|
|
1358
1439
|
workloadPodsError={supportsWorkloadPods ? (workloadPodsQuery.error as Error | null) : null}
|
|
1440
|
+
workloadSource={workloadSource}
|
|
1359
1441
|
servingResources={servingResources}
|
|
1360
1442
|
renderServicePortAction={renderServicePortAction}
|
|
1361
1443
|
renderServicePortPanel={renderServicePortPanel}
|
|
@@ -1398,6 +1480,7 @@ export function WorkloadView({
|
|
|
1398
1480
|
activeTab={migratedTab}
|
|
1399
1481
|
extraTabsComplete={migratedTab === 'deploys' ? true : undefined}
|
|
1400
1482
|
onTabChange={handleTabChange}
|
|
1483
|
+
onDrawerViewChange={handleDrawerViewChange}
|
|
1401
1484
|
// Render props
|
|
1402
1485
|
renderLogsTab={(props) => (
|
|
1403
1486
|
<LogsTabContent
|
|
@@ -1411,7 +1494,8 @@ export function WorkloadView({
|
|
|
1411
1494
|
viewNamespaces={viewNamespaces}
|
|
1412
1495
|
/>
|
|
1413
1496
|
)}
|
|
1414
|
-
{...
|
|
1497
|
+
{...detailSlots}
|
|
1498
|
+
breadcrumb={rest.breadcrumb ?? detailSlots.breadcrumb}
|
|
1415
1499
|
onSelectTopologyMember={batchExecution && batchKind === 'JobSet' ? handleSelectTopologyMember : undefined}
|
|
1416
1500
|
renderExpandedOverview={({ kind: k, apiKind, namespace: ns, name: n, resource: res, leadContent }) =>
|
|
1417
1501
|
supportsBatchExecution(k, apiKind, effectiveGroup, res?.apiVersion) &&
|
|
@@ -1423,7 +1507,16 @@ export function WorkloadView({
|
|
|
1423
1507
|
name={n}
|
|
1424
1508
|
resource={res}
|
|
1425
1509
|
selectedRunKey={selectedRunKey}
|
|
1426
|
-
leadContent={
|
|
1510
|
+
leadContent={
|
|
1511
|
+
workloadSource ? (
|
|
1512
|
+
<>
|
|
1513
|
+
{leadContent}
|
|
1514
|
+
<WorkloadSourceSection state={workloadSource} variant="card" />
|
|
1515
|
+
</>
|
|
1516
|
+
) : (
|
|
1517
|
+
leadContent
|
|
1518
|
+
)
|
|
1519
|
+
}
|
|
1427
1520
|
canViewLogs={baseActionsBarProps.canViewLogs}
|
|
1428
1521
|
onSelectRun={handleSelectedRunChange}
|
|
1429
1522
|
onSwitchToLogs={() => handleTabChange('logs')}
|
|
@@ -1443,6 +1536,11 @@ export function WorkloadView({
|
|
|
1443
1536
|
collapsible={!expanded}
|
|
1444
1537
|
workerPods={typeof resource?.status?.replicas === 'number' ? resource.status.replicas : undefined}
|
|
1445
1538
|
/>
|
|
1539
|
+
) : substratePodPool ? (
|
|
1540
|
+
<div className="flex h-full min-h-0 flex-col gap-2">
|
|
1541
|
+
<SubstrateWorkerPodScope namespace={ns} pool={substratePodPool} pod={n} tab="metrics" />
|
|
1542
|
+
<div className="min-h-0 flex-1 overflow-auto"><MetricsTabContent kind={kind} namespace={ns} name={n} resource={resource} expanded={expanded} /></div>
|
|
1543
|
+
</div>
|
|
1446
1544
|
) : (
|
|
1447
1545
|
<>
|
|
1448
1546
|
<MetricsTabContent
|
|
@@ -1491,7 +1589,8 @@ export function WorkloadView({
|
|
|
1491
1589
|
onDownload={desktopDownload}
|
|
1492
1590
|
actionsBarProps={actionsBarProps}
|
|
1493
1591
|
rendererOverrides={resourceRendererOverrides}
|
|
1494
|
-
|
|
1592
|
+
specTab={isSubstrateWorkerPool && resource ? { render: () => <PoolSpecStatus resource={resource} onNavigate={rest.onNavigateToResource} /> } : rest.specTab}
|
|
1593
|
+
renderOverviewIntro={isSubstrateWorkerPool && substrateWorkspace === 'unsupported'
|
|
1495
1594
|
? ({ namespace: ns, name: n }) => <SubstrateVerdictLine target={{ kind: 'workerpool', namespace: ns, name: n }} onOpenMetrics={expanded ? () => handleTabChange('metrics') : undefined} />
|
|
1496
1595
|
: isNode && resource?.metadata?.uid
|
|
1497
1596
|
? () => (
|
|
@@ -1557,9 +1656,10 @@ export function WorkloadView({
|
|
|
1557
1656
|
rowChanges={issueRowNotes.rowChanges}
|
|
1558
1657
|
onVisibleIssuesChange={issueRowNotes.onVisibleIssuesChange}
|
|
1559
1658
|
/>
|
|
1659
|
+
{overviewLead}
|
|
1560
1660
|
</div>
|
|
1561
1661
|
)}
|
|
1562
|
-
hasOverviewLead={hasOperationalIssues || Boolean(schedulingEvidence && schedulingEvidence.state !== 'reported') || nodeCertificateContextVisible(certificateEvidence, hasCertificateIssue)}
|
|
1662
|
+
hasOverviewLead={Boolean(overviewLead) || hasOperationalIssues || Boolean(schedulingEvidence && schedulingEvidence.state !== 'reported') || nodeCertificateContextVisible(certificateEvidence, hasCertificateIssue)}
|
|
1563
1663
|
hasOperationalIssues={hasOperationalIssues}
|
|
1564
1664
|
operationalIssuesPending={issuesPending}
|
|
1565
1665
|
// A manager answer's chip links only managers the server found; a
|
|
@@ -1860,16 +1960,21 @@ function PodLogsTab({
|
|
|
1860
1960
|
}
|
|
1861
1961
|
}, [initialContainer, containers, onConsumeInitialContainer])
|
|
1862
1962
|
|
|
1963
|
+
const { support: substrateWorkspace } = useRadarFeature('substrateWorkspace')
|
|
1964
|
+
const pool = resource?.metadata?.labels?.[SUBSTRATE_WORKER_POOL_LABEL]
|
|
1863
1965
|
return (
|
|
1864
|
-
<div className="h-full">
|
|
1865
|
-
<
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1966
|
+
<div className="flex h-full min-h-0 flex-col">
|
|
1967
|
+
{pool && substrateWorkspace !== 'unsupported' && <div className="border-b-subtle px-4 py-2"><SubstrateWorkerPodScope namespace={namespace} pool={pool} pod={name} tab="logs" /></div>}
|
|
1968
|
+
<div className="min-h-0 flex-1">
|
|
1969
|
+
<LogsViewer
|
|
1970
|
+
namespace={namespace}
|
|
1971
|
+
podName={name}
|
|
1972
|
+
containers={containers}
|
|
1973
|
+
initialContainer={initialContainer || getDefaultLogContainerName(resource)}
|
|
1974
|
+
initContainers={initContainers}
|
|
1975
|
+
autoStream={autoStream}
|
|
1976
|
+
/>
|
|
1977
|
+
</div>
|
|
1873
1978
|
</div>
|
|
1874
1979
|
)
|
|
1875
1980
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 { onlineManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { DockProvider, ToastProvider } from '@skyhook-io/k8s-ui'
|
|
7
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
8
|
+
import * as workloadSourceApi from '../../api/workloadSource'
|
|
9
|
+
import { WorkloadView } from './WorkloadView'
|
|
10
|
+
|
|
11
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
12
|
+
|
|
13
|
+
const DEPLOYMENT = {
|
|
14
|
+
apiVersion: 'apps/v1',
|
|
15
|
+
kind: 'Deployment',
|
|
16
|
+
metadata: { namespace: 'shop', name: 'web', uid: 'uid-web-1' },
|
|
17
|
+
spec: {
|
|
18
|
+
replicas: 1,
|
|
19
|
+
template: { spec: { containers: [{ name: 'web', image: 'ghcr.io/skyhook-io/web:v1' }] } },
|
|
20
|
+
},
|
|
21
|
+
status: { readyReplicas: 1, replicas: 1 },
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('WorkloadView workloadSource query gating', () => {
|
|
25
|
+
let host: HTMLDivElement
|
|
26
|
+
let root: ReturnType<typeof createRoot>
|
|
27
|
+
let client: QueryClient
|
|
28
|
+
let wasOnline: boolean
|
|
29
|
+
let hookSpy: ReturnType<typeof vi.spyOn>
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
host = document.createElement('div')
|
|
33
|
+
document.body.appendChild(host)
|
|
34
|
+
root = createRoot(host)
|
|
35
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
36
|
+
client.setQueryData(['resource', 'deployments', 'shop', 'web', 'apps'], {
|
|
37
|
+
resource: DEPLOYMENT,
|
|
38
|
+
})
|
|
39
|
+
wasOnline = onlineManager.isOnline()
|
|
40
|
+
onlineManager.setOnline(false)
|
|
41
|
+
hookSpy = vi.spyOn(workloadSourceApi, 'useWorkloadSource')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
act(() => root.unmount())
|
|
46
|
+
host.remove()
|
|
47
|
+
hookSpy.mockRestore()
|
|
48
|
+
client.clear()
|
|
49
|
+
onlineManager.setOnline(wasOnline)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
function lastEnabledArg(): boolean | undefined {
|
|
53
|
+
const call = hookSpy.mock.calls.at(-1)
|
|
54
|
+
return call?.[3] as boolean | undefined
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function renderView(
|
|
58
|
+
props: Partial<React.ComponentProps<typeof WorkloadView>>,
|
|
59
|
+
initialEntry = '/resources/deployments',
|
|
60
|
+
) {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
root.render(
|
|
63
|
+
<QueryClientProvider client={client}>
|
|
64
|
+
<ToastProvider>
|
|
65
|
+
<DockProvider>
|
|
66
|
+
<MemoryRouter key={initialEntry} initialEntries={[initialEntry]}>
|
|
67
|
+
<WorkloadView
|
|
68
|
+
kind="deployments"
|
|
69
|
+
group="apps"
|
|
70
|
+
namespace="shop"
|
|
71
|
+
name="web"
|
|
72
|
+
onBack={() => {}}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
</MemoryRouter>
|
|
76
|
+
</DockProvider>
|
|
77
|
+
</ToastProvider>
|
|
78
|
+
</QueryClientProvider>,
|
|
79
|
+
)
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
it('enables workload source on drawer overview, disables on drawer YAML, and toggles with the YAML button', async () => {
|
|
84
|
+
// Drawer opened to overview (even if the background page URL carries ?tab=deploys).
|
|
85
|
+
await renderView({ expanded: false, initialTab: 'detail' }, '/applications?tab=deploys')
|
|
86
|
+
expect(lastEnabledArg()).toBe(true)
|
|
87
|
+
|
|
88
|
+
// Clicking the YAML toggle hides the overview and disables the query.
|
|
89
|
+
const yamlButton = [...host.querySelectorAll('button')].find((b) => b.textContent?.trim() === 'YAML')
|
|
90
|
+
expect(yamlButton).toBeDefined()
|
|
91
|
+
await act(async () => {
|
|
92
|
+
yamlButton!.click()
|
|
93
|
+
})
|
|
94
|
+
expect(lastEnabledArg()).toBe(false)
|
|
95
|
+
|
|
96
|
+
// Clicking YAML again returns to overview and re-enables the query.
|
|
97
|
+
await act(async () => {
|
|
98
|
+
yamlButton!.click()
|
|
99
|
+
})
|
|
100
|
+
expect(lastEnabledArg()).toBe(true)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('does not enable workload source when the drawer opens directly to YAML', async () => {
|
|
104
|
+
await renderView({ expanded: false, initialTab: 'yaml' })
|
|
105
|
+
expect(hookSpy).toHaveBeenCalled()
|
|
106
|
+
for (const call of hookSpy.mock.calls) {
|
|
107
|
+
expect(call[3]).toBe(false)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('enables workload source in expanded mode only on the overview tab', async () => {
|
|
112
|
+
await renderView({ expanded: true }, '/workload/deployments/shop/web')
|
|
113
|
+
expect(lastEnabledArg()).toBe(true)
|
|
114
|
+
|
|
115
|
+
await renderView({ expanded: true }, '/workload/deployments/shop/web?tab=yaml')
|
|
116
|
+
expect(lastEnabledArg()).toBe(false)
|
|
117
|
+
|
|
118
|
+
await renderView({ expanded: true }, '/workload/deployments/shop/web?tab=timeline')
|
|
119
|
+
expect(lastEnabledArg()).toBe(false)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -5,7 +5,7 @@ import { AlertTriangle, X } from 'lucide-react'
|
|
|
5
5
|
import { Tooltip, formatUpdatedAgo, grantParts, toneTextClass, type Grant } from '@skyhook-io/k8s-ui'
|
|
6
6
|
import type { SelectedResource } from '../../types'
|
|
7
7
|
import { sameSelectedResource } from '../../utils/drawer-trail'
|
|
8
|
-
import { ROW_HOVER, TABLE_HEAD, TABLE_WRAP, TBODY, TD, TH } from './table'
|
|
8
|
+
import { ROW_HOVER, TABLE_HEAD, TABLE_WRAP, TBODY, TD, TH, TH_BASE } from './table'
|
|
9
9
|
|
|
10
10
|
export function Notice({ children }: { children: ReactNode }) {
|
|
11
11
|
return (
|
|
@@ -126,6 +126,8 @@ export function SectionTable<T>({
|
|
|
126
126
|
inspected,
|
|
127
127
|
empty,
|
|
128
128
|
minWidth = 760,
|
|
129
|
+
wrapHeaders = false,
|
|
130
|
+
framed = true,
|
|
129
131
|
footer,
|
|
130
132
|
}: {
|
|
131
133
|
/** Left out where the page heading already names the table. */
|
|
@@ -139,15 +141,19 @@ export function SectionTable<T>({
|
|
|
139
141
|
inspected?: SelectedResource | null
|
|
140
142
|
empty: ReactNode
|
|
141
143
|
minWidth?: number
|
|
144
|
+
wrapHeaders?: boolean
|
|
145
|
+
framed?: boolean
|
|
142
146
|
footer?: ReactNode
|
|
143
147
|
}) {
|
|
144
148
|
return (
|
|
145
149
|
<section>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
{(title || subtitle) && (
|
|
151
|
+
<div className="mb-2 flex flex-wrap items-baseline gap-x-2.5 gap-y-1">
|
|
152
|
+
{title && <h2 className="text-sm font-semibold text-theme-text-primary">{title}</h2>}
|
|
153
|
+
{subtitle && <span className="text-xs text-theme-text-tertiary">{subtitle}</span>}
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
<div className={clsx(framed && 'overflow-hidden rounded-xl border border-theme-border bg-theme-surface shadow-theme-sm')}>
|
|
151
157
|
{rows.length === 0 ? (
|
|
152
158
|
<div className="px-4 py-5 text-sm text-theme-text-tertiary">{empty}</div>
|
|
153
159
|
) : (
|
|
@@ -161,7 +167,7 @@ export function SectionTable<T>({
|
|
|
161
167
|
<thead className={TABLE_HEAD}>
|
|
162
168
|
<tr>
|
|
163
169
|
{columns.map((c, i) => (
|
|
164
|
-
<th key={i} className={TH}>{c.header}</th>
|
|
170
|
+
<th key={i} className={wrapHeaders ? `${TH_BASE} whitespace-normal` : TH}>{c.header}</th>
|
|
165
171
|
))}
|
|
166
172
|
</tr>
|
|
167
173
|
</thead>
|