@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
|
@@ -27,7 +27,7 @@ describe('destinationToast', () => {
|
|
|
27
27
|
})
|
|
28
28
|
test('unknown destination', () => {
|
|
29
29
|
const t = destinationToast('ConfigMap a/b', { canSwitch: true })
|
|
30
|
-
expect(t.message).toBe(
|
|
30
|
+
expect(t.message).toBe("ConfigMap a/b can't be opened from this cluster")
|
|
31
31
|
expect(t.actionLabel).toBeUndefined()
|
|
32
32
|
})
|
|
33
33
|
})
|
|
@@ -32,8 +32,8 @@ export function destinationToast(resource: string, dest: DestinationCluster): De
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
|
-
message: `${resource}
|
|
36
|
-
detail: "Radar couldn't tell which cluster, so it can't open it from here.",
|
|
35
|
+
message: `${resource} can't be opened from this cluster`,
|
|
36
|
+
detail: "Radar couldn't tell which cluster holds the recorded resource, so it can't open it from here.",
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
|
2
|
+
import { clsx } from 'clsx'
|
|
3
|
+
import { useDockReservedHeight } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import { TRANSITION_DRAWER } from '../../utils/animation'
|
|
5
|
+
|
|
6
|
+
const MIN_WIDTH = 500
|
|
7
|
+
const MAX_WIDTH_PERCENT = 0.8
|
|
8
|
+
const DEFAULT_WIDTH = 1000
|
|
9
|
+
const HEADER_HEIGHT = 49
|
|
10
|
+
|
|
11
|
+
interface HelmDrawerFrameProps {
|
|
12
|
+
onClose: () => void
|
|
13
|
+
/** Controls slide-in/out animation (driven by useAnimatedUnmount) */
|
|
14
|
+
isOpen: boolean
|
|
15
|
+
/** Right inset in px so the drawer sits beside a docked side panel (AI), not under it. */
|
|
16
|
+
rightInset: number
|
|
17
|
+
children: ReactNode
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The Helm drawer's position, width and Esc handling, kept across a change of content. */
|
|
21
|
+
export function HelmDrawerFrame({ onClose, isOpen, rightInset, children }: HelmDrawerFrameProps) {
|
|
22
|
+
const [drawerWidth, setDrawerWidth] = useState(DEFAULT_WIDTH)
|
|
23
|
+
const [viewportWidth, setViewportWidth] = useState(() => (typeof window === 'undefined' ? DEFAULT_WIDTH : window.innerWidth))
|
|
24
|
+
const [isResizing, setIsResizing] = useState(false)
|
|
25
|
+
const resizeStartX = useRef(0)
|
|
26
|
+
const resizeStartWidth = useRef(DEFAULT_WIDTH)
|
|
27
|
+
const dockInset = useDockReservedHeight()
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
31
|
+
if (event.key === 'Escape') onClose()
|
|
32
|
+
}
|
|
33
|
+
document.addEventListener('keydown', handleKeyDown)
|
|
34
|
+
return () => document.removeEventListener('keydown', handleKeyDown)
|
|
35
|
+
}, [onClose])
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const handleWindowResize = () => setViewportWidth(window.innerWidth)
|
|
39
|
+
handleWindowResize()
|
|
40
|
+
window.addEventListener('resize', handleWindowResize)
|
|
41
|
+
return () => window.removeEventListener('resize', handleWindowResize)
|
|
42
|
+
}, [])
|
|
43
|
+
|
|
44
|
+
const minDrawerWidth = Math.min(MIN_WIDTH, viewportWidth)
|
|
45
|
+
const maxDrawerWidth = viewportWidth < MIN_WIDTH ? viewportWidth : Math.max(MIN_WIDTH, viewportWidth * MAX_WIDTH_PERCENT)
|
|
46
|
+
const renderedDrawerWidth = Math.max(minDrawerWidth, Math.min(drawerWidth, maxDrawerWidth))
|
|
47
|
+
|
|
48
|
+
const handleResizeStart = useCallback((e: React.MouseEvent) => {
|
|
49
|
+
e.preventDefault()
|
|
50
|
+
setIsResizing(true)
|
|
51
|
+
resizeStartX.current = e.clientX
|
|
52
|
+
resizeStartWidth.current = renderedDrawerWidth
|
|
53
|
+
}, [renderedDrawerWidth])
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!isResizing) return
|
|
57
|
+
|
|
58
|
+
document.body.style.cursor = 'ew-resize'
|
|
59
|
+
document.body.style.userSelect = 'none'
|
|
60
|
+
|
|
61
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
62
|
+
const deltaX = resizeStartX.current - e.clientX
|
|
63
|
+
const newWidth = resizeStartWidth.current + deltaX
|
|
64
|
+
const viewport = window.innerWidth
|
|
65
|
+
const minWidth = Math.min(MIN_WIDTH, viewport)
|
|
66
|
+
const maxWidth = viewport < MIN_WIDTH ? viewport : Math.max(MIN_WIDTH, viewport * MAX_WIDTH_PERCENT)
|
|
67
|
+
setDrawerWidth(Math.max(minWidth, Math.min(newWidth, maxWidth)))
|
|
68
|
+
}
|
|
69
|
+
const handleMouseUp = () => setIsResizing(false)
|
|
70
|
+
document.addEventListener('mousemove', handleMouseMove)
|
|
71
|
+
document.addEventListener('mouseup', handleMouseUp)
|
|
72
|
+
return () => {
|
|
73
|
+
document.body.style.cursor = ''
|
|
74
|
+
document.body.style.userSelect = ''
|
|
75
|
+
document.removeEventListener('mousemove', handleMouseMove)
|
|
76
|
+
document.removeEventListener('mouseup', handleMouseUp)
|
|
77
|
+
}
|
|
78
|
+
}, [isResizing])
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
className={clsx(
|
|
83
|
+
'fixed right-0 bg-theme-surface border-l border-theme-border flex flex-col shadow-drawer z-40',
|
|
84
|
+
TRANSITION_DRAWER,
|
|
85
|
+
isOpen ? 'translate-x-0 opacity-100' : 'translate-x-full opacity-0'
|
|
86
|
+
)}
|
|
87
|
+
style={{ width: renderedDrawerWidth, top: HEADER_HEIGHT, right: rightInset, height: `calc(100vh - ${HEADER_HEIGHT}px - ${dockInset}px)` }}
|
|
88
|
+
>
|
|
89
|
+
{/* Resize handle */}
|
|
90
|
+
<div
|
|
91
|
+
onMouseDown={handleResizeStart}
|
|
92
|
+
className={clsx(
|
|
93
|
+
'absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize z-10 hover:bg-blue-500/50 transition-colors',
|
|
94
|
+
'hidden sm:block',
|
|
95
|
+
isResizing && 'bg-blue-500/50'
|
|
96
|
+
)}
|
|
97
|
+
/>
|
|
98
|
+
{children}
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { HelmReleaseDrawer } from './HelmReleaseDrawer'
|
|
6
|
+
|
|
7
|
+
const state = vi.hoisted(() => ({
|
|
8
|
+
error: null as unknown,
|
|
9
|
+
support: 'supported' as 'supported' | 'unsupported',
|
|
10
|
+
detailEnabled: [] as (boolean | undefined)[],
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
vi.mock('../../api/client', async (importOriginal) => ({
|
|
14
|
+
...(await importOriginal<typeof import('../../api/client')>()),
|
|
15
|
+
useHelmRelease: (_namespace: string, _name: string, options?: { enabled?: boolean }) => {
|
|
16
|
+
state.detailEnabled.push(options?.enabled)
|
|
17
|
+
return { data: undefined, error: state.error, isLoading: false, refetch: vi.fn() }
|
|
18
|
+
},
|
|
19
|
+
useRadarFeature: () => ({ support: state.support }),
|
|
20
|
+
}))
|
|
21
|
+
vi.mock('./HelmDrawerFrame', () => ({ HelmDrawerFrame: ({ children }: { children: unknown }) => children }))
|
|
22
|
+
vi.mock('./ObservedHelmReleaseDrawer', () => ({ ObservedHelmReleaseDrawer: () => 'observed drawer' }))
|
|
23
|
+
|
|
24
|
+
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
25
|
+
|
|
26
|
+
// The routing is what's under test, so the full drawer's own data hooks are out
|
|
27
|
+
// of the way: it throws a recognisable marker as soon as it renders.
|
|
28
|
+
vi.mock('react-router-dom', async (importOriginal) => ({
|
|
29
|
+
...(await importOriginal<typeof import('react-router-dom')>()),
|
|
30
|
+
useNavigate: () => {
|
|
31
|
+
throw new Error('full drawer')
|
|
32
|
+
},
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
let root: Root | undefined
|
|
36
|
+
|
|
37
|
+
function render(release: Parameters<typeof HelmReleaseDrawer>[0]['release']): string {
|
|
38
|
+
const container = document.createElement('div')
|
|
39
|
+
root = createRoot(container, { onCaughtError: () => {}, onUncaughtError: () => {} })
|
|
40
|
+
try {
|
|
41
|
+
act(() => root!.render(<HelmReleaseDrawer release={release} onClose={() => {}} />))
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return (err as Error).message
|
|
44
|
+
}
|
|
45
|
+
return container.textContent ?? ''
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
act(() => root?.unmount())
|
|
50
|
+
root = undefined
|
|
51
|
+
state.error = null
|
|
52
|
+
state.support = 'supported'
|
|
53
|
+
state.detailEnabled = []
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const denied = async () => {
|
|
57
|
+
const { ApiError } = await vi.importActual<typeof import('../../api/client')>('../../api/client')
|
|
58
|
+
return { ApiError, read: new ApiError('no', 403, { error_code: 'release_read_denied' }), other: new ApiError('no', 403) }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe('HelmReleaseDrawer', () => {
|
|
62
|
+
it('opens an observed row without asking for the release', () => {
|
|
63
|
+
expect(render({ namespace: 'apps', name: 'api', observed: true })).toBe('observed drawer')
|
|
64
|
+
expect(state.detailEnabled.every((enabled) => enabled === false)).toBe(true)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('follows a shared link to the observed view when the read is the caller’s denial', async () => {
|
|
68
|
+
state.error = (await denied()).read
|
|
69
|
+
expect(render({ namespace: 'apps', name: 'api' })).toBe('observed drawer')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('leaves any other 403 to the full drawer, which reports it', async () => {
|
|
73
|
+
state.error = (await denied()).other
|
|
74
|
+
expect(render({ namespace: 'apps', name: 'api' })).toBe('full drawer')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('stays with the full drawer on a Radar without the inventory', async () => {
|
|
78
|
+
state.error = (await denied()).read
|
|
79
|
+
state.support = 'unsupported'
|
|
80
|
+
expect(render({ namespace: 'apps', name: 'api' })).toBe('full drawer')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('shows the full drawer to someone who can read the release', () => {
|
|
84
|
+
expect(render({ namespace: 'apps', name: 'api' })).toBe('full drawer')
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { AlertBanner } from '@skyhook-io/k8s-ui/components/ui/drawer-components'
|
|
2
2
|
import { useState, useCallback, useEffect, useRef } from 'react'
|
|
3
3
|
import { flushSync } from 'react-dom'
|
|
4
|
-
import { FetchResult,
|
|
4
|
+
import { FetchResult, compareVersions, usePhoneLayout } from '@skyhook-io/k8s-ui'
|
|
5
5
|
import { startViewTransitionSafe } from '@skyhook-io/k8s-ui/utils/view-transition'
|
|
6
|
-
import { TRANSITION_DRAWER } from '../../utils/animation'
|
|
7
6
|
import { useRefreshAnimation } from '../../hooks/useRefreshAnimation'
|
|
8
7
|
import { X, Copy, Check, RefreshCw, Package, Code, History, Settings, Link2, Anchor, GitFork, BookOpen, ArrowUpCircle, Trash2, GitBranch, AlertTriangle, RotateCcw, Clock, GitCompare, ExternalLink, SlidersHorizontal, Eye, Loader2 } from 'lucide-react'
|
|
9
8
|
import yaml from 'yaml'
|
|
10
9
|
import { useNavigate } from 'react-router-dom'
|
|
11
10
|
import { clsx } from 'clsx'
|
|
12
|
-
import { useHelmRelease, useHelmManifest, useHelmValues, useHelmUpgradeInfo, useHelmReleaseVersions, useHelmUninstall, upgradeWithProgress, rollbackWithProgress, useHelmPreviewValues, useHelmSourceVersions, useRadarFeature, HelmSourceSelectionError } from '../../api/client'
|
|
11
|
+
import { useHelmRelease, useHelmManifest, useHelmValues, useHelmUpgradeInfo, useHelmReleaseVersions, useHelmUninstall, upgradeWithProgress, rollbackWithProgress, useHelmPreviewValues, useHelmSourceVersions, useRadarFeature, HelmSourceSelectionError, isHelmReleaseReadDenied } from '../../api/client'
|
|
13
12
|
import { ValuesDiffPreview } from './ValuesDiffPreview'
|
|
14
13
|
import { useQueryClient } from '@tanstack/react-query'
|
|
15
14
|
import { ConfirmDialog } from '../ui/ConfirmDialog'
|
|
@@ -26,6 +25,8 @@ import { ManifestViewer } from './ManifestViewer'
|
|
|
26
25
|
import { ValuesViewer } from './ValuesViewer'
|
|
27
26
|
import { OwnedResources } from './OwnedResources'
|
|
28
27
|
import { TrackChartSourceDialog } from './TrackChartSourceDialog'
|
|
28
|
+
import { HelmDrawerFrame } from './HelmDrawerFrame'
|
|
29
|
+
import { ObservedHelmReleaseDrawer } from './ObservedHelmReleaseDrawer'
|
|
29
30
|
import { Collapse, CollapseChevron } from '@skyhook-io/k8s-ui/components/ui/Collapse'
|
|
30
31
|
import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure'
|
|
31
32
|
|
|
@@ -142,18 +143,29 @@ export function upgradePickerVersions(available: string[] | undefined, current:
|
|
|
142
143
|
return entries.length > 1 ? entries : null
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
const MIN_WIDTH = 500
|
|
146
|
-
const MAX_WIDTH_PERCENT = 0.8
|
|
147
|
-
const DEFAULT_WIDTH = 1000
|
|
148
146
|
export const DEFAULT_SHOW_EFFECTIVE_VALUES = false
|
|
149
147
|
|
|
150
148
|
export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOpen = true, rightInset = 0 }: HelmReleaseDrawerProps) {
|
|
149
|
+
// A row built without Helm's storage says so, which spares a read that would
|
|
150
|
+
// only be refused. A shared link doesn't, so it learns from the refusal.
|
|
151
|
+
const { error } = useHelmRelease(effectiveHelmStorageNamespace(release), release.name, { enabled: !release.observed })
|
|
152
|
+
const { support } = useRadarFeature('helmInventory')
|
|
153
|
+
const observed = release.observed || (support === 'supported' && isHelmReleaseReadDenied(error))
|
|
154
|
+
return (
|
|
155
|
+
<HelmDrawerFrame onClose={onClose} isOpen={isOpen} rightInset={rightInset}>
|
|
156
|
+
{observed ? (
|
|
157
|
+
<ObservedHelmReleaseDrawer release={release} onClose={onClose} onNavigateToResource={onNavigateToResource} />
|
|
158
|
+
) : (
|
|
159
|
+
<FullHelmRelease release={release} onClose={onClose} onNavigateToResource={onNavigateToResource} />
|
|
160
|
+
)}
|
|
161
|
+
</HelmDrawerFrame>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function FullHelmRelease({ release, onClose, onNavigateToResource }: Pick<HelmReleaseDrawerProps, 'release' | 'onClose' | 'onNavigateToResource'>) {
|
|
151
166
|
const navigate = useNavigate()
|
|
152
167
|
const [activeTab, setActiveTab] = useState<TabId>('overview')
|
|
153
168
|
const [copied, setCopied] = useState<string | null>(null)
|
|
154
|
-
const [drawerWidth, setDrawerWidth] = useState(DEFAULT_WIDTH)
|
|
155
|
-
const [viewportWidth, setViewportWidth] = useState(() => (typeof window === 'undefined' ? DEFAULT_WIDTH : window.innerWidth))
|
|
156
|
-
const [isResizing, setIsResizing] = useState(false)
|
|
157
169
|
const [selectedRevision, setSelectedRevision] = useState<number | undefined>(undefined)
|
|
158
170
|
const [showEffectiveValues, setShowEffectiveValues] = useState(DEFAULT_SHOW_EFFECTIVE_VALUES)
|
|
159
171
|
const [rollbackRevision, setRollbackRevision] = useState<number | null>(null)
|
|
@@ -177,8 +189,6 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
177
189
|
const [upgradePreview, setUpgradePreview] = useState<ValuesPreviewResponse | null>(null)
|
|
178
190
|
const [upgradePreviewRequest, setUpgradePreviewRequest] = useState<UpgradePreviewRequest | null>(null)
|
|
179
191
|
const [showUpgradePreview, setShowUpgradePreview] = useState(false)
|
|
180
|
-
const resizeStartX = useRef(0)
|
|
181
|
-
const resizeStartWidth = useRef(DEFAULT_WIDTH)
|
|
182
192
|
const targetVersionRef = useRef('')
|
|
183
193
|
const editedUpgradeYamlRef = useRef('')
|
|
184
194
|
const helmNamespace = effectiveHelmStorageNamespace(release)
|
|
@@ -280,59 +290,6 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
280
290
|
setIsUpgrading(false)
|
|
281
291
|
}, [releaseKey])
|
|
282
292
|
|
|
283
|
-
// ESC key handler
|
|
284
|
-
useEffect(() => {
|
|
285
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
286
|
-
if (event.key === 'Escape') onClose()
|
|
287
|
-
}
|
|
288
|
-
document.addEventListener('keydown', handleKeyDown)
|
|
289
|
-
return () => document.removeEventListener('keydown', handleKeyDown)
|
|
290
|
-
}, [onClose])
|
|
291
|
-
|
|
292
|
-
useEffect(() => {
|
|
293
|
-
const handleWindowResize = () => setViewportWidth(window.innerWidth)
|
|
294
|
-
handleWindowResize()
|
|
295
|
-
window.addEventListener('resize', handleWindowResize)
|
|
296
|
-
return () => window.removeEventListener('resize', handleWindowResize)
|
|
297
|
-
}, [])
|
|
298
|
-
|
|
299
|
-
const minDrawerWidth = Math.min(MIN_WIDTH, viewportWidth)
|
|
300
|
-
const maxDrawerWidth = viewportWidth < MIN_WIDTH ? viewportWidth : Math.max(MIN_WIDTH, viewportWidth * MAX_WIDTH_PERCENT)
|
|
301
|
-
const renderedDrawerWidth = Math.max(minDrawerWidth, Math.min(drawerWidth, maxDrawerWidth))
|
|
302
|
-
|
|
303
|
-
// Resize handlers
|
|
304
|
-
const handleResizeStart = useCallback((e: React.MouseEvent) => {
|
|
305
|
-
e.preventDefault()
|
|
306
|
-
setIsResizing(true)
|
|
307
|
-
resizeStartX.current = e.clientX
|
|
308
|
-
resizeStartWidth.current = renderedDrawerWidth
|
|
309
|
-
}, [renderedDrawerWidth])
|
|
310
|
-
|
|
311
|
-
useEffect(() => {
|
|
312
|
-
if (!isResizing) return
|
|
313
|
-
|
|
314
|
-
document.body.style.cursor = 'ew-resize'
|
|
315
|
-
document.body.style.userSelect = 'none'
|
|
316
|
-
|
|
317
|
-
const handleMouseMove = (e: MouseEvent) => {
|
|
318
|
-
const deltaX = resizeStartX.current - e.clientX
|
|
319
|
-
const newWidth = resizeStartWidth.current + deltaX
|
|
320
|
-
const viewport = window.innerWidth
|
|
321
|
-
const minWidth = Math.min(MIN_WIDTH, viewport)
|
|
322
|
-
const maxWidth = viewport < MIN_WIDTH ? viewport : Math.max(MIN_WIDTH, viewport * MAX_WIDTH_PERCENT)
|
|
323
|
-
setDrawerWidth(Math.max(minWidth, Math.min(newWidth, maxWidth)))
|
|
324
|
-
}
|
|
325
|
-
const handleMouseUp = () => setIsResizing(false)
|
|
326
|
-
document.addEventListener('mousemove', handleMouseMove)
|
|
327
|
-
document.addEventListener('mouseup', handleMouseUp)
|
|
328
|
-
return () => {
|
|
329
|
-
document.body.style.cursor = ''
|
|
330
|
-
document.body.style.userSelect = ''
|
|
331
|
-
document.removeEventListener('mousemove', handleMouseMove)
|
|
332
|
-
document.removeEventListener('mouseup', handleMouseUp)
|
|
333
|
-
}
|
|
334
|
-
}, [isResizing])
|
|
335
|
-
|
|
336
293
|
const copyToClipboard = useCallback((text: string, key: string) => {
|
|
337
294
|
navigator.clipboard.writeText(text)
|
|
338
295
|
setCopied(key)
|
|
@@ -598,9 +555,6 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
598
555
|
void runUpgrade(upgradePreviewRequest.targetVersion, upgradePreviewRequest.values, upgradePreviewRequest.repositoryName, selection)
|
|
599
556
|
}
|
|
600
557
|
|
|
601
|
-
const headerHeight = 49
|
|
602
|
-
const dockInset = useDockReservedHeight()
|
|
603
|
-
|
|
604
558
|
const tabs: { id: TabId; label: string; icon: typeof Package }[] = [
|
|
605
559
|
{ id: 'overview', label: 'Overview', icon: Package },
|
|
606
560
|
{ id: 'history', label: 'History', icon: History },
|
|
@@ -611,24 +565,7 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
611
565
|
]
|
|
612
566
|
|
|
613
567
|
return (
|
|
614
|
-
|
|
615
|
-
className={clsx(
|
|
616
|
-
'fixed right-0 bg-theme-surface border-l border-theme-border flex flex-col shadow-drawer z-40',
|
|
617
|
-
TRANSITION_DRAWER,
|
|
618
|
-
isOpen ? 'translate-x-0 opacity-100' : 'translate-x-full opacity-0'
|
|
619
|
-
)}
|
|
620
|
-
style={{ width: renderedDrawerWidth, top: headerHeight, right: rightInset, height: `calc(100vh - ${headerHeight}px - ${dockInset}px)` }}
|
|
621
|
-
>
|
|
622
|
-
{/* Resize handle */}
|
|
623
|
-
<div
|
|
624
|
-
onMouseDown={handleResizeStart}
|
|
625
|
-
className={clsx(
|
|
626
|
-
'absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize z-10 hover:bg-blue-500/50 transition-colors',
|
|
627
|
-
'hidden sm:block',
|
|
628
|
-
isResizing && 'bg-blue-500/50'
|
|
629
|
-
)}
|
|
630
|
-
/>
|
|
631
|
-
|
|
568
|
+
<>
|
|
632
569
|
{/* Header */}
|
|
633
570
|
<div className="border-b border-theme-border shrink-0">
|
|
634
571
|
<div className="flex items-center justify-between px-4 pt-3 pb-2">
|
|
@@ -1129,7 +1066,7 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
1129
1066
|
sourceIssue={upgradeSourceIssue}
|
|
1130
1067
|
sourceError={upgradeInfo?.error}
|
|
1131
1068
|
/>
|
|
1132
|
-
|
|
1069
|
+
</>
|
|
1133
1070
|
)
|
|
1134
1071
|
}
|
|
1135
1072
|
|