@skyhook-io/radar-app 1.21.6 → 1.21.7
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 +1 -1
- package/package.json +7 -7
- package/src/App.tsx +19 -1
- package/src/RadarApp.tsx +8 -2
- package/src/api/client.discoverMetrics.test.tsx +69 -0
- package/src/api/client.issueCorrelation.test.tsx +244 -0
- package/src/api/client.issueRowChanges.test.tsx +129 -0
- package/src/api/client.pendingOwnership.test.tsx +197 -0
- package/src/api/client.prometheusStatus.test.ts +4 -0
- package/src/api/client.restartError.test.ts +36 -1
- package/src/api/client.stopWorkflow.test.tsx +133 -0
- package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
- package/src/api/client.ts +572 -111
- package/src/api/connectionBinding.test.tsx +3 -1
- package/src/api/connectionBinding.ts +14 -2
- package/src/api/gitOpsPermissions.render.test.tsx +155 -0
- package/src/api/gitOpsPermissions.test.ts +90 -0
- package/src/api/gitOpsPermissions.ts +51 -0
- package/src/api/httpErrors.test.ts +30 -1
- package/src/api/httpErrors.ts +17 -0
- package/src/api/openobserveSetup.ts +85 -0
- package/src/api/podDebug.test.tsx +137 -0
- package/src/api/podDebug.ts +82 -0
- package/src/api/prometheusCharts.test.ts +23 -0
- package/src/api/prometheusCharts.ts +25 -0
- package/src/api/radarFeatures.render.test.tsx +43 -2
- package/src/api/radarFeatures.test.ts +18 -1
- package/src/api/radarFeatures.ts +17 -4
- package/src/api/reviewedActionMutation.ts +9 -2
- package/src/api/workloadMetrics.ts +2 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
- package/src/components/applications/ApplicationsView.tsx +56 -31
- package/src/components/cnpg/host.test.tsx +1 -1
- package/src/components/cnpg/host.tsx +0 -2
- package/src/components/dock/BottomDock.tsx +7 -3
- package/src/components/dock/MissingShellDebug.test.tsx +193 -0
- package/src/components/dock/MissingShellDebug.tsx +114 -0
- package/src/components/dock/PodDebugSession.test.tsx +60 -0
- package/src/components/dock/PodDebugSession.tsx +96 -0
- package/src/components/dock/TerminalTab.test.tsx +48 -4
- package/src/components/dock/TerminalTab.tsx +47 -25
- package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
- package/src/components/dock/WorkloadLogsTab.tsx +16 -0
- package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
- package/src/components/execution/BatchExecutionView.tsx +88 -5
- package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
- package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
- package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
- package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
- package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
- package/src/components/gitops/GitOpsView.tsx +93 -32
- package/src/components/helm/OwnedResources.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +1 -0
- package/src/components/issues/IssuesPane.render.test.tsx +1 -1
- package/src/components/issues/IssuesPane.tsx +11 -0
- package/src/components/issues/useIssueExpansion.ts +91 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
- package/src/components/resource/MetricsNotConnected.tsx +114 -0
- package/src/components/resource/PVCUsageBar.tsx +2 -1
- package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
- package/src/components/resource/PrometheusCharts.tsx +14 -2
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
- package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
- package/src/components/resource/RestartChart.tsx +4 -3
- package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
- package/src/components/resource/RightsizingStrip.tsx +5 -3
- package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
- package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
- package/src/components/resource/nameMatchedScope.ts +9 -3
- package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
- package/src/components/resources/PodDebugAction.test.tsx +157 -0
- package/src/components/resources/PodDebugAction.tsx +207 -0
- package/src/components/resources/PodDebugPermission.tsx +21 -0
- package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
- package/src/components/resources/ResourcesView.tsx +39 -5
- package/src/components/resources/namespaceHint.test.ts +34 -0
- package/src/components/resources/namespaceHint.ts +19 -0
- package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
- package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
- package/src/components/resources/renderers/PodRenderer.tsx +12 -5
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
- package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
- package/src/components/settings/MetricsBackendSwitch.tsx +167 -0
- package/src/components/settings/OpenObserveSetup.test.tsx +343 -0
- package/src/components/settings/OpenObserveSetup.tsx +358 -0
- package/src/components/settings/SettingsDialog.tsx +21 -7
- package/src/components/settings/openobserveStatus.test.ts +34 -0
- package/src/components/settings/openobserveStatus.ts +55 -0
- package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
- package/src/components/timeline/TimelineList.test.ts +18 -0
- package/src/components/timeline/TimelineList.tsx +19 -5
- package/src/components/timeline/TimelineView.tsx +2 -0
- package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
- package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +95 -10
- package/src/context/TimelineNavigation.test.ts +59 -0
- package/src/context/TimelineNavigation.tsx +86 -0
- package/src/contexts/CapabilitiesContext.tsx +3 -1
- package/src/hooks/useResourceCounts.ts +2 -1
- package/src/hooks/useWorkflowStopAction.ts +31 -0
- package/src/index.css +1 -0
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +4 -2
- package/src/k8s-ui-exports.test.ts +10 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
|
@@ -39,7 +39,9 @@ const byNewest = (a: TimelineEvent, b: TimelineEvent) => new Date(b.timestamp).g
|
|
|
39
39
|
// and routine child activity, each newest first under its own `limit`. Separate
|
|
40
40
|
// budgets keep the promises the toggle makes: a burst of owner rows can't crowd
|
|
41
41
|
// out child problems, and showing routine activity only ever adds rows.
|
|
42
|
-
|
|
42
|
+
// `keepId` is the event a link opened (?event=): it always stays, past the cap
|
|
43
|
+
// and with routine activity hidden, so the link lands on it.
|
|
44
|
+
export function splitRoutineActivity(allRows: TimelineEvent[], limit: number, keepId?: string | null) {
|
|
43
45
|
const owners: TimelineEvent[] = []
|
|
44
46
|
const childProblems: TimelineEvent[] = []
|
|
45
47
|
const routine: TimelineEvent[] = []
|
|
@@ -47,8 +49,15 @@ export function splitRoutineActivity(allRows: TimelineEvent[], limit: number) {
|
|
|
47
49
|
const bucket = !isManagedTimelineEvent(e) ? owners : isTimelineProblem(e) ? childProblems : routine
|
|
48
50
|
bucket.push(e)
|
|
49
51
|
}
|
|
50
|
-
const base = [...owners.slice(0, limit), ...childProblems.slice(0, limit)]
|
|
52
|
+
const base = [...owners.slice(0, limit), ...childProblems.slice(0, limit)]
|
|
51
53
|
const shownRoutine = routine.slice(0, limit)
|
|
54
|
+
const kept = keepId ? allRows.find((e) => e.id === keepId) : undefined
|
|
55
|
+
if (kept && !base.includes(kept)) base.push(kept)
|
|
56
|
+
base.sort(byNewest)
|
|
57
|
+
if (kept) {
|
|
58
|
+
const at = shownRoutine.indexOf(kept)
|
|
59
|
+
if (at >= 0) shownRoutine.splice(at, 1)
|
|
60
|
+
}
|
|
52
61
|
return {
|
|
53
62
|
withoutRoutine: base,
|
|
54
63
|
withRoutine: [...base, ...shownRoutine].sort(byNewest),
|
|
@@ -95,9 +104,12 @@ interface TimelineListProps {
|
|
|
95
104
|
topology?: Topology
|
|
96
105
|
appScopeLoading?: boolean
|
|
97
106
|
onOpenDiagnostics?: () => void
|
|
107
|
+
// The selected event (the URL's ?event=): marked and scrolled into view.
|
|
108
|
+
selectedEventId?: string | null
|
|
109
|
+
onSelectEvent?: (id: string | null) => void
|
|
98
110
|
}
|
|
99
111
|
|
|
100
|
-
export function TimelineList({ namespaces, onViewChange, currentView, onResourceClick, initialFilter, initialTimeRange, showDeleted, onShowDeletedChange, showRoutine, onShowRoutineChange, search, onSearchChange, activityFilter, onActivityFilterChange, kindFilter, onKindFilterChange, selectionWindow, onVisibleWindowChange, scrollToMs, focusedAppIndex, appScoped = false, topology, appScopeLoading = false, onOpenDiagnostics }: TimelineListProps) {
|
|
112
|
+
export function TimelineList({ namespaces, onViewChange, currentView, onResourceClick, initialFilter, initialTimeRange, showDeleted, onShowDeletedChange, showRoutine, onShowRoutineChange, search, onSearchChange, activityFilter, onActivityFilterChange, kindFilter, onKindFilterChange, selectionWindow, onVisibleWindowChange, scrollToMs, focusedAppIndex, appScoped = false, topology, appScopeLoading = false, onOpenDiagnostics, selectedEventId, onSelectEvent }: TimelineListProps) {
|
|
101
113
|
const hasLimitedAccess = useHasLimitedAccess()
|
|
102
114
|
const timelineSource = useTimelineSource()
|
|
103
115
|
const [queryParams, setQueryParams] = useState<{ timeRange: TimeRange; kinds: string[] }>({
|
|
@@ -127,8 +139,8 @@ export function TimelineList({ namespaces, onViewChange, currentView, onResource
|
|
|
127
139
|
})
|
|
128
140
|
const loadError = useStickyError(error, fetchedEvents != null)
|
|
129
141
|
const split = useMemo(
|
|
130
|
-
() => (splitRows && fetchedEvents ? splitRoutineActivity(fetchedEvents, fetchLimit) : undefined),
|
|
131
|
-
[splitRows, fetchedEvents, fetchLimit],
|
|
142
|
+
() => (splitRows && fetchedEvents ? splitRoutineActivity(fetchedEvents, fetchLimit, selectedEventId) : undefined),
|
|
143
|
+
[splitRows, fetchedEvents, fetchLimit, selectedEventId],
|
|
132
144
|
)
|
|
133
145
|
const events = useMemo(() => {
|
|
134
146
|
const unscoped = split ? (showRoutine ? split.withRoutine : split.withoutRoutine) : fetchedEvents ?? []
|
|
@@ -204,6 +216,8 @@ export function TimelineList({ namespaces, onViewChange, currentView, onResource
|
|
|
204
216
|
onKindFilterChange={onKindFilterChange}
|
|
205
217
|
onVisibleWindowChange={onVisibleWindowChange}
|
|
206
218
|
scrollToMs={scrollToMs}
|
|
219
|
+
selectedEventId={selectedEventId}
|
|
220
|
+
onSelectEvent={onSelectEvent}
|
|
207
221
|
truncatedAt={fetchLimit}
|
|
208
222
|
isTruncated={sourceTruncated}
|
|
209
223
|
truncationMessage={appScoped && sourceTruncated
|
|
@@ -1060,6 +1060,8 @@ export function TimelineView({ namespaces, onResourceClick, initialViewMode, ini
|
|
|
1060
1060
|
topology={stableTopology}
|
|
1061
1061
|
appScopeLoading={focusedAppLoading}
|
|
1062
1062
|
onOpenDiagnostics={onOpenDiagnostics}
|
|
1063
|
+
selectedEventId={selectedEventId}
|
|
1064
|
+
onSelectEvent={setSelectedEventId}
|
|
1063
1065
|
/>
|
|
1064
1066
|
)
|
|
1065
1067
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { renderToString } from 'react-dom/server'
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { DockProvider, ToastProvider } from '@skyhook-io/k8s-ui'
|
|
6
|
+
import { expect, it, vi } from 'vitest'
|
|
7
|
+
import * as api from '../../api/client'
|
|
8
|
+
import { WorkloadView, WorkloadViewRoute } from './WorkloadView'
|
|
9
|
+
|
|
10
|
+
it.each([
|
|
11
|
+
['full-page route', undefined, true],
|
|
12
|
+
['active drawer layer', true, true],
|
|
13
|
+
['prewarm or outgoing drawer layer', false, false],
|
|
14
|
+
] as const)('sets ownership polling for the %s', (_, active, expected) => {
|
|
15
|
+
const client = new QueryClient()
|
|
16
|
+
const hook = vi.spyOn(api, 'useResourceWithRelationships')
|
|
17
|
+
try {
|
|
18
|
+
renderToString(
|
|
19
|
+
<QueryClientProvider client={client}>
|
|
20
|
+
<ToastProvider><DockProvider>
|
|
21
|
+
<MemoryRouter initialEntries={['/workload/configmaps/shop/settings']}>
|
|
22
|
+
{active === undefined
|
|
23
|
+
? <WorkloadViewRoute />
|
|
24
|
+
: <WorkloadView kind="configmaps" namespace="shop" name="settings" group="" onBack={() => {}} active={active} />}
|
|
25
|
+
</MemoryRouter>
|
|
26
|
+
</DockProvider></ToastProvider>
|
|
27
|
+
</QueryClientProvider>,
|
|
28
|
+
)
|
|
29
|
+
expect(hook).toHaveBeenCalledWith('configmaps', 'shop', 'settings', '', { pollPendingOwnership: expected })
|
|
30
|
+
} finally {
|
|
31
|
+
hook.mockRestore()
|
|
32
|
+
client.clear()
|
|
33
|
+
}
|
|
34
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { createMemoryRouter, RouterProvider } from 'react-router-dom'
|
|
5
|
+
import { onlineManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { DockProvider, ToastProvider } from '@skyhook-io/k8s-ui'
|
|
7
|
+
import { expect, it } from 'vitest'
|
|
8
|
+
import { WorkloadViewRoute } from './WorkloadView'
|
|
9
|
+
|
|
10
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
11
|
+
|
|
12
|
+
it.each([
|
|
13
|
+
['deploys', '?namespaces=shop', 'REPLACE'],
|
|
14
|
+
['logs', '?namespaces=shop', 'REPLACE'],
|
|
15
|
+
['runs', '?tab=runs&namespaces=shop', 'POP'],
|
|
16
|
+
])('opens Overview for ?tab=%s with the expected URL and history action', async (tab, search, historyAction) => {
|
|
17
|
+
const path = '/workload/configmaps/shop/settings'
|
|
18
|
+
const client = new QueryClient()
|
|
19
|
+
client.setQueryData(['resource', 'configmaps', 'shop', 'settings', ''], {
|
|
20
|
+
resource: { apiVersion: 'v1', kind: 'ConfigMap', metadata: { namespace: 'shop', name: 'settings' } },
|
|
21
|
+
})
|
|
22
|
+
const router = createMemoryRouter([{ path: '*', element: <WorkloadViewRoute /> }], {
|
|
23
|
+
initialEntries: [{ pathname: path, search: `?tab=${tab}&namespaces=shop`, state: { from: 'apps' } }],
|
|
24
|
+
})
|
|
25
|
+
const host = document.createElement('div')
|
|
26
|
+
const root = createRoot(host)
|
|
27
|
+
const wasOnline = onlineManager.isOnline()
|
|
28
|
+
onlineManager.setOnline(false)
|
|
29
|
+
try {
|
|
30
|
+
await act(async () => root.render(
|
|
31
|
+
<QueryClientProvider client={client}>
|
|
32
|
+
<ToastProvider><DockProvider><RouterProvider router={router} /></DockProvider></ToastProvider>
|
|
33
|
+
</QueryClientProvider>,
|
|
34
|
+
))
|
|
35
|
+
expect(host.querySelector('[role="tab"][aria-selected="true"]')?.textContent).toBe('Overview')
|
|
36
|
+
expect(router.state.location).toMatchObject({ pathname: path, search, state: { from: 'apps' } })
|
|
37
|
+
expect(router.state.historyAction).toBe(historyAction)
|
|
38
|
+
} finally {
|
|
39
|
+
act(() => root.unmount())
|
|
40
|
+
router.dispose()
|
|
41
|
+
client.clear()
|
|
42
|
+
onlineManager.setOnline(wasOnline)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { podDebugAccessKey } from '../../api/podDebug'
|
|
1
2
|
import { supportsWorkloadRevisions, WorkloadRevisionsButton } from './WorkloadRevisionsButton'
|
|
2
3
|
import { RelatedFindingsSection } from './RelatedFindingsSection'
|
|
3
4
|
import { decorateResourceDiagnose, resourceDetailRedirect, resourceDetailSlots, resourceIssueDetail, resourceLogs, resourceRendererOverrides } from '../../integrations/resourceHosts'
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
EditableYamlView,
|
|
13
14
|
FetchResult,
|
|
14
15
|
Section,
|
|
15
|
-
type
|
|
16
|
+
type WorkloadDetailTab,
|
|
16
17
|
type WorkloadExtraTab,
|
|
17
18
|
type GitOpsOwnerRef,
|
|
18
19
|
type HelmOwnerRef,
|
|
@@ -27,6 +28,8 @@ import {
|
|
|
27
28
|
isRolloutKind,
|
|
28
29
|
canSetWorkloadImages,
|
|
29
30
|
canPauseDeployment,
|
|
31
|
+
canSubmitWorkflowTemplate,
|
|
32
|
+
type WorkflowTemplateSubmission,
|
|
30
33
|
isCoreBatchJob,
|
|
31
34
|
type SetImageOwnership,
|
|
32
35
|
SET_IMAGE_WRITES,
|
|
@@ -68,6 +71,7 @@ import {
|
|
|
68
71
|
useTriggerCronJob,
|
|
69
72
|
useSuspendCronJob,
|
|
70
73
|
useResumeCronJob,
|
|
74
|
+
useSubmitWorkflowTemplate,
|
|
71
75
|
useRestartWorkload,
|
|
72
76
|
usePauseDeployment,
|
|
73
77
|
useResumeDeployment,
|
|
@@ -85,6 +89,7 @@ import {
|
|
|
85
89
|
useFluxSuspend,
|
|
86
90
|
useFluxResume,
|
|
87
91
|
useArgoSync,
|
|
92
|
+
useGitOpsActionCapabilities,
|
|
88
93
|
useArgoRefresh,
|
|
89
94
|
useArgoSuspend,
|
|
90
95
|
useArgoResume,
|
|
@@ -105,20 +110,24 @@ import { TIME_RANGES, PrometheusCharts, isPrometheusSupported } from '../resourc
|
|
|
105
110
|
import { RightsizingStrip } from '../resource/RightsizingStrip'
|
|
106
111
|
import { PrometheusChartsGrid } from '../resource/PrometheusChartsGrid'
|
|
107
112
|
import { DatadogSetupHint, DatadogWorkloadCharts, useDatadogWorkloadCharts, WorkloadCostRightsizing } from '../resource/DatadogWorkloadCharts'
|
|
113
|
+
import { PodDebugAction, usePodDetailAccess, type PodDebugTarget } from '../resources/PodDebugAction'
|
|
108
114
|
import { useNavCustomization } from '../../context/NavCustomization'
|
|
109
115
|
import { RestartEventLane } from '../resource/RestartChart'
|
|
110
116
|
import { WorkloadCostTab } from '../cost/WorkloadCostTab'
|
|
111
117
|
import { isOpenCostWorkloadKind } from '../cost/kinds'
|
|
112
118
|
import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
|
|
113
119
|
import { useTrafficAvailable } from '../../api/traffic'
|
|
120
|
+
import { useIssueExpansion, useIssueRowNotes } from '../issues/useIssueExpansion'
|
|
114
121
|
import { isNotFoundError, useResourceAudit, useResourceIssues, useSubjectIssues, useRadarFeature, useTrace, fetchTraceWithProbes, fetchInClusterCapability, runInClusterMerged } from '../../api/client'
|
|
115
122
|
import { AuditAlerts, getRadarUpgradeRequirement, ResourceIssuesSection, ReachabilityView, TraceSummary, InClusterConsentDialog, traceFingerprint, staticPollUnreliable, summarizeInClusterTests, type Trace as NetworkTrace, type InClusterCapability, inClusterConsentGiven, consentRequestRows, getDefaultLogContainerName, getLogContainerNames, getInitContainerNames } from '@skyhook-io/k8s-ui'
|
|
123
|
+
import { WorkloadLogsTab } from '../dock/WorkloadLogsTab'
|
|
116
124
|
import { WorkloadLogsViewer } from '../logs/WorkloadLogsViewer'
|
|
117
125
|
import { ScheduledWorkloadLogsViewer } from '../logs/ScheduledWorkloadLogsViewer'
|
|
118
126
|
import { LogsViewer } from '../logs/LogsViewer'
|
|
119
127
|
import { MultiPodLogsTab } from '../logs/MultiPodLogsTab'
|
|
120
128
|
import { RayClusterLogsTab } from '../logs/RayClusterLogsTab'
|
|
121
129
|
import { isKubeRayCluster } from '../logs/rayClusterPods'
|
|
130
|
+
import { useWorkflowStopAction } from '../../hooks/useWorkflowStopAction'
|
|
122
131
|
import { BatchExecutionFullscreen } from '../execution/BatchExecutionView'
|
|
123
132
|
import { workloadRunTimelineEvents } from '../execution/batch-timeline'
|
|
124
133
|
import {
|
|
@@ -151,11 +160,11 @@ import { recordUsageEvent } from '../../api/usage-data'
|
|
|
151
160
|
import { issueResourceOpener } from './issueResourceOpener'
|
|
152
161
|
import { isVeleroBackupKind } from '../velero/routes'
|
|
153
162
|
|
|
154
|
-
type TabType =
|
|
163
|
+
type TabType = WorkloadDetailTab
|
|
155
164
|
|
|
156
165
|
// The usage-report view a tab counts under. Timeline holds the resource's
|
|
157
166
|
// events (it replaced the Events tab), so it counts as panel:events.
|
|
158
|
-
const PANEL_USAGE_VIEWS: Readonly<Partial<Record<TabType
|
|
167
|
+
const PANEL_USAGE_VIEWS: Readonly<Partial<Record<TabType, string>>> = {
|
|
159
168
|
logs: 'panel:logs',
|
|
160
169
|
yaml: 'panel:yaml',
|
|
161
170
|
metrics: 'panel:metrics',
|
|
@@ -332,6 +341,7 @@ function useActionsBarProps(
|
|
|
332
341
|
group: string | undefined,
|
|
333
342
|
cascadeEnabled: boolean,
|
|
334
343
|
nodeUID: string,
|
|
344
|
+
pod?: PodDebugTarget,
|
|
335
345
|
) {
|
|
336
346
|
const [deletePreviewOpen, setDeletePreviewOpen] = useState(false)
|
|
337
347
|
const { showCopied } = useToast()
|
|
@@ -340,7 +350,9 @@ function useActionsBarProps(
|
|
|
340
350
|
const openLogs = useOpenLogs()
|
|
341
351
|
const openWorkloadLogs = useOpenWorkloadLogs()
|
|
342
352
|
const openNodeTerminal = useOpenNodeTerminal()
|
|
343
|
-
const
|
|
353
|
+
const nsCaps = useNamespacedCapabilities(namespace)
|
|
354
|
+
const { canViewLogs, canPortForward, workloadWrites, workloadWritesPending } = nsCaps
|
|
355
|
+
const { canExec, debugImage, unverifiedReview, debugDenial, reviewStatus } = usePodDetailAccess(pod, nsCaps)
|
|
344
356
|
const queryClient = useQueryClient()
|
|
345
357
|
// Live forward when local+RBAC; otherwise (in-cluster/Cloud) still surface the
|
|
346
358
|
// copy-paste kubectl command. The button picks live vs. copy by deployment mode.
|
|
@@ -359,6 +371,8 @@ function useActionsBarProps(
|
|
|
359
371
|
const triggerCronJobMutation = useTriggerCronJob()
|
|
360
372
|
const suspendCronJobMutation = useSuspendCronJob()
|
|
361
373
|
const resumeCronJobMutation = useResumeCronJob()
|
|
374
|
+
const workflowStop = useWorkflowStopAction(kind, group, namespace)
|
|
375
|
+
const submitWorkflowTemplateMutation = useSubmitWorkflowTemplate()
|
|
362
376
|
|
|
363
377
|
const isRolloutShape = isRolloutKind(kind)
|
|
364
378
|
const isRollout = isRolloutShape && group === 'argoproj.io'
|
|
@@ -373,6 +387,8 @@ function useActionsBarProps(
|
|
|
373
387
|
const canSetImages = isRolloutShape
|
|
374
388
|
? imageUpdatesSupported && isRollout && !rolloutCapabilitiesPending && rolloutCapabilities?.setImage === true
|
|
375
389
|
: !workloadWritesPending && canSetWorkloadImages({ name: kind, group }, workloadWrites, imageUpdatesSupported)
|
|
390
|
+
const { support: replicaSetLogSupport } = useRadarFeature('replicaSetLogs')
|
|
391
|
+
const isAppsReplicaSet = kind === 'replicasets' && group === 'apps'
|
|
376
392
|
const { support: deploymentPauseSupport } = useRadarFeature('deploymentPause')
|
|
377
393
|
const canPauseDeployments = !workloadWritesPending &&
|
|
378
394
|
canPauseDeployment({ name: kind, group }, workloadWrites, deploymentPauseSupport === 'supported')
|
|
@@ -396,6 +412,7 @@ function useActionsBarProps(
|
|
|
396
412
|
const fluxSuspendMutation = useFluxSuspend()
|
|
397
413
|
const fluxResumeMutation = useFluxResume()
|
|
398
414
|
|
|
415
|
+
const { disabledReasons: gitOpsActionDisabledReasons } = useGitOpsActionCapabilities(kind, group, namespace, name)
|
|
399
416
|
const argoSyncMutation = useArgoSync()
|
|
400
417
|
const argoRefreshMutation = useArgoRefresh()
|
|
401
418
|
const argoSuspendMutation = useArgoSuspend()
|
|
@@ -403,6 +420,10 @@ function useActionsBarProps(
|
|
|
403
420
|
const { upgrade: argoResumeUpgrade, blockedReason: argoResumeBlockedReason } = useRadarFeature('argoAutoSyncEnable')
|
|
404
421
|
const { support: argoInheritanceSupport } = useRadarFeature('argoSyncInheritance')
|
|
405
422
|
const { support: cronJobJobNameSupport } = useRadarFeature('cronJobTriggerJobName')
|
|
423
|
+
const { support: workflowTemplateSubmitSupport, upgrade: workflowTemplateSubmitUpgrade } = useRadarFeature('workflowTemplateSubmit')
|
|
424
|
+
const isArgoWorkflowTemplate = kind === 'workflowtemplates' && group === 'argoproj.io'
|
|
425
|
+
const canSubmitTemplates = !workloadWritesPending &&
|
|
426
|
+
canSubmitWorkflowTemplate({ name: kind, group }, workloadWrites, workflowTemplateSubmitSupport === 'supported')
|
|
406
427
|
|
|
407
428
|
const {
|
|
408
429
|
data: cascadePreview,
|
|
@@ -430,8 +451,11 @@ function useActionsBarProps(
|
|
|
430
451
|
canViewLogs,
|
|
431
452
|
canPortForward: showPortForward,
|
|
432
453
|
onOpenTerminal: openTerminal,
|
|
454
|
+
podDebugAction: pod && <PodDebugAction key={pod.metadata.uid} pod={pod} defaultImage={debugImage} unverifiedReview={unverifiedReview} debugDenial={debugDenial} reviewStatus={reviewStatus} />,
|
|
433
455
|
onOpenLogs: openLogs,
|
|
434
456
|
onOpenWorkloadLogs: openWorkloadLogs,
|
|
457
|
+
replicaSetLogs: isAppsReplicaSet && replicaSetLogSupport === 'supported',
|
|
458
|
+
replicaSetLogTab: isAppsReplicaSet && replicaSetLogSupport !== 'unsupported',
|
|
435
459
|
onOpenNodeTerminal: openNodeTerminal,
|
|
436
460
|
onCopyCommand: (text: string, message: string, event: React.MouseEvent) =>
|
|
437
461
|
showCopied(text, message, event),
|
|
@@ -511,6 +535,16 @@ function useActionsBarProps(
|
|
|
511
535
|
onResumeCronJob: (params: Parameters<typeof resumeCronJobMutation.mutate>[0]) =>
|
|
512
536
|
resumeCronJobMutation.mutate(params),
|
|
513
537
|
isResumingCronJob: resumeCronJobMutation.isPending,
|
|
538
|
+
// mutateAsync, not mutate: the submit dialog stays open when this rejects.
|
|
539
|
+
onSubmitWorkflowTemplate: canSubmitTemplates
|
|
540
|
+
? (submission: WorkflowTemplateSubmission) => submitWorkflowTemplateMutation.mutateAsync(submission)
|
|
541
|
+
: undefined,
|
|
542
|
+
isSubmittingWorkflowTemplate: submitWorkflowTemplateMutation.isPending,
|
|
543
|
+
// Only a Radar known to lack the endpoint gets the upgrade note; a failed
|
|
544
|
+
// capabilities probe is not evidence of an old Radar.
|
|
545
|
+
workflowTemplateSubmitUpgrade: isArgoWorkflowTemplate && workflowTemplateSubmitSupport === 'unsupported' ? workflowTemplateSubmitUpgrade : null,
|
|
546
|
+
gitOpsActionDisabledReasons,
|
|
547
|
+
...workflowStop,
|
|
514
548
|
onFluxReconcile: (params: Parameters<typeof fluxReconcileMutation.mutate>[0]) =>
|
|
515
549
|
fluxReconcileMutation.mutate(params),
|
|
516
550
|
isFluxReconciling: fluxReconcileMutation.isPending,
|
|
@@ -596,8 +630,8 @@ export function WorkloadView({
|
|
|
596
630
|
// recount the same open tab: the drawer mounts hidden WorkloadView layers
|
|
597
631
|
// for expand-on-hover and crossfades.
|
|
598
632
|
const handleTabChange = useCallback(
|
|
599
|
-
(tab: TabType
|
|
600
|
-
const panel = PANEL_USAGE_VIEWS[tab]
|
|
633
|
+
(tab: TabType, opts?: { replace?: boolean }) => {
|
|
634
|
+
const panel = Object.hasOwn(PANEL_USAGE_VIEWS, tab) ? PANEL_USAGE_VIEWS[tab] : undefined
|
|
601
635
|
if (panel && tab !== migratedTab) recordUsageEvent({ type: 'view', name: panel })
|
|
602
636
|
const params = new URLSearchParams(searchParams)
|
|
603
637
|
if (tab === 'overview') {
|
|
@@ -632,9 +666,12 @@ export function WorkloadView({
|
|
|
632
666
|
const {
|
|
633
667
|
data: resourceResponse,
|
|
634
668
|
isLoading: resourceLoading,
|
|
669
|
+
isFetching: resourceFetching,
|
|
635
670
|
error: resourceError,
|
|
636
671
|
refetch: refetchResource,
|
|
637
|
-
} = useResourceWithRelationships<any>(apiKind, namespace, name, rest.group
|
|
672
|
+
} = useResourceWithRelationships<any>(apiKind, namespace, name, rest.group, {
|
|
673
|
+
pollPendingOwnership: rest.active !== false,
|
|
674
|
+
})
|
|
638
675
|
const resource = resourceResponse?.resource
|
|
639
676
|
const relationships = resourceResponse?.relationships
|
|
640
677
|
useRefreshRevisionsOnNewRollout(
|
|
@@ -686,6 +723,10 @@ export function WorkloadView({
|
|
|
686
723
|
await Promise.all([
|
|
687
724
|
refetchResource(),
|
|
688
725
|
onRefresh?.(),
|
|
726
|
+
...(apiKind === 'pods' && !effectiveGroup && resource?.metadata?.uid ? [
|
|
727
|
+
queryClient.invalidateQueries({queryKey: ['capabilities', namespace], exact: true}),
|
|
728
|
+
queryClient.invalidateQueries({queryKey: podDebugAccessKey(namespace, name, resource.metadata.uid)}),
|
|
729
|
+
] : []),
|
|
689
730
|
...(apiKind === 'rayjobs' && effectiveGroup === 'ray.io' ? [
|
|
690
731
|
queryClient.refetchQueries({ queryKey: ['resource', 'jobs', namespace, name, 'batch'], type: 'active' }),
|
|
691
732
|
...(resource?.spec?.clusterSelector?.['ray.io/cluster'] ? [queryClient.refetchQueries({ queryKey: ['resource', 'rayclusters', namespace, resource.spec.clusterSelector['ray.io/cluster'], 'ray.io'], type: 'active' })] : []),
|
|
@@ -699,7 +740,7 @@ export function WorkloadView({
|
|
|
699
740
|
...(apiKind === 'rayclusters' ? { type: 'active' as const } : {}),
|
|
700
741
|
}),
|
|
701
742
|
])
|
|
702
|
-
}, [apiKind, effectiveGroup, name, namespace, queryClient, refetchResource, resource?.spec?.clusterSelector, onRefresh])
|
|
743
|
+
}, [apiKind, effectiveGroup, name, namespace, queryClient, refetchResource, resource?.metadata?.uid, resource?.spec?.clusterSelector, onRefresh])
|
|
703
744
|
const podWorkloadOwner = useMemo(
|
|
704
745
|
() => podWorkloadOwnerFromRelationships(apiKind, namespace, relationships, resource),
|
|
705
746
|
[apiKind, namespace, relationships, resource],
|
|
@@ -893,6 +934,7 @@ export function WorkloadView({
|
|
|
893
934
|
effectiveGroup,
|
|
894
935
|
!resourceLoading && Boolean(resource),
|
|
895
936
|
apiKind === 'nodes' && !effectiveGroup ? resource?.metadata?.uid ?? '' : '',
|
|
937
|
+
apiKind === 'pods' && resource?.apiVersion === 'v1' && resource?.kind === 'Pod' ? resource : undefined,
|
|
896
938
|
)
|
|
897
939
|
const desktopDownload = useDesktopDownload()
|
|
898
940
|
|
|
@@ -913,6 +955,11 @@ export function WorkloadView({
|
|
|
913
955
|
rest.active !== false && !useReportCoverage && !isNotFoundError(resourceError), issueObservation)
|
|
914
956
|
const subjectIssues = useSubjectIssues(useReportCoverage ? { kind: isCoreNode ? 'Node' : 'CronJob', group: isCoreNode ? '' : 'batch', namespace, name, uid: resource?.metadata?.uid } : null, useReportCoverage && Boolean(resource))
|
|
915
957
|
const liveIssues = useReportCoverage ? subjectIssues.data?.issues : ordinaryIssues.data
|
|
958
|
+
const issueExpansion = useIssueExpansion(() => {
|
|
959
|
+
if (useReportCoverage) void subjectIssues.refetch()
|
|
960
|
+
else void ordinaryIssues.refetch()
|
|
961
|
+
})
|
|
962
|
+
const issueRowNotes = useIssueRowNotes()
|
|
916
963
|
const issuesPending = useReportCoverage ? subjectIssues.isPending : ordinaryIssues.isPending
|
|
917
964
|
const schedulingEvidence = isCronJob && subjectIssues.data?.scheduling_report?.uid === resource?.metadata?.uid ? subjectIssues.data?.scheduling_report : undefined
|
|
918
965
|
const certificateEvidence = isCoreNode && subjectIssues.data?.node_certificate_report?.uid === resource?.metadata?.uid ? subjectIssues.data?.node_certificate_report : undefined
|
|
@@ -1151,12 +1198,38 @@ export function WorkloadView({
|
|
|
1151
1198
|
imageOwnerVerified,
|
|
1152
1199
|
imageSelection,
|
|
1153
1200
|
])
|
|
1201
|
+
// A submitted run opens as a Workflow, as Argo's UI does: its full page from
|
|
1202
|
+
// the full page (the same run view, with the Workflow's own actions), and the
|
|
1203
|
+
// resource drawer from the drawer.
|
|
1204
|
+
const viewIdentity = `${apiKind}/${namespace}/${name}`
|
|
1205
|
+
const currentViewIdentity = useRef(viewIdentity)
|
|
1206
|
+
currentViewIdentity.current = viewIdentity
|
|
1207
|
+
useEffect(() => () => { currentViewIdentity.current = '' }, [])
|
|
1208
|
+
const navigateToResource = rest.onNavigateToResource
|
|
1209
|
+
const submitWorkflowTemplate = baseActionsBarProps.onSubmitWorkflowTemplate
|
|
1210
|
+
const submitAndOpenRun = useMemo(
|
|
1211
|
+
() => submitWorkflowTemplate
|
|
1212
|
+
? async (submission: WorkflowTemplateSubmission) => {
|
|
1213
|
+
const submittedFrom = currentViewIdentity.current
|
|
1214
|
+
const run = await submitWorkflowTemplate(submission)
|
|
1215
|
+
// The user moved on while the request ran: don't pull them back.
|
|
1216
|
+
if (currentViewIdentity.current === submittedFrom) {
|
|
1217
|
+
const target = { kind: 'workflows', namespace: run.namespace, name: run.name, group: 'argoproj.io' }
|
|
1218
|
+
if (expanded) navigateRouter(buildWorkloadPath(target))
|
|
1219
|
+
else navigateToResource?.(target)
|
|
1220
|
+
}
|
|
1221
|
+
return run
|
|
1222
|
+
}
|
|
1223
|
+
: undefined,
|
|
1224
|
+
[expanded, navigateRouter, navigateToResource, submitWorkflowTemplate],
|
|
1225
|
+
)
|
|
1154
1226
|
const actionsBarProps = useMemo(
|
|
1155
1227
|
() => ({
|
|
1156
1228
|
...baseActionsBarProps,
|
|
1157
1229
|
onLoadImages: baseActionsBarProps.onLoadImages
|
|
1158
1230
|
? loadImagesWithTargetOwnership
|
|
1159
1231
|
: undefined,
|
|
1232
|
+
onSubmitWorkflowTemplate: submitAndOpenRun,
|
|
1160
1233
|
onCompareTo,
|
|
1161
1234
|
onCompareAcrossClusters,
|
|
1162
1235
|
imageOwnership,
|
|
@@ -1164,6 +1237,7 @@ export function WorkloadView({
|
|
|
1164
1237
|
[
|
|
1165
1238
|
baseActionsBarProps,
|
|
1166
1239
|
loadImagesWithTargetOwnership,
|
|
1240
|
+
submitAndOpenRun,
|
|
1167
1241
|
imageOwnership,
|
|
1168
1242
|
onCompareTo,
|
|
1169
1243
|
onCompareAcrossClusters,
|
|
@@ -1271,6 +1345,7 @@ export function WorkloadView({
|
|
|
1271
1345
|
renderServicePortAction={renderServicePortAction}
|
|
1272
1346
|
renderServicePortPanel={renderServicePortPanel}
|
|
1273
1347
|
isLoading={resourceLoading}
|
|
1348
|
+
isFetching={resourceFetching}
|
|
1274
1349
|
resourceError={resourceError}
|
|
1275
1350
|
refetch={refetchResourceAndRuns}
|
|
1276
1351
|
// Timeline
|
|
@@ -1306,11 +1381,13 @@ export function WorkloadView({
|
|
|
1306
1381
|
yamlSchemaLoader={features?.yamlSchemas ? fetchYamlSchemas : undefined}
|
|
1307
1382
|
// Tab state (URL-synced)
|
|
1308
1383
|
activeTab={migratedTab}
|
|
1384
|
+
extraTabsComplete={migratedTab === 'deploys' ? true : undefined}
|
|
1309
1385
|
onTabChange={handleTabChange}
|
|
1310
1386
|
// Render props
|
|
1311
1387
|
renderLogsTab={(props) => (
|
|
1312
1388
|
<LogsTabContent
|
|
1313
1389
|
{...props}
|
|
1390
|
+
replicaSetLogs={baseActionsBarProps.replicaSetLogs || (baseActionsBarProps.replicaSetLogTab && props.pods.length === 0)}
|
|
1314
1391
|
resourceLoading={resourceLoading}
|
|
1315
1392
|
resourceError={resourceError}
|
|
1316
1393
|
group={effectiveGroup}
|
|
@@ -1459,6 +1536,11 @@ export function WorkloadView({
|
|
|
1459
1536
|
compact={!expanded}
|
|
1460
1537
|
subjectResource={{ kind: apiKind, namespace, name, group: identityGroup }}
|
|
1461
1538
|
onResourceClick={openIssueResource}
|
|
1539
|
+
onOpenIssueChange={issueExpansion.onOpenIssueChange}
|
|
1540
|
+
expandedIssue={issueExpansion.expandedIssue}
|
|
1541
|
+
timelineLinks={issueExpansion.timelineLinks}
|
|
1542
|
+
rowChanges={issueRowNotes.rowChanges}
|
|
1543
|
+
onVisibleIssuesChange={issueRowNotes.onVisibleIssuesChange}
|
|
1462
1544
|
/>
|
|
1463
1545
|
</div>
|
|
1464
1546
|
)}
|
|
@@ -1614,6 +1696,7 @@ const SCHEDULED_LOG_KINDS = new Set([
|
|
|
1614
1696
|
])
|
|
1615
1697
|
|
|
1616
1698
|
function LogsTabContent({
|
|
1699
|
+
replicaSetLogs,
|
|
1617
1700
|
kind,
|
|
1618
1701
|
apiKind,
|
|
1619
1702
|
group,
|
|
@@ -1631,6 +1714,7 @@ function LogsTabContent({
|
|
|
1631
1714
|
resourceLoading,
|
|
1632
1715
|
resourceError,
|
|
1633
1716
|
}: {
|
|
1717
|
+
replicaSetLogs: boolean
|
|
1634
1718
|
kind: string
|
|
1635
1719
|
apiKind: string
|
|
1636
1720
|
group?: string
|
|
@@ -1682,7 +1766,8 @@ function LogsTabContent({
|
|
|
1682
1766
|
)
|
|
1683
1767
|
}
|
|
1684
1768
|
|
|
1685
|
-
|
|
1769
|
+
if (replicaSetLogs) return <WorkloadLogsTab namespace={namespace} workloadKind={apiKind} workloadName={name} />
|
|
1770
|
+
|
|
1686
1771
|
if (WORKLOAD_LOG_KINDS.has(kind) && (kind !== 'Job' || isCoreBatchJob(apiKind, group))) {
|
|
1687
1772
|
return (
|
|
1688
1773
|
<div className="h-full">
|
|
@@ -1709,7 +1794,7 @@ function LogsTabContent({
|
|
|
1709
1794
|
)
|
|
1710
1795
|
}
|
|
1711
1796
|
|
|
1712
|
-
// Other
|
|
1797
|
+
// Other resources with associated Pods offer their individual logs.
|
|
1713
1798
|
return (
|
|
1714
1799
|
<MultiPodLogsTab
|
|
1715
1800
|
pods={pods}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { canOpenTimelineEvent, openTimelineEventIn, type TimelineScopeControls } from './TimelineNavigation'
|
|
3
|
+
|
|
4
|
+
const namespaced = { eventId: 'ev-cm', namespace: 'shop', timestamp: '2026-11-18T12:00:00Z' }
|
|
5
|
+
const clusterScoped = { eventId: 'ev-hook', namespace: '', timestamp: '2026-11-18T12:00:00Z' }
|
|
6
|
+
|
|
7
|
+
// The pick request behaves like the namespace mutation: the server's answer
|
|
8
|
+
// arrives later, and a refusal (Radar Hub's proxy passes GET only) rejects.
|
|
9
|
+
function controls(current: string[], serverAccepts: boolean) {
|
|
10
|
+
const navigate = vi.fn<(search: URLSearchParams) => void>()
|
|
11
|
+
const setNamespaces = vi.fn<(namespaces: string[]) => void>()
|
|
12
|
+
const answers: Promise<string[]>[] = []
|
|
13
|
+
const c: TimelineScopeControls = {
|
|
14
|
+
currentNamespaces: current,
|
|
15
|
+
cacheScoped: false,
|
|
16
|
+
setNamespaces,
|
|
17
|
+
requestNamespaces: (picked) => {
|
|
18
|
+
const answer = serverAccepts ? Promise.resolve(picked) : Promise.reject(new Error('HTTP 405: method not allowed'))
|
|
19
|
+
answer.catch(() => {})
|
|
20
|
+
answers.push(answer)
|
|
21
|
+
},
|
|
22
|
+
navigate,
|
|
23
|
+
}
|
|
24
|
+
const settled = () => Promise.allSettled(answers)
|
|
25
|
+
return { c, navigate, setNamespaces, answers, settled }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('openTimelineEventIn', () => {
|
|
29
|
+
it.each([true, false])('opens a namespaced event scoped to its namespace (server accepts the pick: %s)', async (accepts) => {
|
|
30
|
+
const { c, navigate, setNamespaces, answers, settled } = controls(['gate'], accepts)
|
|
31
|
+
openTimelineEventIn(namespaced, c)
|
|
32
|
+
expect(answers).toHaveLength(1)
|
|
33
|
+
expect((await settled())[0].status).toBe(accepts ? 'fulfilled' : 'rejected')
|
|
34
|
+
expect(navigate).toHaveBeenCalledTimes(1)
|
|
35
|
+
expect(setNamespaces).toHaveBeenCalledWith(['shop'])
|
|
36
|
+
expect(navigate.mock.calls[0][0].get('namespaces')).toBe('shop')
|
|
37
|
+
expect(navigate.mock.calls[0][0].get('event')).toBe('ev-cm')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it.each([true, false])('opens a cluster-scoped event in all namespaces, even when the server refuses the pick (accepts: %s)', async (accepts) => {
|
|
41
|
+
const { c, navigate, setNamespaces, answers, settled } = controls(['shop'], accepts)
|
|
42
|
+
openTimelineEventIn(clusterScoped, c)
|
|
43
|
+
expect(answers).toHaveLength(1)
|
|
44
|
+
expect((await settled())[0].status).toBe(accepts ? 'fulfilled' : 'rejected')
|
|
45
|
+
expect(setNamespaces).toHaveBeenCalledTimes(1)
|
|
46
|
+
expect(setNamespaces).toHaveBeenCalledWith([])
|
|
47
|
+
expect(navigate).toHaveBeenCalledTimes(1)
|
|
48
|
+
expect(navigate.mock.calls[0][0].has('namespaces')).toBe(false)
|
|
49
|
+
expect(navigate.mock.calls[0][0].get('event')).toBe('ev-hook')
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe('canOpenTimelineEvent', () => {
|
|
54
|
+
it('offers a cluster-scoped event only when the view can widen to all namespaces', () => {
|
|
55
|
+
expect(canOpenTimelineEvent(namespaced, true)).toBe(true)
|
|
56
|
+
expect(canOpenTimelineEvent(clusterScoped, false)).toBe(true)
|
|
57
|
+
expect(canOpenTimelineEvent(clusterScoped, true)).toBe(false)
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { IssueTimelineEventTarget, IssueTimelineLinks, TimeRange } from '@skyhook-io/k8s-ui'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Opens the Timeline on one event. The app shell provides it because opening
|
|
6
|
+
* the Timeline in a namespace moves the app's namespace scope, the URL and the
|
|
7
|
+
* server's pick together. Absent outside the shell, where change rows keep
|
|
8
|
+
* their link to the changed object.
|
|
9
|
+
*/
|
|
10
|
+
const TimelineNavigationContext = createContext<Required<Pick<IssueTimelineLinks, 'onTimelineEventClick' | 'canOpenTimelineEvent'>> | undefined>(undefined)
|
|
11
|
+
|
|
12
|
+
export const TimelineNavigationProvider = TimelineNavigationContext.Provider
|
|
13
|
+
|
|
14
|
+
/** The change-row Timeline links the app shell offers, or undefined outside it. */
|
|
15
|
+
export function useTimelineEventLinks(): IssueTimelineLinks | undefined {
|
|
16
|
+
return useContext(TimelineNavigationContext)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// How much of the Timeline around the event the link shows. The range is
|
|
20
|
+
// frozen there, so an event older than the Timeline's default last hour is
|
|
21
|
+
// still in view.
|
|
22
|
+
const EVENT_CONTEXT_MS = 30 * 60 * 1000
|
|
23
|
+
|
|
24
|
+
const HOUR_MS = 60 * 60 * 1000
|
|
25
|
+
// The list's own range choices, narrowest first, at or above its 1h default;
|
|
26
|
+
// past them it offers only 'all'.
|
|
27
|
+
const LIST_RANGES: [TimeRange, number][] = [['1h', HOUR_MS], ['6h', 6 * HOUR_MS], ['24h', 24 * HOUR_MS]]
|
|
28
|
+
|
|
29
|
+
/** The /timeline query that opens target's event: the event id and a frozen
|
|
30
|
+
* range around it, which the scrubber and the swimlane use. A list without a
|
|
31
|
+
* scrubber (a cluster too large for one without a namespace filter) keeps its
|
|
32
|
+
* own range instead, so `time` names the narrowest of its ranges that reaches
|
|
33
|
+
* back to the event. Namespace scope is the caller's (see openTimelineEventIn). */
|
|
34
|
+
export function timelineEventSearch(target: IssueTimelineEventTarget, now = Date.now()): URLSearchParams {
|
|
35
|
+
const params = new URLSearchParams({ event: target.eventId })
|
|
36
|
+
const at = Date.parse(target.timestamp)
|
|
37
|
+
if (Number.isFinite(at)) {
|
|
38
|
+
const to = Math.min(now, at + EVENT_CONTEXT_MS)
|
|
39
|
+
const from = Math.min(at, to) - EVENT_CONTEXT_MS
|
|
40
|
+
params.set('from', String(from))
|
|
41
|
+
params.set('to', String(to))
|
|
42
|
+
params.set('time', LIST_RANGES.find(([, ms]) => ms >= now - from)?.[0] ?? 'all')
|
|
43
|
+
}
|
|
44
|
+
return params
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** What opening the Timeline in a namespace scope needs from the app shell. */
|
|
48
|
+
export interface TimelineScopeControls {
|
|
49
|
+
/** The namespaces the app is scoped to now; empty is all. */
|
|
50
|
+
currentNamespaces: string[]
|
|
51
|
+
/** The cache itself is scoped to namespaces (--namespace-scope), so the
|
|
52
|
+
* view can't widen to all of them. */
|
|
53
|
+
cacheScoped: boolean
|
|
54
|
+
/** The app's own scope state. */
|
|
55
|
+
setNamespaces: (namespaces: string[]) => void
|
|
56
|
+
/** Records the pick with the server. It can fail (Radar Hub's proxy passes
|
|
57
|
+
* GET only), so nothing waits on it. */
|
|
58
|
+
requestNamespaces: (namespaces: string[]) => void
|
|
59
|
+
navigate: (search: URLSearchParams) => void
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Whether the Timeline can show target's event: a cluster-scoped event shows
|
|
63
|
+
* only with no namespace filter, which a namespace-scoped cache can't drop. */
|
|
64
|
+
export function canOpenTimelineEvent(target: IssueTimelineEventTarget, cacheScoped: boolean): boolean {
|
|
65
|
+
return Boolean(target.namespace) || !cacheScoped
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Opens the Timeline on target's event in the event's namespace, or in all
|
|
69
|
+
* namespaces for a cluster-scoped event. Scope state and URL move together,
|
|
70
|
+
* as the Timeline's own namespace prompt does: the URL-write effect would
|
|
71
|
+
* otherwise restore the previous scope over the destination's `namespaces`
|
|
72
|
+
* while the URL-read effect applies it, and the two would alternate. The
|
|
73
|
+
* server's pick is requested alongside, never awaited. Only a Radar that
|
|
74
|
+
* reports change event ids gets here, and such a Radar never applies a
|
|
75
|
+
* stored pick to a read that names no namespace. */
|
|
76
|
+
export function openTimelineEventIn(target: IssueTimelineEventTarget, controls: TimelineScopeControls, now = Date.now()) {
|
|
77
|
+
const params = timelineEventSearch(target, now)
|
|
78
|
+
const scope = target.namespace ? [target.namespace] : []
|
|
79
|
+
if (target.namespace) params.set('namespaces', target.namespace)
|
|
80
|
+
const unchanged = scope.length === controls.currentNamespaces.length && scope.every((ns, i) => ns === controls.currentNamespaces[i])
|
|
81
|
+
if (!unchanged) {
|
|
82
|
+
controls.setNamespaces(scope)
|
|
83
|
+
controls.requestNamespaces(scope)
|
|
84
|
+
}
|
|
85
|
+
controls.navigate(params)
|
|
86
|
+
}
|
|
@@ -165,6 +165,8 @@ export function useNamespacedCapabilities(namespace: string | undefined) {
|
|
|
165
165
|
// the global value is not an answer for this namespace.
|
|
166
166
|
const namespaceUnknown = Boolean(namespace && !nsCaps && (isPending || error))
|
|
167
167
|
return useMemo(() => ({
|
|
168
|
+
canOpenEphemeralTerminal: !error && nsCaps?.podExecUID === true,
|
|
169
|
+
podDebugImage: nsCaps?.podDebug ? nsCaps.podDebugImage : undefined,
|
|
168
170
|
canExec: nsCaps?.exec ?? globalCaps.exec,
|
|
169
171
|
canViewLogs: nsCaps?.logs ?? globalCaps.logs,
|
|
170
172
|
canPortForward: nsCaps?.portForward ?? globalCaps.portForward,
|
|
@@ -173,5 +175,5 @@ export function useNamespacedCapabilities(namespace: string | undefined) {
|
|
|
173
175
|
workloadWritesPending: Boolean(namespace && isPending),
|
|
174
176
|
helmWriteUnknown: namespaceUnknown,
|
|
175
177
|
logsUnknown: namespaceUnknown,
|
|
176
|
-
}), [globalCaps.exec, globalCaps.logs, globalCaps.portForward, globalCaps.helmWrite, globalCaps.workloadWrites, isPending, namespace, nsCaps, namespaceUnknown])
|
|
178
|
+
}), [error, globalCaps.exec, globalCaps.logs, globalCaps.portForward, globalCaps.helmWrite, globalCaps.workloadWrites, isPending, namespace, nsCaps, namespaceUnknown])
|
|
177
179
|
}
|