@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,63 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs'
|
|
2
|
+
import { join, relative } from 'node:path'
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
6
|
+
import { useIntegrationSidebars } from './sidebarWorkspaces'
|
|
7
|
+
|
|
8
|
+
const calls = vi.hoisted(() => ({} as Record<string, any>))
|
|
9
|
+
const part = (name: string) => ({ [name]: { tools: name, destinations: [{ id: name, label: name, onSelect: () => {} }] } as SidebarCategoryWorkspace })
|
|
10
|
+
|
|
11
|
+
vi.mock('../components/cnpg/useCNPGSidebarWorkspace', () => ({ useCNPGSidebarWorkspace: (o: any) => { calls.cnpg = o; return part('CNPG') } }))
|
|
12
|
+
vi.mock('../components/velero/useVeleroSidebarWorkspace', () => ({ useVeleroSidebarWorkspace: (o: any) => { calls.velero = o; return part('Velero') } }))
|
|
13
|
+
vi.mock('../components/substrate/useSubstrateSidebarWorkspace', () => ({ useSubstrateSidebarWorkspace: (o: any) => { calls.substrate = o; return part('Substrate') } }))
|
|
14
|
+
vi.mock('../components/agentsandbox/useAgentSandboxSidebarWorkspace', () => ({ useAgentSandboxSidebarWorkspace: (o: any) => { calls.agentSandbox = o; return part('AgentSandbox') } }))
|
|
15
|
+
vi.mock('../components/kagent/useKagentSidebarWorkspace', () => ({ useKagentSidebarWorkspace: (o: any) => { calls.kagent = o; return part('Kagent') } }))
|
|
16
|
+
|
|
17
|
+
const SRC = join(__dirname, '..')
|
|
18
|
+
|
|
19
|
+
function sourceFiles(dir: string): string[] {
|
|
20
|
+
return readdirSync(dir).flatMap((name) => {
|
|
21
|
+
const path = join(dir, name)
|
|
22
|
+
if (statSync(path).isDirectory()) return name === 'node_modules' ? [] : sourceFiles(path)
|
|
23
|
+
return /\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name) ? [path] : []
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('useIntegrationSidebars', () => {
|
|
28
|
+
it('merges every integration’s part, in order, passing each only its own options', () => {
|
|
29
|
+
let merged: Record<string, SidebarCategoryWorkspace> | undefined
|
|
30
|
+
function Host() {
|
|
31
|
+
merged = useIntegrationSidebars({ apiResources: [], namespaces: ['team'], cnpg: { withMetrics: true }, velero: { active: true }, substrate: { active: 'actors' }, agentSandbox: { active: true } })
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
renderToStaticMarkup(<Host />)
|
|
35
|
+
expect(Object.keys(merged ?? {})).toEqual(['CNPG', 'Velero', 'Substrate', 'AgentSandbox', 'Kagent'])
|
|
36
|
+
expect(calls.cnpg).toEqual({ apiResources: [], namespaces: ['team'], withMetrics: true })
|
|
37
|
+
expect(calls.velero).toEqual({ apiResources: [], active: true })
|
|
38
|
+
expect(calls.substrate).toEqual({ apiResources: [], active: 'actors' })
|
|
39
|
+
expect(calls.agentSandbox).toEqual({ apiResources: [], namespaces: ['team'], active: true })
|
|
40
|
+
expect(calls.kagent).toEqual({ apiResources: [], namespaces: ['team'] })
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// An integration's sidebar hook added beside the others, or a view that
|
|
44
|
+
// calls the hooks itself, is how a screen ends up without an integration's
|
|
45
|
+
// row: every hook goes through useIntegrationSidebars, and nothing else
|
|
46
|
+
// calls one.
|
|
47
|
+
it('is the only caller of every integration sidebar hook', () => {
|
|
48
|
+
const files = sourceFiles(SRC)
|
|
49
|
+
const hooks = files.flatMap((f) => [...readFileSync(f, 'utf8').matchAll(/export function (use\w+SidebarWorkspace)\(/g)].map((m) => m[1]))
|
|
50
|
+
expect(hooks.sort()).toEqual(['useAgentSandboxSidebarWorkspace', 'useCNPGSidebarWorkspace', 'useKagentSidebarWorkspace', 'useSubstrateSidebarWorkspace', 'useVeleroSidebarWorkspace'])
|
|
51
|
+
const own = readFileSync(join(SRC, 'integrations/sidebarWorkspaces.ts'), 'utf8')
|
|
52
|
+
const strays: string[] = []
|
|
53
|
+
for (const hook of [...hooks, 'useMergedSidebarWorkspaces']) {
|
|
54
|
+
expect(own, `${hook} is not merged by useIntegrationSidebars`).toMatch(new RegExp(`\\b${hook}\\(`))
|
|
55
|
+
for (const f of files) {
|
|
56
|
+
if (f.endsWith('integrations/sidebarWorkspaces.ts')) continue
|
|
57
|
+
const text = readFileSync(f, 'utf8')
|
|
58
|
+
if (new RegExp(`(?<!function )\\b${hook}\\(`).test(text)) strays.push(`${relative(SRC, f)}: ${hook}`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
expect(strays).toEqual([])
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
2
|
+
import type { APIResource } from '../types'
|
|
3
|
+
import { useCNPGSidebarWorkspace } from '../components/cnpg/useCNPGSidebarWorkspace'
|
|
4
|
+
import { useVeleroSidebarWorkspace } from '../components/velero/useVeleroSidebarWorkspace'
|
|
5
|
+
import { useSubstrateSidebarWorkspace } from '../components/substrate/useSubstrateSidebarWorkspace'
|
|
6
|
+
import { useAgentSandboxSidebarWorkspace } from '../components/agentsandbox/useAgentSandboxSidebarWorkspace'
|
|
7
|
+
import { useKagentSidebarWorkspace } from '../components/kagent/useKagentSidebarWorkspace'
|
|
8
|
+
import { useMergedSidebarWorkspaces } from '../components/workspace/sidebar'
|
|
9
|
+
|
|
10
|
+
type Workspaces = Record<string, SidebarCategoryWorkspace>
|
|
11
|
+
|
|
12
|
+
/** Each integration's own options, for the view that is that integration's screen. */
|
|
13
|
+
export interface IntegrationSidebarOptions {
|
|
14
|
+
cnpg?: Omit<Parameters<typeof useCNPGSidebarWorkspace>[0], 'apiResources' | 'namespaces'>
|
|
15
|
+
velero?: Omit<Parameters<typeof useVeleroSidebarWorkspace>[0], 'apiResources'>
|
|
16
|
+
substrate?: Omit<Parameters<typeof useSubstrateSidebarWorkspace>[0], 'apiResources'>
|
|
17
|
+
agentSandbox?: Omit<Parameters<typeof useAgentSandboxSidebarWorkspace>[0], 'apiResources' | 'namespaces'>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Every integration's part of the Resources sidebar, merged, in the order the
|
|
22
|
+
* rows list them. Each workspace view (Resources, CloudNativePG, Velero,
|
|
23
|
+
* Agent Substrate, Agent Sandbox) renders the same sidebar, so they all call
|
|
24
|
+
* this rather than the integrations' hooks: an integration added here shows
|
|
25
|
+
* on every screen.
|
|
26
|
+
*/
|
|
27
|
+
export function useIntegrationSidebars({
|
|
28
|
+
apiResources,
|
|
29
|
+
namespaces,
|
|
30
|
+
cnpg,
|
|
31
|
+
velero,
|
|
32
|
+
substrate,
|
|
33
|
+
agentSandbox,
|
|
34
|
+
}: { apiResources: APIResource[] | undefined; namespaces: string[] } & IntegrationSidebarOptions): Workspaces | undefined {
|
|
35
|
+
const cnpgSidebar = useCNPGSidebarWorkspace({ apiResources, namespaces, ...cnpg })
|
|
36
|
+
const veleroSidebar = useVeleroSidebarWorkspace({ apiResources, ...velero })
|
|
37
|
+
const substrateSidebar = useSubstrateSidebarWorkspace({ apiResources, ...substrate })
|
|
38
|
+
const sandboxSidebar = useAgentSandboxSidebarWorkspace({ apiResources, namespaces, ...agentSandbox })
|
|
39
|
+
const kagentSidebar = useKagentSidebarWorkspace({ apiResources, namespaces })
|
|
40
|
+
return useMergedSidebarWorkspaces(cnpgSidebar, veleroSidebar, substrateSidebar, sandboxSidebar, kagentSidebar)
|
|
41
|
+
}
|
|
@@ -9,7 +9,7 @@ export interface WorkspaceScreenProps {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface WorkspaceRoute {
|
|
12
|
-
id: 'cnpg' | 'capacity' | 'velero'
|
|
12
|
+
id: 'cnpg' | 'capacity' | 'velero' | 'substrate' | 'agent-sandbox' | 'kagent'
|
|
13
13
|
path: string
|
|
14
14
|
label: string
|
|
15
15
|
navView: 'resources' | 'capacity'
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import { kagentWorkspaceRoute } from '../components/kagent/workspaceRoute'
|
|
2
|
+
import { agentSandboxWorkspaceRoute } from '../components/agentsandbox/workspaceRoute'
|
|
1
3
|
import { capacityWorkspaceRoute } from '../components/capacity/workspaceRoute'
|
|
2
4
|
import { cnpgWorkspaceRoute } from '../components/cnpg/workspaceRoute'
|
|
5
|
+
import { substrateWorkspaceRoute } from '../components/substrate/workspaceRoute'
|
|
3
6
|
import { veleroWorkspaceRoute } from '../components/velero/workspaceRoute'
|
|
4
7
|
import type { WorkspaceRoute } from './workspaceRoute'
|
|
5
8
|
|
|
6
|
-
export const workspaceRoutes = [cnpgWorkspaceRoute, capacityWorkspaceRoute, veleroWorkspaceRoute] as const
|
|
9
|
+
export const workspaceRoutes = [cnpgWorkspaceRoute, capacityWorkspaceRoute, veleroWorkspaceRoute, substrateWorkspaceRoute, agentSandboxWorkspaceRoute, kagentWorkspaceRoute] as const
|
|
7
10
|
|
|
8
11
|
export const workspaceLabels = {
|
|
9
12
|
cnpg: cnpgWorkspaceRoute.label,
|
|
10
13
|
capacity: capacityWorkspaceRoute.label,
|
|
11
14
|
velero: veleroWorkspaceRoute.label,
|
|
15
|
+
substrate: substrateWorkspaceRoute.label,
|
|
16
|
+
'agent-sandbox': agentSandboxWorkspaceRoute.label,
|
|
17
|
+
kagent: kagentWorkspaceRoute.label,
|
|
12
18
|
} satisfies Record<WorkspaceRoute['id'], string>
|
|
13
19
|
|
|
14
20
|
export function workspaceForPath(pathname: string) {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { KagentView } from '../components/kagent/KagentView'
|
|
1
2
|
import type { ComponentType } from 'react'
|
|
3
|
+
import { AgentSandboxView } from '../components/agentsandbox/AgentSandboxView'
|
|
2
4
|
import { CapacityView } from '../components/capacity/CapacityView'
|
|
3
5
|
import { CNPGView } from '../components/cnpg/CNPGView'
|
|
6
|
+
import { SubstrateView } from '../components/substrate/SubstrateView'
|
|
4
7
|
import { VeleroView } from '../components/velero/VeleroView'
|
|
5
8
|
import type { WorkspaceRoute, WorkspaceScreenProps } from './workspaceRoute'
|
|
6
9
|
|
|
7
10
|
const screens: Record<WorkspaceRoute['id'], ComponentType<WorkspaceScreenProps>> = {
|
|
11
|
+
kagent: KagentView,
|
|
8
12
|
cnpg: CNPGView,
|
|
9
13
|
capacity: ({ onOpenResource }) => <CapacityView onOpenResource={onOpenResource} />,
|
|
10
14
|
velero: VeleroView,
|
|
15
|
+
substrate: SubstrateView,
|
|
16
|
+
'agent-sandbox': AgentSandboxView,
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
export function WorkspaceScreen({ workspace, ...props }: WorkspaceScreenProps & { workspace: WorkspaceRoute }) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { Topology } from '@skyhook-io/k8s-ui/types/core'
|
|
2
1
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
3
2
|
import {
|
|
4
3
|
initNavigationMap,
|
|
5
4
|
resetNavigationMap,
|
|
6
5
|
} from '@skyhook-io/k8s-ui/utils/navigation'
|
|
7
|
-
import {
|
|
6
|
+
import { relatedResourcePath, resourcePath, withCrossViewParams, writeViewParams } from './navigation'
|
|
8
7
|
|
|
9
8
|
afterEach(resetNavigationMap)
|
|
10
9
|
|
|
@@ -56,10 +55,6 @@ describe('JobSet investigation navigation', () => {
|
|
|
56
55
|
})
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
it('uses the Kubernetes kind for a Calico aggregate target', () => {
|
|
60
|
-
expect(getNetworkPolicyResourceTarget({nodes: [{id: 'policy', kind: 'CalicoNetworkPolicy', name: 'allow', status: 'healthy', data: {apiVersion: 'crd.projectcalico.org/v1', resourceKind: 'NetworkPolicy'}}], edges: []} as unknown as Topology))
|
|
61
|
-
.toEqual({kind: 'networkpolicies', group: 'crd.projectcalico.org'})
|
|
62
|
-
})
|
|
63
58
|
|
|
64
59
|
describe('withCrossViewParams', () => {
|
|
65
60
|
it('carries the namespace pick and open investigation onto a bare path', () => {
|
package/src/utils/navigation.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../api/config'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import type { SearchHit } from '../api/client'
|
|
2
|
+
import { kindToPluralWithGroup } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
3
|
+
import type { GroupingMode, SelectedResource, TopologyMode } from '@skyhook-io/k8s-ui/types/core'
|
|
4
|
+
import type { DashboardNetworkPolicyCoverage, SearchHit } from '../api/client'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Map a resource-search Hit to a SelectedResource. Hit.kind is the singular
|
|
@@ -18,46 +17,12 @@ export function searchHitToSelectedResource(hit: SearchHit): SelectedResource {
|
|
|
18
17
|
export { namespacesFromSearch, kindToPlural, kindToPluralWithGroup, pluralToKind, knownKindForPluralWithGroup, refToSelectedResource, apiVersionToGroup } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
19
18
|
export type { NavigateToResource } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'CalicoStagedKubernetesNetworkPolicy',
|
|
28
|
-
'CiliumNetworkPolicy',
|
|
29
|
-
'CiliumClusterwideNetworkPolicy',
|
|
30
|
-
'ClusterNetworkPolicy',
|
|
31
|
-
])
|
|
32
|
-
|
|
33
|
-
function networkPolicyGroup(node: Topology['nodes'][number]): string | undefined {
|
|
34
|
-
const apiVersionGroup = apiVersionToGroup(node.data.apiVersion as string | undefined)
|
|
35
|
-
if (apiVersionGroup) return apiVersionGroup
|
|
36
|
-
|
|
37
|
-
const sourceGroup = node.data.sourceGroup
|
|
38
|
-
if (typeof sourceGroup === 'string' && sourceGroup) return sourceGroup
|
|
39
|
-
|
|
40
|
-
if (node.kind === 'NetworkPolicy') return 'networking.k8s.io'
|
|
41
|
-
return undefined
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Return a resource route only when the policy aggregate has one target. */
|
|
45
|
-
export function getNetworkPolicyResourceTarget(topology: Topology | null): { kind: string; group?: string } | undefined {
|
|
46
|
-
const targets = new Map<string, { kind: string; group?: string }>()
|
|
47
|
-
for (const node of topology?.nodes ?? []) {
|
|
48
|
-
if (!NETWORK_POLICY_TOPOLOGY_KINDS.has(node.kind)) continue
|
|
49
|
-
|
|
50
|
-
const group = networkPolicyGroup(node)
|
|
51
|
-
const target = {
|
|
52
|
-
kind: kindToPluralWithGroup(topologyNodeResourceKind(node), group ?? ''),
|
|
53
|
-
...(group ? { group } : {}),
|
|
54
|
-
}
|
|
55
|
-
targets.set(`${target.kind}\u0000${target.group ?? ''}`, target)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (targets.size !== 1) return undefined
|
|
59
|
-
for (const target of targets.values()) return target
|
|
60
|
-
return undefined
|
|
20
|
+
/** The one list holding every counted policy, when there is only one. */
|
|
21
|
+
export function getNetworkPolicyResourceTarget(coverage: Pick<DashboardNetworkPolicyCoverage, 'policyKinds'> | null | undefined): { kind: string; group: string } | undefined {
|
|
22
|
+
const kinds = coverage?.policyKinds
|
|
23
|
+
if (kinds?.length !== 1) return undefined
|
|
24
|
+
const [{ kind, group }] = kinds
|
|
25
|
+
return { kind: kindToPluralWithGroup(kind, group), group }
|
|
61
26
|
}
|
|
62
27
|
|
|
63
28
|
/**
|
|
@@ -1,68 +1,53 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import type { Topology, TopologyNode } from '@skyhook-io/k8s-ui/types/core'
|
|
3
2
|
import { getNetworkPolicyResourceTarget } from './navigation'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
id: `${kind}/default/policy`,
|
|
8
|
-
kind,
|
|
9
|
-
name: 'policy',
|
|
10
|
-
status: 'healthy',
|
|
11
|
-
data: { namespace: 'default', ...(apiVersion ? { apiVersion } : {}) },
|
|
12
|
-
} as TopologyNode
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function topology(...nodes: TopologyNode[]): Topology {
|
|
16
|
-
return { nodes, edges: [] }
|
|
17
|
-
}
|
|
4
|
+
const coverage = (...policyKinds: { kind: string; group: string }[]) => ({ policyKinds })
|
|
18
5
|
|
|
19
6
|
describe('getNetworkPolicyResourceTarget', () => {
|
|
20
7
|
it('routes a Calico policy to its API group instead of the native policy list', () => {
|
|
21
|
-
expect(getNetworkPolicyResourceTarget(
|
|
8
|
+
expect(getNetworkPolicyResourceTarget(coverage({ kind: 'NetworkPolicy', group: 'projectcalico.org' }))).toEqual({
|
|
22
9
|
kind: 'networkpolicies',
|
|
23
10
|
group: 'projectcalico.org',
|
|
24
11
|
})
|
|
25
12
|
})
|
|
26
13
|
|
|
27
|
-
it('uses the Calico
|
|
28
|
-
expect(getNetworkPolicyResourceTarget(
|
|
14
|
+
it('uses the Calico kind when the policies are all global', () => {
|
|
15
|
+
expect(getNetworkPolicyResourceTarget(coverage({ kind: 'GlobalNetworkPolicy', group: 'crd.projectcalico.org' }))).toEqual({
|
|
29
16
|
kind: 'globalnetworkpolicies',
|
|
30
17
|
group: 'crd.projectcalico.org',
|
|
31
18
|
})
|
|
32
19
|
})
|
|
33
20
|
|
|
34
21
|
it('routes staged Kubernetes Calico policies to their exact API group', () => {
|
|
35
|
-
expect(getNetworkPolicyResourceTarget(
|
|
22
|
+
expect(getNetworkPolicyResourceTarget(coverage({ kind: 'StagedKubernetesNetworkPolicy', group: 'crd.projectcalico.org' }))).toEqual({
|
|
36
23
|
kind: 'stagedkubernetesnetworkpolicies',
|
|
37
24
|
group: 'crd.projectcalico.org',
|
|
38
25
|
})
|
|
39
26
|
})
|
|
40
27
|
|
|
41
|
-
it('
|
|
42
|
-
expect(getNetworkPolicyResourceTarget(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
))).toBeUndefined()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('keeps a stable route when multiple policies share one kind and group', () => {
|
|
49
|
-
expect(getNetworkPolicyResourceTarget(topology(
|
|
50
|
-
node('CalicoNetworkPolicy', 'crd.projectcalico.org/v1'),
|
|
51
|
-
node('CalicoNetworkPolicy', 'crd.projectcalico.org/v1'),
|
|
52
|
-
))).toEqual({
|
|
53
|
-
kind: 'networkpolicies',
|
|
54
|
-
group: 'crd.projectcalico.org',
|
|
28
|
+
it('routes Cilium policies to their own list', () => {
|
|
29
|
+
expect(getNetworkPolicyResourceTarget(coverage({ kind: 'CiliumNetworkPolicy', group: 'cilium.io' }))).toEqual({
|
|
30
|
+
kind: 'ciliumnetworkpolicies',
|
|
31
|
+
group: 'cilium.io',
|
|
55
32
|
})
|
|
56
33
|
})
|
|
57
34
|
|
|
58
|
-
it('
|
|
59
|
-
expect(getNetworkPolicyResourceTarget(
|
|
35
|
+
it('keeps the native NetworkPolicy API group', () => {
|
|
36
|
+
expect(getNetworkPolicyResourceTarget(coverage({ kind: 'NetworkPolicy', group: 'networking.k8s.io' }))).toEqual({
|
|
60
37
|
kind: 'networkpolicies',
|
|
61
38
|
group: 'networking.k8s.io',
|
|
62
39
|
})
|
|
63
40
|
})
|
|
64
41
|
|
|
65
|
-
it('
|
|
66
|
-
expect(getNetworkPolicyResourceTarget(
|
|
42
|
+
it('uses the generic resources view when the policies span several lists', () => {
|
|
43
|
+
expect(getNetworkPolicyResourceTarget(coverage(
|
|
44
|
+
{ kind: 'NetworkPolicy', group: 'networking.k8s.io' },
|
|
45
|
+
{ kind: 'NetworkPolicy', group: 'crd.projectcalico.org' },
|
|
46
|
+
))).toBeUndefined()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('uses the generic resources view when the Radar does not say which kinds it counted', () => {
|
|
50
|
+
expect(getNetworkPolicyResourceTarget({})).toBeUndefined()
|
|
51
|
+
expect(getNetworkPolicyResourceTarget(null)).toBeUndefined()
|
|
67
52
|
})
|
|
68
53
|
})
|