@skyhook-io/radar-app 1.20.1 → 1.20.3
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 +1 -1
- package/src/App.tsx +12 -7
- package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +218 -11
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +3 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -0
- package/src/components/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- package/src/components/cost/CostView.tsx +27 -9
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +1 -9
- package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
- package/src/components/helm/HelmView.tsx +5 -3
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +65 -8
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +22 -10
- package/src/components/home/HelmSummary.tsx +15 -15
- package/src/components/home/mcpToolCatalog.ts +2 -2
- package/src/components/resource/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -2
- package/src/components/traffic/TrafficView.tsx +27 -27
- package/src/components/traffic/trafficFilters.test.ts +18 -1
- package/src/components/traffic/trafficFilters.ts +30 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.test.tsx +23 -1
- package/src/components/ui/UpdateNotification.tsx +26 -2
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -1
- package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +51 -11
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +4 -0
- package/src/utils/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
|
@@ -4,6 +4,13 @@ import { contentMatchLabel, partialSearchNotices } from './omnibar-match'
|
|
|
4
4
|
const site = (s: string) => ({ token: 't', site: s, score: 12 })
|
|
5
5
|
|
|
6
6
|
describe('contentMatchLabel', () => {
|
|
7
|
+
it('names Event content without claiming Events have a spec', () => {
|
|
8
|
+
for (const path of ['reason', 'message', 'type', 'involvedObject.name', 'related.name']) {
|
|
9
|
+
expect(contentMatchLabel([site(`content:${path}`)])).toBe('in event')
|
|
10
|
+
}
|
|
11
|
+
expect(contentMatchLabel([site('content:reason'), site('content:message')])).toBe('in event')
|
|
12
|
+
expect(contentMatchLabel([site('content:reason'), site('name')])).toBe('')
|
|
13
|
+
})
|
|
7
14
|
it('names a match inside Trivy findings', () => {
|
|
8
15
|
expect(contentMatchLabel([site('content:report.vulnerabilities[3]')])).toBe('in findings')
|
|
9
16
|
})
|
|
@@ -5,6 +5,7 @@ import type { SearchMatchedField } from '../../api/client'
|
|
|
5
5
|
// reports keep their findings under `report`, not a spec.
|
|
6
6
|
export function contentMatchLabel(matched: SearchMatchedField[] | undefined): string {
|
|
7
7
|
if (!matched?.length || !matched.every((m) => m.site.startsWith('content:'))) return ''
|
|
8
|
+
if (matched.every((m) => /^content:(reason|message|type|involvedObject|related)(\.|$)/.test(m.site))) return 'in event'
|
|
8
9
|
return matched.every((m) => m.site.startsWith('content:report.')) ? 'in findings' : 'in spec'
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -7,6 +7,23 @@ const searchCoverageNote = (entries: SearchCoverageEntry[] | undefined, opts: Pa
|
|
|
7
7
|
const entry = (kind: string, reason: string, group = '', count?: number): SearchCoverageEntry => ({ kind, group, reason, count })
|
|
8
8
|
|
|
9
9
|
describe('searchCoverageNote', () => {
|
|
10
|
+
it('keeps collection limits visible beside an Event search action', () => {
|
|
11
|
+
const searchEvents = vi.fn()
|
|
12
|
+
const note = noteFor({ status: 'complete', narrowedBy: ['kind_collection'], gaps: [] }, { hits: [], query: 'CertificateExpirationWarning', searchEvents })
|
|
13
|
+
expect(note?.parts?.[0].text).toContain("doesn't watch every kind")
|
|
14
|
+
expect(note?.parts?.[1].text).toBe("Kubernetes Events aren't included in a broad search.")
|
|
15
|
+
expect(note?.parts?.[1].action).toMatchObject({ label: 'Search Events', keepOpen: true })
|
|
16
|
+
note?.parts?.[1].action?.onSelect()
|
|
17
|
+
expect(searchEvents).toHaveBeenCalledOnce()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('does not offer Event search for unread scope, existing hits or older coverage', () => {
|
|
21
|
+
const opts = { hits: [], query: 'CertificateExpirationWarning', searchEvents: vi.fn() }
|
|
22
|
+
expect(searchCoverageNote([entry('*', 'kind_sync_pending')], opts)?.action).toBeUndefined()
|
|
23
|
+
expect(noteFor(undefined, opts)).toBeUndefined()
|
|
24
|
+
expect(noteFor({ status: 'complete', gaps: [] }, { ...opts, hits: [{ kind: 'Pod' }] })).toBeUndefined()
|
|
25
|
+
})
|
|
26
|
+
|
|
10
27
|
it('explains an empty search narrowed by kind collection, without an action', () => {
|
|
11
28
|
expect(noteFor({ status: 'complete', narrowedBy: ['kind_collection'], gaps: [] }, { hits: [] })).toEqual({
|
|
12
29
|
text: "Radar doesn't watch every kind; search kind:<name> to include one.",
|
|
@@ -21,6 +21,9 @@ export interface SearchCoverageNoteOptions {
|
|
|
21
21
|
hits?: { kind: string; group?: string }[]
|
|
22
22
|
query?: string
|
|
23
23
|
recheckKind?: (kind: string) => void
|
|
24
|
+
/** Opt into Event search without changing the current terms or namespace. */
|
|
25
|
+
searchEvents?: () => void
|
|
26
|
+
eventSearchNeedsUpgrade?: boolean
|
|
24
27
|
/** Re-querying a still-loading search ran out of budget. */
|
|
25
28
|
pendingExhausted?: boolean
|
|
26
29
|
/** Returns how to open a kind's resource list, or undefined when the host can't. */
|
|
@@ -110,6 +113,14 @@ function failedKinds(entries: SearchCoverageEntry[], label: (e: SearchCoverageEn
|
|
|
110
113
|
return { text: `${shown.join(', ')} and ${more} more ${more === 1 ? 'kind' : 'kinds'}`, one: false }
|
|
111
114
|
}
|
|
112
115
|
|
|
116
|
+
function queryKinds(query: string): string[] {
|
|
117
|
+
const tokens = query.match(/(?:[^\s"]|"[^"]*(?:"|$))+/g) ?? []
|
|
118
|
+
return tokens.flatMap((token) => {
|
|
119
|
+
const match = /^(?:kind|k):(.+)$/i.exec(token.replaceAll('"', ''))
|
|
120
|
+
return match ? [match[1].toLowerCase()] : []
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
113
124
|
// Radar's ⌘K note for one search: what happened to the kinds and namespaces
|
|
114
125
|
// the query named, whether results are still loading, and which kinds failed
|
|
115
126
|
// to read. Broad searches keep access exclusions quiet; namespace collection
|
|
@@ -121,12 +132,26 @@ export function searchCoverageNote(coverage: SearchCoverage | undefined, opts: S
|
|
|
121
132
|
if (coverage?.gaps.length === 0) {
|
|
122
133
|
// Collection limits come from how Radar is installed, and nothing else
|
|
123
134
|
// in the omnibar shows them, so they are said with hits too.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
const collection = coverage.narrowedBy?.includes('namespace_collection')
|
|
136
|
+
? "Radar collects some kinds only in some namespaces; matches for them elsewhere won't show."
|
|
137
|
+
: coverage.narrowedBy?.includes('kind_collection') && !opts.hits?.length
|
|
138
|
+
? "Radar doesn't watch every kind; search kind:<name> to include one."
|
|
139
|
+
: undefined
|
|
140
|
+
const kinds = queryKinds(opts.query ?? '')
|
|
141
|
+
const emptyBroadSearch = opts.hits?.length === 0 && kinds.length === 0
|
|
142
|
+
const needsUpgrade = opts.eventSearchNeedsUpgrade && (emptyBroadSearch || kinds.some((kind) => kind === 'event' || kind === 'events' || kind === 'ev'))
|
|
143
|
+
if (opts.query?.trim() && (needsUpgrade || (opts.searchEvents && emptyBroadSearch))) {
|
|
144
|
+
const eventNote: OmnibarNotePart = needsUpgrade ? {
|
|
145
|
+
text: 'Update the connected Radar server to search Event reasons and messages.',
|
|
146
|
+
} : {
|
|
147
|
+
text: "Kubernetes Events aren't included in a broad search.",
|
|
148
|
+
action: opts.searchEvents ? { label: 'Search Events', onSelect: opts.searchEvents, keepOpen: true } : undefined,
|
|
149
|
+
}
|
|
150
|
+
return collection
|
|
151
|
+
? { text: [collection, eventNote.text, eventNote.action?.label].filter(Boolean).join(' '), parts: [{ text: collection }, eventNote] }
|
|
152
|
+
: eventNote
|
|
129
153
|
}
|
|
154
|
+
if (collection) return { text: collection }
|
|
130
155
|
}
|
|
131
156
|
return undefined
|
|
132
157
|
}
|
|
@@ -149,8 +174,7 @@ export function searchCoverageNote(coverage: SearchCoverage | undefined, opts: S
|
|
|
149
174
|
if (failed.length) {
|
|
150
175
|
const { text, one } = failedKinds(failed, (e) => label(e))
|
|
151
176
|
const warning = `Couldn't read ${text}; matches of ${one ? 'that kind' : 'those kinds'} may be missing.`
|
|
152
|
-
const
|
|
153
|
-
const namedKind = tokens.some((token) => /^(kind|k):.+/i.test(token.replaceAll('"', '')))
|
|
177
|
+
const namedKind = queryKinds(opts.query ?? '').length > 0
|
|
154
178
|
const retry = !namedKind && failed.find((e) => e.kind !== '*' && e.reason === 'read_error')
|
|
155
179
|
const unnamedRetry = !namedKind && !retry && failed.some((e) => e.kind === '*' && e.count && e.reason === 'read_error')
|
|
156
180
|
if (unnamedRetry) {
|
|
@@ -4,6 +4,7 @@ import { pluralize } from '@skyhook-io/k8s-ui'
|
|
|
4
4
|
import { useSwitchContext, fetchSessionCounts, SwitchContextError, type SessionCounts } from '../api/client'
|
|
5
5
|
import { useContextSwitch } from '../context/ContextSwitchContext'
|
|
6
6
|
import { useToast } from './ui/Toast'
|
|
7
|
+
import { Tooltip } from './ui/Tooltip'
|
|
7
8
|
import { useDock } from './dock'
|
|
8
9
|
import type { ContextInfo, SelectedResource } from '../types'
|
|
9
10
|
import { parseContextForSwitcher } from '../utils/context-name'
|
|
@@ -130,7 +131,10 @@ export function useContextSwitchFlow() {
|
|
|
130
131
|
)}
|
|
131
132
|
</ul>
|
|
132
133
|
<p className="text-xs text-theme-text-tertiary">
|
|
133
|
-
Switch to:
|
|
134
|
+
Switch to:{' '}
|
|
135
|
+
<Tooltip content={shortNameHides(pending.context) ? pending.context.name : ''}>
|
|
136
|
+
<span className="text-theme-text-secondary">{parseContextForSwitcher(pending.context).clusterName}</span>
|
|
137
|
+
</Tooltip>
|
|
134
138
|
</p>
|
|
135
139
|
</div>
|
|
136
140
|
<div className="px-4 py-3 border-t border-theme-border flex justify-end gap-2">
|
|
@@ -162,3 +166,7 @@ export function useContextSwitchFlow() {
|
|
|
162
166
|
confirmDialog,
|
|
163
167
|
}
|
|
164
168
|
}
|
|
169
|
+
|
|
170
|
+
function shortNameHides(context: ContextInfo) {
|
|
171
|
+
return parseContextForSwitcher(context).clusterName !== context.name
|
|
172
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { NodeCertificateContext, NodeCertificateDetails } from './NodeCertificateEvidence'
|
|
4
|
+
import type { NodeCertificateReport } from '../../api/client'
|
|
5
|
+
|
|
6
|
+
const report: NodeCertificateReport = {
|
|
7
|
+
uid: 'current-node', event_id: 'certificate-event', state: 'reported',
|
|
8
|
+
reason: 'CertificateExpirationWarning', message: 'Original node monitor warning',
|
|
9
|
+
last_reported_at: '2026-10-31T08:00:00Z', expires_at: '2027-02-05T10:00:00Z',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('Node certificate reports', () => {
|
|
13
|
+
it('keeps the original report available when no matching Issue is shown', () => {
|
|
14
|
+
const html = renderToStaticMarkup(<NodeCertificateContext evidence={report} hasIssue={false} onViewTimeline={() => {}} />)
|
|
15
|
+
expect(html).toContain('Node certificate warning reported')
|
|
16
|
+
expect(html).toContain('Last reported')
|
|
17
|
+
expect(html).toContain('Reported expiry')
|
|
18
|
+
expect(html).toContain(report.message)
|
|
19
|
+
expect(html).toContain('View timeline')
|
|
20
|
+
expect(html).not.toContain('API is down')
|
|
21
|
+
})
|
|
22
|
+
it('does not duplicate a fresh or unverified Issue or claim current health after an OK report', () => {
|
|
23
|
+
expect(renderToStaticMarkup(<NodeCertificateContext evidence={report} hasIssue onViewTimeline={() => {}} />)).toBe('')
|
|
24
|
+
expect(renderToStaticMarkup(<NodeCertificateContext evidence={{ ...report, state: 'unverified' }} hasIssue onViewTimeline={() => {}} />)).toBe('')
|
|
25
|
+
expect(renderToStaticMarkup(<NodeCertificateContext evidence={{ ...report, state: 'ok' }} hasIssue={false} onViewTimeline={() => {}} />)).toBe('')
|
|
26
|
+
expect(renderToStaticMarkup(<NodeCertificateContext evidence={{ ...report, state: 'unverified', reason: 'CertificateExpirationOK', history_incomplete: true }} hasIssue={false} onViewTimeline={() => {}} />)).toBe('')
|
|
27
|
+
const details = renderToStaticMarkup(<NodeCertificateDetails evidence={report} onViewTimeline={() => {}} includeOriginalReport={false} />)
|
|
28
|
+
expect(details).toContain('Reported expiry')
|
|
29
|
+
expect(details).not.toContain(report.message)
|
|
30
|
+
})
|
|
31
|
+
it('retains stale evidence with an explicit unverified state', () => {
|
|
32
|
+
const html = renderToStaticMarkup(<NodeCertificateContext evidence={{ ...report, state: 'unverified' }} hasIssue={false} onViewTimeline={() => {}} />)
|
|
33
|
+
expect(html).toContain('Node certificate status unverified')
|
|
34
|
+
expect(html).toContain('current certificate state is unverified')
|
|
35
|
+
expect(html).toContain(report.message)
|
|
36
|
+
expect(html).not.toContain('renewed')
|
|
37
|
+
expect(html).not.toContain('healthy')
|
|
38
|
+
const details = renderToStaticMarkup(<NodeCertificateDetails evidence={{ ...report, state: 'unverified' }} onViewTimeline={() => {}} includeOriginalReport={false} />)
|
|
39
|
+
expect(details).toContain('current certificate state is unverified')
|
|
40
|
+
expect(details).toContain('last retained report')
|
|
41
|
+
expect(details).not.toContain(report.message)
|
|
42
|
+
})
|
|
43
|
+
it('explains history and parsing gaps', () => {
|
|
44
|
+
const html = renderToStaticMarkup(<NodeCertificateDetails evidence={{ ...report, history_incomplete: true, validity_unknown: true }} onViewTimeline={() => {}} />)
|
|
45
|
+
expect(html).toContain('a later report may be missing')
|
|
46
|
+
expect(html).toContain('could not read the validity dates')
|
|
47
|
+
const context = renderToStaticMarkup(<NodeCertificateContext evidence={{ ...report, validity_unknown: true }} hasIssue={false} onViewTimeline={() => {}} />)
|
|
48
|
+
expect(context).toContain('Review the original monitor report')
|
|
49
|
+
expect(context).not.toContain('Review the reported validity dates')
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Clock, Info } from 'lucide-react'
|
|
2
|
+
import { AlertBanner, CardSection, Disclosure, TimeValue } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import type { NodeCertificateReport } from '../../api/client'
|
|
4
|
+
|
|
5
|
+
type EvidenceProps = { evidence: NodeCertificateReport; onViewTimeline: () => void; includeOriginalReport?: boolean }
|
|
6
|
+
|
|
7
|
+
export function NodeCertificateDetails({ evidence, onViewTimeline, includeOriginalReport = true }: EvidenceProps) {
|
|
8
|
+
return (
|
|
9
|
+
<CardSection icon={Clock} label="Certificate evidence">
|
|
10
|
+
<p className="text-sm text-theme-text-secondary">Last reported: <TimeValue timestamp={evidence.last_reported_at} />.</p>
|
|
11
|
+
{evidence.expires_at && <p className="text-sm text-theme-text-secondary">Reported expiry: <TimeValue timestamp={evidence.expires_at} />.</p>}
|
|
12
|
+
{evidence.not_before && <p className="text-sm text-theme-text-secondary">Reported valid from: <TimeValue timestamp={evidence.not_before} />.</p>}
|
|
13
|
+
{evidence.state === 'unverified' && <p className="text-sm text-theme-text-secondary">The current certificate state is unverified; this is the last retained report.</p>}
|
|
14
|
+
{evidence.history_incomplete && <p className="text-sm text-theme-text-secondary">Some history is unavailable; a later report may be missing.</p>}
|
|
15
|
+
{evidence.validity_unknown && <p className="text-sm text-theme-text-secondary">Radar could not read the validity dates from this report.</p>}
|
|
16
|
+
{includeOriginalReport && <Disclosure summary="Original report" summaryClassName="text-xs text-theme-text-secondary">
|
|
17
|
+
<pre className="mt-2 max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-theme-elevated p-3 text-xs text-theme-text-secondary">{evidence.message}</pre>
|
|
18
|
+
</Disclosure>}
|
|
19
|
+
<button type="button" onClick={onViewTimeline} className="self-start text-left text-sm font-medium text-accent-text hover:underline">View timeline</button>
|
|
20
|
+
</CardSection>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function nodeCertificateContextVisible(evidence: NodeCertificateReport | undefined, hasIssue: boolean): boolean {
|
|
25
|
+
return Boolean(evidence && evidence.reason !== 'CertificateExpirationOK' && evidence.state !== 'ok' && !hasIssue)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function NodeCertificateContext({ evidence, hasIssue, onViewTimeline }: { evidence?: NodeCertificateReport; hasIssue: boolean; onViewTimeline: () => void }) {
|
|
29
|
+
if (!evidence || !nodeCertificateContextVisible(evidence, hasIssue)) return null
|
|
30
|
+
const unverified = evidence.state === 'unverified'
|
|
31
|
+
return (
|
|
32
|
+
<AlertBanner
|
|
33
|
+
variant="info"
|
|
34
|
+
icon={Info}
|
|
35
|
+
title={unverified ? 'Node certificate status unverified' : 'Node certificate warning reported'}
|
|
36
|
+
message={unverified ? 'The earlier warning is retained, but the current certificate state is unverified.' : evidence.validity_unknown ? "Review the original monitor report and the distribution's certificate guidance." : "Review the reported validity dates and the distribution's certificate guidance."}
|
|
37
|
+
className="mb-0"
|
|
38
|
+
>
|
|
39
|
+
<div className="mt-3">
|
|
40
|
+
<NodeCertificateDetails evidence={evidence} onViewTimeline={onViewTimeline} />
|
|
41
|
+
</div>
|
|
42
|
+
</AlertBanner>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
isDiagnoseKind,
|
|
26
26
|
isRolloutKind,
|
|
27
27
|
canSetWorkloadImages,
|
|
28
|
+
canPauseDeployment,
|
|
28
29
|
isCoreBatchJob,
|
|
29
30
|
type SetImageOwnership,
|
|
30
31
|
SET_IMAGE_WRITES,
|
|
@@ -38,6 +39,7 @@ import type { ServicePortRenderProps } from '@skyhook-io/k8s-ui/components/resou
|
|
|
38
39
|
import { isJobSetV1Alpha2 } from '@skyhook-io/k8s-ui/components/resources/resource-utils-jobset-lws'
|
|
39
40
|
import type { SelectedResource, ResourceRef, Relationships, ResourceWithRelationships } from '../../types'
|
|
40
41
|
import { CronJobSchedulingContext, CronJobSchedulingDetails } from './CronJobSchedulingEvidence'
|
|
42
|
+
import { NodeCertificateContext, NodeCertificateDetails, nodeCertificateContextVisible } from './NodeCertificateEvidence'
|
|
41
43
|
import { useHistoryPaging } from './historyPaging'
|
|
42
44
|
import { findInheritedGitOpsLookupRef, useResolvedGitOpsOwner } from '../../hooks/useResolvedGitOpsOwner'
|
|
43
45
|
import { useGitOpsWriteGuard } from '../../hooks/useGitOpsWriteGuard'
|
|
@@ -64,10 +66,13 @@ import {
|
|
|
64
66
|
useSuspendCronJob,
|
|
65
67
|
useResumeCronJob,
|
|
66
68
|
useRestartWorkload,
|
|
69
|
+
usePauseDeployment,
|
|
70
|
+
useResumeDeployment,
|
|
67
71
|
fetchWorkloadImages,
|
|
68
72
|
fetchResourceWithRelationships,
|
|
69
73
|
useSetWorkloadImages,
|
|
70
74
|
useWorkloadRevisions,
|
|
75
|
+
useRefreshRevisionsOnNewRollout,
|
|
71
76
|
useRollbackWorkload,
|
|
72
77
|
useRolloutAction,
|
|
73
78
|
useRolloutCapabilities,
|
|
@@ -326,6 +331,8 @@ function useActionsBarProps(
|
|
|
326
331
|
|
|
327
332
|
const deleteMutation = useDeleteResource()
|
|
328
333
|
const restartWorkloadMutation = useRestartWorkload()
|
|
334
|
+
const pauseDeploymentMutation = usePauseDeployment()
|
|
335
|
+
const resumeDeploymentMutation = useResumeDeployment()
|
|
329
336
|
const setWorkloadImagesMutation = useSetWorkloadImages()
|
|
330
337
|
const rollbackMutation = useRollbackWorkload()
|
|
331
338
|
// Only the revision dialog drives this one, and it explains a failed promote in place
|
|
@@ -348,6 +355,9 @@ function useActionsBarProps(
|
|
|
348
355
|
const canSetImages = isRolloutShape
|
|
349
356
|
? imageUpdatesSupported && isRollout && !rolloutCapabilitiesPending && rolloutCapabilities?.setImage === true
|
|
350
357
|
: !workloadWritesPending && canSetWorkloadImages({ name: kind, group }, workloadWrites, imageUpdatesSupported)
|
|
358
|
+
const { support: deploymentPauseSupport } = useRadarFeature('deploymentPause')
|
|
359
|
+
const canPauseDeployments = !workloadWritesPending &&
|
|
360
|
+
canPauseDeployment({ name: kind, group }, workloadWrites, deploymentPauseSupport === 'supported')
|
|
351
361
|
const loadImages = useCallback(
|
|
352
362
|
(params: { kind: string; namespace: string; name: string }) =>
|
|
353
363
|
queryClient.fetchQuery({
|
|
@@ -434,6 +444,16 @@ function useActionsBarProps(
|
|
|
434
444
|
restartWorkloadMutation.mutate(params)
|
|
435
445
|
: undefined,
|
|
436
446
|
isRestarting: restartWorkloadMutation.isPending,
|
|
447
|
+
onPauseDeployment: canPauseDeployments
|
|
448
|
+
? (params: Parameters<typeof pauseDeploymentMutation.mutate>[0]) =>
|
|
449
|
+
pauseDeploymentMutation.mutate(params)
|
|
450
|
+
: undefined,
|
|
451
|
+
onResumeDeployment: canPauseDeployments
|
|
452
|
+
? (params: Parameters<typeof resumeDeploymentMutation.mutate>[0]) =>
|
|
453
|
+
resumeDeploymentMutation.mutate(params)
|
|
454
|
+
: undefined,
|
|
455
|
+
isPausingDeployment: pauseDeploymentMutation.isPending,
|
|
456
|
+
isResumingDeployment: resumeDeploymentMutation.isPending,
|
|
437
457
|
onLoadImages: canSetImages ? loadImages : undefined,
|
|
438
458
|
onSetImages: canSetImages
|
|
439
459
|
? (params: Parameters<typeof setWorkloadImagesMutation.mutateAsync>[0]) =>
|
|
@@ -592,6 +612,12 @@ export function WorkloadView({
|
|
|
592
612
|
} = useResourceWithRelationships<any>(apiKind, namespace, name, rest.group)
|
|
593
613
|
const resource = resourceResponse?.resource
|
|
594
614
|
const relationships = resourceResponse?.relationships
|
|
615
|
+
useRefreshRevisionsOnNewRollout(
|
|
616
|
+
apiKind.toLowerCase(),
|
|
617
|
+
namespace,
|
|
618
|
+
name,
|
|
619
|
+
resource ? resource.metadata?.annotations?.['deployment.kubernetes.io/revision'] ?? '' : undefined,
|
|
620
|
+
)
|
|
595
621
|
const resourceGroup = useMemo(
|
|
596
622
|
() => (resource?.apiVersion ? apiVersionToGroup(resource.apiVersion) : undefined),
|
|
597
623
|
[resource?.apiVersion],
|
|
@@ -654,6 +680,7 @@ export function WorkloadView({
|
|
|
654
680
|
[podWorkloadOwner, podOwnerAppsQuery.data?.applications],
|
|
655
681
|
)
|
|
656
682
|
const certificateInfo = resourceResponse?.certificateInfo
|
|
683
|
+
const certificateSigningRequest = resourceResponse?.certificateSigningRequest
|
|
657
684
|
const hpaDiagnosis = resourceResponse?.hpaDiagnosis
|
|
658
685
|
const activeImageTargetOwnership = useMemo(
|
|
659
686
|
() =>
|
|
@@ -845,20 +872,27 @@ export function WorkloadView({
|
|
|
845
872
|
// the renderer banners. The backend canonicalizes a plural kind via discovery,
|
|
846
873
|
// so using the normalized API kind resolves direct links and app navigation alike.
|
|
847
874
|
const isCronJob = apiKind === 'cronjobs' && (!effectiveGroup || effectiveGroup === 'batch')
|
|
875
|
+
const isCoreNode = apiKind === 'nodes' && !effectiveGroup
|
|
848
876
|
const { support: coverageSupport } = useRadarFeature('resourceIssueCoverage')
|
|
849
|
-
const
|
|
877
|
+
const useReportCoverage = (isCronJob || isCoreNode) && coverageSupport === 'supported'
|
|
850
878
|
const issueObservation = resource ? JSON.stringify([resource.metadata?.uid, resource.metadata?.resourceVersion]) : undefined
|
|
851
879
|
const ordinaryIssues = useResourceIssues(apiKind, rest.group, namespace, name,
|
|
852
|
-
rest.active !== false && !
|
|
853
|
-
const
|
|
854
|
-
const liveIssues =
|
|
855
|
-
const issuesPending =
|
|
856
|
-
const schedulingEvidence =
|
|
857
|
-
const
|
|
880
|
+
rest.active !== false && !useReportCoverage && !isNotFoundError(resourceError), issueObservation)
|
|
881
|
+
const subjectIssues = useSubjectIssues(useReportCoverage ? { kind: isCoreNode ? 'Node' : 'CronJob', group: isCoreNode ? '' : 'batch', namespace, name, uid: resource?.metadata?.uid } : null, useReportCoverage && Boolean(resource))
|
|
882
|
+
const liveIssues = useReportCoverage ? subjectIssues.data?.issues : ordinaryIssues.data
|
|
883
|
+
const issuesPending = useReportCoverage ? subjectIssues.isPending : ordinaryIssues.isPending
|
|
884
|
+
const schedulingEvidence = isCronJob && subjectIssues.data?.scheduling_report?.uid === resource?.metadata?.uid ? subjectIssues.data?.scheduling_report : undefined
|
|
885
|
+
const certificateEvidence = isCoreNode && subjectIssues.data?.node_certificate_report?.uid === resource?.metadata?.uid ? subjectIssues.data?.node_certificate_report : undefined
|
|
886
|
+
const hasCertificateIssue = Boolean(liveIssues?.some(issue => issue.kind === 'Node' && issue.reason === 'NodeCertificateExpiry'))
|
|
887
|
+
const [reportTimelineFocus, setReportTimelineFocus] = useState<{ uid: string; id: string }>()
|
|
858
888
|
const viewSchedulingReport = useCallback(() => {
|
|
859
|
-
|
|
889
|
+
setReportTimelineFocus(schedulingEvidence?.event_id ? { uid: schedulingEvidence.uid, id: schedulingEvidence.event_id } : undefined)
|
|
860
890
|
handleTabChange('timeline')
|
|
861
891
|
}, [schedulingEvidence, handleTabChange])
|
|
892
|
+
const viewCertificateReport = useCallback(() => {
|
|
893
|
+
setReportTimelineFocus(certificateEvidence?.event_id ? { uid: certificateEvidence.uid, id: certificateEvidence.event_id } : undefined)
|
|
894
|
+
handleTabChange('timeline')
|
|
895
|
+
}, [certificateEvidence, handleTabChange])
|
|
862
896
|
const { data: auditFindings } = useResourceAudit(apiKind, namespace, name, effectiveGroup)
|
|
863
897
|
const hasOperationalIssues = Boolean(liveIssues?.length)
|
|
864
898
|
const openIssueResource = issueResourceOpener(rest.onNavigateToResource)
|
|
@@ -1187,6 +1221,7 @@ export function WorkloadView({
|
|
|
1187
1221
|
ownershipContext={ownershipContext}
|
|
1188
1222
|
onOpenApplication={handleOpenApplication}
|
|
1189
1223
|
certificateInfo={certificateInfo}
|
|
1224
|
+
certificateSigningRequest={certificateSigningRequest}
|
|
1190
1225
|
hpaDiagnosis={hpaDiagnosis}
|
|
1191
1226
|
workloadPods={supportsWorkloadPods ? workloadPodsQuery.data?.pods : undefined}
|
|
1192
1227
|
onEvaluateCapacity={
|
|
@@ -1207,7 +1242,7 @@ export function WorkloadView({
|
|
|
1207
1242
|
refetch={refetchResourceAndRuns}
|
|
1208
1243
|
// Timeline
|
|
1209
1244
|
allEvents={allEvents}
|
|
1210
|
-
timelineFocusEvent={
|
|
1245
|
+
timelineFocusEvent={reportTimelineFocus?.uid === resource?.metadata?.uid ? reportTimelineFocus : undefined}
|
|
1211
1246
|
historyTruncated={!historyFallback && historyTruncated}
|
|
1212
1247
|
onLoadOlderHistory={historyFallback ? undefined : loadOlderHistory}
|
|
1213
1248
|
loadingOlderHistory={!historyFallback && loadingOlderHistory}
|
|
@@ -1355,16 +1390,21 @@ export function WorkloadView({
|
|
|
1355
1390
|
renderOverviewLead={() => (
|
|
1356
1391
|
<div className="flex flex-col gap-4">
|
|
1357
1392
|
<CronJobSchedulingContext evidence={schedulingEvidence} onViewTimeline={viewSchedulingReport} />
|
|
1393
|
+
<NodeCertificateContext evidence={certificateEvidence} hasIssue={hasCertificateIssue} onViewTimeline={viewCertificateReport} />
|
|
1358
1394
|
<ResourceIssuesSection
|
|
1359
1395
|
issues={liveIssues}
|
|
1360
|
-
renderDetailSection={
|
|
1396
|
+
renderDetailSection={({ issue }) => {
|
|
1397
|
+
if (schedulingEvidence?.state === 'reported' && issue.kind === 'CronJob' && issue.reason === schedulingEvidence.reason) return <CronJobSchedulingDetails evidence={schedulingEvidence} onViewTimeline={viewSchedulingReport} />
|
|
1398
|
+
if (certificateEvidence && issue.kind === 'Node' && issue.reason === 'NodeCertificateExpiry') return <NodeCertificateDetails evidence={certificateEvidence} onViewTimeline={viewCertificateReport} includeOriginalReport={false} />
|
|
1399
|
+
return null
|
|
1400
|
+
}}
|
|
1361
1401
|
compact={!expanded}
|
|
1362
1402
|
subjectResource={{ kind: apiKind, namespace, name, group: rest.group }}
|
|
1363
1403
|
onResourceClick={openIssueResource}
|
|
1364
1404
|
/>
|
|
1365
1405
|
</div>
|
|
1366
1406
|
)}
|
|
1367
|
-
hasOverviewLead={hasOperationalIssues || Boolean(schedulingEvidence && schedulingEvidence.state !== 'reported')}
|
|
1407
|
+
hasOverviewLead={hasOperationalIssues || Boolean(schedulingEvidence && schedulingEvidence.state !== 'reported') || nodeCertificateContextVisible(certificateEvidence, hasCertificateIssue)}
|
|
1368
1408
|
hasOperationalIssues={hasOperationalIssues}
|
|
1369
1409
|
operationalIssuesPending={issuesPending}
|
|
1370
1410
|
// A manager answer's chip links only managers the server found; a
|
|
@@ -43,6 +43,7 @@ describe('shouldAutoRetryConnection', () => {
|
|
|
43
43
|
it('leaves configuration and RBAC errors for the user to resolve', () => {
|
|
44
44
|
expect(shouldAutoRetryConnection('config')).toBe(false)
|
|
45
45
|
expect(shouldAutoRetryConnection('rbac')).toBe(false)
|
|
46
|
+
expect(shouldAutoRetryConnection('settings')).toBe(false)
|
|
46
47
|
})
|
|
47
48
|
})
|
|
48
49
|
|
|
@@ -79,8 +79,8 @@ export function shouldAutoRetryConnection(errorType?: string): boolean {
|
|
|
79
79
|
// Auth-shaped failures are excluded: the server runs its own backoff
|
|
80
80
|
// reconnect loop for those, and each browser retry would invoke the exec
|
|
81
81
|
// credential plugin again. Manual "Retry Connection" stays available for
|
|
82
|
-
// an immediate check.
|
|
83
|
-
return errorType !== 'config' && errorType !== 'rbac' && !errorType?.startsWith('auth')
|
|
82
|
+
// an immediate check. A settings error can't clear until Radar restarts.
|
|
83
|
+
return errorType !== 'config' && errorType !== 'settings' && errorType !== 'rbac' && !errorType?.startsWith('auth')
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export function shouldApplyPolledConnection(
|
|
@@ -51,11 +51,11 @@ describe('application resource hosts', () => {
|
|
|
51
51
|
'CustomResourceDefinitionRenderer', 'RayJobRenderer', 'JobRenderer', 'JobSetRenderer', 'RayServiceRenderer', 'RayClusterRenderer',
|
|
52
52
|
'KueueWorkloadRenderer', 'LocalQueueRenderer', 'ClusterQueueRenderer', 'CAPIClusterRenderer', 'PodRenderer', 'KarpenterNodePoolRenderer',
|
|
53
53
|
'NodeRenderer', 'ServiceRenderer', 'WorkloadRenderer', 'CompositeRenderer', 'ServiceAccountRenderer',
|
|
54
|
-
'RoleRenderer', 'RoleBindingRenderer', 'NamespaceRenderer', 'HPARenderer', 'PVCRenderer',
|
|
54
|
+
'RoleRenderer', 'RoleBindingRenderer', 'NamespaceRenderer', 'HPARenderer', 'PVCRenderer', 'HTTPRouteRenderer',
|
|
55
55
|
'RolloutRenderer', 'KyvernoPolicyCoverage', 'KyvernoPolicyQueued', 'CNPGObjectStoreRenderer',
|
|
56
56
|
'VeleroBSLRenderer', 'VeleroBackupRenderer', 'VeleroRestoreRenderer', 'CNPGClusterRenderer',
|
|
57
57
|
'CNPGDatabaseRenderer', 'CNPGPublicationRenderer', 'CNPGSubscriptionRenderer', 'CNPGImageCatalogRenderer',
|
|
58
|
-
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer',
|
|
58
|
+
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer', 'SecretProviderClassRenderer',
|
|
59
59
|
].sort())
|
|
60
60
|
const inherited = [{ id: 'local', label: 'Local', render: () => null }]
|
|
61
61
|
expect(resourceDetailSlots({ kind: 'Pod', group: '', namespace: 'db', name: 'pg-1' }, inherited).extraTabs).toEqual(inherited)
|
|
@@ -32,6 +32,7 @@ import { NamespaceRenderer } from '../components/resources/renderers/NamespaceRe
|
|
|
32
32
|
import { CAPIClusterRenderer } from '../components/resources/renderers/CAPIClusterRenderer'
|
|
33
33
|
import { HPARenderer } from '../components/resources/renderers/HPARenderer'
|
|
34
34
|
import { PVCRenderer } from '../components/resources/renderers/PVCRenderer'
|
|
35
|
+
import { HTTPRouteRenderer } from '../components/resources/renderers/HTTPRouteRenderer'
|
|
35
36
|
import { RolloutRenderer } from '../components/resources/renderers/RolloutRenderer'
|
|
36
37
|
import { KyvernoPolicyCoverage } from '../components/resources/renderers/KyvernoPolicyCoverage'
|
|
37
38
|
import { KyvernoPolicyQueued } from '../components/resources/renderers/KyvernoPolicyQueued'
|
|
@@ -39,6 +40,7 @@ import { VeleroBSLRenderer } from '../components/resources/renderers/VeleroBSLRe
|
|
|
39
40
|
import { VeleroBackupRenderer } from '../components/resources/renderers/VeleroBackupRenderer'
|
|
40
41
|
import { VeleroRestoreRenderer } from '../components/resources/renderers/VeleroRestoreRenderer'
|
|
41
42
|
import { FluxHelmReleaseRenderer } from '../components/resources/renderers/FluxHelmReleaseRenderer'
|
|
43
|
+
import { SecretProviderClassRenderer } from '../components/resources/renderers/SecretProviderClassRenderer'
|
|
42
44
|
import {
|
|
43
45
|
ValidatingAdmissionPolicyBindingRenderer,
|
|
44
46
|
ValidatingAdmissionPolicyRenderer,
|
|
@@ -46,6 +48,7 @@ import {
|
|
|
46
48
|
|
|
47
49
|
export const resourceHosts: readonly ResourceHost[] = [
|
|
48
50
|
{ id: 'kubernetes', renderers: { PodRenderer, NodeRenderer, ServiceRenderer, WorkloadRenderer, HPARenderer, PVCRenderer } },
|
|
51
|
+
{ id: 'gateway-api', renderers: { HTTPRouteRenderer } },
|
|
49
52
|
{ id: 'rbac', renderers: { ServiceAccountRenderer, RoleRenderer, RoleBindingRenderer, NamespaceRenderer } },
|
|
50
53
|
{ id: 'batch-and-admission', renderers: { JobRenderer, JobSetRenderer, KueueWorkloadRenderer } },
|
|
51
54
|
{
|
|
@@ -64,6 +67,7 @@ export const resourceHosts: readonly ResourceHost[] = [
|
|
|
64
67
|
{ id: 'kyverno', renderers: { KyvernoPolicyCoverage, KyvernoPolicyQueued } },
|
|
65
68
|
{ id: 'velero', renderers: { VeleroBSLRenderer, VeleroBackupRenderer, VeleroRestoreRenderer } },
|
|
66
69
|
{ id: 'flux', renderers: { FluxHelmReleaseRenderer } },
|
|
70
|
+
{ id: 'secrets-store-csi', renderers: { SecretProviderClassRenderer } },
|
|
67
71
|
{ id: 'admission-policy', renderers: { ValidatingAdmissionPolicyRenderer, ValidatingAdmissionPolicyBindingRenderer } },
|
|
68
72
|
cnpgResourceHost,
|
|
69
73
|
crdResourceHost,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import type { NamespaceScope } from '../api/client'
|
|
4
|
+
import { applyTabPick, readTabPick, writeTabPick } from './namespacePick'
|
|
5
|
+
|
|
6
|
+
function scope(over: Partial<NamespaceScope> = {}): NamespaceScope {
|
|
7
|
+
return {
|
|
8
|
+
actives: [],
|
|
9
|
+
context: 'ctx-a',
|
|
10
|
+
kubeconfigNamespace: '',
|
|
11
|
+
mode: 'cluster-wide',
|
|
12
|
+
accessibleNamespaces: ['team-a', 'team-b', 'team-c'],
|
|
13
|
+
deniedNamespaces: [],
|
|
14
|
+
authoritative: true,
|
|
15
|
+
canClearNamespace: true,
|
|
16
|
+
cacheScoped: false,
|
|
17
|
+
namespaceRescope: false,
|
|
18
|
+
...over,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
beforeEach(() => sessionStorage.clear())
|
|
23
|
+
|
|
24
|
+
describe('applyTabPick', () => {
|
|
25
|
+
it('seeds a tab with no pick from the server and keeps it after the server pick moves', () => {
|
|
26
|
+
expect(applyTabPick(scope({ actives: ['team-a'], mode: 'namespace' }), '/api').actives).toEqual(['team-a'])
|
|
27
|
+
const later = applyTabPick(scope({ actives: ['team-b'], mode: 'namespace' }), '/api')
|
|
28
|
+
expect(later.actives).toEqual(['team-a'])
|
|
29
|
+
expect(later.mode).toBe('namespace')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('keeps an explicit All over a narrowed server pick', () => {
|
|
33
|
+
writeTabPick('/api', 'ctx-a', [])
|
|
34
|
+
const seen = applyTabPick(scope({ actives: ['team-b'], mode: 'namespace' }), '/api')
|
|
35
|
+
expect(seen.actives).toEqual([])
|
|
36
|
+
expect(seen.mode).toBe('cluster-wide')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('reports restricted when an unpicked tab has only a partial list', () => {
|
|
40
|
+
writeTabPick('/api', 'ctx-a', [])
|
|
41
|
+
expect(applyTabPick(scope({ authoritative: false, actives: ['team-a'] }), '/api').mode).toBe('restricted')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('keeps one pick per Radar address', () => {
|
|
45
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
46
|
+
writeTabPick('/clusters/2/api', 'ctx-a', ['team-c'])
|
|
47
|
+
expect(applyTabPick(scope({ actives: ['team-b'] }), '/api').actives).toEqual(['team-a'])
|
|
48
|
+
expect(applyTabPick(scope({ actives: ['team-b'] }), '/clusters/2/api').actives).toEqual(['team-c'])
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('starts again from the server pick after a context switch, also when switching back', () => {
|
|
52
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
53
|
+
expect(applyTabPick(scope({ context: 'ctx-b', actives: ['team-b'] }), '/api').actives).toEqual(['team-b'])
|
|
54
|
+
expect(applyTabPick(scope({ actives: ['team-c'] }), '/api').actives).toEqual(['team-c'])
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('drops namespaces a complete list or a completed access check no longer has, and keeps them after a failed lookup', () => {
|
|
58
|
+
writeTabPick('/api', 'ctx-a', ['team-a', 'gone'])
|
|
59
|
+
expect(applyTabPick(scope({ authoritative: false }), '/api').actives).toEqual(['team-a', 'gone'])
|
|
60
|
+
expect(applyTabPick(scope({ accessibleNamespaces: [] }), '/api').actives).toEqual(['team-a', 'gone'])
|
|
61
|
+
expect(applyTabPick(scope({ authoritative: false, accessChecked: true, accessibleNamespaces: ['team-b'] }), '/api').actives).toEqual([])
|
|
62
|
+
writeTabPick('/api', 'ctx-a', ['team-a', 'gone'])
|
|
63
|
+
expect(applyTabPick(scope(), '/api').actives).toEqual(['team-a'])
|
|
64
|
+
expect(readTabPick('/api', 'ctx-a')).toEqual(['team-a'])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('leaves the shared server pick alone under --namespace-scope and on servers without a context', () => {
|
|
68
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
69
|
+
expect(applyTabPick(scope({ cacheScoped: true, actives: ['team-b'] }), '/api').actives).toEqual(['team-b'])
|
|
70
|
+
expect(applyTabPick(scope({ context: undefined, actives: ['team-b'] }), '/api').actives).toEqual(['team-b'])
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('writeTabPick', () => {
|
|
75
|
+
it('keeps an accepted pick for the page when sessionStorage is full', () => {
|
|
76
|
+
writeTabPick('/api', 'ctx-a', ['team-a'])
|
|
77
|
+
const setItem = vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => {
|
|
78
|
+
throw new DOMException('full', 'QuotaExceededError')
|
|
79
|
+
})
|
|
80
|
+
writeTabPick('/api', 'ctx-a', ['team-b'])
|
|
81
|
+
expect(readTabPick('/api', 'ctx-a')).toEqual(['team-b'])
|
|
82
|
+
setItem.mockRestore()
|
|
83
|
+
writeTabPick('/api', 'ctx-a', ['team-c'])
|
|
84
|
+
expect(sessionStorage.getItem('radar:namespace-pick:/api')).toContain('team-c')
|
|
85
|
+
expect(readTabPick('/api', 'ctx-a')).toEqual(['team-c'])
|
|
86
|
+
})
|
|
87
|
+
})
|