@skyhook-io/radar-app 1.17.1 → 1.18.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 +9 -9
- package/src/App.tsx +14 -30
- package/src/api/client.gitopsPoll.test.ts +99 -0
- package/src/api/client.helmPreview.test.tsx +48 -0
- package/src/api/client.resourceAvailability.test.ts +24 -0
- package/src/api/client.ts +337 -87
- package/src/api/client.workloadRuns.test.ts +53 -0
- package/src/api/config.test.ts +23 -1
- package/src/api/config.ts +7 -3
- package/src/api/diagnose.ts +4 -1
- package/src/api/drain-plan.test.ts +70 -40
- package/src/api/policy.ts +5 -5
- package/src/api/radarFeatures.ts +1 -0
- package/src/api/traffic.scope.render.test.tsx +60 -0
- package/src/api/traffic.ts +3 -1
- package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
- package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
- package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
- package/src/components/diagnose/InvestigationView.tsx +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
- package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
- package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
- package/src/components/diagnose/investigationEvidence/observations.ts +20 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +107 -0
- package/src/components/diagnose/investigationEvidence/types.ts +11 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
- package/src/components/diagnose/investigationState.test.ts +36 -1
- package/src/components/diagnose/investigationState.ts +8 -0
- package/src/components/diagnose/launch.ts +2 -2
- package/src/components/dock/BottomDock.tsx +6 -3
- package/src/components/dock/WorkloadLogsTab.tsx +3 -0
- package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
- package/src/components/execution/BatchExecutionView.tsx +23 -8
- package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
- package/src/components/gitops/GitOpsView.tsx +7 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
- package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
- package/src/components/helm/HelmReleaseNotes.tsx +26 -0
- package/src/components/helm/OwnedResources.tsx +2 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +76 -4
- package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
- package/src/components/helm/TrackChartSourceDialog.tsx +41 -15
- package/src/components/helm/ValuesDiffPreview.tsx +4 -1
- package/src/components/home/ClusterHealthCard.tsx +4 -4
- package/src/components/home/CostCard.test.tsx +100 -0
- package/src/components/home/CostCard.tsx +2 -2
- package/src/components/home/HelmSummary.tsx +2 -2
- package/src/components/home/HomeView.tsx +15 -6
- package/src/components/home/MCPSetupDialog.test.tsx +30 -0
- package/src/components/home/MCPSetupDialog.tsx +13 -6
- package/src/components/home/ProblemsPanel.test.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +18 -2
- package/src/components/issues/IssuesPane.render.test.tsx +21 -0
- package/src/components/issues/IssuesPane.tsx +31 -7
- package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
- package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
- package/src/components/issues/uncheckedSources.test.ts +43 -0
- package/src/components/issues/uncheckedSources.ts +58 -5
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
- package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
- package/src/components/resources/ImageFilesystemModal.tsx +11 -4
- package/src/components/resources/PodFilesystemModal.tsx +2 -2
- package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
- package/src/components/resources/ResourcesView.tsx +18 -3
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
- package/src/components/settings/SettingsDialog.tsx +21 -15
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
- package/src/components/traffic/TrafficView.tsx +12 -12
- package/src/components/traffic/trafficFilters.test.ts +20 -1
- package/src/components/traffic/trafficFilters.ts +13 -0
- package/src/components/ui/Omnibar.tsx +13 -2
- package/src/components/ui/Toast.tsx +1 -1
- package/src/components/ui/omnibar-match.test.ts +30 -0
- package/src/components/ui/omnibar-match.ts +18 -0
- package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
- package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
- package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
- package/src/components/workload/NodeDrainStatus.tsx +55 -0
- package/src/components/workload/WorkloadView.tsx +37 -5
- package/src/context/ConnectionContext.test.ts +27 -1
- package/src/context/ConnectionContext.tsx +17 -7
- package/src/integrations/resourceHosts.test.tsx +1 -0
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/navigation.ts +14 -0
- package/src/utils/wails-clipboard.ts +4 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AlertBanner } from '@skyhook-io/k8s-ui/components/ui/drawer-components'
|
|
1
2
|
import { useState, useCallback, useEffect, useRef } from 'react'
|
|
2
3
|
import { flushSync } from 'react-dom'
|
|
3
4
|
import { FetchResult, useDockReservedHeight, compareVersions } from '@skyhook-io/k8s-ui'
|
|
@@ -8,13 +9,14 @@ import { X, Copy, Check, RefreshCw, Package, Code, History, Settings, Link2, Anc
|
|
|
8
9
|
import yaml from 'yaml'
|
|
9
10
|
import { useNavigate } from 'react-router-dom'
|
|
10
11
|
import { clsx } from 'clsx'
|
|
11
|
-
import { useHelmRelease, useHelmManifest, useHelmValues, useHelmUpgradeInfo, useHelmReleaseVersions, useHelmUninstall, upgradeWithProgress, rollbackWithProgress, useHelmPreviewValues } from '../../api/client'
|
|
12
|
+
import { useHelmRelease, useHelmManifest, useHelmValues, useHelmUpgradeInfo, useHelmReleaseVersions, useHelmUninstall, upgradeWithProgress, rollbackWithProgress, useHelmPreviewValues, useHelmSourceVersions, useRadarFeature, HelmSourceSelectionError } from '../../api/client'
|
|
12
13
|
import { ValuesDiffPreview } from './ValuesDiffPreview'
|
|
13
14
|
import { useQueryClient } from '@tanstack/react-query'
|
|
14
15
|
import { ConfirmDialog } from '../ui/ConfirmDialog'
|
|
15
16
|
import { Tooltip } from '../ui/Tooltip'
|
|
16
17
|
import { Markdown } from '../ui/Markdown'
|
|
17
|
-
import
|
|
18
|
+
import { HelmReleaseNotes } from './HelmReleaseNotes'
|
|
19
|
+
import type { SelectedHelmRelease, HelmHook, ChartDependency, HelmOperation, HelmOperationInsight, HelmOwnedResource, HookDiagnostic, HookLogEvidence, UpgradeInfo, ValuesPreviewResponse, SourceUpgradeSelection } from '../../types'
|
|
18
20
|
import { apiVersionToGroup, kindToPluralWithGroup, type NavigateToResource } from '../../utils/navigation'
|
|
19
21
|
import { formatDate } from './helm-utils'
|
|
20
22
|
import { getHelmStatusColor, getKindBadgeColor, getResourceStatusColor, SEVERITY_BADGE, SEVERITY_TEXT } from '../../utils/badge-colors'
|
|
@@ -44,6 +46,8 @@ export function effectiveHelmStorageNamespace(release: SelectedHelmRelease): str
|
|
|
44
46
|
type TabId = 'overview' | 'history' | 'manifest' | 'values' | 'resources' | 'hooks'
|
|
45
47
|
|
|
46
48
|
interface UpgradePreviewRequest {
|
|
49
|
+
sourceUpgrade?: SourceUpgradeSelection
|
|
50
|
+
sourceYaml?: string
|
|
47
51
|
targetVersion: string
|
|
48
52
|
values: Record<string, unknown>
|
|
49
53
|
repositoryName?: string
|
|
@@ -55,7 +59,7 @@ interface ParsedUpgradeValues {
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
type UpgradeSourceIssue = NonNullable<UpgradeInfo['sourceIssue']>
|
|
58
|
-
type ActionableUpgradeSourceIssue = UpgradeSourceIssue
|
|
62
|
+
type ActionableUpgradeSourceIssue = Exclude<UpgradeSourceIssue, 'release_changing'>
|
|
59
63
|
|
|
60
64
|
function getUpgradeSourceIssue(upgradeInfo: UpgradeInfo): UpgradeSourceIssue | undefined {
|
|
61
65
|
return upgradeInfo.sourceIssue
|
|
@@ -63,6 +67,9 @@ function getUpgradeSourceIssue(upgradeInfo: UpgradeInfo): UpgradeSourceIssue | u
|
|
|
63
67
|
|
|
64
68
|
function getUpgradeSourceIssueLabel(issue: UpgradeSourceIssue) {
|
|
65
69
|
switch (issue) {
|
|
70
|
+
case 'release_changing': return 'Helm operation in progress'
|
|
71
|
+
case 'source_confirmation_required': return 'confirm chart source'
|
|
72
|
+
case 'source_change_required': return 'choose chart source'
|
|
66
73
|
case 'repo_index_error':
|
|
67
74
|
return 'upgrade source blocked'
|
|
68
75
|
case 'ambiguous_repository':
|
|
@@ -81,10 +88,13 @@ function getUpgradeSourceIssueTooltip(issue: UpgradeSourceIssue, error: string |
|
|
|
81
88
|
return disabledReason ?? error ?? 'Helm actions are disabled.'
|
|
82
89
|
}
|
|
83
90
|
switch (issue) {
|
|
91
|
+
case 'release_changing': return 'Wait for the current Helm operation to finish.'
|
|
92
|
+
case 'source_confirmation_required': return 'Verify the recorded source, or select a source for the next upgrade.'
|
|
93
|
+
case 'source_change_required': return 'The previous chart change failed. Select a source and preview again.'
|
|
84
94
|
case 'repo_index_error':
|
|
85
95
|
return 'A configured Helm repo index failed. Fix or refresh that repo, or register an OCI prefix if this chart came from OCI.'
|
|
86
96
|
case 'ambiguous_repository':
|
|
87
|
-
return '
|
|
97
|
+
return 'Select the original chart source, or choose a source for the next upgrade.'
|
|
88
98
|
case 'ambiguous_source':
|
|
89
99
|
return 'Multiple configured sources match this chart. Select the original source explicitly.'
|
|
90
100
|
case 'source_unavailable':
|
|
@@ -108,7 +118,7 @@ function parseUpgradeValuesYaml(raw: string): ParsedUpgradeValues {
|
|
|
108
118
|
}
|
|
109
119
|
|
|
110
120
|
export function isUpgradeSourceIssueActionable(issue: UpgradeInfo['sourceIssue']): issue is ActionableUpgradeSourceIssue {
|
|
111
|
-
return Boolean(issue)
|
|
121
|
+
return Boolean(issue && issue !== 'release_changing')
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
export interface UpgradePickerVersion {
|
|
@@ -149,8 +159,13 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
149
159
|
const [rollbackRevision, setRollbackRevision] = useState<number | null>(null)
|
|
150
160
|
const [showUninstallConfirm, setShowUninstallConfirm] = useState(false)
|
|
151
161
|
const [showUpgradeConfirm, setShowUpgradeConfirm] = useState(false)
|
|
162
|
+
const sourceFeature = useRadarFeature('helmSourceIdentity')
|
|
152
163
|
const [showTrackSource, setShowTrackSource] = useState(false)
|
|
153
164
|
const [selectedVersion, setSelectedVersion] = useState<string | null>(null)
|
|
165
|
+
const [sourceRetryMessage, setSourceRetryMessage] = useState<string | null>(null)
|
|
166
|
+
const [sourceRetryYaml, setSourceRetryYaml] = useState<string | null>(null)
|
|
167
|
+
const [selectedSourceUpgrade, setSelectedSourceUpgrade] = useState<SourceUpgradeSelection | null>(null)
|
|
168
|
+
const selectedSourceRef = useRef<SourceUpgradeSelection | null>(null)
|
|
154
169
|
const [adjustValues, setAdjustValues] = useState(false)
|
|
155
170
|
const [editedUpgradeYaml, setEditedUpgradeYaml] = useState('')
|
|
156
171
|
const [upgradeYamlError, setUpgradeYamlError] = useState<string | null>(null)
|
|
@@ -163,6 +178,8 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
163
178
|
const targetVersionRef = useRef('')
|
|
164
179
|
const editedUpgradeYamlRef = useRef('')
|
|
165
180
|
const helmNamespace = effectiveHelmStorageNamespace(release)
|
|
181
|
+
const releaseKey = `${helmNamespace}/${release.name}`
|
|
182
|
+
const activeReleaseRef = useRef(releaseKey)
|
|
166
183
|
const { allowed: canHelmWrite, reason: helmActReason } = useCanHelmAct(helmNamespace)
|
|
167
184
|
|
|
168
185
|
const { data: releaseDetail, isLoading, error: releaseError, refetch: refetchRelease } = useHelmRelease(
|
|
@@ -208,11 +225,15 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
208
225
|
// Available versions for the upgrade dialog's picker — only fetched while the
|
|
209
226
|
// confirm dialog is open. Default the selection to latest when it opens.
|
|
210
227
|
const {
|
|
211
|
-
data:
|
|
212
|
-
isLoading:
|
|
213
|
-
error:
|
|
214
|
-
} = useHelmReleaseVersions(helmNamespace, release.name, showUpgradeConfirm)
|
|
215
|
-
const
|
|
228
|
+
data: normalVersions,
|
|
229
|
+
isLoading: normalVersionsLoading,
|
|
230
|
+
error: normalVersionsError,
|
|
231
|
+
} = useHelmReleaseVersions(helmNamespace, release.name, showUpgradeConfirm && !selectedSourceUpgrade)
|
|
232
|
+
const sourceVersions = useHelmSourceVersions(helmNamespace, release.name, selectedSourceUpgrade, showUpgradeConfirm)
|
|
233
|
+
const availableVersions = selectedSourceUpgrade ? sourceVersions.data : normalVersions
|
|
234
|
+
const availableVersionsLoading = selectedSourceUpgrade ? sourceVersions.isLoading : normalVersionsLoading
|
|
235
|
+
const availableVersionsError = selectedSourceUpgrade ? sourceVersions.error : normalVersionsError
|
|
236
|
+
const targetVersion = selectedVersion ?? (selectedSourceUpgrade ? sourceVersions.data?.[0] : upgradeInfo?.latestVersion) ?? ''
|
|
216
237
|
const selectableVersions = upgradePickerVersions(availableVersions, upgradeInfo?.currentVersion)
|
|
217
238
|
// Semver compare, not list-position: the installed version may be older than
|
|
218
239
|
// the newest-N versions the picker shows, so it isn't always in the list.
|
|
@@ -235,6 +256,26 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
235
256
|
targetVersionRef.current = targetVersion
|
|
236
257
|
}, [targetVersion])
|
|
237
258
|
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
activeReleaseRef.current = releaseKey
|
|
261
|
+
setSourceRetryMessage(null)
|
|
262
|
+
setSourceRetryYaml(null)
|
|
263
|
+
selectedSourceRef.current = null
|
|
264
|
+
setSelectedSourceUpgrade(null)
|
|
265
|
+
setSelectedVersion(null)
|
|
266
|
+
setShowUpgradeConfirm(false)
|
|
267
|
+
setShowTrackSource(false)
|
|
268
|
+
setAdjustValues(false)
|
|
269
|
+
setUpgradeValuesSeeded(false)
|
|
270
|
+
setEditedUpgradeYaml('')
|
|
271
|
+
editedUpgradeYamlRef.current = ''
|
|
272
|
+
setUpgradePreview(null)
|
|
273
|
+
setUpgradePreviewRequest(null)
|
|
274
|
+
setShowUpgradePreview(false)
|
|
275
|
+
setUpgradeProgress([])
|
|
276
|
+
setIsUpgrading(false)
|
|
277
|
+
}, [releaseKey])
|
|
278
|
+
|
|
238
279
|
// ESC key handler
|
|
239
280
|
useEffect(() => {
|
|
240
281
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
@@ -381,6 +422,8 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
381
422
|
}
|
|
382
423
|
|
|
383
424
|
const resetUpgradeDialog = () => {
|
|
425
|
+
setSelectedSourceUpgrade(null)
|
|
426
|
+
selectedSourceRef.current = null
|
|
384
427
|
setUpgradeProgress([])
|
|
385
428
|
setSelectedVersion(null)
|
|
386
429
|
setAdjustValues(false)
|
|
@@ -404,6 +447,7 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
404
447
|
}, [adjustValues, upgradeValues, upgradeValuesSeeded])
|
|
405
448
|
|
|
406
449
|
const handleToggleAdjustValues = () => {
|
|
450
|
+
if (selectedSourceUpgrade) return
|
|
407
451
|
if (adjustValues) {
|
|
408
452
|
setAdjustValues(false)
|
|
409
453
|
return
|
|
@@ -424,7 +468,23 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
424
468
|
return parsed.values
|
|
425
469
|
}
|
|
426
470
|
|
|
471
|
+
const reopenSourcePicker = (message: string) => {
|
|
472
|
+
queryClient.invalidateQueries({ queryKey: ['helm-source-status', helmNamespace, release.name] })
|
|
473
|
+
queryClient.invalidateQueries({ queryKey: ['helm-source-versions', helmNamespace, release.name] })
|
|
474
|
+
queryClient.invalidateQueries({ queryKey: ['helm-values', helmNamespace, release.name] })
|
|
475
|
+
queryClient.invalidateQueries({ queryKey: ['helm-upgrade-info', helmNamespace, release.name] })
|
|
476
|
+
queryClient.invalidateQueries({ queryKey: ['helm-batch-upgrade-info'] })
|
|
477
|
+
setSourceRetryYaml(adjustValues ? editedUpgradeYamlRef.current : null)
|
|
478
|
+
setSourceRetryMessage(message)
|
|
479
|
+
selectedSourceRef.current = null
|
|
480
|
+
setSelectedSourceUpgrade(null)
|
|
481
|
+
setShowUpgradePreview(false)
|
|
482
|
+
setShowUpgradeConfirm(false)
|
|
483
|
+
setShowTrackSource(true)
|
|
484
|
+
}
|
|
485
|
+
|
|
427
486
|
const handleUpgradePreview = async () => {
|
|
487
|
+
const previewReleaseKey = releaseKey
|
|
428
488
|
if (!targetVersion || upgradeValuesLoading || upgradeValuesError || !upgradeValuesSeeded) return
|
|
429
489
|
const editedValues = getEditedUpgradeValues()
|
|
430
490
|
if (!editedValues) return
|
|
@@ -432,7 +492,9 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
432
492
|
const previewRequest: UpgradePreviewRequest = {
|
|
433
493
|
targetVersion,
|
|
434
494
|
values: editedValues,
|
|
435
|
-
repositoryName: upgradeInfo?.repositoryName,
|
|
495
|
+
repositoryName: selectedSourceUpgrade ? undefined : upgradeInfo?.repositoryName,
|
|
496
|
+
sourceUpgrade: selectedSourceUpgrade ?? undefined,
|
|
497
|
+
sourceYaml: previewYaml,
|
|
436
498
|
}
|
|
437
499
|
try {
|
|
438
500
|
const result = await upgradePreviewMutation.mutateAsync({
|
|
@@ -441,18 +503,20 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
441
503
|
values: previewRequest.values,
|
|
442
504
|
version: previewRequest.targetVersion,
|
|
443
505
|
repository: previewRequest.repositoryName,
|
|
506
|
+
sourceUpgrade: previewRequest.sourceUpgrade,
|
|
444
507
|
})
|
|
445
|
-
if (targetVersionRef.current !== previewRequest.targetVersion || editedUpgradeYamlRef.current !== previewYaml) return
|
|
508
|
+
if (activeReleaseRef.current !== previewReleaseKey || targetVersionRef.current !== previewRequest.targetVersion || editedUpgradeYamlRef.current !== previewYaml || JSON.stringify(selectedSourceRef.current) !== JSON.stringify(previewRequest.sourceUpgrade ?? null)) return
|
|
446
509
|
setUpgradePreview(result)
|
|
447
510
|
setUpgradePreviewRequest(previewRequest)
|
|
448
511
|
setShowUpgradePreview(true)
|
|
449
|
-
} catch {
|
|
512
|
+
} catch (error) {
|
|
513
|
+
if (activeReleaseRef.current === previewReleaseKey && error instanceof HelmSourceSelectionError) reopenSourcePicker(error.message)
|
|
450
514
|
return
|
|
451
515
|
}
|
|
452
516
|
}
|
|
453
517
|
|
|
454
|
-
const runUpgrade = async (versionToApply: string, editedValuesOverride: Record<string, unknown> | undefined, repositoryName: string | undefined) => {
|
|
455
|
-
if (!versionToApply) return
|
|
518
|
+
const runUpgrade = async (versionToApply: string, editedValuesOverride: Record<string, unknown> | undefined, repositoryName: string | undefined, sourceUpgrade?: SourceUpgradeSelection) => {
|
|
519
|
+
if (!versionToApply || (selectedSourceRef.current && !sourceUpgrade)) return
|
|
456
520
|
|
|
457
521
|
let editedValues = editedValuesOverride
|
|
458
522
|
if (editedValues === undefined && adjustValues) {
|
|
@@ -461,6 +525,7 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
461
525
|
if (!editedValues) return
|
|
462
526
|
}
|
|
463
527
|
|
|
528
|
+
const operationReleaseKey = releaseKey
|
|
464
529
|
setShowUpgradePreview(false)
|
|
465
530
|
setIsUpgrading(true)
|
|
466
531
|
setUpgradeProgress([])
|
|
@@ -472,16 +537,18 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
472
537
|
versionToApply,
|
|
473
538
|
repositoryName,
|
|
474
539
|
(event) => {
|
|
475
|
-
if (event.type === 'progress' && event.message) {
|
|
540
|
+
if (activeReleaseRef.current === operationReleaseKey && event.type === 'progress' && event.message) {
|
|
476
541
|
setUpgradeProgress(prev => [...prev, {
|
|
477
542
|
phase: event.phase || 'progress',
|
|
478
543
|
message: event.message || '',
|
|
479
544
|
}])
|
|
480
545
|
}
|
|
481
546
|
},
|
|
482
|
-
editedValues
|
|
547
|
+
editedValues,
|
|
548
|
+
sourceUpgrade
|
|
483
549
|
)
|
|
484
550
|
|
|
551
|
+
if (activeReleaseRef.current !== operationReleaseKey) return
|
|
485
552
|
setUpgradeProgress(prev => [...prev, {
|
|
486
553
|
phase: 'complete',
|
|
487
554
|
message: `Successfully upgraded to ${versionToApply}`,
|
|
@@ -495,28 +562,36 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
495
562
|
queryClient.invalidateQueries({ queryKey: ['helm-batch-upgrade-info'] })
|
|
496
563
|
|
|
497
564
|
setTimeout(() => {
|
|
565
|
+
if (activeReleaseRef.current !== operationReleaseKey) return
|
|
498
566
|
setShowUpgradeConfirm(false)
|
|
567
|
+
queryClient.invalidateQueries({queryKey:['helm-source-status',helmNamespace,release.name]})
|
|
568
|
+
queryClient.invalidateQueries({queryKey:['helm-source-versions',helmNamespace,release.name]})
|
|
499
569
|
resetUpgradeDialog()
|
|
500
570
|
refetch()
|
|
501
571
|
switchTab('resources')
|
|
502
572
|
}, 1500)
|
|
503
573
|
} catch (err) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}])
|
|
574
|
+
if (activeReleaseRef.current !== operationReleaseKey) return
|
|
575
|
+
const message = err instanceof Error ? err.message : 'Upgrade failed'
|
|
576
|
+
if (sourceUpgrade || err instanceof HelmSourceSelectionError) { reopenSourcePicker(message); return }
|
|
577
|
+
setUpgradeProgress(prev => [...prev, { phase: 'error', message }])
|
|
508
578
|
} finally {
|
|
509
|
-
setIsUpgrading(false)
|
|
579
|
+
if (activeReleaseRef.current === operationReleaseKey) setIsUpgrading(false)
|
|
510
580
|
}
|
|
511
581
|
}
|
|
512
582
|
|
|
513
583
|
const handleUpgradeConfirm = () => {
|
|
584
|
+
if (selectedSourceUpgrade) { void handleUpgradePreview(); return }
|
|
514
585
|
void runUpgrade(targetVersion, undefined, upgradeInfo?.repositoryName)
|
|
515
586
|
}
|
|
516
587
|
|
|
517
588
|
const handleApplyUpgradePreview = () => {
|
|
518
589
|
if (!upgradePreviewRequest) return
|
|
519
|
-
|
|
590
|
+
if (upgradePreviewRequest.sourceUpgrade && (targetVersionRef.current !== upgradePreviewRequest.targetVersion || editedUpgradeYamlRef.current !== upgradePreviewRequest.sourceYaml || JSON.stringify(selectedSourceRef.current) !== JSON.stringify(upgradePreviewRequest.sourceUpgrade))) return
|
|
591
|
+
const selection = upgradePreviewRequest.sourceUpgrade
|
|
592
|
+
? { ...upgradePreviewRequest.sourceUpgrade, previewDigest: upgradePreview?.previewDigest }
|
|
593
|
+
: undefined
|
|
594
|
+
void runUpgrade(upgradePreviewRequest.targetVersion, upgradePreviewRequest.values, upgradePreviewRequest.repositoryName, selection)
|
|
520
595
|
}
|
|
521
596
|
|
|
522
597
|
const headerHeight = 49
|
|
@@ -645,6 +720,9 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
645
720
|
) : null}
|
|
646
721
|
</div>
|
|
647
722
|
<div className="flex items-center gap-1">
|
|
723
|
+
{sourceFeature.support === 'supported' && !releaseDetail?.managedByFluxHelmRelease && <Tooltip content="Choose chart source">
|
|
724
|
+
<button type="button" aria-label="Choose chart source" disabled={!canHelmWrite} onClick={() => setShowTrackSource(true)} className="p-1.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded disabled:opacity-50"><Link2 className="w-4 h-4" /></button>
|
|
725
|
+
</Tooltip>}
|
|
648
726
|
<Tooltip content="Refresh">
|
|
649
727
|
<button
|
|
650
728
|
onClick={refetch}
|
|
@@ -847,19 +925,24 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
847
925
|
}
|
|
848
926
|
}}
|
|
849
927
|
onConfirm={handleUpgradeConfirm}
|
|
850
|
-
title=
|
|
928
|
+
title={selectedSourceUpgrade ? 'Upgrade from selected source' : 'Upgrade Release'}
|
|
851
929
|
message={`Upgrade "${release.name}" to version ${targetVersion}?`}
|
|
852
930
|
details={upgradeProgress.length === 0
|
|
853
|
-
? `The chart will move from version ${upgradeInfo?.currentVersion} to ${targetVersion}. ${adjustValues ? 'Your edited values will be applied.' : 'Your existing values will be preserved.'} The change is applied to your cluster immediately.`
|
|
931
|
+
? selectedSourceUpgrade ? 'Review the selected chart and settings. Nothing is applied until you confirm the preview.' : `The chart will move from version ${upgradeInfo?.currentVersion} to ${targetVersion}. ${adjustValues ? 'Your edited values will be applied.' : 'Your existing values will be preserved.'} The change is applied to your cluster immediately.`
|
|
854
932
|
: undefined
|
|
855
933
|
}
|
|
856
|
-
confirmLabel={isDowngrade ? 'Downgrade' : 'Upgrade'}
|
|
934
|
+
confirmLabel={selectedSourceUpgrade ? 'Preview selected source' : isDowngrade ? 'Downgrade' : 'Upgrade'}
|
|
857
935
|
variant="warning"
|
|
858
936
|
isLoading={isUpgrading}
|
|
859
|
-
confirmDisabled={isPreviewingUpgrade || (adjustValues && (upgradeValuesLoading || !!upgradeValuesError || !upgradeValuesSeeded || !!upgradeYamlError))}
|
|
937
|
+
confirmDisabled={!targetVersion || Boolean(selectedSourceUpgrade && availableVersionsError) || isPreviewingUpgrade || (adjustValues && (upgradeValuesLoading || !!upgradeValuesError || !upgradeValuesSeeded || !!upgradeYamlError))}
|
|
860
938
|
isClosable
|
|
861
939
|
className="max-w-2xl"
|
|
862
940
|
>
|
|
941
|
+
{selectedSourceUpgrade && <div className="mb-3 rounded-lg border border-theme-border p-3 text-sm">
|
|
942
|
+
<p>Last recorded source: <span className="font-mono break-all">{selectedSourceUpgrade.expectedSource?.url ?? selectedSourceUpgrade.expectedSource?.reference ?? 'Not recorded'}</span></p>
|
|
943
|
+
<p className="mt-1">Selected source: <span className="font-mono break-all">{selectedSourceUpgrade.source.url ?? selectedSourceUpgrade.source.reference}</span></p>
|
|
944
|
+
<p className="mt-1 text-theme-text-secondary">Review your settings and the resource changes. A different source can remove resources or require different settings. Helm does not upgrade CRDs from the chart's crds directory.</p>
|
|
945
|
+
</div>}
|
|
863
946
|
{upgradeProgress.length === 0 && (
|
|
864
947
|
<div className="mb-1">
|
|
865
948
|
<label
|
|
@@ -892,8 +975,8 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
892
975
|
{selectableVersions.map(({ version: v, selectable }) => (
|
|
893
976
|
<option key={v} value={v} disabled={!selectable}>
|
|
894
977
|
{v}
|
|
895
|
-
{v === upgradeInfo?.latestVersion ? ' (latest)' : ''}
|
|
896
|
-
{v === upgradeInfo?.currentVersion ? (selectable ? ' (current)' : ' (current, no longer in the repository)') : ''}
|
|
978
|
+
{v === (selectedSourceUpgrade ? sourceVersions.data?.[0] : upgradeInfo?.latestVersion) ? ' (latest)' : ''}
|
|
979
|
+
{v === upgradeInfo?.currentVersion ? (selectable ? ' (current)' : selectedSourceUpgrade ? ' (current, not in this source)' : ' (current, no longer in the repository)') : ''}
|
|
897
980
|
</option>
|
|
898
981
|
))}
|
|
899
982
|
</select>
|
|
@@ -910,9 +993,10 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
910
993
|
This is a downgrade from {upgradeInfo?.currentVersion}.
|
|
911
994
|
</p>
|
|
912
995
|
)}
|
|
996
|
+
{selectedSourceUpgrade && !availableVersionsLoading && !availableVersionsError && availableVersions?.length === 0 && <p role="status" className="mt-2 text-sm text-theme-text-secondary">This source does not list versions of {releaseDetail?.chart || 'this chart'}. Choose another source.</p>}
|
|
913
997
|
{availableVersionsError && (
|
|
914
998
|
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
915
|
-
Version list unavailable; using the detected target version.
|
|
999
|
+
{selectedSourceUpgrade ? `Could not read this source's versions: ${availableVersionsError instanceof Error ? availableVersionsError.message : 'Request failed'}. Select another source or retry.` : 'Version list unavailable; using the detected target version.'}
|
|
916
1000
|
</p>
|
|
917
1001
|
)}
|
|
918
1002
|
{availableVersions && availableVersions.length >= 50 && (
|
|
@@ -928,14 +1012,14 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
928
1012
|
<button
|
|
929
1013
|
type="button"
|
|
930
1014
|
onClick={handleToggleAdjustValues}
|
|
931
|
-
disabled={isUpgrading || isPreviewingUpgrade}
|
|
1015
|
+
disabled={isUpgrading || isPreviewingUpgrade || Boolean(selectedSourceUpgrade)}
|
|
932
1016
|
aria-expanded={adjustValues}
|
|
933
1017
|
aria-controls="helm-upgrade-values-panel"
|
|
934
1018
|
className="flex items-center gap-1.5 text-sm font-medium text-theme-text-secondary hover:text-theme-text-primary disabled:opacity-50"
|
|
935
1019
|
>
|
|
936
1020
|
<CollapseChevron open={adjustValues} className="w-4 h-4" />
|
|
937
1021
|
<SlidersHorizontal className="w-3.5 h-3.5" />
|
|
938
|
-
Adjust your values (optional)
|
|
1022
|
+
{selectedSourceUpgrade ? 'Review your settings' : 'Adjust your values (optional)'}
|
|
939
1023
|
</button>
|
|
940
1024
|
</Tooltip>
|
|
941
1025
|
{/* unmountOnExit: the editor (uncontrolled textarea + seeded values)
|
|
@@ -975,14 +1059,10 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
975
1059
|
/>
|
|
976
1060
|
)}
|
|
977
1061
|
{upgradeYamlError && (
|
|
978
|
-
<
|
|
979
|
-
{upgradeYamlError}
|
|
980
|
-
</div>
|
|
1062
|
+
<AlertBanner variant="error" title="Check your values" message={upgradeYamlError} className="mt-2" />
|
|
981
1063
|
)}
|
|
982
1064
|
{upgradePreviewMutation.error && (
|
|
983
|
-
<
|
|
984
|
-
Couldn’t preview against {targetVersion}: {upgradePreviewMutation.error.message}. You can still upgrade.
|
|
985
|
-
</div>
|
|
1065
|
+
<AlertBanner variant="error" title={`Couldn’t preview against ${targetVersion}`} message={<>{upgradePreviewMutation.error.message}. {selectedSourceUpgrade ? 'Preview must succeed before you can apply this source.' : 'You can still upgrade.'}</>} className="mt-2" />
|
|
986
1066
|
)}
|
|
987
1067
|
<div className="mt-2 flex justify-end">
|
|
988
1068
|
<Tooltip
|
|
@@ -1013,14 +1093,32 @@ export function HelmReleaseDrawer({ release, onClose, onNavigateToResource, isOp
|
|
|
1013
1093
|
onClose={() => setShowUpgradePreview(false)}
|
|
1014
1094
|
onApply={handleApplyUpgradePreview}
|
|
1015
1095
|
isApplying={isUpgrading}
|
|
1096
|
+
notice={upgradePreviewRequest.sourceUpgrade ? `Selected source: ${upgradePreviewRequest.sourceUpgrade.source.url ?? upgradePreviewRequest.sourceUpgrade.source.reference}. Preview shows rendered changes, not a guarantee that hooks, data or immutable fields are compatible. Baseline revision: ${upgradePreview.baselineRevision ?? 'unknown'}, recorded source: ${upgradePreview.baselineSource?.url ?? upgradePreview.baselineSource?.reference ?? 'not recorded'}.` : undefined}
|
|
1016
1097
|
title={`Preview upgrade to ${upgradePreviewRequest.targetVersion}`}
|
|
1017
|
-
applyLabel={upgradeInfo?.currentVersion && compareVersions(upgradePreviewRequest.targetVersion, upgradeInfo.currentVersion) === -1 ? 'Downgrade' : 'Upgrade'}
|
|
1098
|
+
applyLabel={upgradePreviewRequest.sourceUpgrade ? 'Use selected source' : upgradeInfo?.currentVersion && compareVersions(upgradePreviewRequest.targetVersion, upgradeInfo.currentVersion) === -1 ? 'Downgrade' : 'Upgrade'}
|
|
1018
1099
|
/>
|
|
1019
1100
|
)}
|
|
1020
1101
|
|
|
1021
1102
|
<TrackChartSourceDialog
|
|
1103
|
+
operationError={sourceRetryMessage}
|
|
1104
|
+
onSelectUpgradeSource={(selection) => {
|
|
1105
|
+
const retryYaml = sourceRetryYaml
|
|
1106
|
+
resetUpgradeDialog()
|
|
1107
|
+
setSourceRetryMessage(null)
|
|
1108
|
+
setSourceRetryYaml(null)
|
|
1109
|
+
if (retryYaml !== null) {
|
|
1110
|
+
setEditedUpgradeYaml(retryYaml)
|
|
1111
|
+
editedUpgradeYamlRef.current = retryYaml
|
|
1112
|
+
setUpgradeValuesSeeded(true)
|
|
1113
|
+
}
|
|
1114
|
+
selectedSourceRef.current = selection
|
|
1115
|
+
setSelectedSourceUpgrade(selection)
|
|
1116
|
+
setAdjustValues(true)
|
|
1117
|
+
setShowTrackSource(false)
|
|
1118
|
+
setShowUpgradeConfirm(true)
|
|
1119
|
+
}}
|
|
1022
1120
|
open={showTrackSource}
|
|
1023
|
-
onClose={() => setShowTrackSource(false)}
|
|
1121
|
+
onClose={() => { setShowTrackSource(false); setSourceRetryMessage(null); setSourceRetryYaml(null) }}
|
|
1024
1122
|
chartName={releaseDetail?.chart}
|
|
1025
1123
|
namespace={helmNamespace}
|
|
1026
1124
|
releaseName={release.name}
|
|
@@ -1431,21 +1529,7 @@ function OverviewTab({ release, onCopy, copied }: OverviewTabProps) {
|
|
|
1431
1529
|
|
|
1432
1530
|
{/* Notes */}
|
|
1433
1531
|
{release.notes && (
|
|
1434
|
-
<
|
|
1435
|
-
<div className="flex items-center justify-between mb-2">
|
|
1436
|
-
<h3 className="text-sm font-medium text-theme-text-secondary">Release Notes</h3>
|
|
1437
|
-
<button
|
|
1438
|
-
onClick={() => onCopy(release.notes, 'notes')}
|
|
1439
|
-
className="flex items-center gap-1 px-2 py-1 text-xs text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded"
|
|
1440
|
-
>
|
|
1441
|
-
{copied === 'notes' ? <Check className="w-3.5 h-3.5 text-green-400" /> : <Copy className="w-3.5 h-3.5" />}
|
|
1442
|
-
Copy
|
|
1443
|
-
</button>
|
|
1444
|
-
</div>
|
|
1445
|
-
<div className="text-xs bg-theme-base/50 rounded p-3 max-h-64 overflow-auto">
|
|
1446
|
-
<Markdown>{release.notes}</Markdown>
|
|
1447
|
-
</div>
|
|
1448
|
-
</div>
|
|
1532
|
+
<HelmReleaseNotes notes={release.notes} copied={copied === 'notes'} onCopy={text => onCopy(text, 'notes')} />
|
|
1449
1533
|
)}
|
|
1450
1534
|
|
|
1451
1535
|
{/* Dependencies */}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
5
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { HelmReleaseNotes } from './HelmReleaseNotes'
|
|
7
|
+
|
|
8
|
+
describe('Helm release notes', () => {
|
|
9
|
+
it('preserves terminal artwork, blank lines, indentation and literal Markdown', () => {
|
|
10
|
+
const notes = ' ███ ███\n ░██ ░██\n\n# Installed\n\n- **Keep backups**\n\t[docs](https://example.com)\n'
|
|
11
|
+
const container = document.createElement('div')
|
|
12
|
+
container.innerHTML = renderToStaticMarkup(<HelmReleaseNotes notes={notes} copied={false} onCopy={() => {}} />)
|
|
13
|
+
|
|
14
|
+
expect(container.querySelector('pre')?.textContent).toBe(notes)
|
|
15
|
+
expect(container.querySelector('.markdown-content, h1, a, ul, strong')).toBeNull()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('renders HTML as text', () => {
|
|
19
|
+
const notes = '<script>alert(1)</script>\n<img src=x onerror=alert(1)>'
|
|
20
|
+
const container = document.createElement('div')
|
|
21
|
+
container.innerHTML = renderToStaticMarkup(<HelmReleaseNotes notes={notes} copied={false} onCopy={() => {}} />)
|
|
22
|
+
|
|
23
|
+
expect(container.querySelector('pre')?.textContent).toBe(notes)
|
|
24
|
+
expect(container.querySelector('script, img')).toBeNull()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('displays and copies the full text without terminal escape sequences', async () => {
|
|
28
|
+
const notes = '\u001b[34m ███\n ░██\u001b[0m\n\n# Ready\n'
|
|
29
|
+
const clean = ' ███\n ░██\n\n# Ready\n'
|
|
30
|
+
const container = document.createElement('div')
|
|
31
|
+
const root = createRoot(container)
|
|
32
|
+
const copy = vi.fn()
|
|
33
|
+
try {
|
|
34
|
+
await act(async () => root.render(<HelmReleaseNotes notes={notes} copied={false} onCopy={copy} />))
|
|
35
|
+
expect(container.querySelector('pre')?.textContent).toBe(clean)
|
|
36
|
+
await act(async () => container.querySelector('button')?.click())
|
|
37
|
+
expect(copy).toHaveBeenCalledExactlyOnceWith(clean)
|
|
38
|
+
} finally {
|
|
39
|
+
await act(async () => root.unmount())
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Check, Copy } from 'lucide-react'
|
|
2
|
+
import { stripAnsi } from '@skyhook-io/k8s-ui'
|
|
3
|
+
|
|
4
|
+
export function HelmReleaseNotes({ notes, copied, onCopy }: {
|
|
5
|
+
notes: string
|
|
6
|
+
copied: boolean
|
|
7
|
+
onCopy: (text: string) => void
|
|
8
|
+
}) {
|
|
9
|
+
const text = stripAnsi(notes)
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className="bg-theme-elevated/30 rounded-lg p-4">
|
|
13
|
+
<div className="flex items-center justify-between mb-2">
|
|
14
|
+
<h3 className="text-sm font-medium text-theme-text-secondary">Release Notes</h3>
|
|
15
|
+
<button
|
|
16
|
+
onClick={() => onCopy(text)}
|
|
17
|
+
className="flex items-center gap-1 px-2 py-1 text-xs text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded"
|
|
18
|
+
>
|
|
19
|
+
{copied ? <Check className="w-3.5 h-3.5 text-green-400" /> : <Copy className="w-3.5 h-3.5" />}
|
|
20
|
+
Copy
|
|
21
|
+
</button>
|
|
22
|
+
</div>
|
|
23
|
+
<pre className="text-xs font-mono whitespace-pre text-theme-text-secondary bg-theme-base/50 rounded p-3 max-h-64 overflow-auto">{text}</pre>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -12,7 +12,7 @@ import { PortForwardInlineButton } from '../portforward/PortForwardButton'
|
|
|
12
12
|
import { useAvailablePorts } from '../../api/client'
|
|
13
13
|
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
14
14
|
import { useNamespacedCapabilities, useIsLocalDeployment } from '../../contexts/CapabilitiesContext'
|
|
15
|
-
import { pluralize } from '@skyhook-io/k8s-ui'
|
|
15
|
+
import { pluralize, getExecContainerNames } from '@skyhook-io/k8s-ui'
|
|
16
16
|
import { Tooltip } from '../ui/Tooltip'
|
|
17
17
|
|
|
18
18
|
interface OwnedResourcesProps {
|
|
@@ -358,7 +358,7 @@ function PodQuickActions({ namespace, podName, isRunning }: PodQuickActionsProps
|
|
|
358
358
|
namespace,
|
|
359
359
|
podName,
|
|
360
360
|
containerName: containers[0].name,
|
|
361
|
-
containers:
|
|
361
|
+
containers: getExecContainerNames(data.resource),
|
|
362
362
|
})
|
|
363
363
|
}
|
|
364
364
|
} catch (error) {
|