@skyhook-io/radar-app 1.18.0 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +2 -3
- package/src/App.tsx +43 -12
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +197 -57
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/components/capacity/CapacityDemand.tsx +6 -3
- package/src/components/capacity/CapacityOverview.tsx +14 -7
- package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
- package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
- package/src/components/capacity/shared.tsx +9 -5
- package/src/components/cnpg/CNPGOverview.tsx +4 -1
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +60 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +62 -2
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +6 -5
- package/src/components/diagnose/InvestigationView.tsx +47 -13
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/assessmentCopy.ts +11 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
- package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +16 -2
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/observations.ts +8 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +81 -4
- package/src/components/diagnose/investigationEvidence/types.ts +15 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/storyParts.test.tsx +53 -0
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.tsx +6 -4
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +62 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +9 -8
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
- package/src/components/helm/HelmView.tsx +34 -23
- package/src/components/helm/InstallWizard.tsx +6 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
- package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
- package/src/components/helm/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +28 -21
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/mcpToolCatalog.ts +39 -2
- package/src/components/issues/IssuesPane.render.test.tsx +5 -5
- package/src/components/nav/PrimaryNavRail.tsx +34 -2
- package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
- package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
- package/src/components/product-hunt/launchWindow.ts +78 -0
- package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
- package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +30 -68
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +9 -55
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +82 -18
- package/src/components/ui/RadarOmnibar.test.tsx +201 -0
- package/src/components/ui/RadarOmnibar.tsx +39 -4
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +4 -1
- package/src/components/ui/UpdateNotification.tsx +61 -10
- package/src/components/ui/omnibar-match.test.ts +15 -8
- package/src/components/ui/omnibar-match.ts +11 -6
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/WorkloadView.tsx +18 -6
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
- package/src/hooks/useGitOpsWriteGuard.ts +25 -3
- package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +87 -4
- package/src/index.ts +7 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, expect, it } from 'vitest'
|
|
5
|
+
import { SearchSyntaxHelp } from './SearchSyntaxHelp'
|
|
6
|
+
|
|
7
|
+
let root: Root | undefined
|
|
8
|
+
let host: HTMLDivElement | undefined
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
act(() => root?.unmount())
|
|
11
|
+
host?.remove()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
function render() {
|
|
15
|
+
host = document.createElement('div')
|
|
16
|
+
document.body.appendChild(host)
|
|
17
|
+
root = createRoot(host)
|
|
18
|
+
act(() => root!.render(<SearchSyntaxHelp />))
|
|
19
|
+
return host.querySelector('button')!
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const cardShown = () => document.body.textContent?.includes('Search syntax') ?? false
|
|
23
|
+
|
|
24
|
+
it('toggles on a click with no pointer before it (assistive activation)', () => {
|
|
25
|
+
const button = render()
|
|
26
|
+
act(() => button.click())
|
|
27
|
+
expect(cardShown()).toBe(true)
|
|
28
|
+
expect(button.getAttribute('aria-expanded')).toBe('true')
|
|
29
|
+
act(() => button.click())
|
|
30
|
+
expect(cardShown()).toBe(false)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('keeps a hover-opened card open on the click that follows', () => {
|
|
34
|
+
const button = render()
|
|
35
|
+
act(() => { button.dispatchEvent(new MouseEvent('mouseover', { bubbles: true, relatedTarget: document.body })) })
|
|
36
|
+
expect(cardShown()).toBe(true)
|
|
37
|
+
act(() => button.click())
|
|
38
|
+
expect(cardShown()).toBe(true)
|
|
39
|
+
})
|
|
@@ -2,6 +2,7 @@ import { useState, useRef, useEffect, useCallback } from 'react'
|
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
3
|
import { HelpCircle } from 'lucide-react'
|
|
4
4
|
import { clsx } from 'clsx'
|
|
5
|
+
import { isTouchIntent } from '@skyhook-io/k8s-ui'
|
|
5
6
|
|
|
6
7
|
// The query operators recognized by the search engine (internal/search/parse.go).
|
|
7
8
|
const OPERATORS: { syntax: string; desc: string }[] = [
|
|
@@ -16,6 +17,10 @@ const OPERATORS: { syntax: string; desc: string }[] = [
|
|
|
16
17
|
// reference tooltip, not a second click-to-open panel stacked over the results).
|
|
17
18
|
// Self-contained + portaled to <body> so the header's stacking context can't
|
|
18
19
|
// trap it; a short close grace lets the pointer travel onto the card.
|
|
20
|
+
// A tap also fires mouseenter, and the "?" can sit right under the finger
|
|
21
|
+
// that just opened the search box, so hover ignores a tap's side effects. A
|
|
22
|
+
// click (a tap, or assistive-technology activation) toggles the card, except
|
|
23
|
+
// right after a mouse hover opened it; a tap elsewhere closes it.
|
|
19
24
|
export function SearchSyntaxHelp() {
|
|
20
25
|
const [open, setOpen] = useState(false)
|
|
21
26
|
const btnRef = useRef<HTMLButtonElement>(null)
|
|
@@ -24,11 +29,22 @@ export function SearchSyntaxHelp() {
|
|
|
24
29
|
const [anchor, setAnchor] = useState<{ right: number; top: number } | null>(null)
|
|
25
30
|
|
|
26
31
|
const show = useCallback(() => { clearTimeout(closeTimer.current); setOpen(true) }, [])
|
|
32
|
+
const openedByHover = useRef(false)
|
|
27
33
|
const scheduleHide = useCallback(() => {
|
|
28
34
|
clearTimeout(closeTimer.current)
|
|
29
35
|
closeTimer.current = setTimeout(() => setOpen(false), 120)
|
|
30
36
|
}, [])
|
|
31
37
|
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!open) return
|
|
40
|
+
const onDown = (e: globalThis.PointerEvent) => {
|
|
41
|
+
const t = e.target as Node
|
|
42
|
+
if (!btnRef.current?.contains(t) && !popRef.current?.contains(t)) setOpen(false)
|
|
43
|
+
}
|
|
44
|
+
document.addEventListener('pointerdown', onDown)
|
|
45
|
+
return () => document.removeEventListener('pointerdown', onDown)
|
|
46
|
+
}, [open])
|
|
47
|
+
|
|
32
48
|
useEffect(() => () => clearTimeout(closeTimer.current), [])
|
|
33
49
|
|
|
34
50
|
useEffect(() => {
|
|
@@ -53,8 +69,13 @@ export function SearchSyntaxHelp() {
|
|
|
53
69
|
type="button"
|
|
54
70
|
tabIndex={-1}
|
|
55
71
|
aria-label="Search syntax help"
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
aria-expanded={open}
|
|
73
|
+
onMouseEnter={() => { if (!isTouchIntent()) { openedByHover.current = !open; show() } }}
|
|
74
|
+
onMouseLeave={() => { openedByHover.current = false; scheduleHide() }}
|
|
75
|
+
onClick={() => {
|
|
76
|
+
if (openedByHover.current) { openedByHover.current = false; return }
|
|
77
|
+
setOpen((o) => !o)
|
|
78
|
+
}}
|
|
58
79
|
onMouseDown={(e) => e.preventDefault()}
|
|
59
80
|
className={clsx('shrink-0 rounded p-0.5 cursor-help transition-colors', open ? 'text-theme-text-secondary' : 'text-theme-text-tertiary hover:text-theme-text-secondary')}
|
|
60
81
|
>
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import type { VersionInfo } from '../../api/client'
|
|
7
|
+
|
|
8
|
+
vi.mock('../../api/client', () => ({
|
|
9
|
+
useCapabilities: () => ({ data: { deployment: { mode: 'local' } } }),
|
|
10
|
+
useVersionCheck: () => ({ data: { currentVersion: '1.2.3', updateAvailable: false, installMethod: 'desktop' } }),
|
|
11
|
+
useStartDesktopUpdate: () => ({ mutate: vi.fn(), isPending: false }),
|
|
12
|
+
useDesktopUpdateStatus: () => ({ data: undefined }),
|
|
13
|
+
useApplyDesktopUpdate: () => ({ mutate: vi.fn() }),
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
import { UpdateNotification } from './UpdateNotification'
|
|
17
|
+
import { ToastProvider, showApiNotice } from './Toast'
|
|
18
|
+
import { DURATION_TOAST_EXIT } from '../../utils/animation'
|
|
19
|
+
import { setApiBase } from '../../api/config'
|
|
20
|
+
|
|
21
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
22
|
+
|
|
23
|
+
let root: Root
|
|
24
|
+
let container: HTMLDivElement
|
|
25
|
+
let client: QueryClient
|
|
26
|
+
const current: VersionInfo = { currentVersion: '1.2.3', updateAvailable: false, installMethod: 'desktop' }
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
vi.clearAllMocks()
|
|
30
|
+
vi.useFakeTimers()
|
|
31
|
+
setApiBase('/desktop/api')
|
|
32
|
+
client = new QueryClient()
|
|
33
|
+
client.setQueryData(['version-check', '/desktop/api'], current)
|
|
34
|
+
container = document.createElement('div')
|
|
35
|
+
document.body.appendChild(container)
|
|
36
|
+
root = createRoot(container)
|
|
37
|
+
act(() => root.render(
|
|
38
|
+
<QueryClientProvider client={client}>
|
|
39
|
+
<ToastProvider>
|
|
40
|
+
<UpdateNotification />
|
|
41
|
+
<UpdateNotification placement="settings" />
|
|
42
|
+
</ToastProvider>
|
|
43
|
+
</QueryClientProvider>,
|
|
44
|
+
))
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
act(() => root.unmount())
|
|
49
|
+
container.remove()
|
|
50
|
+
client.clear()
|
|
51
|
+
setApiBase('/api')
|
|
52
|
+
vi.useRealTimers()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('manual Desktop version checks', () => {
|
|
56
|
+
it('acknowledges one check even when Settings is also mounted', () => {
|
|
57
|
+
act(() => { window.dispatchEvent(new Event('radar:check-for-updates')) })
|
|
58
|
+
expect(container.querySelectorAll('[role="status"]')).toHaveLength(1)
|
|
59
|
+
expect(container.textContent).toContain('Checking for updates…')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('reports an up-to-date result once', () => {
|
|
63
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: current })) })
|
|
64
|
+
expect(container.querySelectorAll('[role="status"]')).toHaveLength(1)
|
|
65
|
+
expect(container.textContent).toContain("You're up to date")
|
|
66
|
+
expect(container.textContent).toContain('Radar 1.2.3')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('publishes a fresh available update and clears its dismissal', () => {
|
|
70
|
+
localStorage.setItem('radar-update-dismissed', '1.3.0')
|
|
71
|
+
const info = { ...current, updateAvailable: true, latestVersion: '1.3.0' }
|
|
72
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: info })) })
|
|
73
|
+
expect(client.getQueryData(['version-check', '/desktop/api'])).toEqual(info)
|
|
74
|
+
expect(localStorage.getItem('radar-update-dismissed')).toBeNull()
|
|
75
|
+
expect(container.textContent).toContain('Radar 1.3.0 is available')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('reports failure without replacing known version data', () => {
|
|
79
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: { ...current, error: 'offline' } })) })
|
|
80
|
+
expect(container.querySelector('[role="status"]')?.textContent).toContain('Could not check for updates')
|
|
81
|
+
expect(container.textContent).toContain('offline')
|
|
82
|
+
expect(container.textContent).not.toContain("You're up to date")
|
|
83
|
+
expect(client.getQueryData(['version-check', '/desktop/api'])).toEqual(current)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('does not claim a development build is up to date', () => {
|
|
87
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: { ...current, currentVersion: '1.3.0-37-g8b325b372', buildChannel: 'development', latestVersion: '1.3.0' } })) })
|
|
88
|
+
expect(container.textContent).not.toContain("You're up to date")
|
|
89
|
+
expect(container.textContent).toContain('Latest Radar release: 1.3.0')
|
|
90
|
+
expect(container.textContent).toContain('You are running a development build.')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('discards an automatic response that races with the manual result', async () => {
|
|
94
|
+
let resolveAutomatic!: (value: VersionInfo) => void
|
|
95
|
+
const pending = client.fetchQuery({
|
|
96
|
+
queryKey: ['version-check', '/desktop/api'],
|
|
97
|
+
queryFn: () => new Promise<VersionInfo>(resolve => { resolveAutomatic = resolve }),
|
|
98
|
+
staleTime: 0,
|
|
99
|
+
}).catch(() => undefined)
|
|
100
|
+
const info = { ...current, updateAvailable: true, latestVersion: '1.3.0' }
|
|
101
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: info })) })
|
|
102
|
+
resolveAutomatic(current)
|
|
103
|
+
await pending
|
|
104
|
+
expect(client.getQueryData(['version-check', '/desktop/api'])).toEqual(info)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('lets the initial automatic fetch finish when a manual check fails', async () => {
|
|
108
|
+
client.removeQueries({ queryKey: ['version-check', '/desktop/api'], exact: true })
|
|
109
|
+
let resolveAutomatic!: (value: VersionInfo) => void
|
|
110
|
+
const pending = client.fetchQuery({
|
|
111
|
+
queryKey: ['version-check', '/desktop/api'],
|
|
112
|
+
queryFn: () => new Promise<VersionInfo>(resolve => { resolveAutomatic = resolve }),
|
|
113
|
+
})
|
|
114
|
+
act(() => {
|
|
115
|
+
window.dispatchEvent(new Event('radar:check-for-updates'))
|
|
116
|
+
window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: { ...current, error: 'offline' } }))
|
|
117
|
+
})
|
|
118
|
+
resolveAutomatic(current)
|
|
119
|
+
await pending
|
|
120
|
+
expect(client.getQueryData(['version-check', '/desktop/api'])).toEqual(current)
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
describe('manual check toast lifecycle', () => {
|
|
126
|
+
it('updates the same toast element after a slow check and starts the result timer then', () => {
|
|
127
|
+
act(() => { window.dispatchEvent(new Event('radar:check-for-updates')) })
|
|
128
|
+
const toast = container.querySelector('[role="status"]')
|
|
129
|
+
act(() => { vi.advanceTimersByTime(9000) })
|
|
130
|
+
expect(container.querySelector('[role="status"]')).toBe(toast)
|
|
131
|
+
expect(toast?.textContent).toContain('Checking for updates…')
|
|
132
|
+
|
|
133
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: current })) })
|
|
134
|
+
expect(container.querySelector('[role="status"]')).toBe(toast)
|
|
135
|
+
expect(toast?.textContent).toContain("You're up to date")
|
|
136
|
+
expect(container.textContent).not.toContain('Checking for updates…')
|
|
137
|
+
expect(container.querySelectorAll('[role="status"]')).toHaveLength(1)
|
|
138
|
+
act(() => { vi.advanceTimersByTime(6999) })
|
|
139
|
+
expect(container.querySelector('[role="status"]')).toBe(toast)
|
|
140
|
+
act(() => { vi.advanceTimersByTime(1 + DURATION_TOAST_EXIT) })
|
|
141
|
+
expect(container.querySelector('[role="status"]')).toBeNull()
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('replaces progress with an error in the same toast', () => {
|
|
145
|
+
act(() => { window.dispatchEvent(new Event('radar:check-for-updates')) })
|
|
146
|
+
const toast = container.querySelector('[role="status"]')
|
|
147
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: { ...current, error: 'offline' } })) })
|
|
148
|
+
expect(container.querySelector('[role="status"]')).toBe(toast)
|
|
149
|
+
expect(container.textContent).not.toContain('Checking for updates…')
|
|
150
|
+
expect(container.querySelectorAll('[role="status"], [role="alert"]')).toHaveLength(1)
|
|
151
|
+
act(() => { vi.advanceTimersByTime(9999) })
|
|
152
|
+
expect(container.querySelector('[role="status"]')).toBe(toast)
|
|
153
|
+
act(() => { vi.advanceTimersByTime(1 + DURATION_TOAST_EXIT) })
|
|
154
|
+
expect(container.querySelector('[role="status"]')).toBeNull()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('does not let a previous result timer dismiss the next check', () => {
|
|
158
|
+
act(() => { window.dispatchEvent(new CustomEvent('radar:update-check-result', { detail: current })) })
|
|
159
|
+
act(() => { vi.advanceTimersByTime(7100) })
|
|
160
|
+
act(() => { window.dispatchEvent(new Event('radar:check-for-updates')) })
|
|
161
|
+
const toast = container.querySelector('[role="status"]')
|
|
162
|
+
act(() => { vi.advanceTimersByTime(9000) })
|
|
163
|
+
expect(container.querySelector('[role="status"]')).toBe(toast)
|
|
164
|
+
expect(toast?.textContent).toContain('Checking for updates…')
|
|
165
|
+
expect(toast?.classList.contains('animate-out')).toBe(false)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('keeps ordinary toasts independent and auto-dismisses them', () => {
|
|
169
|
+
act(() => {
|
|
170
|
+
showApiNotice('First notice', undefined, 'info')
|
|
171
|
+
showApiNotice('Second notice', undefined, 'info')
|
|
172
|
+
})
|
|
173
|
+
expect(container.querySelectorAll('[role="status"]')).toHaveLength(2)
|
|
174
|
+
act(() => { vi.advanceTimersByTime(7000 + DURATION_TOAST_EXIT) })
|
|
175
|
+
expect(container.querySelectorAll('[role="status"]')).toHaveLength(0)
|
|
176
|
+
})
|
|
177
|
+
})
|
|
@@ -13,6 +13,8 @@ vi.mock('../../api/client', () => ({
|
|
|
13
13
|
updateAvailable: true,
|
|
14
14
|
installMethod: 'direct',
|
|
15
15
|
releaseUrl: 'https://github.com/skyhook-io/radar/releases/tag/v1.3.0',
|
|
16
|
+
// Off, so the Product Hunt launch day doesn't take the corner whatever today is.
|
|
17
|
+
productHuntLaunch: { enabled: false, url: '', start: '0001-01-01T00:00:00Z', end: '0001-01-01T00:00:00Z' },
|
|
16
18
|
},
|
|
17
19
|
}),
|
|
18
20
|
useStartDesktopUpdate: () => ({ mutate: vi.fn(), isPending: false }),
|
|
@@ -21,12 +23,13 @@ vi.mock('../../api/client', () => ({
|
|
|
21
23
|
}))
|
|
22
24
|
|
|
23
25
|
import { UpdateNotification } from './UpdateNotification'
|
|
26
|
+
import { ToastProvider } from './Toast'
|
|
24
27
|
|
|
25
28
|
function renderNotification() {
|
|
26
29
|
const client = new QueryClient()
|
|
27
30
|
return renderToString(
|
|
28
31
|
<QueryClientProvider client={client}>
|
|
29
|
-
<UpdateNotification
|
|
32
|
+
<ToastProvider><UpdateNotification /></ToastProvider>
|
|
30
33
|
</QueryClientProvider>,
|
|
31
34
|
)
|
|
32
35
|
}
|
|
@@ -9,11 +9,15 @@ import {
|
|
|
9
9
|
useDesktopUpdateStatus,
|
|
10
10
|
useApplyDesktopUpdate,
|
|
11
11
|
} from '../../api/client'
|
|
12
|
-
import type { DesktopUpdateState } from '../../api/client'
|
|
12
|
+
import type { DesktopUpdateState, VersionInfo } from '../../api/client'
|
|
13
|
+
import { getApiBase } from '../../api/config'
|
|
14
|
+
import { useToast } from './Toast'
|
|
13
15
|
import { WithTooltip } from './Tooltip'
|
|
14
16
|
import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../utils/animation'
|
|
15
17
|
import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
|
|
16
18
|
import { IN_CLUSTER_UPGRADE_URL } from '../../utils/version'
|
|
19
|
+
import { LAUNCH_NOTICE_DISMISSED_EVENT, launchNoticeHoldsCorner, launchPhase, resolveLaunch } from '../product-hunt/launchWindow'
|
|
20
|
+
import { USAGE_PROMPT_VISIBILITY_EVENT, usagePromptOnScreen } from '../usage-data/UsageDataPrompt'
|
|
17
21
|
|
|
18
22
|
const DISMISSED_KEY = 'radar-update-dismissed'
|
|
19
23
|
|
|
@@ -35,6 +39,7 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
|
|
|
35
39
|
const triggerRef = useRef<HTMLButtonElement>(null)
|
|
36
40
|
const panelId = useId()
|
|
37
41
|
const queryClient = useQueryClient()
|
|
42
|
+
const { showToast } = useToast()
|
|
38
43
|
const { data: capabilities } = useCapabilities()
|
|
39
44
|
const deploymentMode = capabilities ? (capabilities.deployment?.mode ?? 'local') : undefined
|
|
40
45
|
const { data: versionInfo } = useVersionCheck()
|
|
@@ -58,17 +63,55 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
|
|
|
58
63
|
return () => document.removeEventListener('pointerdown', closeOutside)
|
|
59
64
|
}, [expanded])
|
|
60
65
|
|
|
61
|
-
// Listen for "Check for Updates" menu item in desktop app.
|
|
62
66
|
useEffect(() => {
|
|
67
|
+
if (inSettings) return
|
|
68
|
+
const id = 'radar-manual-update-check'
|
|
63
69
|
const handler = () => {
|
|
70
|
+
showToast('Checking for updates…', { id, type: 'info', duration: 0 })
|
|
71
|
+
}
|
|
72
|
+
const resultHandler = (event: Event) => {
|
|
73
|
+
const info = (event as CustomEvent<VersionInfo>).detail
|
|
74
|
+
if (info.error) {
|
|
75
|
+
showToast('Could not check for updates', { id, type: 'error', detail: info.error })
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
void queryClient.cancelQueries({ queryKey: ['version-check', getApiBase()], exact: true })
|
|
64
79
|
setDismissed(false)
|
|
65
80
|
try { localStorage.removeItem(DISMISSED_KEY) } catch { /* ignore */ }
|
|
66
|
-
queryClient.
|
|
81
|
+
queryClient.setQueryData(['version-check', getApiBase()], info)
|
|
82
|
+
if (info.updateAvailable) {
|
|
83
|
+
showToast(`Radar ${info.latestVersion} is available`, { id, type: 'info' })
|
|
84
|
+
} else if (info.buildChannel === 'development') {
|
|
85
|
+
showToast(`Latest Radar release: ${info.latestVersion}`, { id, type: 'info', detail: 'You are running a development build.' })
|
|
86
|
+
} else {
|
|
87
|
+
showToast("You're up to date", { id, type: 'success', detail: `Radar ${info.currentVersion}` })
|
|
88
|
+
}
|
|
67
89
|
}
|
|
68
90
|
|
|
69
91
|
window.addEventListener('radar:check-for-updates', handler)
|
|
70
|
-
|
|
71
|
-
|
|
92
|
+
window.addEventListener('radar:update-check-result', resultHandler)
|
|
93
|
+
return () => {
|
|
94
|
+
window.removeEventListener('radar:check-for-updates', handler)
|
|
95
|
+
window.removeEventListener('radar:update-check-result', resultHandler)
|
|
96
|
+
}
|
|
97
|
+
}, [queryClient, inSettings, showToast])
|
|
98
|
+
|
|
99
|
+
// Runs until the launch window is over, so a notice already on screen when
|
|
100
|
+
// the launch day starts steps aside too.
|
|
101
|
+
const launch = resolveLaunch(versionInfo?.productHuntLaunch)
|
|
102
|
+
const [launchNow, setLaunchNow] = useState(() => Date.now())
|
|
103
|
+
const launchWindowOpen = launchPhase(launch, launchNow) !== null
|
|
104
|
+
const launchHoldsCorner = launchNoticeHoldsCorner(launch, launchNow)
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (inSettings || !launchWindowOpen) return
|
|
107
|
+
const recheck = () => setLaunchNow(Date.now())
|
|
108
|
+
window.addEventListener(LAUNCH_NOTICE_DISMISSED_EVENT, recheck)
|
|
109
|
+
const poll = window.setInterval(recheck, 60_000)
|
|
110
|
+
return () => {
|
|
111
|
+
window.removeEventListener(LAUNCH_NOTICE_DISMISSED_EVENT, recheck)
|
|
112
|
+
window.clearInterval(poll)
|
|
113
|
+
}
|
|
114
|
+
}, [inSettings, launchWindowOpen])
|
|
72
115
|
|
|
73
116
|
// Log version check errors for debugging
|
|
74
117
|
useEffect(() => {
|
|
@@ -77,13 +120,21 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
|
|
|
77
120
|
}
|
|
78
121
|
}, [versionInfo?.error])
|
|
79
122
|
|
|
80
|
-
//
|
|
123
|
+
// Dismissal is per release: a newer one found while the page is open shows again.
|
|
81
124
|
useEffect(() => {
|
|
82
|
-
if (versionInfo?.latestVersion
|
|
83
|
-
setDismissed(true)
|
|
84
|
-
}
|
|
125
|
+
if (versionInfo?.latestVersion) setDismissed(isUpdateDismissed(versionInfo.latestVersion))
|
|
85
126
|
}, [versionInfo?.latestVersion])
|
|
86
127
|
|
|
128
|
+
// The first-run usage card shares the corner; an update found while it is
|
|
129
|
+
// open waits for it.
|
|
130
|
+
const [usagePromptShowing, setUsagePromptShowing] = useState(usagePromptOnScreen)
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (inSettings) return
|
|
133
|
+
const onUsagePrompt = () => setUsagePromptShowing(usagePromptOnScreen())
|
|
134
|
+
window.addEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
|
|
135
|
+
return () => window.removeEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
|
|
136
|
+
}, [inSettings])
|
|
137
|
+
|
|
87
138
|
// Stop polling when update reaches a terminal state
|
|
88
139
|
useEffect(() => {
|
|
89
140
|
if (updateStatus?.state === 'error' || updateStatus?.state === 'idle') {
|
|
@@ -125,7 +176,7 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
|
|
|
125
176
|
// Shared in-cluster viewers get a persistent Home notice instead of a
|
|
126
177
|
// floating action prompt they may not be able to act on.
|
|
127
178
|
const available = !!versionInfo?.updateAvailable && deploymentMode !== undefined && deploymentMode !== 'cloud'
|
|
128
|
-
const show = available && deploymentMode !== 'in-cluster' && (inSettings ? expanded : !dismissed)
|
|
179
|
+
const show = available && deploymentMode !== 'in-cluster' && (inSettings ? expanded : !dismissed && !launchHoldsCorner && !usagePromptShowing)
|
|
129
180
|
// Presence outlives `show` by the menu exit so a dismiss fades the chip out
|
|
130
181
|
// instead of snapping it away; the enter runs the same transition in reverse.
|
|
131
182
|
const { shouldRender, isOpen } = useAnimatedUnmount(show, overlayExitMs('menu'))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { contentMatchLabel,
|
|
2
|
+
import { contentMatchLabel, partialSearchNotices } from './omnibar-match'
|
|
3
3
|
|
|
4
4
|
const site = (s: string) => ({ token: 't', site: s, score: 12 })
|
|
5
5
|
|
|
@@ -18,13 +18,20 @@ describe('contentMatchLabel', () => {
|
|
|
18
18
|
})
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
describe('
|
|
22
|
-
it('
|
|
23
|
-
expect(
|
|
24
|
-
|
|
21
|
+
describe('partialSearchNotices', () => {
|
|
22
|
+
it('says why each part of the search is missing', () => {
|
|
23
|
+
expect(partialSearchNotices({ access_incomplete: true })).toEqual([
|
|
24
|
+
"Couldn't confirm your access to scan reports in some namespaces, so they were left out. Search again to check more.",
|
|
25
|
+
])
|
|
26
|
+
expect(partialSearchNotices({ incomplete_findings: 'time_limit' })).toEqual([
|
|
27
|
+
"Search ran out of time before checking every scan report's findings. Narrow with ns: to cover the rest.",
|
|
28
|
+
])
|
|
25
29
|
})
|
|
26
|
-
it('
|
|
27
|
-
expect(
|
|
28
|
-
|
|
30
|
+
it('shows both causes when both happened', () => {
|
|
31
|
+
expect(partialSearchNotices({ access_incomplete: true, incomplete_findings: 'time_limit' })).toHaveLength(2)
|
|
32
|
+
})
|
|
33
|
+
it('is empty for a whole result or an older Radar', () => {
|
|
34
|
+
expect(partialSearchNotices({})).toEqual([])
|
|
35
|
+
expect(partialSearchNotices(undefined)).toEqual([])
|
|
29
36
|
})
|
|
30
37
|
})
|
|
@@ -8,11 +8,16 @@ export function contentMatchLabel(matched: SearchMatchedField[] | undefined): st
|
|
|
8
8
|
return matched.every((m) => m.site.startsWith('content:report.')) ? 'in findings' : 'in spec'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
// missing CVE doesn't read as "not affected".
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
// partialSearchNotices explain a result the server says is incomplete, so a
|
|
12
|
+
// missing CVE doesn't read as "not affected". One line per cause; empty when
|
|
13
|
+
// the search was whole.
|
|
14
|
+
export function partialSearchNotices(data: { incomplete_findings?: string; access_incomplete?: boolean } | undefined): string[] {
|
|
15
|
+
const out: string[] = []
|
|
16
|
+
if (data?.access_incomplete) {
|
|
17
|
+
out.push("Couldn't confirm your access to scan reports in some namespaces, so they were left out. Search again to check more.")
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
if (data?.incomplete_findings) {
|
|
20
|
+
out.push("Search ran out of time before checking every scan report's findings. Narrow with ns: to cover the rest.")
|
|
21
|
+
}
|
|
22
|
+
return out
|
|
18
23
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SearchCoverage } from '@skyhook-io/k8s-ui/types/read-coverage'
|
|
2
|
+
import type { SearchCoverageEntry } from './searchCoverageNote'
|
|
3
|
+
|
|
4
|
+
/** The wire coverage that flattens back to entries, for tests: each gap lists
|
|
5
|
+
* one axis and gives the other as an extent, as Radar sends it. */
|
|
6
|
+
export function coverageOf(entries: SearchCoverageEntry[]): SearchCoverage {
|
|
7
|
+
return {
|
|
8
|
+
status: entries.length ? 'partial' : 'complete',
|
|
9
|
+
gaps: entries.map((e) => {
|
|
10
|
+
if (e.kind !== '*') return { code: e.reason, kinds: { count: 1, names: [{ kind: e.kind, group: e.group || undefined }] }, namespaces: { extent: 'all' } }
|
|
11
|
+
if (e.namespaces) return { code: e.reason, kinds: { extent: 'all' }, namespaces: { count: e.namespaces.length, names: e.namespaces } }
|
|
12
|
+
if (e.count) return { code: e.reason, kinds: { count: e.count }, namespaces: { extent: 'all' } }
|
|
13
|
+
return { code: e.reason, kinds: { extent: 'unknown' }, namespaces: { extent: 'all' } }
|
|
14
|
+
}),
|
|
15
|
+
}
|
|
16
|
+
}
|