@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
|
@@ -4,7 +4,7 @@ import { createPortal } from 'react-dom'
|
|
|
4
4
|
import {
|
|
5
5
|
Settings, X, RotateCcw, RotateCw, Loader2, Copy, Check, Pin, Shield, Lock, Plug,
|
|
6
6
|
Terminal, Boxes, Activity, GitBranch, Sparkles, SlidersHorizontal, Zap,
|
|
7
|
-
LayoutDashboard, ChevronRight, AlertTriangle, Coins, EyeOff,
|
|
7
|
+
LayoutDashboard, ChevronRight, AlertTriangle, Coins, EyeOff, Bot,
|
|
8
8
|
type LucideIcon,
|
|
9
9
|
} from 'lucide-react'
|
|
10
10
|
import { clsx } from 'clsx'
|
|
@@ -15,7 +15,7 @@ import { TRANSITION_BACKDROP, TRANSITION_PANEL, overlayExitMs, overlayTransition
|
|
|
15
15
|
import { apiUrl, getApiBase, getAuthHeaders, getCredentialsMode, mcpEndpointUrl } from '../../api/config'
|
|
16
16
|
import {
|
|
17
17
|
useCloudRole, useVersionCheck, useClusterInfo, usePrometheusStatus, useArgoStatus,
|
|
18
|
-
useOpenCostSummary,
|
|
18
|
+
useOpenCostSummary, useMetricsRelayCheck, useMetricsRelayChecking,
|
|
19
19
|
} from '../../api/client'
|
|
20
20
|
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
21
21
|
import { Input, ResourceRefBadge, SelectMenu, type ResourceRef } from '@skyhook-io/k8s-ui'
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
costSourcePreferenceLabel,
|
|
37
37
|
COST_SOURCE_OPTIONS,
|
|
38
38
|
} from '../cost/source'
|
|
39
|
-
import { costSourceApplyLabel, pendingSectionLabels, pendingSections, shouldShowSettingsFooter } from './settings-state'
|
|
39
|
+
import { costSourceApplyLabel, pendingSectionLabels, pendingSections, shouldShowSettingsFooter, showsSubstrateSection } from './settings-state'
|
|
40
40
|
import { PrometheusConfigField } from './PrometheusConfigField'
|
|
41
41
|
import { LocalConnectionSettings, type IntegrationProfiles, type IntegrationKind } from './LocalConnectionSettings'
|
|
42
42
|
import { LocalIntegrationStatus } from './LocalIntegrationStatus'
|
|
@@ -46,7 +46,14 @@ import { useContextSwitch } from '../../context/ContextSwitchContext'
|
|
|
46
46
|
import { previousIntegrationSettingsKey, type IntegrationSettingsResponse } from '../../hooks/usePreviousIntegrationSettings'
|
|
47
47
|
import type { SettingsSectionId } from './settings-state'
|
|
48
48
|
import { OperatorManagedNotice } from './OperatorManagedNotice'
|
|
49
|
+
import { CloudHintLink } from '../cloudHints/CloudHintLink'
|
|
50
|
+
import { useCloudHintsEnabled } from '../cloudHints/cloudHints'
|
|
49
51
|
import { FormSaveActions } from './FormSaveActions'
|
|
52
|
+
import { SubstrateSettings } from './SubstrateSettings'
|
|
53
|
+
import { useAPIResources } from '../../api/apiResources'
|
|
54
|
+
import { useRadarFeature } from '../../api/client'
|
|
55
|
+
import { useSubstrateConnection } from '../../api/substrateWorkspace'
|
|
56
|
+
import { substrateDiscovered } from '../substrate/useSubstrateSidebarWorkspace'
|
|
50
57
|
export type { SettingsSectionId } from './settings-state'
|
|
51
58
|
|
|
52
59
|
interface Config {
|
|
@@ -148,6 +155,7 @@ export function SettingsDialog({
|
|
|
148
155
|
onNavigateToResource,
|
|
149
156
|
}: SettingsDialogProps) {
|
|
150
157
|
const queryClient = useQueryClient()
|
|
158
|
+
useMetricsRelayCheck(open)
|
|
151
159
|
const dialogRef = useRef<HTMLDivElement>(null)
|
|
152
160
|
const { shouldRender, isOpen } = useAnimatedUnmount(open, overlayExitMs('dialog'))
|
|
153
161
|
const { data: versionInfo } = useVersionCheck()
|
|
@@ -168,6 +176,8 @@ export function SettingsDialog({
|
|
|
168
176
|
const metricsDirtyChange = useCallback((dirty: boolean) => setLocalDirty(value => ({ ...value, metrics: dirty })), [])
|
|
169
177
|
const argoDirtyChange = useCallback((dirty: boolean) => setLocalDirty(value => ({ ...value, argocd: dirty })), [])
|
|
170
178
|
const costDirtyChange = useCallback((dirty: boolean) => setLocalDirty(value => ({ ...value, cost: dirty })), [])
|
|
179
|
+
const [substrateDirty, setSubstrateDirty] = useState(false)
|
|
180
|
+
const [substrateBusy, setSubstrateBusy] = useState(false)
|
|
171
181
|
const [connectionsChangedAt, setConnectionsChangedAt] = useState(0)
|
|
172
182
|
const overviewHeading = useRef<HTMLHeadingElement>(null)
|
|
173
183
|
const previousNoticeDismissed = useCallback(() => {
|
|
@@ -193,6 +203,7 @@ export function SettingsDialog({
|
|
|
193
203
|
|
|
194
204
|
const [configData, setConfigData] = useState<ConfigResponse | null>(null)
|
|
195
205
|
const operatorManaged = configData?.management === 'operator'
|
|
206
|
+
const cloudHints = useCloudHintsEnabled()
|
|
196
207
|
const canEditConfig = configData != null && !operatorManaged && canAtLeast('owner')
|
|
197
208
|
const [editedConfig, setEditedConfig] = useState<Config>({})
|
|
198
209
|
const [saving, setSaving] = useState(false)
|
|
@@ -276,12 +287,12 @@ export function SettingsDialog({
|
|
|
276
287
|
const advancedDirty = mcpDirty || timelineDirty
|
|
277
288
|
const configDirty = configData != null && (connectionDirty || advancedDirty)
|
|
278
289
|
const prometheusDirty = prometheusCredentialDirty || localDirty.metrics || (editedConfig.prometheusUrl ?? '') !== (configData?.effective.prometheusUrl ?? '')
|
|
279
|
-
const pending = pendingSections({ prometheus: prometheusDirty, cost: costIntegrationDirty, argocd: localDirty.argocd, ai: aiDirty })
|
|
290
|
+
const pending = pendingSections({ prometheus: prometheusDirty, cost: costIntegrationDirty, argocd: localDirty.argocd, substrate: substrateDirty, ai: aiDirty })
|
|
280
291
|
const integrationDirty = pending.some(item => item !== 'ai')
|
|
281
292
|
// Drafts that save through their own form, which "Save startup settings" leaves in place.
|
|
282
293
|
const formDirty = pending.length > 0
|
|
283
294
|
const reviewSection = pending.find(item => item !== section)
|
|
284
|
-
const settingsBusy = saving || costCurrencySaving || integrationBusy || storageBusy
|
|
295
|
+
const settingsBusy = saving || costCurrencySaving || integrationBusy || storageBusy || substrateBusy
|
|
285
296
|
const metricsDraft = useRef({ open, scope: `${settingsApiBase}:${settingsCluster?.context}`, dirty: false })
|
|
286
297
|
const [draftFrozen, setDraftFrozen] = useState(false)
|
|
287
298
|
const [reloadVersion, setReloadVersion] = useState(0)
|
|
@@ -303,8 +314,8 @@ export function SettingsDialog({
|
|
|
303
314
|
return
|
|
304
315
|
}
|
|
305
316
|
if (draftFrozen) return
|
|
306
|
-
metricsDraft.current = { open, scope: settingsScope, dirty: configData != null && (prometheusDirty || configDirty || costIntegrationDirty || localDirty.argocd || aiDirty) }
|
|
307
|
-
}, [open, settingsScope, targetChangedWithDraft, draftFrozen, configData, prometheusDirty, configDirty, costIntegrationDirty, localDirty.argocd, aiDirty])
|
|
317
|
+
metricsDraft.current = { open, scope: settingsScope, dirty: substrateDirty || (configData != null && (prometheusDirty || configDirty || costIntegrationDirty || localDirty.argocd || aiDirty)) }
|
|
318
|
+
}, [open, settingsScope, targetChangedWithDraft, draftFrozen, configData, prometheusDirty, configDirty, costIntegrationDirty, localDirty.argocd, aiDirty, substrateDirty])
|
|
308
319
|
|
|
309
320
|
// Load config on open + snapshot AI prefs + pick a default section that's
|
|
310
321
|
// actually accessible to the current identity.
|
|
@@ -348,6 +359,33 @@ export function SettingsDialog({
|
|
|
348
359
|
if (open) setSection(initialSection)
|
|
349
360
|
}, [open, initialSection])
|
|
350
361
|
|
|
362
|
+
const { data: apiResources } = useAPIResources()
|
|
363
|
+
const { support: substrateSupport } = useRadarFeature('substrateWorkspace')
|
|
364
|
+
const substrateHere = substrateDiscovered(apiResources)
|
|
365
|
+
const substrateSupported = substrateSupport !== 'unsupported'
|
|
366
|
+
const canReadSavedSubstrate = capabilities.substrateLocalConnection === true
|
|
367
|
+
// A leftover saved connection can be disconnected even after Substrate is removed.
|
|
368
|
+
const substrateLeftover = useSubstrateConnection(open && apiResources !== undefined && !substrateHere && substrateSupported && canReadSavedSubstrate)
|
|
369
|
+
const substrateSaved = canReadSavedSubstrate && substrateLeftover.data?.view === 'local' && substrateLeftover.data.saved
|
|
370
|
+
// Kept until the dialog closes or the cluster changes, so Disconnect doesn't pull the section away mid-use.
|
|
371
|
+
const [substrateSavedOn, setSubstrateSavedOn] = useState<string | undefined>()
|
|
372
|
+
useEffect(() => {
|
|
373
|
+
if (!open) setSubstrateSavedOn(undefined)
|
|
374
|
+
else if (substrateSaved) setSubstrateSavedOn(settingsCluster?.context)
|
|
375
|
+
}, [open, substrateSaved, settingsCluster?.context])
|
|
376
|
+
const showSubstrate = showsSubstrateSection({
|
|
377
|
+
supported: substrateSupported,
|
|
378
|
+
discovered: substrateHere,
|
|
379
|
+
saved: substrateSaved || (substrateSavedOn !== undefined && substrateSavedOn === settingsCluster?.context),
|
|
380
|
+
dirty: substrateDirty,
|
|
381
|
+
})
|
|
382
|
+
const substrateKnown = apiResources !== undefined && (substrateHere || !substrateSupported ||
|
|
383
|
+
capabilities.substrateLocalConnection === false || substrateLeftover.isFetched)
|
|
384
|
+
// A cluster without Substrate has no section to stay on.
|
|
385
|
+
useEffect(() => {
|
|
386
|
+
if (open && section === 'substrate' && substrateKnown && !showSubstrate) setSection('overview')
|
|
387
|
+
}, [open, section, substrateKnown, showSubstrate])
|
|
388
|
+
|
|
351
389
|
useEffect(() => {
|
|
352
390
|
if (!open || diag.agents.length === 0) return
|
|
353
391
|
setAiDraft((current) => {
|
|
@@ -518,7 +556,7 @@ export function SettingsDialog({
|
|
|
518
556
|
requestCloseRef.current = (afterClose) => {
|
|
519
557
|
if (settingsBusy) return
|
|
520
558
|
pendingCloseActionRef.current = afterClose ?? null
|
|
521
|
-
if ((canEditConfig && (configDirty || integrationDirty)) || aiDirty) setConfirmingClose(true)
|
|
559
|
+
if ((canEditConfig && (configDirty || integrationDirty)) || aiDirty || substrateDirty) setConfirmingClose(true)
|
|
522
560
|
else finishClose()
|
|
523
561
|
}
|
|
524
562
|
|
|
@@ -566,17 +604,19 @@ export function SettingsDialog({
|
|
|
566
604
|
// per-section captions carry the restart-vs-live semantics, so group labels
|
|
567
605
|
// would only add visual weight. AI investigations is always shown (the section
|
|
568
606
|
// explains how to enable it when no agent CLI is installed).
|
|
569
|
-
const navItems
|
|
607
|
+
const navItems = ([
|
|
570
608
|
{ id: 'overview', label: 'Overview', icon: LayoutDashboard, ownerOnly: false, dirty: false },
|
|
571
609
|
{ id: 'perms', label: 'My permissions', icon: Shield, ownerOnly: false, dirty: false },
|
|
572
610
|
{ id: 'connection', label: 'Connection', icon: Boxes, ownerOnly: true, dirty: connectionDirty },
|
|
573
611
|
{ id: 'prometheus', label: 'Metrics', icon: Activity, ownerOnly: true, dirty: prometheusDirty },
|
|
574
612
|
{ id: 'cost', label: 'Cost', icon: Coins, ownerOnly: true, dirty: costIntegrationDirty },
|
|
575
613
|
{ id: 'argocd', label: 'Argo CD', icon: GitBranch, ownerOnly: true, dirty: localDirty.argocd },
|
|
614
|
+
// Open to everyone: in a shared Radar it shows how Radar reads Substrate and the person's own access. Only on clusters it applies to.
|
|
615
|
+
{ id: 'substrate', label: 'Agent Substrate', icon: Bot, ownerOnly: false, dirty: substrateDirty },
|
|
576
616
|
{ id: 'ai', label: 'AI investigations', icon: Sparkles, ownerOnly: false, dirty: aiDirty },
|
|
577
617
|
{ id: 'privacy', label: 'Privacy', icon: EyeOff, ownerOnly: false, dirty: false },
|
|
578
618
|
{ id: 'advanced', label: 'Advanced', icon: SlidersHorizontal, ownerOnly: true, dirty: advancedDirty },
|
|
579
|
-
]
|
|
619
|
+
] as NavItemDef[]).filter((item) => item.id !== 'substrate' || showSubstrate)
|
|
580
620
|
|
|
581
621
|
const showFooter = shouldShowSettingsFooter({
|
|
582
622
|
canEditConfig,
|
|
@@ -698,10 +738,10 @@ export function SettingsDialog({
|
|
|
698
738
|
setReloadVersion((version) => version + 1)
|
|
699
739
|
}}>Discard draft and load current cluster</button>
|
|
700
740
|
</div>}
|
|
701
|
-
{!configData && !['overview', 'perms', 'ai', 'privacy'].includes(section) ? (
|
|
741
|
+
{!configData && !['overview', 'perms', 'ai', 'privacy', 'substrate'].includes(section) ? (
|
|
702
742
|
<p className="text-sm text-theme-text-secondary">{loadError ? 'Configuration is unavailable. Close Settings and try again.' : 'Loading configuration…'}</p>
|
|
703
743
|
) : <div inert={draftFrozen || settingsBusy || undefined} className={draftFrozen ? 'opacity-60' : undefined}>
|
|
704
|
-
{operatorManaged && section !== 'perms' && section !== 'ai' && section !== 'privacy' && <div className="mb-4"><OperatorManagedNotice /></div>}
|
|
744
|
+
{operatorManaged && section !== 'perms' && section !== 'ai' && section !== 'privacy' && section !== 'substrate' && <div className="mb-4"><OperatorManagedNotice /></div>}
|
|
705
745
|
{/* Overview — status at a glance; the landing section */}
|
|
706
746
|
<div className={clsx(section !== 'overview' && 'hidden')} role="tabpanel" inert={section !== 'overview' || undefined}>
|
|
707
747
|
<div className="mb-1">
|
|
@@ -896,6 +936,17 @@ export function SettingsDialog({
|
|
|
896
936
|
/>}
|
|
897
937
|
</SectionPane>
|
|
898
938
|
|
|
939
|
+
{/* Agent Substrate — a local Radar saves this context's connection; elsewhere a read-only summary. */}
|
|
940
|
+
<SectionPane
|
|
941
|
+
id="substrate"
|
|
942
|
+
active={section}
|
|
943
|
+
title="Agent Substrate"
|
|
944
|
+
caption={configData?.management === 'local' ? localIntegrationCaption : undefined}
|
|
945
|
+
live
|
|
946
|
+
>
|
|
947
|
+
<SubstrateSettings key={`${discardGeneration}:${reloadVersion}`} active={open && section === 'substrate' && showSubstrate && (substrateHere || canReadSavedSubstrate)} onDirtyChange={setSubstrateDirty} onBusyChange={setSubstrateBusy} />
|
|
948
|
+
</SectionPane>
|
|
949
|
+
|
|
899
950
|
{/* AI investigations — self-saving, usable by everyone. Same heading block
|
|
900
951
|
as every other tab; the body is the agent controls (when a CLI is
|
|
901
952
|
installed) or an enable explainer (when not). */}
|
|
@@ -910,7 +961,22 @@ export function SettingsDialog({
|
|
|
910
961
|
: "Investigate incidents with an AI agent that runs on your own machine — reading logs, events, and topology to understand what's happening. No Radar cloud, no API key."}
|
|
911
962
|
</p>
|
|
912
963
|
</div>
|
|
913
|
-
{operatorManaged ?
|
|
964
|
+
{operatorManaged ? (
|
|
965
|
+
<p className="text-sm text-theme-text-secondary">
|
|
966
|
+
Local AI investigations are unavailable in a shared installation. Use local Radar with an agent CLI, or{' '}
|
|
967
|
+
{cloudHints ? (
|
|
968
|
+
<CloudHintLink
|
|
969
|
+
entry="settings-ai"
|
|
970
|
+
// Through the close guard, so unsaved startup edits still
|
|
971
|
+
// prompt; the Cloud dialog opens once Settings has left.
|
|
972
|
+
onBeforeOpen={(open) => requestCloseRef.current(() => window.setTimeout(open, overlayExitMs('dialog')))}
|
|
973
|
+
/>
|
|
974
|
+
) : (
|
|
975
|
+
'Radar Cloud'
|
|
976
|
+
)}
|
|
977
|
+
.
|
|
978
|
+
</p>
|
|
979
|
+
) : aiAvailable ? (
|
|
914
980
|
<div className="space-y-4">
|
|
915
981
|
<AISettingsSection
|
|
916
982
|
available={diag.available}
|
|
@@ -1213,6 +1279,7 @@ function SectionCaption({ children, live }: { children: ReactNode; live?: boolea
|
|
|
1213
1279
|
|
|
1214
1280
|
function OperatorSettingsSummary({ section, config }: { section: SettingsSectionId; config: ConfigResponse }) {
|
|
1215
1281
|
const { data: prom, error: promError } = usePrometheusStatus()
|
|
1282
|
+
const metricsChecking = useMetricsRelayChecking()
|
|
1216
1283
|
const { data: argo, error: argoError } = useArgoStatus(section === 'argocd')
|
|
1217
1284
|
const { data: cost, error: costError } = useOpenCostSummary()
|
|
1218
1285
|
const { data: cluster } = useClusterInfo()
|
|
@@ -1226,7 +1293,7 @@ function OperatorSettingsSummary({ section, config }: { section: SettingsSection
|
|
|
1226
1293
|
break
|
|
1227
1294
|
case 'prometheus':
|
|
1228
1295
|
rows = [
|
|
1229
|
-
['Status', promError ? 'Status unavailable' : metricsConnectionLabel(prom)],
|
|
1296
|
+
['Status', promError ? 'Status unavailable' : metricsChecking ? 'Checking…' : metricsConnectionLabel(prom)],
|
|
1230
1297
|
['Endpoint', prom?.address || c.prometheusUrl || 'Auto-discovery'],
|
|
1231
1298
|
['Headers', config.prometheusHeaderKeys?.join(', ') || 'None configured'],
|
|
1232
1299
|
]
|
|
@@ -1314,6 +1381,7 @@ interface OverviewRow {
|
|
|
1314
1381
|
function OverviewPanel({ active, onNavigate }: { active: boolean; onNavigate: (s: SettingsSectionId) => void }) {
|
|
1315
1382
|
const { data: cluster } = useClusterInfo()
|
|
1316
1383
|
const { data: prom } = usePrometheusStatus()
|
|
1384
|
+
const metricsChecking = useMetricsRelayChecking()
|
|
1317
1385
|
const { data: cost } = useOpenCostSummary()
|
|
1318
1386
|
const { data: argo } = useArgoStatus(active)
|
|
1319
1387
|
const capabilities = useCapabilitiesContext()
|
|
@@ -1345,8 +1413,8 @@ function OverviewPanel({ active, onNavigate }: { active: boolean; onNavigate: (s
|
|
|
1345
1413
|
},
|
|
1346
1414
|
{
|
|
1347
1415
|
id: 'prometheus', icon: Activity, label: 'Metrics',
|
|
1348
|
-
tone: hasPrometheusCharts(prom) ? 'ok' : metricsSourceUnavailable(prom) ? 'warn' : prom?.discovering ? 'unknown' : prom?.error ? 'warn' : 'off',
|
|
1349
|
-
value: prom ? metricsConnectionLabel(prom) : 'Not connected',
|
|
1416
|
+
tone: metricsChecking ? 'unknown' : hasPrometheusCharts(prom) ? 'ok' : metricsSourceUnavailable(prom) ? 'warn' : prom?.discovering ? 'unknown' : prom?.error ? 'warn' : 'off',
|
|
1417
|
+
value: metricsChecking ? 'Checking…' : prom ? metricsConnectionLabel(prom) : 'Not connected',
|
|
1350
1418
|
detail: hasPrometheusCharts(prom) && prom?.connected ? prom.address : prom?.gkeSystemMetrics || prom?.discovering ? undefined : prom?.error || metricsSourceUnavailable(prom) ? 'Open Metrics for connection details.' : undefined,
|
|
1351
1419
|
},
|
|
1352
1420
|
{
|
|
@@ -0,0 +1,210 @@
|
|
|
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 { SubstrateSettings } from './SubstrateSettings'
|
|
6
|
+
|
|
7
|
+
// The form's lifecycle: what it saves against, what it keeps across refetches
|
|
8
|
+
// and cluster changes, and which access it shows.
|
|
9
|
+
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
const state = vi.hoisted(() => ({
|
|
12
|
+
view: undefined as any,
|
|
13
|
+
status: undefined as any,
|
|
14
|
+
put: vi.fn(),
|
|
15
|
+
refetch: vi.fn(),
|
|
16
|
+
dirty: vi.fn(),
|
|
17
|
+
}))
|
|
18
|
+
|
|
19
|
+
vi.mock('../../api/substrateWorkspace', () => ({
|
|
20
|
+
useSubstrateConnection: () => ({ data: state.view, refetch: state.refetch }),
|
|
21
|
+
useSubstrateStatus: () => state.status,
|
|
22
|
+
useUpdateSubstrateConnection: () => ({ mutate: state.put, reset() {}, isPending: false, error: null }),
|
|
23
|
+
substrateErrorCode: (e: any) => e?.code,
|
|
24
|
+
}))
|
|
25
|
+
vi.mock('../substrate/shared', () => ({
|
|
26
|
+
Term: ({ children }: any) => children,
|
|
27
|
+
CommandChip: () => null,
|
|
28
|
+
}))
|
|
29
|
+
vi.mock('@skyhook-io/k8s-ui', () => ({
|
|
30
|
+
Input: (props: any) => <input {...props} />,
|
|
31
|
+
AlertBanner: ({ children, title }: any) => <div>{title}{children}</div>,
|
|
32
|
+
Badge: ({ children }: any) => <span>{children}</span>,
|
|
33
|
+
Collapse: ({ children }: any) => <div>{children}</div>,
|
|
34
|
+
CollapseChevron: () => null,
|
|
35
|
+
ConfirmDialog: ({ open, onConfirm, confirmLabel }: any) => (open ? <button onClick={onConfirm}>{confirmLabel}</button> : null),
|
|
36
|
+
toneTextClass: () => '',
|
|
37
|
+
}))
|
|
38
|
+
|
|
39
|
+
let root: Root
|
|
40
|
+
let host: HTMLDivElement
|
|
41
|
+
const draw = (active = true) => act(async () => root.render(<SubstrateSettings active={active} onDirtyChange={state.dirty} onBusyChange={() => {}} />))
|
|
42
|
+
const input = (placeholder: string) => host.querySelector<HTMLInputElement>(`input[placeholder="${placeholder}"]`)!
|
|
43
|
+
async function type(placeholder: string, value: string) {
|
|
44
|
+
const el = input(placeholder)
|
|
45
|
+
await act(async () => {
|
|
46
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(el, value)
|
|
47
|
+
el.dispatchEvent(new Event('input', { bubbles: true }))
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
const click = (label: string) => act(async () => Array.from(host.querySelectorAll('button')).find((b) => b.textContent === label)!.click())
|
|
51
|
+
|
|
52
|
+
const target = { binding: 'b', context: 'dev', fingerprint: 'fp', clientGeneration: 1, operationGeneration: 1 }
|
|
53
|
+
const localView = (over: any = {}) => ({
|
|
54
|
+
view: 'local', saved: true, targetChanged: false, target, revision: 'r1',
|
|
55
|
+
settings: { identity: 'tokenFile', tokenFile: '/old.token' },
|
|
56
|
+
sharedPrincipal: 'system:serviceaccount:ate-system:ate-client',
|
|
57
|
+
access: { state: 'connected' },
|
|
58
|
+
...over,
|
|
59
|
+
})
|
|
60
|
+
const status = (apiTier: any = { state: 'connected' }) => ({
|
|
61
|
+
data: { installed: true, apiService: { namespace: 'ate-system', name: 'api', port: 443, found: true }, apiTier, coverage: { pools: { state: 'full' } }, canConfigure: true },
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
beforeEach(async () => {
|
|
65
|
+
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
|
|
66
|
+
state.put.mockReset()
|
|
67
|
+
state.refetch.mockReset()
|
|
68
|
+
state.dirty.mockClear()
|
|
69
|
+
state.view = localView()
|
|
70
|
+
state.status = status()
|
|
71
|
+
host = document.createElement('div')
|
|
72
|
+
document.body.append(host)
|
|
73
|
+
root = createRoot(host)
|
|
74
|
+
await draw()
|
|
75
|
+
})
|
|
76
|
+
afterEach(async () => {
|
|
77
|
+
await act(async () => root.unmount())
|
|
78
|
+
host.remove()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('the local Substrate connection form', () => {
|
|
82
|
+
it('saves an edit against the revision it was read at, even after another save lands', async () => {
|
|
83
|
+
await type('research, support-bots', 'research')
|
|
84
|
+
expect(state.dirty).toHaveBeenLastCalledWith(true)
|
|
85
|
+
state.view = localView({ revision: 'r2', settings: { identity: 'tokenFile', tokenFile: '/someone-elses.token' } })
|
|
86
|
+
await draw()
|
|
87
|
+
expect(host.textContent).toContain('This connection changed since you started editing')
|
|
88
|
+
await click('Save changes')
|
|
89
|
+
// The server refuses r1 with conflict; the form never pairs its old draft with r2.
|
|
90
|
+
expect(state.put.mock.calls[0][0]).toMatchObject({ revision: 'r1', settings: { tokenFile: '/old.token', atespaces: ['research'] } })
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('loads the other save on Discard', async () => {
|
|
94
|
+
await type('research, support-bots', 'research')
|
|
95
|
+
state.view = localView({ revision: 'r2', settings: { identity: 'tokenFile', tokenFile: '/new.token' } })
|
|
96
|
+
await draw()
|
|
97
|
+
await click('Discard')
|
|
98
|
+
expect(input('~/ate.token').value).toBe('/new.token')
|
|
99
|
+
expect(state.dirty).toHaveBeenLastCalledWith(false)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('follows a newer save when it has no edits', async () => {
|
|
103
|
+
state.view = localView({ revision: 'r2', settings: { identity: 'tokenFile', tokenFile: '/new.token' } })
|
|
104
|
+
await draw()
|
|
105
|
+
expect(input('~/ate.token').value).toBe('/new.token')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('follows a new target generation while clean, and saves against it', async () => {
|
|
109
|
+
state.view = localView({ target: { ...target, clientGeneration: 2, operationGeneration: 2 } })
|
|
110
|
+
await draw()
|
|
111
|
+
await type('research, support-bots', 'research')
|
|
112
|
+
await click('Save changes')
|
|
113
|
+
expect(state.put.mock.calls[0][0].target).toMatchObject({ clientGeneration: 2, operationGeneration: 2 })
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('adopts a later return to the revision a save replaced, once the save was seen', async () => {
|
|
117
|
+
state.put.mockImplementationOnce((_update: unknown, callbacks: any) =>
|
|
118
|
+
callbacks.onSuccess(localView({ revision: 'r2', settings: { identity: 'tokenFile', tokenFile: '/old.token', atespaces: ['research'] } })))
|
|
119
|
+
await type('research, support-bots', 'research')
|
|
120
|
+
await click('Save changes')
|
|
121
|
+
// The query still holds r1 for a moment: not adopted.
|
|
122
|
+
await draw()
|
|
123
|
+
expect(input('research, support-bots').value).toBe('research')
|
|
124
|
+
// It catches up to r2, then another Radar restores r1's contents.
|
|
125
|
+
state.view = localView({ revision: 'r2', settings: { identity: 'tokenFile', tokenFile: '/old.token', atespaces: ['research'] } })
|
|
126
|
+
await draw()
|
|
127
|
+
state.view = localView({ revision: 'r1' })
|
|
128
|
+
await draw()
|
|
129
|
+
expect(input('research, support-bots').value).toBe('')
|
|
130
|
+
await type('research, support-bots', 'support-bots')
|
|
131
|
+
await click('Save changes')
|
|
132
|
+
expect(state.put.mock.calls[1][0].revision).toBe('r1')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('keeps an edited draft on screen while the next cluster’s view loads, and doesn’t adopt it', async () => {
|
|
136
|
+
await type('research, support-bots', 'research')
|
|
137
|
+
state.view = undefined
|
|
138
|
+
await draw()
|
|
139
|
+
expect(input('research, support-bots').value).toBe('research')
|
|
140
|
+
expect(state.dirty).toHaveBeenLastCalledWith(true)
|
|
141
|
+
state.view = localView({ target: { ...target, binding: 'other', context: 'other', fingerprint: 'other-fp' } })
|
|
142
|
+
await draw()
|
|
143
|
+
expect(input('research, support-bots').value).toBe('research')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('shows the polled access, not the one the view was read with', async () => {
|
|
147
|
+
state.view = localView({ access: { state: 'connecting' } })
|
|
148
|
+
state.status = status({ state: 'connected', endpoint: '127.0.0.1:18443' })
|
|
149
|
+
await draw()
|
|
150
|
+
expect(host.textContent).toContain('Connected')
|
|
151
|
+
expect(host.textContent).not.toContain('Connecting')
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('says a failed status request failed, and still offers the form', async () => {
|
|
155
|
+
state.status = { isError: true, error: new Error('HTTP 503') }
|
|
156
|
+
await draw()
|
|
157
|
+
expect(host.textContent).toContain('Radar couldn’t check Substrate’s status on this cluster: HTTP 503.')
|
|
158
|
+
expect(host.textContent).toContain('Who Radar reads Substrate as')
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('offers Disconnect for a connection saved on a cluster that no longer serves Substrate', async () => {
|
|
162
|
+
state.status = { data: { ...status().data, installed: false } }
|
|
163
|
+
await draw()
|
|
164
|
+
expect(host.textContent).toContain('a connection to it is still saved here')
|
|
165
|
+
expect(host.textContent).toContain('Disconnect API')
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('says only that Substrate isn’t installed when nothing is saved here', async () => {
|
|
169
|
+
state.view = localView({ saved: false, settings: null })
|
|
170
|
+
state.status = { data: { ...status().data, installed: false } }
|
|
171
|
+
await draw()
|
|
172
|
+
expect(host.textContent).toContain('Agent Substrate isn’t installed on this cluster')
|
|
173
|
+
expect(host.textContent).not.toContain('Disconnect API')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('leaves a clean, empty form after a disconnect', async () => {
|
|
177
|
+
state.put.mockImplementationOnce((_update: unknown, callbacks: any) =>
|
|
178
|
+
callbacks.onSuccess(localView({ saved: false, settings: null, revision: 'r2', access: { state: 'notConfigured' } })))
|
|
179
|
+
await click('Disconnect API')
|
|
180
|
+
await click('Disconnect')
|
|
181
|
+
expect(input('~/ate.token').value).toBe('')
|
|
182
|
+
expect(state.dirty).toHaveBeenLastCalledWith(false)
|
|
183
|
+
expect(host.textContent).toContain('Disconnected.')
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('resends the same draft, target and revision with explicit destination consent', async () => {
|
|
187
|
+
await type('api.example.com:443', 'new.example.com:443')
|
|
188
|
+
state.put.mockImplementationOnce((_update: unknown, callbacks: any) => callbacks.onError({ code: 'confirmDestination', message: 'The saved credential would go to a changed address: endpoint 127.0.0.1:18443 → new.example.com:443.' }))
|
|
189
|
+
await click('Save changes')
|
|
190
|
+
const original = state.put.mock.calls[0][0]
|
|
191
|
+
expect(original.confirmDestination).toBeUndefined()
|
|
192
|
+
await click('Send and save')
|
|
193
|
+
expect(state.put.mock.calls[1][0]).toEqual({ ...original, confirmDestination: true })
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
describe('the managed Substrate summary', () => {
|
|
198
|
+
it('refreshes changed access only while the managed settings are active', async () => {
|
|
199
|
+
state.view = {
|
|
200
|
+
view: 'managed', sharedPrincipal: 'system:serviceaccount:ate-system:ate-client', access: { state: 'connecting' },
|
|
201
|
+
managed: { enabled: true, readsAs: 'eachUser', endpoint: 'api.ate-system.svc:443', serverName: 'api.ate-system.svc', trust: 'clusterTrustBundle', helm: { api: 'substrate.api.enabled', endpoint: '', serverName: '', ca: '', atespaces: '' } },
|
|
202
|
+
}
|
|
203
|
+
state.status = status({ state: 'connected' })
|
|
204
|
+
await draw(false)
|
|
205
|
+
expect(state.refetch).not.toHaveBeenCalled()
|
|
206
|
+
await draw()
|
|
207
|
+
expect(state.refetch).toHaveBeenCalledOnce()
|
|
208
|
+
expect(host.textContent).toContain('Connected')
|
|
209
|
+
})
|
|
210
|
+
})
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
4
|
+
import { SubstrateSettings } from './SubstrateSettings'
|
|
5
|
+
import { apiDisabledTier, connection, managedConnection, mintDeniedTier, sharedTier, status } from '../substrate/substrate.fixtures'
|
|
6
|
+
|
|
7
|
+
const state = vi.hoisted(() => ({
|
|
8
|
+
connection: undefined as unknown,
|
|
9
|
+
status: undefined as unknown,
|
|
10
|
+
upgrade: false,
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
vi.mock('../../api/client', async (importOriginal) => ({
|
|
14
|
+
...(await importOriginal<typeof import('../../api/client')>()),
|
|
15
|
+
usePrometheusStatus: () => ({ data: { connected: true } }),
|
|
16
|
+
}))
|
|
17
|
+
vi.mock('../../api/substrateWorkspace', async (importOriginal) => ({
|
|
18
|
+
...(await importOriginal<typeof import('../../api/substrateWorkspace')>()),
|
|
19
|
+
useSubstrateConnection: () => ({ data: state.connection, isError: false, upgrade: state.upgrade, blockedReason: state.upgrade ? 'Agent Substrate needs a newer Radar on this cluster.' : undefined }),
|
|
20
|
+
useSubstrateStatus: () => ({ data: state.status, isError: false, upgrade: false }),
|
|
21
|
+
useUpdateSubstrateConnection: () => ({ mutate: vi.fn(), reset: vi.fn(), isPending: false, error: null }),
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
const text = (html: string) => html.replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, '&')
|
|
25
|
+
|
|
26
|
+
// Status polls the same access the view was read with.
|
|
27
|
+
function render(conn: { access?: unknown }, over: Parameters<typeof status>[0] = {}) {
|
|
28
|
+
state.connection = conn
|
|
29
|
+
state.status = status({ apiTier: conn.access as never, ...over })
|
|
30
|
+
return text(renderToStaticMarkup(
|
|
31
|
+
<MemoryRouter>
|
|
32
|
+
<SubstrateSettings active onDirtyChange={() => {}} onBusyChange={() => {}} />
|
|
33
|
+
</MemoryRouter>,
|
|
34
|
+
))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('Settings → Agent Substrate on a local Radar', () => {
|
|
38
|
+
it('leads with who Radar reads as, recommends a token file, and saves only after an edit', () => {
|
|
39
|
+
const html = render(connection())
|
|
40
|
+
expect(html).toContain('Who Radar reads Substrate as')
|
|
41
|
+
expect(html).toContain('A token file')
|
|
42
|
+
expect(html).toContain('Recommended')
|
|
43
|
+
expect(html).toContain('Radar saves only the path, and never sends the token to the browser.')
|
|
44
|
+
expect(html).toContain('Substrate’s shared client')
|
|
45
|
+
expect(html).toContain('This identity may be a global owner')
|
|
46
|
+
expect(html).toContain('Radar found Service ')
|
|
47
|
+
expect(html).toContain('Advanced: API server address, TLS and atespaces')
|
|
48
|
+
// The fallback atespaces are never offered as a limit on access.
|
|
49
|
+
expect(html).toContain('These names don’t limit what it can read.')
|
|
50
|
+
expect(html.indexOf('Who Radar reads Substrate as')).toBeLessThan(html.indexOf('Advanced: API server address'))
|
|
51
|
+
// Nothing edited: nothing to save, and nothing saved to disconnect.
|
|
52
|
+
expect(html).toMatch(/<button type="button" disabled=""[^>]*>Save changes<\/button>/)
|
|
53
|
+
expect(html).not.toContain('Disconnect API')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('offers Disconnect apart from saving, in the destructive tone, once a connection is saved', async () => {
|
|
57
|
+
const { toneTextClass } = await import('@skyhook-io/k8s-ui')
|
|
58
|
+
const html = render(connection({ saved: true, settings: { identity: 'tokenFile', tokenFile: '/Users/me/.radar/viewer.token', caFile: '/Users/me/.radar/a-long-ca-bundle.pem' } }))
|
|
59
|
+
const at = html.indexOf('>Disconnect API</button>')
|
|
60
|
+
expect(at).toBeGreaterThan(html.indexOf('Save changes'))
|
|
61
|
+
expect(html.slice(html.lastIndexOf('<button', at), at)).toContain(toneTextClass('unhealthy'))
|
|
62
|
+
// A long path is inspectable whole, on hover.
|
|
63
|
+
expect(html).toContain('title="/Users/me/.radar/a-long-ca-bundle.pem"')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('unfolds the shared identity’s warning once that identity is chosen', () => {
|
|
67
|
+
const html = render(connection({ saved: true, settings: { identity: 'shared' } }))
|
|
68
|
+
const at = html.indexOf('This identity may be a global owner')
|
|
69
|
+
const fold = html.lastIndexOf('<div class="relative overflow-hidden"', at)
|
|
70
|
+
expect(html.slice(fold, at)).not.toContain('inert')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('asks to review a connection saved for another cluster before using it here', () => {
|
|
74
|
+
const html = render(connection({ saved: true, targetChanged: true, settings: { identity: 'shared' }, access: { state: 'failed', code: 'targetChanged' } }))
|
|
75
|
+
expect(html).toContain('Saved for another cluster')
|
|
76
|
+
expect(html).toContain('>Use it for this cluster</button>')
|
|
77
|
+
expect(html).toContain('Disconnect API instead')
|
|
78
|
+
expect(html).toMatch(/<fieldset disabled=""/)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('says when Substrate isn’t installed instead of offering a form', () => {
|
|
82
|
+
const html = render(connection(), { installed: false })
|
|
83
|
+
expect(html).toContain('Agent Substrate isn’t installed on this cluster')
|
|
84
|
+
expect(html).not.toContain('Who Radar reads Substrate as')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('says an older Radar can’t serve these settings', () => {
|
|
88
|
+
state.upgrade = true
|
|
89
|
+
const html = render(connection())
|
|
90
|
+
state.upgrade = false
|
|
91
|
+
expect(html).toContain('needs a newer Radar')
|
|
92
|
+
expect(html).not.toContain('Who Radar reads Substrate as')
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('Settings → Agent Substrate on an in-cluster Radar or Radar Hub', () => {
|
|
97
|
+
it('shows how the installation reads Substrate as text, never as inputs, with the Helm values that set it', () => {
|
|
98
|
+
const html = render(managedConnection(), { canConfigure: false })
|
|
99
|
+
expect(html).toContain('Your access')
|
|
100
|
+
expect(html).toContain('Connected')
|
|
101
|
+
expect(html).toContain('For each signed-in person, with a token created with their own Kubernetes access.')
|
|
102
|
+
expect(html).toContain('api.ate-system.svc:443')
|
|
103
|
+
expect(html).toContain('The cluster’s trust bundle for Substrate')
|
|
104
|
+
expect(html).toContain('Managed by your operator')
|
|
105
|
+
expect(html).toContain('substrate.api')
|
|
106
|
+
expect(html).not.toContain('<input')
|
|
107
|
+
expect(html).not.toContain('Who Radar reads Substrate as')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('tells a person whose access can’t mint the token what to ask for', () => {
|
|
111
|
+
const html = render(managedConnection({ access: mintDeniedTier }), { canConfigure: false })
|
|
112
|
+
expect(html).toContain('Couldn’t create the shared identity’s token')
|
|
113
|
+
expect(html).toContain('kubectl auth can-i create serviceaccounts/ate-client --subresource=token -n ate-system')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('says the operator turned the API off, or that a Radar without sign-in can’t read it', () => {
|
|
117
|
+
const off = render(managedConnection({ access: apiDisabledTier, managed: { ...managedConnection().managed, enabled: false, readsAs: 'none' } }), { canConfigure: false })
|
|
118
|
+
expect(off).toMatch(/Reads Substrate’s API<\/dt><dd[^>]*>No/)
|
|
119
|
+
expect(off).toContain('Turned off for this Radar')
|
|
120
|
+
expect(off).not.toContain('For each signed-in person')
|
|
121
|
+
const noSignIn = render(managedConnection({ access: sharedTier, managed: { ...managedConnection().managed, enabled: false, readsAs: 'none' } }), { canConfigure: false })
|
|
122
|
+
expect(noSignIn).toContain('Needs sign-in')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('names fallback atespaces only to a connected reader', () => {
|
|
126
|
+
const connected = render(managedConnection({ managed: { ...managedConnection().managed, atespaces: ['research'] } }), { canConfigure: false })
|
|
127
|
+
expect(connected).toContain('research')
|
|
128
|
+
const refused = render(managedConnection({ access: mintDeniedTier }), { canConfigure: false })
|
|
129
|
+
expect(refused).not.toMatch(/Atespaces<\/span>/)
|
|
130
|
+
})
|
|
131
|
+
})
|