@skyhook-io/radar-app 1.18.1 → 1.19.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 +4 -4
- package/src/App.tsx +23 -9
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +136 -37
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +93 -3
- package/src/api/radarFeatures.ts +1 -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/actions/useCNPGWriteGuard.tsx +1 -0
- package/src/components/diagnose/AIMarkdown.tsx +1 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.tsx +1 -1
- package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
- package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
- package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
- package/src/components/diagnose/AnalysisStory.tsx +17 -4
- package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +99 -8
- package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
- package/src/components/diagnose/DiagnoseContext.tsx +205 -9
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +98 -21
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/Home.test.tsx +182 -5
- package/src/components/diagnose/Home.tsx +168 -36
- package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
- package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +119 -2
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +11 -6
- package/src/components/diagnose/InvestigationView.tsx +203 -42
- package/src/components/diagnose/LocalDiagnoseAction.tsx +23 -16
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +487 -0
- package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
- package/src/components/diagnose/QuestionFocus.tsx +123 -0
- package/src/components/diagnose/ResourcePicker.tsx +206 -0
- package/src/components/diagnose/StoryExcerpt.tsx +12 -3
- package/src/components/diagnose/assessmentCopy.ts +16 -0
- package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +42 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +29 -2
- 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/metrics.test.tsx +111 -0
- package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
- package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +3 -1
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/index.ts +1 -1
- package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +7 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +57 -3
- package/src/components/diagnose/investigationEvidence/types.ts +2 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -0
- package/src/components/diagnose/parts.test.tsx +20 -0
- package/src/components/diagnose/questionSuggestions.test.ts +111 -0
- package/src/components/diagnose/questionSuggestions.ts +150 -0
- package/src/components/diagnose/storyParts.test.tsx +66 -0
- package/src/components/diagnose/target.test.ts +143 -2
- package/src/components/diagnose/target.ts +109 -7
- package/src/components/diagnose/testdata/story-runs.json +474 -0
- package/src/components/diagnose/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/helm/ChartBrowser.tsx +4 -4
- 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/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +40 -59
- package/src/components/home/HomeAgentBlock.test.tsx +113 -0
- package/src/components/home/HomeAgentBlock.tsx +94 -0
- package/src/components/home/HomeView.tsx +5 -6
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- package/src/components/home/mcpToolCatalog.ts +29 -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/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +1 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
- package/src/components/ui/Omnibar.tsx +47 -3
- package/src/components/ui/RadarOmnibar.test.tsx +19 -0
- package/src/components/ui/RadarOmnibar.tsx +12 -0
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.test.tsx +2 -0
- package/src/components/ui/UpdateNotification.tsx +32 -5
- package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +3 -3
- package/src/components/whats-new/releaseNotes.ts +60 -1
- package/src/components/workload/WorkloadView.tsx +10 -4
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -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/index.css +85 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
|
|
6
|
+
const state = vi.hoisted(() => ({
|
|
7
|
+
launch: undefined as undefined | { enabled: boolean; url: string; start: string; end: string },
|
|
8
|
+
mode: 'local',
|
|
9
|
+
refetch: vi.fn(),
|
|
10
|
+
usageOnScreen: false,
|
|
11
|
+
}))
|
|
12
|
+
vi.mock('../../api/client', () => ({
|
|
13
|
+
useCapabilities: () => ({ data: { deployment: { mode: state.mode } } }),
|
|
14
|
+
useVersionCheck: () => ({ data: { currentVersion: '1.18.3', updateAvailable: false, installMethod: 'direct', productHuntLaunch: state.launch }, isPending: false, refetch: state.refetch }),
|
|
15
|
+
}))
|
|
16
|
+
vi.mock('../usage-data/UsageDataPrompt', async (importOriginal) => ({
|
|
17
|
+
...(await importOriginal<typeof import('../usage-data/UsageDataPrompt')>()),
|
|
18
|
+
usagePromptOnScreen: () => state.usageOnScreen,
|
|
19
|
+
}))
|
|
20
|
+
vi.mock('../../api/usage-data', () => ({ useSetUsageData: () => ({ mutate: vi.fn(), isPending: false }), useMarkUsagePromptShown: () => vi.fn() }))
|
|
21
|
+
|
|
22
|
+
import { ProductHuntNotice } from './ProductHuntNotice'
|
|
23
|
+
|
|
24
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
25
|
+
let root: Root
|
|
26
|
+
let element: HTMLDivElement
|
|
27
|
+
|
|
28
|
+
const ON = { enabled: true, url: 'https://www.producthunt.com/products/radar-7?launch=radar-101', start: '2026-10-29T07:00:00Z', end: '2026-10-30T07:00:00Z' }
|
|
29
|
+
const OFF = { enabled: false, url: '', start: '0001-01-01T00:00:00Z', end: '0001-01-01T00:00:00Z' }
|
|
30
|
+
|
|
31
|
+
function render() {
|
|
32
|
+
act(() => root.render(<ProductHuntNotice usageData={undefined} usageDataPending={false} />))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
vi.useFakeTimers()
|
|
37
|
+
vi.setSystemTime(new Date('2026-10-29T17:00:00Z'))
|
|
38
|
+
localStorage.clear()
|
|
39
|
+
state.launch = ON
|
|
40
|
+
state.mode = 'local'
|
|
41
|
+
state.refetch = vi.fn()
|
|
42
|
+
state.usageOnScreen = false
|
|
43
|
+
element = document.createElement('div')
|
|
44
|
+
document.body.appendChild(element)
|
|
45
|
+
root = createRoot(element)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
act(() => root.unmount())
|
|
50
|
+
element.remove()
|
|
51
|
+
vi.useRealTimers()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('ProductHuntNotice', () => {
|
|
55
|
+
it('shows the launch-day card after the delay', () => {
|
|
56
|
+
render()
|
|
57
|
+
expect(element.textContent).toBe('')
|
|
58
|
+
act(() => { vi.advanceTimersByTime(10_000) })
|
|
59
|
+
expect(element.textContent).toContain('Live on Product Hunt today')
|
|
60
|
+
expect(element.querySelector('a')?.href).toContain('utm_source=radar-oss')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('fades out without breaking when the launch is called off on screen', () => {
|
|
64
|
+
render()
|
|
65
|
+
act(() => { vi.advanceTimersByTime(10_000) })
|
|
66
|
+
state.launch = OFF
|
|
67
|
+
render()
|
|
68
|
+
expect(element.textContent).toContain('Live on Product Hunt today')
|
|
69
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
70
|
+
expect(element.textContent).toBe('')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('keeps the launch-day wording while it fades at the end of the day', () => {
|
|
74
|
+
render()
|
|
75
|
+
act(() => { vi.advanceTimersByTime(10_000) })
|
|
76
|
+
vi.setSystemTime(new Date('2026-10-30T07:00:30Z'))
|
|
77
|
+
act(() => { vi.advanceTimersByTime(60_000) })
|
|
78
|
+
expect(element.textContent).not.toContain('Launching on Product Hunt')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('shows in-cluster only on the day', () => {
|
|
82
|
+
state.mode = 'in-cluster'
|
|
83
|
+
vi.setSystemTime(new Date('2026-10-28T17:00:00Z'))
|
|
84
|
+
render()
|
|
85
|
+
act(() => { vi.advanceTimersByTime(10_000) })
|
|
86
|
+
expect(element.textContent).toBe('')
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('re-checks the launch hourly while a page stays open', () => {
|
|
90
|
+
render()
|
|
91
|
+
expect(state.refetch).not.toHaveBeenCalled()
|
|
92
|
+
act(() => { vi.advanceTimersByTime(60 * 60_000) })
|
|
93
|
+
expect(state.refetch).toHaveBeenCalledTimes(1)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('stays off the corner when re-enabled while the usage prompt is open', () => {
|
|
97
|
+
state.launch = OFF
|
|
98
|
+
render()
|
|
99
|
+
state.usageOnScreen = true
|
|
100
|
+
act(() => { window.dispatchEvent(new Event('radar:usage-prompt-visibility')) })
|
|
101
|
+
state.launch = ON
|
|
102
|
+
render()
|
|
103
|
+
act(() => { vi.advanceTimersByTime(10_000) })
|
|
104
|
+
expect(element.textContent).toBe('')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('comes back at once when reopened from the sidebar after being closed', () => {
|
|
108
|
+
render()
|
|
109
|
+
act(() => { vi.advanceTimersByTime(10_000) })
|
|
110
|
+
const close = element.querySelector('button[aria-label="Close"]') as HTMLButtonElement
|
|
111
|
+
act(() => { close.click() })
|
|
112
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
113
|
+
expect(element.textContent).toBe('')
|
|
114
|
+
act(() => { window.dispatchEvent(new Event('radar:product-hunt-notice-reopen')) })
|
|
115
|
+
expect(element.textContent).toContain('Live on Product Hunt today')
|
|
116
|
+
act(() => { (element.querySelector('button[aria-label="Close"]') as HTMLButtonElement).click() })
|
|
117
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
118
|
+
expect(element.textContent).toBe('')
|
|
119
|
+
})
|
|
120
|
+
})
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
vi.mock('../../api/client', () => ({ useCapabilities: () => ({ data: undefined }), useVersionCheck: () => ({ data: undefined }) }))
|
|
4
|
+
vi.mock('../../api/usage-data', () => ({ useSetUsageData: () => ({ mutate: vi.fn(), isPending: false }), useMarkUsagePromptShown: () => vi.fn() }))
|
|
5
|
+
|
|
6
|
+
import { launchLink, shouldShowLaunchNotice } from './ProductHuntNotice'
|
|
7
|
+
import { FALLBACK_LAUNCH, isPhaseDismissed, launchDayLabel, launchNoticeHoldsCorner, launchPhase, markPhaseDismissed, resolveLaunch } from './launchWindow'
|
|
8
|
+
|
|
9
|
+
const launch = FALLBACK_LAUNCH
|
|
10
|
+
|
|
11
|
+
describe('launchPhase', () => {
|
|
12
|
+
it('is upcoming before Product Hunt day starts in Pacific time', () => {
|
|
13
|
+
expect(launchPhase(launch, Date.parse('2026-10-28T12:00:00Z'))).toBe('upcoming')
|
|
14
|
+
expect(launchPhase(launch, Date.parse('2026-10-28T23:59:59-07:00'))).toBe('upcoming')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('is live for the whole Pacific day of Oct 29', () => {
|
|
18
|
+
expect(launchPhase(launch, Date.parse('2026-10-29T00:00:00-07:00'))).toBe('live')
|
|
19
|
+
expect(launchPhase(launch, Date.parse('2026-10-29T09:01:00+02:00'))).toBe('live')
|
|
20
|
+
expect(launchPhase(launch, Date.parse('2026-10-29T23:59:59-07:00'))).toBe('live')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('is over once the Pacific day ends', () => {
|
|
24
|
+
expect(launchPhase(launch, Date.parse('2026-10-30T00:00:00-07:00'))).toBe(null)
|
|
25
|
+
expect(launchPhase(launch, Date.parse('2026-11-15T00:00:00Z'))).toBe(null)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('resolveLaunch', () => {
|
|
30
|
+
it('uses the built-in launch only when the version check says nothing', () => {
|
|
31
|
+
expect(resolveLaunch(undefined)).toBe(FALLBACK_LAUNCH)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('follows a moved or cancelled launch from the version check', () => {
|
|
35
|
+
const moved = resolveLaunch({ enabled: true, url: launch.url, start: '2026-11-05T08:00:00Z', end: '2026-11-06T08:00:00Z' })
|
|
36
|
+
expect(launchPhase(moved, Date.parse('2026-10-29T12:00:00Z'))).toBe('upcoming')
|
|
37
|
+
expect(launchPhase(moved, Date.parse('2026-11-05T12:00:00Z'))).toBe('live')
|
|
38
|
+
expect(launchDayLabel(moved)).toBe('Nov 5')
|
|
39
|
+
|
|
40
|
+
const cancelled = resolveLaunch({ enabled: false, url: '', start: '0001-01-01T00:00:00Z', end: '0001-01-01T00:00:00Z' })
|
|
41
|
+
expect(launchPhase(cancelled, Date.parse('2026-10-28T12:00:00Z'))).toBe(null)
|
|
42
|
+
expect(launchPhase(cancelled, Date.parse('2026-10-29T12:00:00Z'))).toBe(null)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('labels the day on Product Hunt time and tags the link', () => {
|
|
46
|
+
expect(launchDayLabel(launch)).toBe('Oct 29')
|
|
47
|
+
const link = new URL(launchLink(launch))
|
|
48
|
+
expect(link.searchParams.get('launch')).toBe('radar-101')
|
|
49
|
+
expect(link.searchParams.get('utm_source')).toBe('radar-oss')
|
|
50
|
+
expect(link.searchParams.get('utm_campaign')).toBe('ph-launch-2026-10')
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('shouldShowLaunchNotice', () => {
|
|
55
|
+
const base = { phase: 'live' as const, deploymentMode: 'local', dismissed: false, ready: true, cornerBusy: false }
|
|
56
|
+
|
|
57
|
+
it('shows on a local install with the corner free', () => {
|
|
58
|
+
expect(shouldShowLaunchNotice(base)).toBe(true)
|
|
59
|
+
expect(shouldShowLaunchNotice({ ...base, phase: 'upcoming' })).toBe(true)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('shows in-cluster on launch day only, and never in Cloud or before capabilities load', () => {
|
|
63
|
+
expect(shouldShowLaunchNotice({ ...base, deploymentMode: 'in-cluster' })).toBe(true)
|
|
64
|
+
expect(shouldShowLaunchNotice({ ...base, deploymentMode: 'in-cluster', phase: 'upcoming' })).toBe(false)
|
|
65
|
+
expect(shouldShowLaunchNotice({ ...base, deploymentMode: 'cloud' })).toBe(false)
|
|
66
|
+
expect(shouldShowLaunchNotice({ ...base, deploymentMode: undefined })).toBe(false)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('stays away once dismissed, outside the window, before the delay, or while another notice holds the corner', () => {
|
|
70
|
+
expect(shouldShowLaunchNotice({ ...base, dismissed: true })).toBe(false)
|
|
71
|
+
expect(shouldShowLaunchNotice({ ...base, phase: null })).toBe(false)
|
|
72
|
+
expect(shouldShowLaunchNotice({ ...base, ready: false })).toBe(false)
|
|
73
|
+
expect(shouldShowLaunchNotice({ ...base, cornerBusy: true })).toBe(false)
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
describe('isPhaseDismissed', () => {
|
|
78
|
+
const store = new Map<string, string>()
|
|
79
|
+
vi.stubGlobal('localStorage', {
|
|
80
|
+
getItem: (k: string) => store.get(k) ?? null,
|
|
81
|
+
setItem: (k: string, v: string) => void store.set(k, v),
|
|
82
|
+
})
|
|
83
|
+
afterEach(() => store.clear())
|
|
84
|
+
|
|
85
|
+
it('keeps the launch-day card for someone who closed the one before it', () => {
|
|
86
|
+
store.set('radar-product-hunt-dismissed-2026-10-29-upcoming', '1')
|
|
87
|
+
expect(isPhaseDismissed(launch, 'upcoming')).toBe(true)
|
|
88
|
+
expect(isPhaseDismissed(launch, 'live')).toBe(false)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('announces a moved launch again', () => {
|
|
92
|
+
store.set('radar-product-hunt-dismissed-2026-10-29-upcoming', '1')
|
|
93
|
+
const moved = resolveLaunch({ enabled: true, url: launch.url, start: '2026-11-05T08:00:00Z', end: '2026-11-06T08:00:00Z' })
|
|
94
|
+
expect(isPhaseDismissed(moved, 'upcoming')).toBe(false)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('holds the corner on launch day until the launch-day card is dismissed', () => {
|
|
98
|
+
const before = Date.parse('2026-10-28T12:00:00Z')
|
|
99
|
+
const during = Date.parse('2026-10-29T10:00:00-07:00')
|
|
100
|
+
const after = Date.parse('2026-10-30T01:00:00-07:00')
|
|
101
|
+
expect(launchNoticeHoldsCorner(launch, before)).toBe(false)
|
|
102
|
+
expect(launchNoticeHoldsCorner(launch, during)).toBe(true)
|
|
103
|
+
expect(launchNoticeHoldsCorner(launch, after)).toBe(false)
|
|
104
|
+
store.set('radar-product-hunt-dismissed-2026-10-29-live', '1')
|
|
105
|
+
expect(launchNoticeHoldsCorner(launch, during)).toBe(false)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('frees the corner for this page when localStorage refuses the dismissal', () => {
|
|
109
|
+
const later = resolveLaunch({ enabled: true, url: launch.url, start: '2026-11-12T08:00:00Z', end: '2026-11-13T08:00:00Z' })
|
|
110
|
+
const during = Date.parse('2026-11-12T10:00:00-08:00')
|
|
111
|
+
vi.stubGlobal('localStorage', {
|
|
112
|
+
getItem: () => { throw new Error('denied') },
|
|
113
|
+
setItem: () => { throw new Error('denied') },
|
|
114
|
+
})
|
|
115
|
+
vi.stubGlobal('window', { dispatchEvent: vi.fn() })
|
|
116
|
+
expect(launchNoticeHoldsCorner(later, during)).toBe(true)
|
|
117
|
+
markPhaseDismissed(later, 'live')
|
|
118
|
+
expect(launchNoticeHoldsCorner(later, during)).toBe(false)
|
|
119
|
+
expect(isPhaseDismissed(later, 'upcoming')).toBe(false)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { useEffect, useReducer, useState } from 'react'
|
|
2
|
+
import type { CSSProperties } from 'react'
|
|
3
|
+
import { clsx } from 'clsx'
|
|
4
|
+
import { Heart, Rocket, X } from 'lucide-react'
|
|
5
|
+
import { useCapabilities, useVersionCheck } from '../../api/client'
|
|
6
|
+
import type { UsageDataStatus } from '../../api/usage-data'
|
|
7
|
+
import { USAGE_PROMPT_VISIBILITY_EVENT, updateNoticeVisible, usagePromptOnScreen } from '../usage-data/UsageDataPrompt'
|
|
8
|
+
import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
|
|
9
|
+
import { TRANSITION_MENU } from '../../utils/animation'
|
|
10
|
+
import { LAUNCH_NOTICE_REOPEN_EVENT, LAUNCH_RAIL_ITEM_ID, isPhaseDismissed, launchDayLabel, launchPhase, launchShownIn, markPhaseDismissed, resolveLaunch, type LaunchPhase, type ProductHuntLaunch } from './launchWindow'
|
|
11
|
+
|
|
12
|
+
// The same tag for every install: it says the click came from inside Radar,
|
|
13
|
+
// nothing about who clicked.
|
|
14
|
+
const UTM = { utm_source: 'radar-oss', utm_medium: 'app', utm_campaign: 'ph-launch-2026-10' }
|
|
15
|
+
const FEATURE_URL = `https://radarhq.io/product/ai-investigations?${new URLSearchParams(UTM)}`
|
|
16
|
+
const SHOW_DELAY_MS = 10_000
|
|
17
|
+
const LAUNCH_RECHECK_MS = 60 * 60_000
|
|
18
|
+
// Long enough to read as growing out of the sidebar item, not snapping in.
|
|
19
|
+
const ENTER_MS = 320
|
|
20
|
+
const EXIT_MS = 220
|
|
21
|
+
|
|
22
|
+
export function shouldShowLaunchNotice(opts: {
|
|
23
|
+
phase: LaunchPhase | null
|
|
24
|
+
deploymentMode: string | undefined
|
|
25
|
+
dismissed: boolean
|
|
26
|
+
ready: boolean
|
|
27
|
+
cornerBusy: boolean
|
|
28
|
+
}): boolean {
|
|
29
|
+
return opts.phase !== null && launchShownIn(opts.deploymentMode, opts.phase) && !opts.dismissed && opts.ready && !opts.cornerBusy
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function launchLink(launch: ProductHuntLaunch): string {
|
|
33
|
+
const url = new URL(launch.url)
|
|
34
|
+
for (const [key, value] of Object.entries(UTM)) url.searchParams.set(key, value)
|
|
35
|
+
return url.toString()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A one-off notice for the October 2026 Product Hunt launch, whose date and
|
|
39
|
+
// link come from the update check. Before the day it waits its turn behind the
|
|
40
|
+
// update notice and the first-run usage prompt; on the day they wait for it.
|
|
41
|
+
// Each phase is dismissed on its own, so the launch-day card still shows to
|
|
42
|
+
// someone who closed the one before.
|
|
43
|
+
export function ProductHuntNotice({ usageData, usageDataPending }: { usageData: UsageDataStatus | undefined; usageDataPending: boolean }) {
|
|
44
|
+
const { data: capabilities } = useCapabilities()
|
|
45
|
+
const { data: versionInfo, isPending: versionPending, refetch: refetchVersion } = useVersionCheck()
|
|
46
|
+
const [now, setNow] = useState(() => Date.now())
|
|
47
|
+
const [ready, setReady] = useState(false)
|
|
48
|
+
|
|
49
|
+
const [usagePromptShowing, setUsagePromptShowing] = useState(usagePromptOnScreen)
|
|
50
|
+
const launch = resolveLaunch(versionInfo?.productHuntLaunch)
|
|
51
|
+
const phase = launchPhase(launch, now)
|
|
52
|
+
const ended = phase === null
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (ended) return
|
|
56
|
+
const delay = window.setTimeout(() => setReady(true), SHOW_DELAY_MS)
|
|
57
|
+
// Re-reads the clock for the phase change, and the update notice's
|
|
58
|
+
// dismissal, which only touches localStorage.
|
|
59
|
+
const poll = window.setInterval(() => setNow(Date.now()), 60_000)
|
|
60
|
+
// Picks up a launch moved or called off while this page stays open.
|
|
61
|
+
const recheck = window.setInterval(() => void refetchVersion(), LAUNCH_RECHECK_MS)
|
|
62
|
+
return () => {
|
|
63
|
+
window.clearTimeout(delay)
|
|
64
|
+
window.clearInterval(poll)
|
|
65
|
+
window.clearInterval(recheck)
|
|
66
|
+
}
|
|
67
|
+
}, [ended, refetchVersion])
|
|
68
|
+
|
|
69
|
+
// Opened again from the sidebar: shows at once, over whatever holds the corner.
|
|
70
|
+
const [reopened, setReopened] = useState(false)
|
|
71
|
+
// Re-renders after a dismissal, which lives outside React state.
|
|
72
|
+
const [, rerender] = useReducer((n: number) => n + 1, 0)
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const onReopen = () => setReopened(true)
|
|
75
|
+
window.addEventListener(LAUNCH_NOTICE_REOPEN_EVENT, onReopen)
|
|
76
|
+
return () => window.removeEventListener(LAUNCH_NOTICE_REOPEN_EVENT, onReopen)
|
|
77
|
+
}, [])
|
|
78
|
+
|
|
79
|
+
// Tracked whatever the launch, so a launch switched back on sees a usage
|
|
80
|
+
// prompt that opened meanwhile.
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const onUsagePrompt = () => setUsagePromptShowing(usagePromptOnScreen())
|
|
83
|
+
window.addEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
|
|
84
|
+
return () => window.removeEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
|
|
85
|
+
}, [])
|
|
86
|
+
|
|
87
|
+
const show = shouldShowLaunchNotice({
|
|
88
|
+
phase,
|
|
89
|
+
deploymentMode: capabilities ? (capabilities.deployment?.mode ?? 'local') : undefined,
|
|
90
|
+
dismissed: phase !== null && isPhaseDismissed(launch, phase) && !reopened,
|
|
91
|
+
// Waits for the version check, which says whether the launch is still on.
|
|
92
|
+
ready: (reopened || ready) && !versionPending,
|
|
93
|
+
// A card already on screen keeps the corner, whatever the day.
|
|
94
|
+
cornerBusy: !reopened && (usagePromptShowing || (phase === 'upcoming' && (
|
|
95
|
+
updateNoticeVisible(versionInfo?.latestVersion, versionInfo?.updateAvailable) || usageDataPending || !!usageData?.firstRunPrompt
|
|
96
|
+
))),
|
|
97
|
+
})
|
|
98
|
+
const { shouldRender, isOpen } = useAnimatedUnmount(show, EXIT_MS)
|
|
99
|
+
// Beside the sidebar's Product Hunt item, growing out of it; the bottom-right
|
|
100
|
+
// corner when the sidebar isn't there (narrow windows, embedded).
|
|
101
|
+
const [anchor, setAnchor] = useState<{ left: number; bottom: number } | null>(null)
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!shouldRender) return
|
|
104
|
+
const item = document.getElementById(LAUNCH_RAIL_ITEM_ID)
|
|
105
|
+
let frame = 0
|
|
106
|
+
const place = () => {
|
|
107
|
+
cancelAnimationFrame(frame)
|
|
108
|
+
frame = requestAnimationFrame(() => {
|
|
109
|
+
const r = item?.getBoundingClientRect()
|
|
110
|
+
setAnchor(r && r.width > 0 ? { left: r.right + 8, bottom: Math.max(16, window.innerHeight - r.bottom) } : null)
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
place()
|
|
114
|
+
const observer = item && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(place) : null
|
|
115
|
+
if (item) observer?.observe(item)
|
|
116
|
+
window.addEventListener('resize', place)
|
|
117
|
+
return () => {
|
|
118
|
+
cancelAnimationFrame(frame)
|
|
119
|
+
observer?.disconnect()
|
|
120
|
+
window.removeEventListener('resize', place)
|
|
121
|
+
}
|
|
122
|
+
}, [shouldRender])
|
|
123
|
+
// What the card last showed, kept through the exit fade: the day can end, or
|
|
124
|
+
// the launch be called off, while it is on screen.
|
|
125
|
+
const [shown, setShown] = useState<{ phase: LaunchPhase; launch: ProductHuntLaunch } | null>(null)
|
|
126
|
+
if (show && phase !== null && (shown?.phase !== phase || shown.launch.url !== launch.url || shown.launch.start !== launch.start)) {
|
|
127
|
+
setShown({ phase, launch })
|
|
128
|
+
}
|
|
129
|
+
if (!shouldRender || !shown) return null
|
|
130
|
+
|
|
131
|
+
const dismiss = () => {
|
|
132
|
+
markPhaseDismissed(shown.launch, shown.phase)
|
|
133
|
+
setReopened(false)
|
|
134
|
+
rerender()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const placement: CSSProperties = anchor
|
|
138
|
+
? { left: anchor.left, bottom: anchor.bottom, maxWidth: `calc(100vw - ${anchor.left + 16}px)`, maxHeight: `calc(100vh - ${anchor.bottom + 16}px)` }
|
|
139
|
+
: { right: 16, bottom: 16, maxWidth: 'calc(100vw - 2rem)', maxHeight: 'calc(100vh - 2rem)' }
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
role="dialog"
|
|
144
|
+
aria-label="Radar on Product Hunt"
|
|
145
|
+
inert={!show || undefined}
|
|
146
|
+
className={clsx(
|
|
147
|
+
'launch-border fixed z-40 w-[24rem] rounded-xl border border-emerald-500/40 dark:border-emerald-400/30 shadow-[0_10px_40px_-6px_rgba(16,185,129,0.6)] dark:shadow-[0_10px_40px_-8px_rgba(16,185,129,0.45)]',
|
|
148
|
+
anchor ? 'origin-bottom-left' : 'origin-bottom-right',
|
|
149
|
+
TRANSITION_MENU,
|
|
150
|
+
isOpen ? 'opacity-100 translate-x-0 translate-y-0 scale-100' : anchor ? 'opacity-0 -translate-x-3 scale-75' : 'opacity-0 translate-y-1 scale-[0.97]',
|
|
151
|
+
!show && 'pointer-events-none',
|
|
152
|
+
)}
|
|
153
|
+
style={{ ...placement, transitionDuration: `${isOpen ? ENTER_MS : EXIT_MS}ms` }}
|
|
154
|
+
>
|
|
155
|
+
<div className="relative flex gap-3 p-4 rounded-[11px] max-h-[inherit] overflow-y-auto bg-theme-surface bg-gradient-to-br from-emerald-500/12 via-emerald-500/4 to-transparent dark:from-emerald-400/18 dark:via-emerald-400/6">
|
|
156
|
+
<button
|
|
157
|
+
type="button"
|
|
158
|
+
onClick={dismiss}
|
|
159
|
+
aria-label="Close"
|
|
160
|
+
className="absolute top-2.5 right-2.5 p-1 rounded text-theme-text-tertiary hover:text-theme-text-primary hover:bg-theme-elevated"
|
|
161
|
+
>
|
|
162
|
+
<X className="w-3.5 h-3.5" />
|
|
163
|
+
</button>
|
|
164
|
+
<span className="flex items-center justify-center w-9 h-9 shrink-0 rounded-lg bg-emerald-500 text-white shadow-[0_4px_14px_-4px_rgba(16,185,129,0.6)]">
|
|
165
|
+
<Rocket className="w-4 h-4 animate-launch-rocket" aria-hidden />
|
|
166
|
+
</span>
|
|
167
|
+
<div className="min-w-0">
|
|
168
|
+
<p className="flex items-center gap-1.5 pr-6 text-sm font-medium text-theme-text-primary">
|
|
169
|
+
Radar <Heart className="w-3.5 h-3.5 fill-current text-red-500 dark:text-red-400" aria-label="loves" /> Agents
|
|
170
|
+
</p>
|
|
171
|
+
<p className="text-xs font-medium text-emerald-700 dark:text-emerald-300 mt-0.5">
|
|
172
|
+
{shown.phase === 'live' ? 'Live on Product Hunt today' : `Launching on Product Hunt ${launchDayLabel(shown.launch)}`}
|
|
173
|
+
</p>
|
|
174
|
+
<p className="text-xs text-theme-text-secondary mt-1.5">
|
|
175
|
+
{shown.phase === 'live'
|
|
176
|
+
? "We're on Product Hunt today with Radar's newly upgraded MCP server and AI investigations. If Radar has made Kubernetes a little easier for you, a comment on the launch would mean a lot. It helps other engineers find Radar."
|
|
177
|
+
: "We're launching Radar's newly upgraded MCP server and AI investigations on Product Hunt. If Radar has made Kubernetes a little easier for you, follow the launch and come say hi on the day. It helps other engineers find Radar."}
|
|
178
|
+
</p>
|
|
179
|
+
<div className="flex items-center gap-3 mt-3">
|
|
180
|
+
<a
|
|
181
|
+
href={launchLink(shown.launch)}
|
|
182
|
+
target="_blank"
|
|
183
|
+
rel="noopener noreferrer"
|
|
184
|
+
onClick={dismiss}
|
|
185
|
+
className="inline-flex items-center rounded-lg bg-emerald-600 hover:bg-emerald-700 dark:bg-emerald-500 dark:hover:bg-emerald-400 px-3 py-1.5 text-xs font-semibold text-white dark:text-emerald-950 whitespace-nowrap transition-colors"
|
|
186
|
+
>
|
|
187
|
+
{shown.phase === 'live' ? 'Comment on Product Hunt →' : 'Follow on Product Hunt →'}
|
|
188
|
+
</a>
|
|
189
|
+
<a
|
|
190
|
+
href={FEATURE_URL}
|
|
191
|
+
target="_blank"
|
|
192
|
+
rel="noopener noreferrer"
|
|
193
|
+
className="text-xs text-theme-text-tertiary hover:text-theme-text-secondary hover:underline whitespace-nowrap"
|
|
194
|
+
>
|
|
195
|
+
How it works
|
|
196
|
+
</a>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { VersionInfo } from '../../api/client'
|
|
2
|
+
|
|
3
|
+
// The launch as the update check last described it (internal/launchday), so it
|
|
4
|
+
// can move or be called off without a release.
|
|
5
|
+
export type ProductHuntLaunch = { enabled: boolean; url: string; start: number; end: number }
|
|
6
|
+
|
|
7
|
+
// Used only when Radar's version check doesn't answer. Product Hunt's day runs
|
|
8
|
+
// midnight to midnight Pacific; PDT is UTC-7 until Nov 1.
|
|
9
|
+
export const FALLBACK_LAUNCH: ProductHuntLaunch = {
|
|
10
|
+
enabled: true,
|
|
11
|
+
url: 'https://www.producthunt.com/products/radar-7?launch=radar-101',
|
|
12
|
+
start: Date.parse('2026-10-29T07:00:00Z'),
|
|
13
|
+
end: Date.parse('2026-10-30T07:00:00Z'),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const LAUNCH_NOTICE_DISMISSED_EVENT = 'radar:product-hunt-notice-dismissed'
|
|
17
|
+
// Sent by the sidebar's Product Hunt item to bring a dismissed card back.
|
|
18
|
+
export const LAUNCH_NOTICE_REOPEN_EVENT = 'radar:product-hunt-notice-reopen'
|
|
19
|
+
// The sidebar item the card opens from and closes into.
|
|
20
|
+
export const LAUNCH_RAIL_ITEM_ID = 'product-hunt-rail-item'
|
|
21
|
+
|
|
22
|
+
export type LaunchPhase = 'upcoming' | 'live'
|
|
23
|
+
|
|
24
|
+
// In-cluster Radar is often shared by people who didn't install it, so they
|
|
25
|
+
// get only the launch day.
|
|
26
|
+
export function launchShownIn(deploymentMode: string | undefined, phase: LaunchPhase): boolean {
|
|
27
|
+
return deploymentMode === 'local' || (deploymentMode === 'in-cluster' && phase === 'live')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function resolveLaunch(fromServer: VersionInfo['productHuntLaunch']): ProductHuntLaunch {
|
|
31
|
+
if (!fromServer) return FALLBACK_LAUNCH
|
|
32
|
+
return { enabled: fromServer.enabled, url: fromServer.url, start: Date.parse(fromServer.start), end: Date.parse(fromServer.end) }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function launchPhase(launch: ProductHuntLaunch, now: number): LaunchPhase | null {
|
|
36
|
+
if (!launch.enabled || !(now < launch.end)) return null
|
|
37
|
+
return now >= launch.start ? 'live' : 'upcoming'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// "Oct 29": the launch day on Product Hunt's own clock.
|
|
41
|
+
export function launchDayLabel(launch: ProductHuntLaunch): string {
|
|
42
|
+
return new Date(launch.start).toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'America/Los_Angeles' })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Keyed by launch day, so a moved launch is announced again.
|
|
46
|
+
function dismissedKey(launch: ProductHuntLaunch, phase: LaunchPhase): string {
|
|
47
|
+
return `radar-product-hunt-dismissed-${new Date(launch.start).toISOString().slice(0, 10)}-${phase}`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Covers this page when localStorage is unavailable.
|
|
51
|
+
const dismissedThisPage = new Set<string>()
|
|
52
|
+
|
|
53
|
+
export function isPhaseDismissed(launch: ProductHuntLaunch, phase: LaunchPhase): boolean {
|
|
54
|
+
const key = dismissedKey(launch, phase)
|
|
55
|
+
if (dismissedThisPage.has(key)) return true
|
|
56
|
+
try {
|
|
57
|
+
return localStorage.getItem(key) !== null
|
|
58
|
+
} catch {
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function markPhaseDismissed(launch: ProductHuntLaunch, phase: LaunchPhase): void {
|
|
64
|
+
const key = dismissedKey(launch, phase)
|
|
65
|
+
dismissedThisPage.add(key)
|
|
66
|
+
try {
|
|
67
|
+
localStorage.setItem(key, '1')
|
|
68
|
+
} catch {
|
|
69
|
+
// localStorage unavailable: dismissedThisPage keeps it for this page
|
|
70
|
+
}
|
|
71
|
+
window.dispatchEvent(new Event(LAUNCH_NOTICE_DISMISSED_EVENT))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// On launch day the Product Hunt card goes first: the update notice and the
|
|
75
|
+
// first-run usage prompt wait until it is dismissed or the day is over.
|
|
76
|
+
export function launchNoticeHoldsCorner(launch: ProductHuntLaunch, now: number): boolean {
|
|
77
|
+
return launchPhase(launch, now) === 'live' && !isPhaseDismissed(launch, 'live')
|
|
78
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
|
|
6
|
+
const state = vi.hoisted(() => ({ mode: 'local', pending: false }))
|
|
7
|
+
vi.mock('../../api/client', () => ({
|
|
8
|
+
useCapabilities: () => ({ data: { deployment: { mode: state.mode } } }),
|
|
9
|
+
useVersionCheck: () => ({ data: undefined, isPending: state.pending }),
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
import { useProductHuntRailEntry } from './useProductHuntRailEntry'
|
|
13
|
+
|
|
14
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
15
|
+
let root: Root
|
|
16
|
+
const seen = vi.fn<(entry: ReturnType<typeof useProductHuntRailEntry>) => void>()
|
|
17
|
+
const entry = () => seen.mock.lastCall?.[0]
|
|
18
|
+
|
|
19
|
+
function Probe() {
|
|
20
|
+
seen(useProductHuntRailEntry())
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function mount() {
|
|
25
|
+
root = createRoot(document.createElement('div'))
|
|
26
|
+
act(() => root.render(<Probe />))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
vi.useFakeTimers()
|
|
31
|
+
vi.setSystemTime(new Date('2026-10-29T17:00:00Z'))
|
|
32
|
+
localStorage.clear()
|
|
33
|
+
state.mode = 'local'
|
|
34
|
+
state.pending = false
|
|
35
|
+
seen.mockClear()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
act(() => root.unmount())
|
|
40
|
+
vi.useRealTimers()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('useProductHuntRailEntry', () => {
|
|
44
|
+
it('is there for the launch window, and opens the card', () => {
|
|
45
|
+
mount()
|
|
46
|
+
expect(entry()?.id).toBe('product-hunt-rail-item')
|
|
47
|
+
expect(entry()?.badge).toBe('Today')
|
|
48
|
+
const reopen = vi.fn()
|
|
49
|
+
window.addEventListener('radar:product-hunt-notice-reopen', reopen)
|
|
50
|
+
entry()?.onOpen()
|
|
51
|
+
expect(reopen).toHaveBeenCalledTimes(1)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('stays away in-cluster before the day and after the window', () => {
|
|
55
|
+
state.mode = 'in-cluster'
|
|
56
|
+
vi.setSystemTime(new Date('2026-10-28T17:00:00Z'))
|
|
57
|
+
mount()
|
|
58
|
+
expect(entry()).toBeUndefined()
|
|
59
|
+
act(() => root.unmount())
|
|
60
|
+
|
|
61
|
+
state.mode = 'local'
|
|
62
|
+
mount()
|
|
63
|
+
expect(entry()?.badge).toBe('Oct 29')
|
|
64
|
+
act(() => root.unmount())
|
|
65
|
+
|
|
66
|
+
vi.setSystemTime(new Date('2026-10-30T17:00:00Z'))
|
|
67
|
+
mount()
|
|
68
|
+
expect(entry()).toBeUndefined()
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('waits for the version check, which may have moved or cancelled the launch', () => {
|
|
72
|
+
state.pending = true
|
|
73
|
+
mount()
|
|
74
|
+
expect(entry()).toBeUndefined()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { useCapabilities, useVersionCheck } from '../../api/client'
|
|
3
|
+
import { LAUNCH_NOTICE_REOPEN_EVENT, LAUNCH_RAIL_ITEM_ID, launchDayLabel, launchPhase, launchShownIn, resolveLaunch } from './launchWindow'
|
|
4
|
+
|
|
5
|
+
// The sidebar's Product Hunt item: where the launch card opens from and closes
|
|
6
|
+
// into, there for the launch window to whoever the card is for.
|
|
7
|
+
export function useProductHuntRailEntry(): { onOpen: () => void; id: string; badge: string } | undefined {
|
|
8
|
+
const { data: capabilities } = useCapabilities()
|
|
9
|
+
const { data: versionInfo, isPending: versionPending } = useVersionCheck()
|
|
10
|
+
const [now, setNow] = useState(() => Date.now())
|
|
11
|
+
const launch = resolveLaunch(versionInfo?.productHuntLaunch)
|
|
12
|
+
const phase = launchPhase(launch, now)
|
|
13
|
+
const ended = phase === null
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (ended) return
|
|
17
|
+
const poll = window.setInterval(() => setNow(Date.now()), 60_000)
|
|
18
|
+
return () => window.clearInterval(poll)
|
|
19
|
+
}, [ended])
|
|
20
|
+
|
|
21
|
+
const mode = capabilities ? (capabilities.deployment?.mode ?? 'local') : undefined
|
|
22
|
+
// Waits for the version check, which says whether the launch is still on.
|
|
23
|
+
if (versionPending || phase === null || !launchShownIn(mode, phase)) return undefined
|
|
24
|
+
// Tagged with the day, so it reads as happening now and gone after.
|
|
25
|
+
const badge = phase === 'live' ? 'Today' : launchDayLabel(launch)
|
|
26
|
+
return { id: LAUNCH_RAIL_ITEM_ID, badge, onOpen: () => window.dispatchEvent(new Event(LAUNCH_NOTICE_REOPEN_EVENT)) }
|
|
27
|
+
}
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
getCrossplaneResourceRefs,
|
|
10
10
|
getBoundXRRef,
|
|
11
|
+
getCrossplanePauseState,
|
|
12
|
+
isManagedResource,
|
|
13
|
+
isComposite,
|
|
11
14
|
isClaim,
|
|
12
15
|
type CrossplaneResourceRef,
|
|
13
16
|
} from '@skyhook-io/k8s-ui/components/resources/resource-utils-crossplane'
|
|
@@ -140,6 +143,7 @@ export function CompositeRenderer({ data, onNavigate }: CompositeRendererProps)
|
|
|
140
143
|
const status = getResourceStatus(kindToPluralWithGroup(ref.kind, groupFromApiVersion(ref.apiVersion)), q.data.resource) ?? undefined
|
|
141
144
|
map.set(key, {
|
|
142
145
|
ref,
|
|
146
|
+
pauseState: isManagedResource(q.data.resource) || isComposite(q.data.resource) || getCrossplanePauseState(q.data.resource) === 'acknowledged' ? getCrossplanePauseState(q.data.resource) : null,
|
|
143
147
|
status: status ? { ...status, level: (status as any).level ?? 'unknown' } : undefined,
|
|
144
148
|
})
|
|
145
149
|
})
|
|
@@ -426,7 +426,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
426
426
|
onCreateResource={handleCreateResource}
|
|
427
427
|
renderKindView={renderKindView}
|
|
428
428
|
// Bulk operations
|
|
429
|
-
onBulkDelete={(items, options) => bulkDeleteMutation.mutate({ items, force: options?.force }, { onSuccess: options?.onSuccess })}
|
|
429
|
+
onBulkDelete={(items, options) => bulkDeleteMutation.mutate({ items, force: options?.force }, { onSuccess: results => { if (!results.some(({ result }) => result.outcomeUnknown)) options?.onSuccess?.() } })}
|
|
430
430
|
isBulkDeleting={bulkDeleteMutation.isPending}
|
|
431
431
|
onBulkRestart={canBulkRestartSelectedKind ? (items, options) => bulkRestartMutation.mutate({ items }, { onSuccess: options?.onSuccess }) : undefined}
|
|
432
432
|
isBulkRestarting={canBulkRestartSelectedKind && bulkRestartMutation.isPending}
|