@skyhook-io/radar-app 1.19.0 → 1.20.1
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/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +37 -9
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +353 -64
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +42 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +50 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
- package/src/components/helm/HelmView.tsx +213 -71
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.tsx +4 -2
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.tsx +28 -5
- package/src/components/home/HelmSummary.tsx +23 -4
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +20 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +126 -10
- package/src/components/home/MCPSetupDialog.tsx +33 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +67 -14
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +22 -1
- package/src/components/issues/uncheckedSources.ts +21 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +8 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +17 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
1
|
+
import { useId, useMemo } from 'react'
|
|
2
2
|
import type { Topology } from '../../types'
|
|
3
|
-
import { Network
|
|
4
|
-
import {
|
|
3
|
+
import { Network } from 'lucide-react'
|
|
4
|
+
import { useElementSize } from '../../hooks/useElementSize'
|
|
5
|
+
import { HomeDiagramCard } from './HomeDiagramCard'
|
|
5
6
|
|
|
6
7
|
interface TopologyPreviewProps {
|
|
7
8
|
topology: Topology | null
|
|
@@ -9,257 +10,143 @@ interface TopologyPreviewProps {
|
|
|
9
10
|
onNavigate: () => void
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const ingress = '#a78bfa' // violet-400
|
|
19
|
-
const service = '#60a5fa' // blue-400
|
|
20
|
-
const deploy = '#34d399' // emerald-400
|
|
21
|
-
const pod = '#84cc16' // lime-500
|
|
22
|
-
const config = '#fbbf24' // amber-400
|
|
23
|
-
const groupBorder = 'rgba(59, 130, 246, 0.25)'
|
|
24
|
-
const groupBg = 'rgba(59, 130, 246, 0.04)'
|
|
25
|
-
|
|
26
|
-
// Edge color — use a concrete color so markers render reliably
|
|
27
|
-
const ec = '#64748b' // slate-500
|
|
28
|
-
|
|
13
|
+
// One node drawn like a Topology card: surface, border, the status bar on the
|
|
14
|
+
// left, the kind as a caption and a bar standing in for the name. The bar is
|
|
15
|
+
// neutral: health drawn here would read as this cluster's.
|
|
16
|
+
function SchematicNode({ x, y, w = 46, label, dashed }: {
|
|
17
|
+
x: number; y: number; w?: number; label: string; dashed?: boolean
|
|
18
|
+
}) {
|
|
29
19
|
return (
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<path d="M 0 0 L 8 3 L 0 6 z" fill={ec} opacity="0.35" />
|
|
39
|
-
</marker>
|
|
40
|
-
</defs>
|
|
41
|
-
|
|
42
|
-
{/* Group 1 — top: Ingress → Service → Deploys → Pods */}
|
|
43
|
-
<rect x="4" y="4" width="100" height="52" rx="6"
|
|
44
|
-
fill={groupBg} stroke={groupBorder} strokeWidth="1" strokeDasharray="3 2" />
|
|
45
|
-
|
|
46
|
-
{/* Nodes */}
|
|
47
|
-
<rect x="10" y="24" width="16" height="10" rx="3" fill={ingress} opacity="0.85" />
|
|
48
|
-
<rect x="38" y="24" width="16" height="10" rx="3" fill={service} opacity="0.85" />
|
|
49
|
-
<rect x="66" y="14" width="16" height="10" rx="3" fill={deploy} opacity="0.85" />
|
|
50
|
-
<rect x="66" y="34" width="16" height="10" rx="3" fill={deploy} opacity="0.85" />
|
|
51
|
-
<circle cx="96" cy="19" r="4.5" fill={pod} opacity="0.65" />
|
|
52
|
-
<circle cx="96" cy="39" r="4.5" fill={pod} opacity="0.65" />
|
|
53
|
-
|
|
54
|
-
{/* Edges — group 1 */}
|
|
55
|
-
<line x1="26" y1="29" x2="37" y2="29" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
56
|
-
<line x1="54" y1="29" x2="65" y2="20" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
57
|
-
<line x1="54" y1="29" x2="65" y2="38" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
58
|
-
<line x1="82" y1="19" x2="90" y2="19" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
59
|
-
<line x1="82" y1="39" x2="90" y2="39" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
60
|
-
|
|
61
|
-
{/* Group 2 — bottom: Service → Deploys → Pods + ConfigMap */}
|
|
62
|
-
<rect x="30" y="64" width="126" height="52" rx="6"
|
|
63
|
-
fill={groupBg} stroke={groupBorder} strokeWidth="1" strokeDasharray="3 2" />
|
|
64
|
-
|
|
65
|
-
{/* Nodes */}
|
|
66
|
-
<rect x="36" y="82" width="16" height="10" rx="3" fill={service} opacity="0.85" />
|
|
67
|
-
<rect x="66" y="72" width="16" height="10" rx="3" fill={deploy} opacity="0.85" />
|
|
68
|
-
<rect x="66" y="92" width="16" height="10" rx="3" fill={deploy} opacity="0.85" />
|
|
69
|
-
<circle cx="96" cy="73" r="4.5" fill={pod} opacity="0.65" />
|
|
70
|
-
<circle cx="96" cy="87" r="4.5" fill={pod} opacity="0.65" />
|
|
71
|
-
<circle cx="96" cy="101" r="4.5" fill={pod} opacity="0.65" />
|
|
72
|
-
|
|
73
|
-
{/* Config node */}
|
|
74
|
-
<rect x="120" y="82" width="16" height="10" rx="3" fill={config} opacity="0.55" />
|
|
75
|
-
|
|
76
|
-
{/* Edges — group 2 */}
|
|
77
|
-
<line x1="52" y1="87" x2="65" y2="78" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
78
|
-
<line x1="52" y1="87" x2="65" y2="96" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
79
|
-
<line x1="82" y1="77" x2="90" y2="74" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
80
|
-
<line x1="82" y1="77" x2="90" y2="87" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
81
|
-
<line x1="82" y1="97" x2="90" y2="101" stroke={ec} strokeWidth="1" opacity="0.55" markerEnd="url(#arr)" />
|
|
82
|
-
|
|
83
|
-
{/* Config dashed edge */}
|
|
84
|
-
<line x1="82" y1="77" x2="119" y2="87" stroke={ec} strokeWidth="0.7" opacity="0.3" strokeDasharray="2 2" markerEnd="url(#arr-f)" />
|
|
85
|
-
|
|
86
|
-
{/* Cross-group curved edge */}
|
|
87
|
-
<path d="M 18 34 Q 18 64, 36 82" fill="none" stroke={ec} strokeWidth="0.8" opacity="0.3" markerEnd="url(#arr-f)" />
|
|
88
|
-
</svg>
|
|
20
|
+
<g>
|
|
21
|
+
<rect x={x} y={y} width={w} height={17} rx={3.5} fill="var(--bg-surface)"
|
|
22
|
+
stroke="var(--border-light)" strokeWidth={0.7} strokeDasharray={dashed ? '2 1.5' : undefined} />
|
|
23
|
+
<rect x={x} y={y + 2.5} width={1.8} height={12} rx={0.9} fill="var(--text-tertiary)" opacity={0.6} />
|
|
24
|
+
<rect x={x + 4.8} y={y + 4.4} width={3.6} height={3.6} rx={0.9} fill="var(--text-tertiary)" opacity={0.55} />
|
|
25
|
+
<text x={x + 10.5} y={y + 7.8} fontSize={4.6} fontWeight={600} letterSpacing={0.3} fill="var(--text-tertiary)">{label}</text>
|
|
26
|
+
<rect x={x + 4.8} y={y + 10.8} width={w * 0.55} height={2.4} rx={1.2} fill="var(--text-tertiary)" opacity={0.35} />
|
|
27
|
+
</g>
|
|
89
28
|
)
|
|
90
29
|
}
|
|
91
30
|
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const kindCounts: Record<string, number> = {}
|
|
98
|
-
const healthCounts = { healthy: 0, degraded: 0, unhealthy: 0, unknown: 0 }
|
|
99
|
-
|
|
100
|
-
for (const node of topology.nodes) {
|
|
101
|
-
kindCounts[node.kind] = (kindCounts[node.kind] || 0) + 1
|
|
102
|
-
if (node.status in healthCounts) {
|
|
103
|
-
healthCounts[node.status as keyof typeof healthCounts]++
|
|
104
|
-
}
|
|
105
|
-
}
|
|
31
|
+
// The drawing's height in its own units. Its width follows the card, up to a
|
|
32
|
+
// limit, so the picture fills a wide card instead of floating in the middle.
|
|
33
|
+
const SCHEMATIC_H = 128
|
|
34
|
+
const SCHEMATIC_MIN_W = 296
|
|
35
|
+
const SCHEMATIC_MAX_W = 560
|
|
106
36
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
37
|
+
// A static picture of what Topology draws: traffic entering an Ingress and
|
|
38
|
+
// fanning out through Services to workloads, in two namespace groups. It is a
|
|
39
|
+
// hint at the view, not a rendering of this cluster, so it never moves and
|
|
40
|
+
// looks the same whatever the cluster's size.
|
|
41
|
+
function TopologySchematic() {
|
|
42
|
+
const arrow = `${useId()}-arrow`
|
|
43
|
+
const [ref, size] = useElementSize<HTMLDivElement>({ width: SCHEMATIC_MIN_W, height: SCHEMATIC_H })
|
|
44
|
+
const width = Math.min(SCHEMATIC_MAX_W, Math.max(SCHEMATIC_MIN_W, (SCHEMATIC_H * size.width) / size.height))
|
|
45
|
+
// Extra width spreads the five columns (web, ingress, service, workload,
|
|
46
|
+
// pods) apart rather than stretching the nodes.
|
|
47
|
+
const extra = width - SCHEMATIC_MIN_W
|
|
48
|
+
const col = (c: number) => (extra * c) / 4
|
|
49
|
+
const X = { web: 4, ingress: 54 + col(1), service: 112 + col(2), workload: 170 + col(3), pods: 228 + col(4) }
|
|
50
|
+
const W = { node: 46, pods: 56 }
|
|
51
|
+
|
|
52
|
+
const edge = (x1: number, y1: number, x2: number, y2: number, dashed?: boolean) => {
|
|
53
|
+
const k = Math.max(10, (x2 - x1) * 0.6)
|
|
54
|
+
return (
|
|
55
|
+
<path d={`M ${x1} ${y1} C ${x1 + k} ${y1}, ${x2 - k} ${y2}, ${x2} ${y2}`} fill="none"
|
|
56
|
+
stroke="var(--text-tertiary)" strokeWidth={0.7} opacity={dashed ? 0.35 : 0.55}
|
|
57
|
+
strokeDasharray={dashed ? '2 1.5' : undefined} markerEnd={`url(#${arrow})`} />
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
const groupX = X.ingress - 8
|
|
61
|
+
const group = (y: number, h: number, name: string) => (
|
|
62
|
+
<g>
|
|
63
|
+
<rect x={groupX} y={y} width={X.pods + W.pods + 10 - groupX} height={h} rx={7} fill="var(--group-header-namespace)"
|
|
64
|
+
fillOpacity={0.45} stroke="var(--group-border-namespace)" strokeWidth={0.7} strokeDasharray="3 2" />
|
|
65
|
+
<text x={groupX + 6} y={y + 8} fontSize={4.6} fontFamily="var(--font-mono, monospace)" fill="var(--text-tertiary)">{name}</text>
|
|
66
|
+
</g>
|
|
67
|
+
)
|
|
68
|
+
const right = (x: number, w = W.node) => x + w
|
|
123
69
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
70
|
+
return (
|
|
71
|
+
<div ref={ref} className="w-full h-full">
|
|
72
|
+
<svg viewBox={`0 2 ${width} ${SCHEMATIC_H}`} className="w-full h-full" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
|
|
73
|
+
<defs>
|
|
74
|
+
<marker id={arrow} viewBox="0 0 8 6" refX="7" refY="3" markerWidth="5" markerHeight="4" orient="auto">
|
|
75
|
+
<path d="M 0 0 L 8 3 L 0 6 z" fill="var(--text-tertiary)" opacity="0.7" />
|
|
76
|
+
</marker>
|
|
77
|
+
</defs>
|
|
78
|
+
|
|
79
|
+
{group(4, 62, 'storefront')}
|
|
80
|
+
{group(72, 56, 'payments')}
|
|
81
|
+
|
|
82
|
+
<rect x={X.web} y={54} width={32} height={16} rx={8} fill="var(--bg-surface)" stroke="var(--border-light)" strokeWidth={0.7} />
|
|
83
|
+
<circle cx={X.web + 7.5} cy={62} r={2.5} fill="none" stroke="var(--color-brand)" strokeWidth={0.8} />
|
|
84
|
+
<text x={X.web + 12} y={63.6} fontSize={4.6} fontWeight={600} fill="var(--text-tertiary)">WEB</text>
|
|
85
|
+
|
|
86
|
+
{edge(X.web + 32, 62, X.ingress, 36)}
|
|
87
|
+
{edge(right(X.ingress), 36, X.service, 36)}
|
|
88
|
+
{edge(right(X.ingress), 36, X.service, 102)}
|
|
89
|
+
{edge(right(X.service), 36, X.workload, 24)}
|
|
90
|
+
{edge(right(X.service), 36, X.workload, 48)}
|
|
91
|
+
{edge(right(X.workload), 24, X.pods, 24)}
|
|
92
|
+
{edge(right(X.workload), 48, X.pods, 48)}
|
|
93
|
+
{edge(right(X.service), 102, X.workload, 90)}
|
|
94
|
+
{edge(right(X.service), 102, X.workload, 112)}
|
|
95
|
+
{edge(right(X.workload), 90, X.pods, 90)}
|
|
96
|
+
{edge(right(X.workload), 112, X.pods, 112, true)}
|
|
97
|
+
|
|
98
|
+
<SchematicNode x={X.ingress} y={28} label="INGRESS" />
|
|
99
|
+
<SchematicNode x={X.service} y={28} label="SERVICE" />
|
|
100
|
+
<SchematicNode x={X.workload} y={16} label="DEPLOY" />
|
|
101
|
+
<SchematicNode x={X.workload} y={40} label="DEPLOY" />
|
|
102
|
+
<SchematicNode x={X.pods} y={16} w={W.pods} label="PODS ×3" />
|
|
103
|
+
<SchematicNode x={X.pods} y={40} w={W.pods} label="PODS ×2" />
|
|
104
|
+
|
|
105
|
+
<SchematicNode x={X.service} y={94} label="SERVICE" />
|
|
106
|
+
<SchematicNode x={X.workload} y={82} label="DEPLOY" />
|
|
107
|
+
<SchematicNode x={X.workload} y={104} label="STATEFUL" />
|
|
108
|
+
<SchematicNode x={X.pods} y={82} w={W.pods} label="PODS ×2" />
|
|
109
|
+
<SchematicNode x={X.pods} y={104} w={W.pods} label="CONFIG" dashed />
|
|
110
|
+
</svg>
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
133
113
|
}
|
|
134
114
|
|
|
135
115
|
export function TopologyPreview({ topology, namespaceSelected, onNavigate }: TopologyPreviewProps) {
|
|
136
|
-
const stats = useTopologyStats(topology)
|
|
137
|
-
|
|
138
116
|
// A large cluster with no namespace filter gets an empty graph carrying this
|
|
139
|
-
// flag instead of a build
|
|
140
|
-
//
|
|
141
|
-
// refusal as zero.
|
|
117
|
+
// flag instead of a build, and Topology asks for a namespace. The card keeps
|
|
118
|
+
// its drawing but states no counts, which would read the refusal as zero.
|
|
142
119
|
//
|
|
143
120
|
// With a pick already active the same flag means something else entirely: SSE
|
|
144
121
|
// only learns to filter server-side after a flagged frame arrives, so a
|
|
145
122
|
// cluster-wide refusal still reaches a viewer whose namespace is on its way
|
|
146
|
-
// to the server. That resolves on its own,
|
|
147
|
-
// already chose is the wrong thing to say while it does.
|
|
123
|
+
// to the server. That resolves on its own, so the header keeps loading.
|
|
148
124
|
const needsNamespaceFilter = topology?.requiresNamespaceFilter === true && !namespaceSelected
|
|
149
125
|
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
//
|
|
126
|
+
// Node count is not the test for whether a frame counts — the stream holds
|
|
127
|
+
// topology at null until one lands and resets it there on reconnect and
|
|
128
|
+
// context switch, so a delivered graph with no nodes is an empty scope and an
|
|
129
|
+
// honest zero.
|
|
154
130
|
const counts = useMemo(() => {
|
|
155
131
|
if (!topology || topology.requiresNamespaceFilter) return null
|
|
156
132
|
return { nodeCount: topology.nodes.length, edgeCount: topology.edges.length }
|
|
157
133
|
}, [topology])
|
|
158
134
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
<div className="flex flex-col h-full w-full">
|
|
165
|
-
<div className="flex items-center justify-between px-5 py-3 border-b border-theme-border/50">
|
|
166
|
-
<div className="flex items-center gap-2">
|
|
167
|
-
<Network className="w-4 h-4 text-theme-text-tertiary" />
|
|
168
|
-
<span className="text-xs font-semibold uppercase tracking-wider text-theme-text-secondary">Topology</span>
|
|
169
|
-
</div>
|
|
170
|
-
{counts ? (
|
|
171
|
-
<span className="text-[11px] text-theme-text-tertiary">
|
|
172
|
-
{counts.nodeCount} resources · {counts.edgeCount} conn
|
|
173
|
-
</span>
|
|
174
|
-
) : needsNamespaceFilter ? null : (
|
|
175
|
-
<span className="h-3 w-28 rounded bg-theme-text-tertiary/20 animate-pulse" />
|
|
176
|
-
)}
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
{/* Stats (left) + Schematic (right) */}
|
|
180
|
-
<div className="flex-1 flex items-stretch min-h-0 px-3 py-1.5 gap-2">
|
|
181
|
-
{needsNamespaceFilter ? (
|
|
182
|
-
<div className="flex-1 flex items-center justify-center px-4">
|
|
183
|
-
<p className="text-[11px] leading-relaxed text-theme-text-tertiary text-center">
|
|
184
|
-
This cluster is too large to graph every namespace.
|
|
185
|
-
<br />
|
|
186
|
-
<span className="text-theme-text-secondary font-medium">Select a namespace</span> to view the topology.
|
|
187
|
-
</p>
|
|
188
|
-
</div>
|
|
189
|
-
) : (
|
|
190
|
-
<>
|
|
191
|
-
{/* Left: compact stats */}
|
|
192
|
-
<div className="flex flex-col justify-center gap-0.5 min-w-0 w-[105px] shrink-0">
|
|
193
|
-
{stats ? (
|
|
194
|
-
<>
|
|
195
|
-
{stats.topKinds.map(([kind, count]) => (
|
|
196
|
-
<div key={kind} className="flex items-center gap-1.5 text-[10px] leading-tight">
|
|
197
|
-
<span className={clsx(
|
|
198
|
-
'w-1.5 h-1.5 rounded-full shrink-0',
|
|
199
|
-
kindDotColors[kind] || 'bg-theme-text-tertiary',
|
|
200
|
-
)} />
|
|
201
|
-
<span className="text-theme-text-primary font-medium w-5 text-right tabular-nums">{count}</span>
|
|
202
|
-
<span className="text-theme-text-tertiary truncate">{kind}</span>
|
|
203
|
-
</div>
|
|
204
|
-
))}
|
|
205
|
-
|
|
206
|
-
{(stats.healthCounts.degraded > 0 || stats.healthCounts.unhealthy > 0) && (
|
|
207
|
-
<div className="flex items-center gap-1.5 text-[10px] text-theme-text-tertiary mt-0.5 pt-1 border-t border-theme-border/50">
|
|
208
|
-
{stats.healthCounts.unhealthy > 0 && (
|
|
209
|
-
<span className="flex items-center gap-0.5">
|
|
210
|
-
<span className="w-1.5 h-1.5 rounded-full bg-red-500" />
|
|
211
|
-
{stats.healthCounts.unhealthy}
|
|
212
|
-
</span>
|
|
213
|
-
)}
|
|
214
|
-
{stats.healthCounts.degraded > 0 && (
|
|
215
|
-
<span className="flex items-center gap-0.5">
|
|
216
|
-
<span className="w-1.5 h-1.5 rounded-full bg-yellow-500" />
|
|
217
|
-
{stats.healthCounts.degraded}
|
|
218
|
-
</span>
|
|
219
|
-
)}
|
|
220
|
-
</div>
|
|
221
|
-
)}
|
|
222
|
-
</>
|
|
223
|
-
) : (
|
|
224
|
-
// No graph yet, or one with nothing in scope. Until a frame lands
|
|
225
|
-
// there is no honest number here — a zero would read as an empty
|
|
226
|
-
// cluster, so pulse instead.
|
|
227
|
-
<div className="flex flex-col gap-0.5">
|
|
228
|
-
<div className="flex items-center gap-1.5 text-[10px] leading-tight">
|
|
229
|
-
<span className={clsx('w-1.5 h-1.5 rounded-full shrink-0', counts ? 'bg-blue-400' : 'bg-theme-text-tertiary/30 animate-pulse')} />
|
|
230
|
-
{counts ? (
|
|
231
|
-
<span className="text-theme-text-primary font-medium w-5 text-right tabular-nums">{counts.nodeCount}</span>
|
|
232
|
-
) : (
|
|
233
|
-
<span className="h-3 w-5 rounded bg-theme-text-tertiary/20 animate-pulse" />
|
|
234
|
-
)}
|
|
235
|
-
<span className="text-theme-text-tertiary">resources</span>
|
|
236
|
-
</div>
|
|
237
|
-
<div className="flex items-center gap-1.5 text-[10px] leading-tight">
|
|
238
|
-
<span className={clsx('w-1.5 h-1.5 rounded-full shrink-0', counts ? 'bg-theme-text-tertiary' : 'bg-theme-text-tertiary/30 animate-pulse')} />
|
|
239
|
-
{counts ? (
|
|
240
|
-
<span className="text-theme-text-primary font-medium w-5 text-right tabular-nums">{counts.edgeCount}</span>
|
|
241
|
-
) : (
|
|
242
|
-
<span className="h-3 w-5 rounded bg-theme-text-tertiary/10 animate-pulse" />
|
|
243
|
-
)}
|
|
244
|
-
<span className="text-theme-text-tertiary">connections</span>
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
)}
|
|
248
|
-
</div>
|
|
249
|
-
|
|
250
|
-
{/* Right: schematic illustration */}
|
|
251
|
-
<div className="flex-1 flex items-center min-w-0">
|
|
252
|
-
<TopologySchematic />
|
|
253
|
-
</div>
|
|
254
|
-
</>
|
|
255
|
-
)}
|
|
256
|
-
</div>
|
|
135
|
+
const fact = counts ? (
|
|
136
|
+
<>{counts.nodeCount} resources · {counts.edgeCount} relationships</>
|
|
137
|
+
) : needsNamespaceFilter ? undefined : (
|
|
138
|
+
<span data-testid="topology-counts-loading" className="inline-block h-3 w-28 rounded bg-theme-text-tertiary/20 animate-pulse align-middle" />
|
|
139
|
+
)
|
|
257
140
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
141
|
+
return (
|
|
142
|
+
<HomeDiagramCard
|
|
143
|
+
icon={Network}
|
|
144
|
+
title="Topology"
|
|
145
|
+
fact={fact}
|
|
146
|
+
drawing={<TopologySchematic />}
|
|
147
|
+
caption="How ingresses, services and workloads connect, grouped by namespace."
|
|
148
|
+
footer="Open Topology"
|
|
149
|
+
onNavigate={onNavigate}
|
|
150
|
+
/>
|
|
264
151
|
)
|
|
265
152
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import type { DashboardTrafficSummary } from '../../api/client'
|
|
6
|
+
import { TrafficSummary, trafficSourceName } from './TrafficSummary'
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
9
|
+
|
|
10
|
+
let container: HTMLDivElement
|
|
11
|
+
let root: Root
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
container = document.createElement('div')
|
|
15
|
+
document.body.appendChild(container)
|
|
16
|
+
root = createRoot(container)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
act(() => root.unmount())
|
|
21
|
+
container.remove()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
function render(data: DashboardTrafficSummary | null, onNavigate = vi.fn()) {
|
|
25
|
+
act(() => root.render(<TrafficSummary data={data} onNavigate={onNavigate} />))
|
|
26
|
+
return onNavigate
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const header = () => container.querySelector('button > div > div')!.textContent
|
|
30
|
+
const drawing = () => container.querySelector('svg')!.outerHTML
|
|
31
|
+
|
|
32
|
+
const observed: DashboardTrafficSummary = { source: 'hubble' }
|
|
33
|
+
|
|
34
|
+
describe('TrafficSummary', () => {
|
|
35
|
+
it('names no source until the server has detected one', () => {
|
|
36
|
+
render(null)
|
|
37
|
+
expect(header()).toBe('Live Traffic')
|
|
38
|
+
expect(container.textContent).not.toMatch(/Needs a traffic source|Nothing to show/)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('names the detected source in the header', () => {
|
|
42
|
+
render(observed)
|
|
43
|
+
expect(header()).toBe('Live TrafficHubble')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('draws the same picture with or without a detected source', () => {
|
|
47
|
+
render(null)
|
|
48
|
+
const empty = drawing()
|
|
49
|
+
render(observed)
|
|
50
|
+
expect(drawing()).toBe(empty)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('opens Live Traffic from anywhere on the card', () => {
|
|
54
|
+
const onNavigate = render(null)
|
|
55
|
+
act(() => container.querySelector('button')!.click())
|
|
56
|
+
expect(onNavigate).toHaveBeenCalledOnce()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('capitalises an unknown source name', () => {
|
|
60
|
+
expect(trafficSourceName('istio')).toBe('Istio')
|
|
61
|
+
expect(trafficSourceName('cilium')).toBe('Cilium')
|
|
62
|
+
})
|
|
63
|
+
})
|