@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
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
import { act, type InputHTMLAttributes, type ReactNode } from 'react'
|
|
3
3
|
import { createRoot, type Root } from 'react-dom/client'
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
-
import type { ChartSourceStatus, HelmRepository } from '../../types'
|
|
5
|
+
import type { ChartSourceStatus, HelmRepository, SourceUpgradeSelection } from '../../types'
|
|
6
6
|
import { TrackChartSourceDialog } from './TrackChartSourceDialog'
|
|
7
7
|
|
|
8
8
|
const state = vi.hoisted(() => ({
|
|
9
9
|
status: undefined as ChartSourceStatus | undefined,
|
|
10
10
|
repositories: [] as HelmRepository[],
|
|
11
11
|
isOwner: true,
|
|
12
|
+
featureSupported: true,
|
|
13
|
+
associateSource: vi.fn(),
|
|
12
14
|
addRepository: vi.fn(),
|
|
13
15
|
}))
|
|
14
16
|
|
|
@@ -22,6 +24,7 @@ vi.mock('../settings/OperatorManagedNotice', () => ({ OperatorManagedNotice: ()
|
|
|
22
24
|
vi.mock('../../api/client', () => {
|
|
23
25
|
const idle = { mutate: vi.fn(), mutateAsync: vi.fn(), isPending: false }
|
|
24
26
|
return {
|
|
27
|
+
useRadarFeature: () => ({ support: state.featureSupported ? 'supported' : 'unsupported' }),
|
|
25
28
|
useHelmSourceStatus: () => ({ data: state.status, error: null, refetch: vi.fn() }),
|
|
26
29
|
useHelmRepositories: () => ({ data: state.repositories, isLoading: false }),
|
|
27
30
|
useHelmOCISources: () => ({ data: [] }),
|
|
@@ -31,7 +34,7 @@ vi.mock('../../api/client', () => {
|
|
|
31
34
|
useAddHelmRepository: () => ({ mutate: state.addRepository, isPending: false }),
|
|
32
35
|
useAddOCISource: () => idle,
|
|
33
36
|
useRemoveOCISource: () => idle,
|
|
34
|
-
useSetHelmSource: () => idle,
|
|
37
|
+
useSetHelmSource: () => ({ ...idle, mutate: state.associateSource }),
|
|
35
38
|
}
|
|
36
39
|
})
|
|
37
40
|
|
|
@@ -50,6 +53,8 @@ beforeEach(() => {
|
|
|
50
53
|
state.status = movedMachine
|
|
51
54
|
state.repositories = []
|
|
52
55
|
state.isOwner = true
|
|
56
|
+
state.featureSupported = true
|
|
57
|
+
state.associateSource.mockReset()
|
|
53
58
|
state.addRepository.mockReset()
|
|
54
59
|
const element = document.createElement('div')
|
|
55
60
|
document.body.appendChild(element)
|
|
@@ -61,8 +66,8 @@ afterEach(async () => {
|
|
|
61
66
|
document.body.replaceChildren()
|
|
62
67
|
})
|
|
63
68
|
|
|
64
|
-
async function renderDialog() {
|
|
65
|
-
await act(async () => root.render(<TrackChartSourceDialog open onClose={() => undefined} chartName="podinfo" namespace="web" releaseName="storefront" />))
|
|
69
|
+
async function renderDialog(onSelectUpgradeSource?: (selection: SourceUpgradeSelection) => void) {
|
|
70
|
+
await act(async () => root.render(<TrackChartSourceDialog onSelectUpgradeSource={onSelectUpgradeSource} open onClose={() => undefined} chartName="podinfo" namespace="web" releaseName="storefront" />))
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
function addRecordedButton() {
|
|
@@ -118,3 +123,70 @@ describe('TrackChartSourceDialog one-click add of the recorded repository', () =
|
|
|
118
123
|
}
|
|
119
124
|
})
|
|
120
125
|
})
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
describe('explicit source choices', () => {
|
|
129
|
+
it('keeps the recorded source visible and selects a different publisher without associating it', async () => {
|
|
130
|
+
const recorded = { type: 'repository' as const, reference: 'official', url: 'https://official.example.test/charts' }
|
|
131
|
+
const other = { type: 'repository' as const, reference: 'other', url: 'https://other.example.test/charts' }
|
|
132
|
+
state.status = { recorded, configured: true, available: true, confirmed: true, revision: 4, candidates: [recorded, other], suggestions: [
|
|
133
|
+
{ source: recorded, current: true, hasInstalledVersion: true, state: 'available' },
|
|
134
|
+
{ source: other, current: false, hasInstalledVersion: true, state: 'available' },
|
|
135
|
+
] }
|
|
136
|
+
const select = vi.fn()
|
|
137
|
+
await renderDialog(select)
|
|
138
|
+
const choices = Array.from(document.querySelectorAll('button')).filter(button => button.textContent?.includes('Select for upgrade'))
|
|
139
|
+
expect(choices).toHaveLength(2)
|
|
140
|
+
expect(choices[0].getAttribute('aria-label')).toContain(recorded.url)
|
|
141
|
+
expect(choices[1].parentElement?.textContent).toContain('Other source')
|
|
142
|
+
await act(async () => choices[1].click())
|
|
143
|
+
expect(select).toHaveBeenCalledWith({source: other, expectedRevision: 4, expectedSource: recorded})
|
|
144
|
+
expect(state.associateSource).not.toHaveBeenCalled()
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('offers a pruned mirror for an explicit upgrade without claiming it supplied the installed version', async () => {
|
|
148
|
+
const mirror = { type: 'repository' as const, reference: 'mirror', url: 'https://mirror.example.test/charts' }
|
|
149
|
+
state.status = { configured: false, available: false, confirmed: false, revision: 1, candidates: [], suggestions: [
|
|
150
|
+
{ source: mirror, current: false, hasInstalledVersion: false, state: 'available' },
|
|
151
|
+
] }
|
|
152
|
+
const select = vi.fn()
|
|
153
|
+
await renderDialog(select)
|
|
154
|
+
const button = Array.from(document.querySelectorAll('button')).find(item => item.textContent?.includes('Select for upgrade'))
|
|
155
|
+
expect(button).toBeDefined()
|
|
156
|
+
await act(async () => button?.click())
|
|
157
|
+
expect(select).toHaveBeenCalledWith({source: mirror, expectedRevision: 1, expectedSource: null})
|
|
158
|
+
expect(state.associateSource).not.toHaveBeenCalled()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('does not offer source switching on a backend without the capability', async () => {
|
|
162
|
+
state.featureSupported = false
|
|
163
|
+
state.status = { configured: false, available: false, revision: 1, suggestions: [
|
|
164
|
+
{ source: {type: 'repository', reference: 'mirror', url: 'https://mirror.example.test/charts'}, current: false, hasInstalledVersion: false, state: 'available' },
|
|
165
|
+
] }
|
|
166
|
+
await renderDialog(vi.fn())
|
|
167
|
+
expect(document.body.textContent).not.toContain('Select for upgrade')
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
describe('OCI original-source verification', () => {
|
|
173
|
+
it('can verify and record an unchecked registered OCI source without upgrading', async () => {
|
|
174
|
+
const source = { type: 'oci' as const, reference: 'oci://registry.example.test/team/podinfo' }
|
|
175
|
+
state.status = { configured: false, available: false, revision: 1, confirmed: false, candidates: [], suggestions: [
|
|
176
|
+
{source, current: false, hasInstalledVersion: false, state: 'unchecked'},
|
|
177
|
+
] }
|
|
178
|
+
const select = vi.fn()
|
|
179
|
+
await renderDialog(select)
|
|
180
|
+
const button = Array.from(document.querySelectorAll('button')).find(item => item.textContent === 'Verify and record original source')
|
|
181
|
+
expect(button).toBeDefined()
|
|
182
|
+
await act(async () => button?.click())
|
|
183
|
+
expect(state.associateSource).toHaveBeenCalledWith(source, expect.anything())
|
|
184
|
+
expect(select).not.toHaveBeenCalled()
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('shows the no-source hint when the backend omits empty suggestions', async () => {
|
|
189
|
+
state.status = { configured: false, available: false, revision: 1 }
|
|
190
|
+
await renderDialog(vi.fn())
|
|
191
|
+
expect(document.body.textContent).toContain('No configured sources found. Add a repository or OCI source.')
|
|
192
|
+
})
|
|
@@ -5,7 +5,7 @@ describe('chart source recovery presentation', () => {
|
|
|
5
5
|
it('keeps recorded, configured, and available states distinct', () => {
|
|
6
6
|
expect(sourceStateLabel(false, false, false)).toBe('Not recorded')
|
|
7
7
|
expect(sourceStateLabel(true, false, false)).toBe('Recorded · not configured here')
|
|
8
|
-
expect(sourceStateLabel(true, true, false)).toBe('Recorded and configured · unavailable
|
|
8
|
+
expect(sourceStateLabel(true, true, false)).toBe('Recorded and configured · source unavailable')
|
|
9
9
|
expect(sourceStateLabel(true, true, true)).toBe('Recorded · configured · available')
|
|
10
10
|
})
|
|
11
11
|
|
|
@@ -17,7 +17,8 @@ describe('chart source recovery presentation', () => {
|
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
it('makes ambiguity explicit rather than selecting a source', () => {
|
|
20
|
-
expect(getSourceIssueCopy('ambiguous_source')?.
|
|
20
|
+
expect(getSourceIssueCopy('ambiguous_source')?.title).toBe('Chart source unresolved')
|
|
21
|
+
expect(getSourceIssueCopy('ambiguous_source')?.body).toContain('choose a source for the next upgrade')
|
|
21
22
|
})
|
|
22
23
|
|
|
23
24
|
it('accepts only HTTP repository URLs', () => {
|
|
@@ -2,11 +2,13 @@ import { useId, useState, type FormEvent } from 'react'
|
|
|
2
2
|
import { DialogPortal } from '@skyhook-io/k8s-ui/components/ui/DialogPortal'
|
|
3
3
|
import { AlertTriangle, Link2, Plus, Trash2, X } from 'lucide-react'
|
|
4
4
|
import { Input } from '@skyhook-io/k8s-ui'
|
|
5
|
-
import { useAddHelmRepository, useAddOCISource, useCapabilities, useCloudRole, useClusterInfo, useHelmOCISources, useHelmRepositories, useHelmSourceStatus, useRemoveOCISource, useSetHelmSource } from '../../api/client'
|
|
5
|
+
import { useAddHelmRepository, useAddOCISource, useCapabilities, useCloudRole, useClusterInfo, useHelmOCISources, useHelmRepositories, useHelmSourceStatus, useRemoveOCISource, useSetHelmSource, useRadarFeature } from '../../api/client'
|
|
6
6
|
import { OperatorManagedNotice } from '../settings/OperatorManagedNotice'
|
|
7
|
-
import type { ChartSourceStatus, HelmRepository, UpgradeInfo } from '../../types'
|
|
7
|
+
import type { ChartSourceStatus, HelmRepository, UpgradeInfo, SourceUpgradeSelection } from '../../types'
|
|
8
8
|
|
|
9
9
|
interface TrackChartSourceDialogProps {
|
|
10
|
+
operationError?: string | null
|
|
11
|
+
onSelectUpgradeSource?: (selection: SourceUpgradeSelection) => void
|
|
10
12
|
open: boolean
|
|
11
13
|
onClose: () => void
|
|
12
14
|
chartName?: string
|
|
@@ -28,13 +30,16 @@ export function isValidHelmRepositoryURL(value: string) {
|
|
|
28
30
|
export function sourceStateLabel(recorded: boolean, configured: boolean, available: boolean) {
|
|
29
31
|
if (!recorded) return 'Not recorded'
|
|
30
32
|
if (!configured) return 'Recorded · not configured here'
|
|
31
|
-
if (!available) return 'Recorded and configured · unavailable
|
|
33
|
+
if (!available) return 'Recorded and configured · source unavailable'
|
|
32
34
|
return 'Recorded · configured · available'
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
// What the dialog says about the release's recorded source. "Not recorded" is
|
|
36
38
|
// a claim about the release, so it shows only once the read has succeeded.
|
|
37
39
|
export function sourceStatusLine(status: ChartSourceStatus | undefined, error: unknown) {
|
|
40
|
+
if (status?.changing) return 'A Helm operation is in progress'
|
|
41
|
+
if (status?.sourceChangeRequired) return 'Source choice required after a failed chart change'
|
|
42
|
+
if (status?.confirmed === false && status.recorded) return 'Last recorded source - confirm before upgrading'
|
|
38
43
|
if (status) return sourceStateLabel(Boolean(status.recorded), status.configured, status.available)
|
|
39
44
|
if (error) return `Could not read this release's source: ${error instanceof Error ? error.message : String(error)}`
|
|
40
45
|
return 'Checking the recorded source...'
|
|
@@ -77,20 +82,24 @@ export function recordedRepositoryName(alias: string, repositories: HelmReposito
|
|
|
77
82
|
|
|
78
83
|
export function getSourceIssueCopy(sourceIssue: UpgradeInfo['sourceIssue'], sourceError?: string) {
|
|
79
84
|
switch (sourceIssue) {
|
|
85
|
+
case 'release_changing': return { title: 'Helm operation in progress', body: 'Wait for the current operation to finish, then refresh the source state.' }
|
|
86
|
+
case 'source_confirmation_required': return { title: 'Confirm the recorded source', body: 'Verify the original source, or select a source for the next upgrade.' }
|
|
87
|
+
case 'source_change_required': return { title: 'Source choice required', body: 'The previous chart change failed. Select a source and preview again before retrying.' }
|
|
80
88
|
case 'repo_index_error': return { title: 'A Helm repo index failed', body: 'Fix or refresh the repository before associating it.' }
|
|
81
89
|
case 'ambiguous_repository':
|
|
82
|
-
case 'ambiguous_source': return { title: '
|
|
90
|
+
case 'ambiguous_source': return { title: 'Chart source unresolved', body: 'Select the original source, or choose a source for the next upgrade.' }
|
|
83
91
|
case 'source_unavailable': return { title: 'Recorded source unavailable', body: 'The release provenance is preserved, but that source cannot currently be verified here.' }
|
|
84
|
-
case 'untracked': return { title: 'Source not recorded', body: '
|
|
92
|
+
case 'untracked': return { title: 'Source not recorded', body: 'Choose a source for the next upgrade, or record the original source.' }
|
|
85
93
|
default: return sourceError ? { title: 'Source unresolved', body: sourceError } : undefined
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
export function TrackChartSourceDialog({ open, onClose, chartName, namespace, releaseName, sourceIssue, sourceError }: TrackChartSourceDialogProps) {
|
|
97
|
+
export function TrackChartSourceDialog({ operationError, onSelectUpgradeSource, open, onClose, chartName, namespace, releaseName, sourceIssue, sourceError }: TrackChartSourceDialogProps) {
|
|
98
|
+
const sourceFeature = useRadarFeature('helmSourceIdentity')
|
|
90
99
|
const [ociPrefix, setOCIPrefix] = useState('')
|
|
91
100
|
const [repositoryName, setRepositoryName] = useState('')
|
|
92
101
|
const [repositoryURL, setRepositoryURL] = useState('')
|
|
93
|
-
const { data: status, error: statusError, refetch: refetchStatus } = useHelmSourceStatus(namespace, releaseName, open)
|
|
102
|
+
const { data: status, error: statusError, refetch: refetchStatus, isFetching: statusFetching } = useHelmSourceStatus(namespace, releaseName, open)
|
|
94
103
|
const { data: ociSources } = useHelmOCISources()
|
|
95
104
|
const { data: clusterInfo } = useClusterInfo()
|
|
96
105
|
const { data: capabilities } = useCapabilities()
|
|
@@ -114,7 +123,8 @@ export function TrackChartSourceDialog({ open, onClose, chartName, namespace, re
|
|
|
114
123
|
|
|
115
124
|
const addRecordedRepository = () => {
|
|
116
125
|
if (!missingRecordedRepository || recordedName === undefined) return
|
|
117
|
-
|
|
126
|
+
const associate = status?.confirmed !== false
|
|
127
|
+
addRepository.mutate({ name: recordedName, url: missingRecordedRepository.url, ...(associate ? { namespace, releaseName } : {}) }, { onSuccess: associate ? onClose : () => { void refetchStatus() } })
|
|
118
128
|
}
|
|
119
129
|
|
|
120
130
|
const addRepositoryAndAssociate = (event: FormEvent) => {
|
|
@@ -122,7 +132,7 @@ export function TrackChartSourceDialog({ open, onClose, chartName, namespace, re
|
|
|
122
132
|
const name = repositoryName.trim()
|
|
123
133
|
const url = repositoryURL.trim()
|
|
124
134
|
if (!name || !isValidHelmRepositoryURL(url)) return
|
|
125
|
-
addRepository.mutate({ name, url
|
|
135
|
+
addRepository.mutate({ name, url }, { onSuccess: () => { setRepositoryName(''); setRepositoryURL(''); void refetchStatus() } })
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
const addOCIPrefix = async (event: FormEvent) => {
|
|
@@ -142,6 +152,8 @@ export function TrackChartSourceDialog({ open, onClose, chartName, namespace, re
|
|
|
142
152
|
<div className="p-4 space-y-4">
|
|
143
153
|
{configManaged && <OperatorManagedNotice helmValue="helm.ociSources" />}
|
|
144
154
|
{!configManaged && ownerOnly && <p className="text-sm text-theme-text-secondary">Only organization owners can add or remove chart sources.</p>}
|
|
155
|
+
{operationError && <p role="alert" className="text-sm text-theme-text-secondary">{operationError}</p>}
|
|
156
|
+
{status?.changing && <button type="button" onClick={() => void refetchStatus()} className="btn-brand px-3 py-2">Refresh source state</button>}
|
|
145
157
|
{issueCopy && <div className="flex gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-sm"><AlertTriangle className="w-4 h-4 mt-0.5 shrink-0" /><div><p className="font-medium">{issueCopy.title}</p><p className="text-theme-text-secondary">{issueCopy.body}</p></div></div>}
|
|
146
158
|
<div className="rounded-lg border border-theme-border px-3 py-2">
|
|
147
159
|
<p className="text-xs uppercase tracking-wide text-theme-text-tertiary">Release source state</p>
|
|
@@ -150,7 +162,7 @@ export function TrackChartSourceDialog({ open, onClose, chartName, namespace, re
|
|
|
150
162
|
{recorded && <p className="font-mono text-xs text-theme-text-secondary mt-1 break-all">{recorded.url ?? recorded.reference}</p>}
|
|
151
163
|
</div>
|
|
152
164
|
{missingRecordedRepository && recordedName !== undefined && <div className="space-y-1">
|
|
153
|
-
<button type="button" onClick={addRecordedRepository} disabled={!canEditSources || repositoriesLoading || addRepository.isPending} className="btn-brand inline-flex items-center gap-1 px-3 py-2 max-w-full"><Plus className="w-4 h-4 shrink-0" /><span className="truncate">Add {repositoryDisplayURL(missingRecordedRepository.url)} and use it</span></button>
|
|
165
|
+
<button type="button" onClick={addRecordedRepository} disabled={!canEditSources || repositoriesLoading || addRepository.isPending} className="btn-brand inline-flex items-center gap-1 px-3 py-2 max-w-full"><Plus className="w-4 h-4 shrink-0" /><span className="truncate">Add {repositoryDisplayURL(missingRecordedRepository.url)}{status?.confirmed !== false ? ' and use it' : ' repository'}</span></button>
|
|
154
166
|
<p className="text-xs text-theme-text-tertiary">{!recordedName
|
|
155
167
|
? 'Radar picks a name for it in Helm.'
|
|
156
168
|
: recordedName === missingRecordedRepository.reference
|
|
@@ -159,15 +171,29 @@ export function TrackChartSourceDialog({ open, onClose, chartName, namespace, re
|
|
|
159
171
|
? <>Saved in Helm as <span className="font-mono">{recordedName}</span>.</>
|
|
160
172
|
: <>Saved in Helm as <span className="font-mono">{recordedName}</span>. The name <span className="font-mono">{missingRecordedRepository.reference}</span> already points to a different repository here.</>}</p>
|
|
161
173
|
</div>}
|
|
162
|
-
{
|
|
174
|
+
{sourceFeature.support === 'supported' && onSelectUpgradeSource && status?.revision && <div className="space-y-2">
|
|
175
|
+
<p className="text-sm font-medium">Sources to use for the next upgrade</p>
|
|
176
|
+
<p className="text-xs text-theme-text-secondary">Matching chart names can contain different settings and resources. Review the selected chart before applying.</p>
|
|
177
|
+
{(status.suggestions ?? []).map(suggestion => <div key={`${suggestion.source.type}:${suggestion.source.url ?? suggestion.source.reference}`} className="w-full rounded-lg border border-theme-border px-3 py-2">
|
|
178
|
+
<span className="text-xs text-theme-text-secondary">{suggestion.current ? status.confirmed && !status.sourceChangeRequired && !status.changing ? 'Current source' : 'Last recorded source' : 'Other source'}{suggestion.state === 'unchecked' ? ' - check versions' : suggestion.state === 'index_unavailable' ? ' - refresh its index first' : ''}</span>
|
|
179
|
+
<span className="block font-mono text-sm break-all">{suggestion.source.url ?? suggestion.source.reference}</span>
|
|
180
|
+
<button type="button" aria-label={`Select for upgrade: ${suggestion.source.url ?? suggestion.source.reference}`} disabled={status.changing || statusFetching} onClick={() => {
|
|
181
|
+
if (!status.revision) return
|
|
182
|
+
onSelectUpgradeSource({ source: suggestion.source, expectedRevision: status.revision, expectedSource: status.recorded ?? null })
|
|
183
|
+
}} className="mt-1 text-sm text-accent hover:underline disabled:opacity-50">Select for upgrade</button>
|
|
184
|
+
{suggestion.source.type === 'oci' && !status.confirmed && !status.sourceChangeRequired && <button type="button" disabled={status.changing || statusFetching || setSource.isPending} onClick={() => setSource.mutate(suggestion.source, { onSuccess: onClose })} className="ml-3 text-sm text-accent hover:underline disabled:opacity-50">Verify and record original source</button>}
|
|
185
|
+
</div>)}
|
|
186
|
+
{(status.suggestions ?? []).length === 0 && <p className="text-sm text-theme-text-secondary">No configured sources found. Add a repository or OCI source.</p>}
|
|
187
|
+
</div>}
|
|
188
|
+
{!status?.confirmed && !status?.sourceChangeRequired && status?.candidates && status.candidates.length > 0 && <div>
|
|
163
189
|
<p className="text-xs uppercase tracking-wide text-theme-text-tertiary mb-2">Configured sources that publish {chartName || 'this chart'} at the installed version</p>
|
|
164
|
-
<div className="space-y-2">{status.candidates.map(candidate => <button key={`${candidate.type}:${candidate.url ?? candidate.reference}`} onClick={() => setSource.mutate(candidate, { onSuccess: onClose })} disabled={setSource.isPending} className="w-full text-left rounded-lg border border-theme-border px-3 py-2 hover:border-accent disabled:opacity-50"><span className="text-xs uppercase text-theme-text-tertiary">{candidate.type}</span><span className="block font-mono text-sm break-all">{candidate.url ?? candidate.reference}</span></button>)}</div>
|
|
165
|
-
{status.candidates.length > 1 && <p className="text-xs text-amber-600 mt-2">Multiple sources
|
|
190
|
+
<div className="space-y-2">{status.candidates.filter(candidate => !status.confirmed || !recorded || (candidate.type === recorded.type && (candidate.url ?? candidate.reference) === (recorded.url ?? recorded.reference))).map(candidate => <button key={`${candidate.type}:${candidate.url ?? candidate.reference}`} onClick={() => setSource.mutate(candidate, { onSuccess: onClose })} disabled={setSource.isPending || statusFetching || status.changing} className="w-full text-left rounded-lg border border-theme-border px-3 py-2 hover:border-accent disabled:opacity-50"><span className="text-xs uppercase text-theme-text-tertiary">{candidate.type}</span><span className="block font-mono text-sm break-all">{candidate.url ?? candidate.reference}</span><span className="text-xs text-accent">Record as original source</span></button>)}</div>
|
|
191
|
+
{status.candidates.length > 1 && <p className="text-xs text-amber-600 mt-2">Multiple sources list this chart name and version. Select the original source; Radar compares the stored chart before recording it.</p>}
|
|
166
192
|
</div>}
|
|
167
193
|
<form onSubmit={addRepositoryAndAssociate} className="space-y-2">
|
|
168
|
-
<p className="text-xs uppercase tracking-wide text-theme-text-tertiary">Add
|
|
194
|
+
<p className="text-xs uppercase tracking-wide text-theme-text-tertiary">Add chart repository</p>
|
|
169
195
|
<div className="grid grid-cols-1 md:grid-cols-[minmax(0,0.8fr)_minmax(0,1.8fr)_auto] gap-2"><Input value={repositoryName} onChange={event => setRepositoryName(event.target.value)} placeholder="Repository name" disabled={!canEditSources} /><Input value={repositoryURL} onChange={event => setRepositoryURL(event.target.value)} placeholder="https://charts.example.com" disabled={!canEditSources} /><button type="submit" disabled={!canEditSources || !repositoryName.trim() || !isValidHelmRepositoryURL(repositoryURL) || addRepository.isPending} className="btn-brand inline-flex items-center justify-center gap-1 px-3 py-2"><Plus className="w-4 h-4" /> Add</button></div>
|
|
170
|
-
<p className="text-xs text-theme-text-tertiary">
|
|
196
|
+
<p className="text-xs text-theme-text-tertiary">After adding it, select the repository for an upgrade, or associate it with the installed version.</p>
|
|
171
197
|
</form>
|
|
172
198
|
<form onSubmit={addOCIPrefix} className="space-y-2">
|
|
173
199
|
<p className="text-xs uppercase tracking-wide text-theme-text-tertiary">Register OCI prefix</p>
|
|
@@ -10,6 +10,7 @@ interface ValuesDiffPreviewProps {
|
|
|
10
10
|
onClose: () => void
|
|
11
11
|
onApply: () => void
|
|
12
12
|
isApplying: boolean
|
|
13
|
+
notice?: string
|
|
13
14
|
title?: string
|
|
14
15
|
applyLabel?: string
|
|
15
16
|
}
|
|
@@ -19,6 +20,7 @@ export function ValuesDiffPreview({
|
|
|
19
20
|
onClose,
|
|
20
21
|
onApply,
|
|
21
22
|
isApplying,
|
|
23
|
+
notice,
|
|
22
24
|
title = 'Preview Changes',
|
|
23
25
|
applyLabel = 'Apply Changes',
|
|
24
26
|
}: ValuesDiffPreviewProps) {
|
|
@@ -81,7 +83,8 @@ export function ValuesDiffPreview({
|
|
|
81
83
|
</div>
|
|
82
84
|
|
|
83
85
|
{/* Content */}
|
|
84
|
-
<
|
|
86
|
+
{notice && <p className="px-4 py-2 text-sm break-words text-theme-text-secondary">{notice}</p>}
|
|
87
|
+
<div className="flex-1 overflow-auto p-4">
|
|
85
88
|
{hasChanges ? (
|
|
86
89
|
<div className="space-y-4">
|
|
87
90
|
<p className="text-sm text-theme-text-secondary">
|
|
@@ -12,7 +12,7 @@ import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
|
12
12
|
import { MCPSetupDialog } from './MCPSetupDialog'
|
|
13
13
|
import { assetUrl, pluralize, parseContextName } from '@skyhook-io/k8s-ui'
|
|
14
14
|
import { Tooltip } from '../ui/Tooltip'
|
|
15
|
-
import {
|
|
15
|
+
import { mcpEndpointUrl } from '../../api/config'
|
|
16
16
|
import { parseMajorMinor } from '../../utils/version'
|
|
17
17
|
import gkeIcon from '../../assets/platform-icons/google_kubernetes_engine.png'
|
|
18
18
|
import eksIcon from '../../assets/platform-icons/aws_eks.png'
|
|
@@ -152,7 +152,7 @@ export function ClusterHealthCard({
|
|
|
152
152
|
const mcpEnabled = caps.mcpEnabled
|
|
153
153
|
const isCloud = deployment.mode === 'cloud'
|
|
154
154
|
const isInCluster = deployment.mode === 'in-cluster' || deployment.mode === 'cloud'
|
|
155
|
-
const mcpUrl =
|
|
155
|
+
const mcpUrl = mcpEndpointUrl(caps.mcpReadOnly)
|
|
156
156
|
// In Cloud, MCP is org-wide and PAT-authed (api.radarhq.io/mcp). The OSS
|
|
157
157
|
// "this binary is your local MCP server" framing is wrong there — Cloud
|
|
158
158
|
// surfaces MCP from the hub Home dashboard instead.
|
|
@@ -316,7 +316,7 @@ export function ClusterHealthCard({
|
|
|
316
316
|
>
|
|
317
317
|
<Radio className="w-3.5 h-3.5 text-purple-400 animate-pulse shrink-0" />
|
|
318
318
|
<div className="flex flex-col gap-0.5 min-w-0 flex-1 text-left">
|
|
319
|
-
<span className="text-xs font-medium text-purple-400">MCP Server Live</span>
|
|
319
|
+
<span className="text-xs font-medium text-purple-400">{caps.mcpReadOnly ? 'MCP Server Live (read-only)' : 'MCP Server Live'}</span>
|
|
320
320
|
<Tooltip content={mcpUrl} wrapperClassName="min-w-0">
|
|
321
321
|
<span className="text-[10px] text-theme-text-tertiary truncate font-mono">
|
|
322
322
|
HTTP · {mcpUrl}
|
|
@@ -326,7 +326,7 @@ export function ClusterHealthCard({
|
|
|
326
326
|
<Info className="w-3.5 h-3.5 text-purple-400/60 shrink-0" />
|
|
327
327
|
</button>
|
|
328
328
|
)}
|
|
329
|
-
<MCPSetupDialog open={mcpDialogOpen} onClose={() => setMcpDialogOpen(false)} mcpUrl={mcpUrl} />
|
|
329
|
+
<MCPSetupDialog open={mcpDialogOpen} onClose={() => setMcpDialogOpen(false)} mcpUrl={mcpUrl} readOnly={caps.mcpReadOnly} />
|
|
330
330
|
</div>
|
|
331
331
|
|
|
332
332
|
{/* Center: Three health rings */}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { useOpenCostSummary } from '../../api/client'
|
|
7
|
+
import { CostCard } from './CostCard'
|
|
8
|
+
|
|
9
|
+
let root: ReturnType<typeof createRoot>
|
|
10
|
+
let client: QueryClient
|
|
11
|
+
let requested: URL[]
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
15
|
+
requested = []
|
|
16
|
+
vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL) => {
|
|
17
|
+
requested.push(new URL(String(input), 'http://radar.invalid'))
|
|
18
|
+
return new Promise<Response>(() => {})
|
|
19
|
+
}))
|
|
20
|
+
root = createRoot(document.createElement('div'))
|
|
21
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
afterEach(async () => {
|
|
25
|
+
await act(async () => root.unmount())
|
|
26
|
+
client.clear()
|
|
27
|
+
vi.unstubAllGlobals()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
describe('CostCard namespace scope', () => {
|
|
31
|
+
it('requests the picked namespaces', async () => {
|
|
32
|
+
await act(async () => {
|
|
33
|
+
root.render(
|
|
34
|
+
<QueryClientProvider client={client}>
|
|
35
|
+
<CostCard namespaces={['team-a', 'team-b']} />
|
|
36
|
+
</QueryClientProvider>,
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const summary = requested.find((url) => url.pathname === '/api/opencost/summary')
|
|
41
|
+
expect(summary?.searchParams.get('namespaces')).toBe('team-a,team-b')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('fetches a separate query when the pick changes', async () => {
|
|
45
|
+
await act(async () => {
|
|
46
|
+
root.render(
|
|
47
|
+
<QueryClientProvider client={client}>
|
|
48
|
+
<CostCard namespaces={['team-a']} />
|
|
49
|
+
</QueryClientProvider>,
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
await act(async () => {
|
|
53
|
+
root.render(
|
|
54
|
+
<QueryClientProvider client={client}>
|
|
55
|
+
<CostCard namespaces={['team-b']} />
|
|
56
|
+
</QueryClientProvider>,
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
expect(requested.filter((url) => url.pathname === '/api/opencost/summary')
|
|
61
|
+
.map((url) => url.searchParams.get('namespaces'))).toEqual(['team-a', 'team-b'])
|
|
62
|
+
expect(client.getQueryCache().findAll({ queryKey: ['opencost-summary'] })).toHaveLength(2)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it.each([
|
|
66
|
+
{ label: 'omitted', namespaces: undefined },
|
|
67
|
+
{ label: 'empty', namespaces: [] },
|
|
68
|
+
])('keeps the unfiltered request for no namespaces ($label)', async ({ namespaces }) => {
|
|
69
|
+
await act(async () => {
|
|
70
|
+
root.render(
|
|
71
|
+
<QueryClientProvider client={client}>
|
|
72
|
+
<CostCard namespaces={namespaces} />
|
|
73
|
+
</QueryClientProvider>,
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const summary = requested.find((url) => url.pathname === '/api/opencost/summary')
|
|
78
|
+
expect(summary?.pathname).toBe('/api/opencost/summary')
|
|
79
|
+
expect(summary?.search).toBe('')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('keeps an unscoped consumer separate from the Home card', async () => {
|
|
83
|
+
function UnscopedCost() {
|
|
84
|
+
useOpenCostSummary()
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
await act(async () => {
|
|
89
|
+
root.render(
|
|
90
|
+
<QueryClientProvider client={client}>
|
|
91
|
+
<CostCard namespaces={['team-a']} />
|
|
92
|
+
<UnscopedCost />
|
|
93
|
+
</QueryClientProvider>,
|
|
94
|
+
)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
expect(requested.filter((url) => url.pathname === '/api/opencost/summary')
|
|
98
|
+
.map((url) => url.searchParams.get('namespaces'))).toEqual(['team-a', null])
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
} from '../cost/format'
|
|
11
11
|
import { costFreshnessLabel } from '../cost/source'
|
|
12
12
|
|
|
13
|
-
export function CostCard({ onNavigate }: { onNavigate?: () => void }) {
|
|
14
|
-
const { data } = useOpenCostSummary()
|
|
13
|
+
export function CostCard({ namespaces, onNavigate }: { namespaces?: string[]; onNavigate?: () => void }) {
|
|
14
|
+
const { data } = useOpenCostSummary(true, namespaces)
|
|
15
15
|
|
|
16
16
|
// Only show when OpenCost data is actually available — no placeholder card
|
|
17
17
|
if (!data || !data.available) {
|
|
@@ -88,8 +88,8 @@ export function HelmSummary({ data, onNavigate }: HelmSummaryProps) {
|
|
|
88
88
|
<span className="text-xs font-medium text-theme-text-secondary">
|
|
89
89
|
{data.errorCode === 'unconfigured' ? 'Helm not configured' : 'Helm unavailable'}
|
|
90
90
|
</span>
|
|
91
|
-
<Tooltip content={data.error} wrapperClassName="!block mt-1 min-w-0 text-center">
|
|
92
|
-
<span className="text-[11px] text-center px-2
|
|
91
|
+
<Tooltip content={data.error} wrapperClassName="!block mt-1 min-w-0 w-full text-center">
|
|
92
|
+
<span className="text-[11px] text-center px-2 line-clamp-2 [overflow-wrap:anywhere] max-w-full">
|
|
93
93
|
{data.errorCode === 'unconfigured'
|
|
94
94
|
? 'Set rbac.helm=true in the Radar Helm chart values.'
|
|
95
95
|
: data.error}
|
|
@@ -31,6 +31,7 @@ import { formatCompactAge } from '@skyhook-io/k8s-ui/utils/format'
|
|
|
31
31
|
import { ClusterHealthCard } from './ClusterHealthCard'
|
|
32
32
|
import { AlertTriangle, CheckCircle, Loader2, Shield } from 'lucide-react'
|
|
33
33
|
import { uncheckedSourceLines } from '../issues/uncheckedSources'
|
|
34
|
+
import { UncheckedSourceHelp } from '../issues/UncheckedSourceHelp'
|
|
34
35
|
import { clsx } from 'clsx'
|
|
35
36
|
import { getVersionUpdateStatus } from '../../utils/version'
|
|
36
37
|
import { RadarVersionLine } from './RadarVersionLine'
|
|
@@ -68,7 +69,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
68
69
|
karpenterState === 'available' || karpenterState === 'denied' || karpenterState === 'not_detected'
|
|
69
70
|
const { data, isLoading, error, dataUpdatedAt, refetch } = useDashboard(namespaces)
|
|
70
71
|
const { connection } = useConnection()
|
|
71
|
-
const { data: issuesData, isLoading: issuesLoading, isFetching: issuesFetching, error: issuesError } = useIssues(namespaces)
|
|
72
|
+
const { data: issuesData, isLoading: issuesLoading, isFetching: issuesFetching, error: issuesError, refetch: refetchIssues } = useIssues(namespaces)
|
|
72
73
|
const issues = issuesData?.issues ?? []
|
|
73
74
|
const issueCount = issuesData?.total_matched ?? issuesData?.total ?? issues.length
|
|
74
75
|
const hasCriticalIssues = issues.some((issue) => issue.severity === 'critical')
|
|
@@ -212,7 +213,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
212
213
|
/>
|
|
213
214
|
</BandItem>
|
|
214
215
|
<BandItem>
|
|
215
|
-
<CostCard onNavigate={() => onNavigateToView('cost')} />
|
|
216
|
+
<CostCard namespaces={namespaces} onNavigate={() => onNavigateToView('cost')} />
|
|
216
217
|
</BandItem>
|
|
217
218
|
</div>
|
|
218
219
|
|
|
@@ -273,6 +274,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
273
274
|
issueCount={issueCount}
|
|
274
275
|
visibility={issuesData?.visibility}
|
|
275
276
|
uncheckedLines={uncheckedSourceLines(issuesData?.unchecked_sources)}
|
|
277
|
+
onRetryIssues={() => { void refetchIssues({ cancelRefetch: false }) }}
|
|
276
278
|
hasData={!!issuesData}
|
|
277
279
|
isLoading={issuesLoading && !issuesData}
|
|
278
280
|
isRefreshing={issuesFetching && !!issuesData}
|
|
@@ -305,6 +307,7 @@ interface ProblemsPanelProps {
|
|
|
305
307
|
/** One line per issue source Radar couldn't check. Any line means an
|
|
306
308
|
* empty list isn't an all-clear. */
|
|
307
309
|
uncheckedLines?: string[]
|
|
310
|
+
onRetryIssues: () => void
|
|
308
311
|
hasData: boolean
|
|
309
312
|
isLoading: boolean
|
|
310
313
|
isRefreshing: boolean
|
|
@@ -319,6 +322,7 @@ export function ProblemsPanel({
|
|
|
319
322
|
issueCount,
|
|
320
323
|
visibility,
|
|
321
324
|
uncheckedLines = [],
|
|
325
|
+
onRetryIssues,
|
|
322
326
|
hasData,
|
|
323
327
|
isLoading,
|
|
324
328
|
isRefreshing,
|
|
@@ -393,9 +397,12 @@ export function ProblemsPanel({
|
|
|
393
397
|
Limited visibility - {visibility.impact} Results may be incomplete.
|
|
394
398
|
</ProblemsPanelNotice>
|
|
395
399
|
)}
|
|
396
|
-
{(issues.length > 0 || hasLimitedVisibility) &&
|
|
397
|
-
<ProblemsPanelNotice
|
|
398
|
-
|
|
400
|
+
{(issues.length > 0 || hasLimitedVisibility) && unchecked && (
|
|
401
|
+
<ProblemsPanelNotice tone="warning">
|
|
402
|
+
{uncheckedLines.map((line) => <p key={line}>{line}</p>)}
|
|
403
|
+
<UncheckedSourceHelp onRetry={onRetryIssues} isRefreshing={isRefreshing} />
|
|
404
|
+
</ProblemsPanelNotice>
|
|
405
|
+
)}
|
|
399
406
|
{isTruncated && (
|
|
400
407
|
<ProblemsPanelNotice tone="neutral">
|
|
401
408
|
Showing {totalReturned} of {issueCount} issues. Narrow by namespace to see the rest.
|
|
@@ -417,6 +424,7 @@ export function ProblemsPanel({
|
|
|
417
424
|
? uncheckedLines.join(' ')
|
|
418
425
|
: 'No critical or warning issues across the selected scope.'
|
|
419
426
|
}
|
|
427
|
+
action={unchecked && !hasLimitedVisibility ? <UncheckedSourceHelp onRetry={onRetryIssues} isRefreshing={isRefreshing} /> : undefined}
|
|
420
428
|
/>
|
|
421
429
|
) : (
|
|
422
430
|
<div className="divide-y divide-theme-border">
|
|
@@ -483,7 +491,7 @@ export function ProblemsPanel({
|
|
|
483
491
|
)
|
|
484
492
|
}
|
|
485
493
|
|
|
486
|
-
function ProblemsPanelState({ icon, title, body }: { icon: ReactNode; title: string; body: string }) {
|
|
494
|
+
function ProblemsPanelState({ icon, title, body, action }: { icon: ReactNode; title: string; body: string; action?: ReactNode }) {
|
|
487
495
|
return (
|
|
488
496
|
<div className="flex min-h-[220px] flex-col items-center justify-center gap-2 px-6 py-10 text-center">
|
|
489
497
|
<div className="flex h-9 w-9 items-center justify-center rounded-full bg-theme-elevated">
|
|
@@ -491,6 +499,7 @@ function ProblemsPanelState({ icon, title, body }: { icon: ReactNode; title: str
|
|
|
491
499
|
</div>
|
|
492
500
|
<p className="text-sm font-medium text-theme-text-primary">{title}</p>
|
|
493
501
|
<p className="max-w-[280px] text-xs leading-5 text-theme-text-secondary">{body}</p>
|
|
502
|
+
{action && <div className="w-full max-w-[280px]">{action}</div>}
|
|
494
503
|
</div>
|
|
495
504
|
)
|
|
496
505
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { MCPSetupDialog } from './MCPSetupDialog'
|
|
5
|
+
import { mcpEndpointUrl, setBasename } from '../../api/config'
|
|
6
|
+
|
|
7
|
+
describe('MCP setup in read-only mode', () => {
|
|
8
|
+
it('generates client configurations for the retained endpoint and hides writes', () => {
|
|
9
|
+
setBasename('/radar')
|
|
10
|
+
try {
|
|
11
|
+
const url = mcpEndpointUrl(true)
|
|
12
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open readOnly mcpUrl={url} onClose={() => {}} />)
|
|
13
|
+
expect(html).toContain(`claude mcp add --transport http radar ${url}`)
|
|
14
|
+
expect(html).toContain(`codex mcp add radar --url ${url}`)
|
|
15
|
+
expect(html).toContain('/radar/mcp-readonly')
|
|
16
|
+
expect(html).toContain('list_namespaces')
|
|
17
|
+
expect(html).not.toContain('apply_resource')
|
|
18
|
+
expect(html).not.toContain('in_cluster')
|
|
19
|
+
expect(html).toContain('Read-only mode blocks write tools')
|
|
20
|
+
} finally {
|
|
21
|
+
setBasename('')
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('keeps the full catalog in default mode', () => {
|
|
26
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
27
|
+
expect(html).toContain('apply_resource')
|
|
28
|
+
expect(html).toContain('in_cluster')
|
|
29
|
+
})
|
|
30
|
+
})
|