@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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Link2 } from 'lucide-react'
|
|
2
|
+
import {
|
|
3
|
+
RelationshipGroup,
|
|
4
|
+
ResourceLink,
|
|
5
|
+
Section,
|
|
6
|
+
type ResourceRef,
|
|
7
|
+
} from '@skyhook-io/k8s-ui'
|
|
8
|
+
import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
|
|
9
|
+
import {
|
|
10
|
+
ValidatingAdmissionPolicyBindingRenderer as BaseBindingRenderer,
|
|
11
|
+
ValidatingAdmissionPolicyRenderer as BasePolicyRenderer,
|
|
12
|
+
} from '@skyhook-io/k8s-ui/components/resources/renderers/ValidatingAdmissionPolicyRenderers'
|
|
13
|
+
import { useResources, useResourceWithRelationships } from '../../../api/client'
|
|
14
|
+
|
|
15
|
+
const ADMISSION_REGISTRATION_GROUP = 'admissionregistration.k8s.io'
|
|
16
|
+
|
|
17
|
+
export function ValidatingAdmissionPolicyRenderer({
|
|
18
|
+
data,
|
|
19
|
+
onNavigate,
|
|
20
|
+
}: {
|
|
21
|
+
data: any
|
|
22
|
+
onNavigate?: (ref: ResourceRef) => void
|
|
23
|
+
}) {
|
|
24
|
+
const name = data?.metadata?.name
|
|
25
|
+
const query = useResources<any>(
|
|
26
|
+
'validatingadmissionpolicybindings',
|
|
27
|
+
undefined,
|
|
28
|
+
ADMISSION_REGISTRATION_GROUP,
|
|
29
|
+
{ enabled: Boolean(name), refetchInterval: 30000 },
|
|
30
|
+
)
|
|
31
|
+
const bindings = (query.data ?? []).filter(binding => binding?.spec?.policyName === name)
|
|
32
|
+
const bindingLookupComplete = query.coverage?.status === 'complete' && !query.error
|
|
33
|
+
const bindingTitle = bindingLookupComplete
|
|
34
|
+
? `Bindings (${bindings.length})`
|
|
35
|
+
: bindings.length > 0 ? `Bindings (${bindings.length}+)` : 'Bindings'
|
|
36
|
+
const refs = bindings.map(binding => ({
|
|
37
|
+
kind: 'ValidatingAdmissionPolicyBinding',
|
|
38
|
+
namespace: '',
|
|
39
|
+
name: binding?.metadata?.name ?? '',
|
|
40
|
+
group: ADMISSION_REGISTRATION_GROUP,
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<BasePolicyRenderer
|
|
45
|
+
data={data}
|
|
46
|
+
onNavigate={onNavigate}
|
|
47
|
+
bindings={
|
|
48
|
+
<Section title={bindingTitle} icon={Link2} defaultExpanded>
|
|
49
|
+
{query.isLoading ? (
|
|
50
|
+
<div className="text-sm text-theme-text-tertiary">Looking for readable bindings…</div>
|
|
51
|
+
) : query.error && bindings.length === 0 ? (
|
|
52
|
+
<LookupFailureNote errors={[query.error]} what="which bindings select this policy" />
|
|
53
|
+
) : bindings.length === 0 && bindingLookupComplete ? (
|
|
54
|
+
<div className="text-sm text-theme-text-tertiary">
|
|
55
|
+
No readable bindings select this policy; this policy has no effect.
|
|
56
|
+
</div>
|
|
57
|
+
) : bindings.length === 0 ? (
|
|
58
|
+
<div className="text-sm text-theme-text-tertiary">
|
|
59
|
+
Binding availability could not be established; this policy may still have readable bindings.
|
|
60
|
+
</div>
|
|
61
|
+
) : (
|
|
62
|
+
<div className="space-y-2">
|
|
63
|
+
{!bindingLookupComplete && !query.error && (
|
|
64
|
+
<div className="text-sm text-theme-text-tertiary">
|
|
65
|
+
This list may be incomplete; binding coverage could not be confirmed.
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
<LookupFailureNote
|
|
69
|
+
errors={[query.error]}
|
|
70
|
+
what="which bindings select this policy"
|
|
71
|
+
incomplete
|
|
72
|
+
/>
|
|
73
|
+
<RelationshipGroup label="Select this policy" refs={refs} onNavigate={onNavigate} />
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
</Section>
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function ValidatingAdmissionPolicyBindingRenderer({
|
|
83
|
+
data,
|
|
84
|
+
onNavigate,
|
|
85
|
+
}: {
|
|
86
|
+
data: any
|
|
87
|
+
onNavigate?: (ref: ResourceRef) => void
|
|
88
|
+
}) {
|
|
89
|
+
const policyName = data?.spec?.policyName ?? ''
|
|
90
|
+
const query = useResourceWithRelationships<any>(
|
|
91
|
+
'validatingadmissionpolicies',
|
|
92
|
+
'',
|
|
93
|
+
policyName,
|
|
94
|
+
ADMISSION_REGISTRATION_GROUP,
|
|
95
|
+
)
|
|
96
|
+
const status = typeof query.error === 'object' && query.error !== null && 'status' in query.error
|
|
97
|
+
? (query.error as { status?: unknown }).status
|
|
98
|
+
: undefined
|
|
99
|
+
const reference = query.isLoading ? (
|
|
100
|
+
<ReferenceState name={policyName} note="Checking policy availability…" />
|
|
101
|
+
) : status === 404 ? (
|
|
102
|
+
<ReferenceState name={policyName} note="Referenced policy was not found." />
|
|
103
|
+
) : status === 403 ? (
|
|
104
|
+
<ReferenceState name={policyName} note="Not permitted to check policy availability." />
|
|
105
|
+
) : query.error ? (
|
|
106
|
+
<ReferenceState name={policyName} note="Could not check policy availability." />
|
|
107
|
+
) : query.data ? (
|
|
108
|
+
<ResourceLink
|
|
109
|
+
name={policyName}
|
|
110
|
+
kind="validatingadmissionpolicies"
|
|
111
|
+
namespace=""
|
|
112
|
+
group={ADMISSION_REGISTRATION_GROUP}
|
|
113
|
+
onNavigate={onNavigate}
|
|
114
|
+
/>
|
|
115
|
+
) : (
|
|
116
|
+
<ReferenceState name={policyName} note="Policy availability was not checked." />
|
|
117
|
+
)
|
|
118
|
+
return <BaseBindingRenderer data={data} onNavigate={onNavigate} policyReference={reference} />
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function ReferenceState({ name, note }: { name: string; note: string }) {
|
|
122
|
+
return (
|
|
123
|
+
<span className="space-y-0.5">
|
|
124
|
+
<span className="block">{name || 'Not specified'}</span>
|
|
125
|
+
<span className="block text-xs text-theme-text-tertiary">{note}</span>
|
|
126
|
+
</span>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
@@ -1308,7 +1308,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
1308
1308
|
// source it names may since have gone. A retry detects again first, which
|
|
1309
1309
|
// also picks another available source, and the first failed connect gets
|
|
1310
1310
|
// one such retry on its own.
|
|
1311
|
-
const handleConnect = useCallback((redetect: boolean) => {
|
|
1311
|
+
const handleConnect = useCallback((redetect: boolean, automatic = false) => {
|
|
1312
1312
|
setIsConnecting(true)
|
|
1313
1313
|
setConnectionError(null)
|
|
1314
1314
|
queryClient.removeQueries({ queryKey: ['traffic-flows'] })
|
|
@@ -1324,7 +1324,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
const detected = fresh ? detectSourcesAgain() : Promise.resolve(undefined)
|
|
1326
1326
|
detected.then(
|
|
1327
|
-
() => connectMutation.mutate(
|
|
1327
|
+
() => connectMutation.mutate({ automatic }, {
|
|
1328
1328
|
onSuccess: (data) => {
|
|
1329
1329
|
if (!data.connected && data.error) {
|
|
1330
1330
|
fail(data.error)
|
|
@@ -1355,7 +1355,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
1355
1355
|
useEffect(() => {
|
|
1356
1356
|
if (wizardState === 'ready' && !hasAutoConnectedRef.current && !isConnecting) {
|
|
1357
1357
|
hasAutoConnectedRef.current = true
|
|
1358
|
-
handleConnect(false)
|
|
1358
|
+
handleConnect(false, true)
|
|
1359
1359
|
}
|
|
1360
1360
|
}, [wizardState, isConnecting, handleConnect])
|
|
1361
1361
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { expect, it, vi } from 'vitest'
|
|
5
|
+
import { bestScore, useCommandItems } from './command-items'
|
|
6
|
+
vi.mock('../../api/client', () => ({ useNamespaces: () => ({ data: [] }), useContexts: () => ({ data: [] }) }))
|
|
7
|
+
vi.mock('../../api/apiResources', () => ({ CORE_RESOURCES: [], useAPIResources: () => ({ data: [{ group: 'apiextensions.k8s.io', kind: 'CustomResourceDefinition', name: 'customresourcedefinitions', verbs: ['list'] }, { group: '', kind: 'Pod', name: 'pods', verbs: ['list'] }] }) }))
|
|
8
|
+
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
|
|
9
|
+
it('uses the shared CRD aliases in command items', () => {
|
|
10
|
+
let scores: number[] = []
|
|
11
|
+
function Probe() {
|
|
12
|
+
const cb = { onNavigateView: vi.fn(), onNavigateKind: vi.fn(), onSwitchContext: vi.fn(), onSetNamespaces: vi.fn(), onToggleTheme: vi.fn() }
|
|
13
|
+
const items = useCommandItems(cb)
|
|
14
|
+
scores = items.filter(i => i.category === 'Resource Kinds').map(i => bestScore(i, 'crd'))
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
const host = document.createElement('div'); const root = createRoot(host)
|
|
18
|
+
act(() => root.render(<Probe />))
|
|
19
|
+
expect(scores).toHaveLength(2)
|
|
20
|
+
expect(scores[0]).toBeGreaterThan(0)
|
|
21
|
+
expect(scores[1]).toBe(0)
|
|
22
|
+
act(() => root.unmount())
|
|
23
|
+
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resourceSearchAliases } from "@skyhook-io/k8s-ui/utils/api-resources";
|
|
1
2
|
import { useMemo } from "react";
|
|
2
3
|
import {
|
|
3
4
|
Home,
|
|
@@ -184,7 +185,7 @@ export function useCommandItems(cb: CommandItemCallbacks): CommandItem[] {
|
|
|
184
185
|
category: "Resource Kinds",
|
|
185
186
|
icon: getResourceIcon(r.kind),
|
|
186
187
|
action: () => cb.onNavigateKind(r.name, r.group),
|
|
187
|
-
searchTerms: [r.name, r.kind],
|
|
188
|
+
searchTerms: [r.name, r.kind, ...resourceSearchAliases(r)],
|
|
188
189
|
priorityBonus: groupPriorityBonus(r.group),
|
|
189
190
|
});
|
|
190
191
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { ContextInfo } from '../types'
|
|
6
|
+
|
|
7
|
+
const mocks = vi.hoisted(() => ({
|
|
8
|
+
mutateAsync: vi.fn(),
|
|
9
|
+
setFailedSwitch: vi.fn(),
|
|
10
|
+
startSwitch: vi.fn(),
|
|
11
|
+
}))
|
|
12
|
+
vi.mock('../api/client', () => ({
|
|
13
|
+
useSwitchContext: () => ({ mutateAsync: mocks.mutateAsync, isPending: false, isError: false, error: null }),
|
|
14
|
+
fetchSessionCounts: async () => ({ portForwards: 0 }),
|
|
15
|
+
SwitchContextError: class extends Error {},
|
|
16
|
+
}))
|
|
17
|
+
vi.mock('../context/ContextSwitchContext', () => ({
|
|
18
|
+
useContextSwitch: () => ({
|
|
19
|
+
startSwitch: mocks.startSwitch,
|
|
20
|
+
endSwitch: vi.fn(),
|
|
21
|
+
setOpenAfterSwitch: vi.fn(),
|
|
22
|
+
setFailedSwitch: mocks.setFailedSwitch,
|
|
23
|
+
}),
|
|
24
|
+
}))
|
|
25
|
+
vi.mock('./ui/Toast', () => ({ useToast: () => ({ showError: vi.fn() }) }))
|
|
26
|
+
vi.mock('./dock', () => ({ useDock: () => ({ tabs: [] }) }))
|
|
27
|
+
|
|
28
|
+
const { useContextSwitchFlow } = await import('./useContextSwitchFlow')
|
|
29
|
+
|
|
30
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
31
|
+
let root: Root
|
|
32
|
+
const seen = vi.fn<(flow: ReturnType<typeof useContextSwitchFlow>) => void>()
|
|
33
|
+
const flow = () => seen.mock.lastCall![0]
|
|
34
|
+
|
|
35
|
+
function Probe() {
|
|
36
|
+
seen(useContextSwitchFlow())
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
vi.clearAllMocks()
|
|
42
|
+
root = createRoot(document.createElement('div'))
|
|
43
|
+
act(() => root.render(<Probe />))
|
|
44
|
+
})
|
|
45
|
+
afterEach(() => act(() => root.unmount()))
|
|
46
|
+
|
|
47
|
+
const ctx = (name: string, isCurrent: boolean) => ({ name, cluster: name, user: 'u', namespace: '', isCurrent }) as ContextInfo
|
|
48
|
+
|
|
49
|
+
describe('useContextSwitchFlow', () => {
|
|
50
|
+
it('picking the cluster you are still on dismisses a refused switch without switching', async () => {
|
|
51
|
+
await act(() => flow().requestSwitch(ctx('current', true)))
|
|
52
|
+
expect(mocks.setFailedSwitch).toHaveBeenCalledWith(null)
|
|
53
|
+
expect(mocks.startSwitch).not.toHaveBeenCalled()
|
|
54
|
+
expect(mocks.mutateAsync).not.toHaveBeenCalled()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('picking another cluster still switches', async () => {
|
|
58
|
+
await act(() => flow().requestSwitch(ctx('staging', false)))
|
|
59
|
+
expect(mocks.mutateAsync).toHaveBeenCalledWith({ name: 'staging' })
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, type ReactNode } from 'react'
|
|
2
2
|
import { AlertTriangle } from 'lucide-react'
|
|
3
3
|
import { pluralize } from '@skyhook-io/k8s-ui'
|
|
4
|
-
import { useSwitchContext, fetchSessionCounts, type SessionCounts } from '../api/client'
|
|
4
|
+
import { useSwitchContext, fetchSessionCounts, SwitchContextError, type SessionCounts } from '../api/client'
|
|
5
5
|
import { useContextSwitch } from '../context/ContextSwitchContext'
|
|
6
6
|
import { useToast } from './ui/Toast'
|
|
7
7
|
import { useDock } from './dock'
|
|
@@ -13,6 +13,12 @@ function shouldSuppressSwitchErrorToast(error: unknown): boolean {
|
|
|
13
13
|
return message.includes('cluster connection failed:')
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// A switch the server refused before leaving the current cluster, because the
|
|
17
|
+
// new one didn't answer. Those show the full connection error screen.
|
|
18
|
+
function refusedBeforeLeaving(error: unknown): error is SwitchContextError & { errorType: string } {
|
|
19
|
+
return error instanceof SwitchContextError && !!error.errorType
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
interface PendingSwitch {
|
|
17
23
|
context: ContextInfo
|
|
18
24
|
openAfter?: SelectedResource
|
|
@@ -24,7 +30,7 @@ interface PendingSwitch {
|
|
|
24
30
|
// live. Callers render `confirmDialog`.
|
|
25
31
|
export function useContextSwitchFlow() {
|
|
26
32
|
const switchContext = useSwitchContext()
|
|
27
|
-
const { startSwitch, endSwitch, setOpenAfterSwitch } = useContextSwitch()
|
|
33
|
+
const { startSwitch, endSwitch, setOpenAfterSwitch, setFailedSwitch } = useContextSwitch()
|
|
28
34
|
const { showError } = useToast()
|
|
29
35
|
const { tabs } = useDock()
|
|
30
36
|
const [pending, setPending] = useState<PendingSwitch | null>(null)
|
|
@@ -48,7 +54,9 @@ export function useContextSwitchFlow() {
|
|
|
48
54
|
endSwitch()
|
|
49
55
|
// Backend may not transition to StateDisconnected on client-side errors
|
|
50
56
|
// (network, timeout) — without this toast the user gets no feedback.
|
|
51
|
-
if (
|
|
57
|
+
if (refusedBeforeLeaving(error)) {
|
|
58
|
+
setFailedSwitch({ context: context.name, error: error.message, errorType: error.errorType })
|
|
59
|
+
} else if (!shouldSuppressSwitchErrorToast(error)) {
|
|
52
60
|
const message = error instanceof Error ? error.message : 'Unknown error'
|
|
53
61
|
showError('Failed to switch context', message)
|
|
54
62
|
}
|
|
@@ -56,7 +64,12 @@ export function useContextSwitchFlow() {
|
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
const requestSwitch = async (context: ContextInfo, openAfter?: SelectedResource) => {
|
|
59
|
-
if (
|
|
67
|
+
if (switchContext.isPending) return
|
|
68
|
+
// Picking the cluster you're still on dismisses a refused switch's screen.
|
|
69
|
+
if (context.isCurrent) {
|
|
70
|
+
setFailedSwitch(null)
|
|
71
|
+
return
|
|
72
|
+
}
|
|
60
73
|
// Active sessions (port forwards from API + terminal tabs from dock) get
|
|
61
74
|
// a confirmation prompt — switching contexts kills both.
|
|
62
75
|
try {
|
|
@@ -142,6 +155,10 @@ export function useContextSwitchFlow() {
|
|
|
142
155
|
requestSwitch,
|
|
143
156
|
isPending: switchContext.isPending,
|
|
144
157
|
error: switchContext.isError ? switchContext.error : null,
|
|
158
|
+
// The picker's inline line is for failures that don't get the full screen.
|
|
159
|
+
errorText: switchContext.isError && switchContext.error && !refusedBeforeLeaving(switchContext.error)
|
|
160
|
+
? switchContext.error.message
|
|
161
|
+
: null,
|
|
145
162
|
confirmDialog,
|
|
146
163
|
}
|
|
147
164
|
}
|
|
@@ -95,17 +95,24 @@ describe('composeReleaseNotes', () => {
|
|
|
95
95
|
|
|
96
96
|
it('turns highlights past the cards into lines ahead of the improvements, within the line cap', () => {
|
|
97
97
|
const notes = composeReleaseNotes([
|
|
98
|
-
entry('v1.16.0', [7, 7, 7, 7, 7, 2], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']),
|
|
98
|
+
entry('v1.16.0', [7, 7, 7, 7, 7, 7, 7, 2], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']),
|
|
99
99
|
entry('v1.15.0', [1], ['old']),
|
|
100
100
|
])
|
|
101
101
|
expect(notes.highlights).toHaveLength(MAX_CARDS)
|
|
102
102
|
expect(notes.lines).toHaveLength(MAX_LINES)
|
|
103
|
-
expect(notes.lines.slice(0, 2).map(l => l.text)).toEqual(['v1.16.0-
|
|
103
|
+
expect(notes.lines.slice(0, 2).map(l => l.text)).toEqual(['v1.16.0-7', 'v1.15.0-0'])
|
|
104
104
|
expect(notes.lines.map(l => l.text)).not.toContain('old')
|
|
105
105
|
})
|
|
106
106
|
|
|
107
|
-
it('scores the dialog by the cards it shows', () => {
|
|
107
|
+
it('scores the dialog by the strongest cards it shows', () => {
|
|
108
108
|
expect(composeReleaseNotes([entry('v1.16.0', [4, 4, 4, 4, 4, 10])]).score).toBe(10 + 4 * 4)
|
|
109
|
+
expect(composeReleaseNotes([entry('v1.16.0', [5, 3, 3, 3, 3, 3, 3])]).score).toBe(5 + 3 * 4)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it("doesn't count cards past the strongest five toward opening", () => {
|
|
113
|
+
const notes = composeReleaseNotes([entry('v1.16.0', [4, 4, 4, 4, 4, 4, 4])])
|
|
114
|
+
expect(notes.highlights).toHaveLength(MAX_CARDS)
|
|
115
|
+
expect(notes.score).toBeLessThan(AUTO_OPEN_SCORE)
|
|
109
116
|
})
|
|
110
117
|
})
|
|
111
118
|
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
type ComposedHighlight,
|
|
20
20
|
type ComposedNotes,
|
|
21
21
|
type ReleaseNotes,
|
|
22
|
+
MAX_CARDS,
|
|
22
23
|
} from './releaseNotes'
|
|
23
24
|
import type { UsageDataStatus } from '../../api/usage-data'
|
|
24
25
|
import { UsageDataAsk } from '../usage-data/UsageDataAsk'
|
|
@@ -276,8 +277,11 @@ export function WhatsNew({ onNavigate, usageData }: WhatsNewProps) {
|
|
|
276
277
|
|
|
277
278
|
if (isCloud) return null
|
|
278
279
|
|
|
280
|
+
// A full grid wraps most descriptions a line longer at the default width.
|
|
281
|
+
const width = view?.notes.highlights.length === MAX_CARDS ? 'w-[840px]' : 'w-[760px]'
|
|
282
|
+
|
|
279
283
|
return (
|
|
280
|
-
<DialogPortal open={open} onClose={close} ariaLabelledBy={titleId} className=
|
|
284
|
+
<DialogPortal open={open} onClose={close} ariaLabelledBy={titleId} className={clsx(width, 'max-w-[calc(100vw-2rem)] max-h-[min(980px,calc(100vh-4rem))] flex flex-col overflow-hidden rounded-xl')}>
|
|
281
285
|
{view && (
|
|
282
286
|
<WhatsNewContent
|
|
283
287
|
titleId={titleId}
|
|
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
7
7
|
import { Megaphone } from 'lucide-react'
|
|
8
8
|
import type { WhatsNewState } from '../../api/client'
|
|
9
9
|
import { openWhatsNew, useWhatsNewStatus, WhatsNew } from './WhatsNew'
|
|
10
|
-
import { RELEASE_NOTES, type ReleaseNotes } from './releaseNotes'
|
|
10
|
+
import { MAX_CARDS, RELEASE_NOTES, type ReleaseNotes } from './releaseNotes'
|
|
11
11
|
|
|
12
12
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
13
13
|
|
|
@@ -275,6 +275,20 @@ describe('WhatsNew', () => {
|
|
|
275
275
|
expect(status.current.unread).toBe(true)
|
|
276
276
|
})
|
|
277
277
|
|
|
278
|
+
it('widens the dialog only for a full set of cards', async () => {
|
|
279
|
+
serverState = { currentVersion: 'v1.15.0', storage: 'server', seenVersion: 'v1.14.1', priorInstall: true }
|
|
280
|
+
await render('/')
|
|
281
|
+
expect(document.querySelector('.w-\\[760px\\]')).not.toBeNull()
|
|
282
|
+
expect(document.querySelector('.w-\\[840px\\]')).toBeNull()
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
it('gives a full set of cards the wider dialog', async () => {
|
|
286
|
+
setCatalog({ ...HEADLINE, highlights: Array.from({ length: MAX_CARDS }, (_, i) => card(`card-${i}`, `Card ${i}`, 9)) })
|
|
287
|
+
serverState = { currentVersion: 'v1.15.0', storage: 'server', seenVersion: 'v1.14.1', priorInstall: true }
|
|
288
|
+
await render('/')
|
|
289
|
+
expect(document.querySelector('.w-\\[840px\\]')).not.toBeNull()
|
|
290
|
+
})
|
|
291
|
+
|
|
278
292
|
it('composes the releases a user skipped, leading with the strongest', async () => {
|
|
279
293
|
setCatalog(HEADLINE, QUIET)
|
|
280
294
|
serverState = { currentVersion: 'v1.16.0', storage: 'server', seenVersion: 'v1.14.1', priorInstall: true }
|
|
@@ -300,11 +314,11 @@ describe('WhatsNew', () => {
|
|
|
300
314
|
expect(seenPosts).toEqual([])
|
|
301
315
|
})
|
|
302
316
|
|
|
303
|
-
it.each(['', '=v1.
|
|
317
|
+
it.each(['', '=v1.20', '=1.20', '=v1.20.0'])('previews v1.20 on a Git development build with ?whats-new%s', async suffix => {
|
|
304
318
|
setCatalog(...SHIPPED)
|
|
305
319
|
serverState = { currentVersion: 'v1.18.0-113-gb49561b78', storage: 'server', seenVersion: 'v1.18.0', priorInstall: true }
|
|
306
320
|
await render(`/resources/pods?whats-new${suffix}`)
|
|
307
|
-
expect(dialog()?.textContent).toContain("What's new in Radar v1.
|
|
321
|
+
expect(dialog()?.textContent).toContain("What's new in Radar v1.20")
|
|
308
322
|
expect(dialog()?.textContent).toContain(SHIPPED[0].highlights[0].title)
|
|
309
323
|
await clickGotIt()
|
|
310
324
|
expect(seenPosts).toEqual([])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LucideIcon } from 'lucide-react'
|
|
2
|
-
import { BellOff, Bot, Database, GitCompareArrows, HardDrive, Hourglass, Layers, MessageCircleQuestionMark, Network, RefreshCcw, Scale, ScanSearch, ScrollText, Search, ShieldAlert, SlidersHorizontal, Undo2 } from 'lucide-react'
|
|
2
|
+
import { Activity, BellOff, Bot, Boxes, Braces, Database, GitCompareArrows, HardDrive, Hourglass, Layers, MessageCircleQuestionMark, Network, RefreshCcw, Scale, ScanSearch, ScrollText, Search, ShieldAlert, SlidersHorizontal, Undo2 } from 'lucide-react'
|
|
3
3
|
import { compareVersions } from '../../utils/version'
|
|
4
4
|
|
|
5
5
|
export interface ReleaseHighlight {
|
|
@@ -48,6 +48,76 @@ export const CHANGELOG_URL = 'https://radarhq.io/changelog'
|
|
|
48
48
|
// major release must have its own entry: scripts/check-whats-new.sh refuses to
|
|
49
49
|
// release one without it.
|
|
50
50
|
export const RELEASE_NOTES: ReleaseNotes[] = [
|
|
51
|
+
{
|
|
52
|
+
version: 'v1.20.0',
|
|
53
|
+
highlights: [
|
|
54
|
+
{
|
|
55
|
+
id: 'crd-schema-browser',
|
|
56
|
+
icon: Braces,
|
|
57
|
+
title: 'Explore CRDs and their schemas',
|
|
58
|
+
description: 'CRDs now have a sidebar row and a schema browser. Search fields, paste a path from an API error, and read types, defaults and validation rules.',
|
|
59
|
+
leadDescription: "CustomResourceDefinitions now have a sidebar row, and typing crd finds them in Cmd-K. The drawer and a full Schema tab show each version's fields in a tree like kubectl explain, with types, defaults and validation rules. Paste a path from an API server error to find the field and see the rules on its parents.",
|
|
60
|
+
importance: 8,
|
|
61
|
+
path: '/resources/customresourcedefinitions?apiGroup=apiextensions.k8s.io',
|
|
62
|
+
cta: 'Open CRDs',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'rollbacks-safer-syncs',
|
|
66
|
+
icon: Undo2,
|
|
67
|
+
title: 'Reliable rollbacks and safer Argo CD syncs',
|
|
68
|
+
description: "Argo CD rollback works and reports what it deployed; Deployment rollback matches kubectl. Syncs keep the Application's options and leave pruning off.",
|
|
69
|
+
importance: 7,
|
|
70
|
+
path: '/gitops',
|
|
71
|
+
cta: 'Open GitOps',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'kueue-support',
|
|
75
|
+
icon: Layers,
|
|
76
|
+
title: 'Deep Kueue support',
|
|
77
|
+
description: 'Browse queue Workloads, admission history and Kueue-reported pending positions. Issues flag rejected checks and broken queues, not quota waits.',
|
|
78
|
+
importance: 7,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'issues-more-failures',
|
|
82
|
+
icon: ShieldAlert,
|
|
83
|
+
title: 'Issues explain more failures',
|
|
84
|
+
description: 'Failed cert-manager renewals, evicted Pods with their node, surge deadlocks on ReadWriteOnce volumes, and webhooks that may block Pod creation.',
|
|
85
|
+
importance: 6,
|
|
86
|
+
path: '/issues',
|
|
87
|
+
cta: 'Open Issues',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'deeper-operator-support',
|
|
91
|
+
icon: Boxes,
|
|
92
|
+
title: 'Deeper Strimzi, Ray, JobSet and KServe support',
|
|
93
|
+
description: 'See failed connector tasks even when Ready, JobSet members in Topology and current Ray Pod logs. KServe flags failed components, not planned stops.',
|
|
94
|
+
importance: 6,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'application-evidence',
|
|
98
|
+
icon: Database,
|
|
99
|
+
title: 'Collect RabbitMQ, NATS and Vault evidence locally',
|
|
100
|
+
description: "On local Radar, collect one Pod's RabbitMQ alarms, NATS consumer counters or Vault seal state from a default plaintext endpoint.",
|
|
101
|
+
importance: 6,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: 'otel-flagger',
|
|
105
|
+
icon: Activity,
|
|
106
|
+
title: 'Deeper OpenTelemetry and Flagger support',
|
|
107
|
+
description: 'Flagger Issues name missing targets, metric templates and provider Secrets. AI diagnosis reads Collectors and Canaries through current workloads.',
|
|
108
|
+
importance: 5,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
improvements: [
|
|
112
|
+
// The grid fills row by row: pair lines of similar length.
|
|
113
|
+
'Switching to an unreachable context keeps your current cluster; Cannot Connect says since when',
|
|
114
|
+
'Issue rows and Investigate buttons show recent local investigations; see an example before your first',
|
|
115
|
+
'Limit what Radar can reach with rbac.namespaces, disableExec and --disable-auto-port-forward',
|
|
116
|
+
'GitOps trees show operator-created workloads; drawers link webhooks, issuers and Secrets',
|
|
117
|
+
'get_changes includes RBAC and Node edits; search finds resources by a pasted IP or ip:port',
|
|
118
|
+
'Issues link a missing Secret to its SealedSecret',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
51
121
|
{
|
|
52
122
|
version: 'v1.19.0',
|
|
53
123
|
highlights: [
|
|
@@ -374,7 +444,10 @@ export function unreadReleases(
|
|
|
374
444
|
// skipped releases sees the best of them, weighted toward the newest; older
|
|
375
445
|
// releases than this list covers are left to the changelog.
|
|
376
446
|
export const RELEASE_WEIGHTS = [1, 0.75, 0.5]
|
|
377
|
-
export const MAX_CARDS =
|
|
447
|
+
export const MAX_CARDS = 7
|
|
448
|
+
// Auto-open weighs only the strongest cards, so a release can't clear the bar
|
|
449
|
+
// on a long list of minor ones.
|
|
450
|
+
export const SCORED_CARDS = 5
|
|
378
451
|
export const MAX_LINES = 8
|
|
379
452
|
// A fuller set of useful improvements can merit an announcement even without
|
|
380
453
|
// a single release-defining feature.
|
|
@@ -396,7 +469,7 @@ export interface ComposedNotes {
|
|
|
396
469
|
/** The first one leads the dialog at full width. */
|
|
397
470
|
highlights: ComposedHighlight[]
|
|
398
471
|
lines: ComposedLine[]
|
|
399
|
-
/** Sum of the shown highlights' scores. */
|
|
472
|
+
/** Sum of the strongest shown highlights' scores, up to SCORED_CARDS. */
|
|
400
473
|
score: number
|
|
401
474
|
/** False when older unseen releases were left out. */
|
|
402
475
|
complete: boolean
|
|
@@ -419,7 +492,7 @@ export function composeReleaseNotes(releases: ReleaseNotes[]): ComposedNotes {
|
|
|
419
492
|
versions: shown.map(notes => notes.version),
|
|
420
493
|
highlights,
|
|
421
494
|
lines,
|
|
422
|
-
score: highlights.reduce((sum, h) => sum + h.score, 0),
|
|
495
|
+
score: highlights.slice(0, SCORED_CARDS).reduce((sum, h) => sum + h.score, 0),
|
|
423
496
|
complete: shown.length === releases.length,
|
|
424
497
|
}
|
|
425
498
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { act } from "react";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
5
|
+
import { renderToString } from "react-dom/server";
|
|
6
|
+
import type { RelatedFindingsGroup } from "@skyhook-io/k8s-ui";
|
|
7
|
+
import { RelatedFindingsSection } from "./RelatedFindingsSection";
|
|
8
|
+
|
|
9
|
+
const cached: RelatedFindingsGroup = {
|
|
10
|
+
associatedVia: {
|
|
11
|
+
group: "kafka.strimzi.io",
|
|
12
|
+
kind: "KafkaConnect",
|
|
13
|
+
namespace: "app",
|
|
14
|
+
name: "connect",
|
|
15
|
+
},
|
|
16
|
+
kinds: {
|
|
17
|
+
count: 1,
|
|
18
|
+
names: [{ group: "kafka.strimzi.io", kind: "KafkaConnector" }],
|
|
19
|
+
},
|
|
20
|
+
checked: 1,
|
|
21
|
+
unknown: 0,
|
|
22
|
+
gaps: [],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("Related findings coverage", () => {
|
|
26
|
+
it("opens the association anchor using the host's resource navigation", () => {
|
|
27
|
+
const onResourceClick = vi.fn();
|
|
28
|
+
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
|
|
29
|
+
const host = document.createElement("div");
|
|
30
|
+
const root = createRoot(host);
|
|
31
|
+
try {
|
|
32
|
+
act(() =>
|
|
33
|
+
root.render(
|
|
34
|
+
<RelatedFindingsSection
|
|
35
|
+
data={[{ ...cached, unknown: 1 }]}
|
|
36
|
+
onResourceClick={onResourceClick}
|
|
37
|
+
/>,
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
const button = host.querySelector("button")!;
|
|
41
|
+
expect(button.textContent).toBe(
|
|
42
|
+
"KafkaConnect app/connect (kafka.strimzi.io)",
|
|
43
|
+
);
|
|
44
|
+
act(() => button.click());
|
|
45
|
+
expect(onResourceClick).toHaveBeenCalledWith(cached.associatedVia);
|
|
46
|
+
} finally {
|
|
47
|
+
act(() => root.unmount());
|
|
48
|
+
vi.unstubAllGlobals();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
it("hides absent, empty and assessed groups without findings or limitations", () => {
|
|
52
|
+
for (const data of [undefined, [], [cached]])
|
|
53
|
+
expect(renderToString(<RelatedFindingsSection data={data} />)).toBe("");
|
|
54
|
+
});
|
|
55
|
+
it("explains unassessable snapshots from structured fields alone", () => {
|
|
56
|
+
const html = renderToString(
|
|
57
|
+
<RelatedFindingsSection data={[{ ...cached, unknown: 1 }]} />,
|
|
58
|
+
);
|
|
59
|
+
expect(html).toContain("1 of 1 checked resources");
|
|
60
|
+
expect(html).toContain("could not be assessed");
|
|
61
|
+
expect(html).toContain("KafkaConnector (kafka.strimzi.io)");
|
|
62
|
+
expect(html).toContain("status is reported separately");
|
|
63
|
+
expect(html).not.toContain("Operational issues");
|
|
64
|
+
});
|
|
65
|
+
it.each([
|
|
66
|
+
["radar_kind_not_collected", "Radar doesn't collect it"],
|
|
67
|
+
["kind_sync_pending", "still loading"],
|
|
68
|
+
])("explains %s using the existing read vocabulary", (code, explanation) => {
|
|
69
|
+
const html = renderToString(
|
|
70
|
+
<RelatedFindingsSection data={[{ ...cached, gaps: [{ code }] }]} />,
|
|
71
|
+
);
|
|
72
|
+
expect(html).toContain(explanation);
|
|
73
|
+
});
|
|
74
|
+
it("keeps input gaps and output omissions distinct", () => {
|
|
75
|
+
const gap = { ...cached, checked: 0, gaps: [{ code: "list_too_large" }] };
|
|
76
|
+
const html = renderToString(<RelatedFindingsSection data={[gap]} />);
|
|
77
|
+
expect(html).toContain("incomplete related inventory");
|
|
78
|
+
expect(html).not.toContain("Additional related findings were omitted");
|
|
79
|
+
const both = renderToString(
|
|
80
|
+
<RelatedFindingsSection data={[{ ...gap, truncated: true }]} />,
|
|
81
|
+
);
|
|
82
|
+
expect(both).toContain("incomplete related inventory");
|
|
83
|
+
expect(both).toContain("Additional related findings were omitted");
|
|
84
|
+
});
|
|
85
|
+
it("keeps independent anchors and counts separate without connector wording", () => {
|
|
86
|
+
const groups: RelatedFindingsGroup[] = [
|
|
87
|
+
{
|
|
88
|
+
...cached,
|
|
89
|
+
associatedVia: {
|
|
90
|
+
group: "postgresql.cnpg.io",
|
|
91
|
+
kind: "Cluster",
|
|
92
|
+
namespace: "db",
|
|
93
|
+
name: "orders",
|
|
94
|
+
},
|
|
95
|
+
kinds: {
|
|
96
|
+
count: 1,
|
|
97
|
+
names: [{ group: "postgresql.cnpg.io", kind: "Backup" }],
|
|
98
|
+
},
|
|
99
|
+
checked: 2,
|
|
100
|
+
unknown: 1,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
...cached,
|
|
104
|
+
associatedVia: {
|
|
105
|
+
group: "external-secrets.io",
|
|
106
|
+
kind: "ExternalSecret",
|
|
107
|
+
namespace: "app",
|
|
108
|
+
name: "credentials",
|
|
109
|
+
},
|
|
110
|
+
kinds: {
|
|
111
|
+
count: 1,
|
|
112
|
+
names: [{ group: "external-secrets.io", kind: "ClusterSecretStore" }],
|
|
113
|
+
},
|
|
114
|
+
checked: 3,
|
|
115
|
+
unknown: 2,
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
const html = renderToString(<RelatedFindingsSection data={groups} />);
|
|
119
|
+
expect(html).toContain("db/orders");
|
|
120
|
+
expect(html).toContain("app/credentials");
|
|
121
|
+
expect(html).toContain("1 of 2 checked");
|
|
122
|
+
expect(html).toContain("2 of 3 checked");
|
|
123
|
+
expect(html).not.toContain("3 of 5");
|
|
124
|
+
expect(html).not.toContain("connector");
|
|
125
|
+
});
|
|
126
|
+
});
|