@skyhook-io/radar-app 1.21.6 → 1.21.8
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 +31 -4
- 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 +582 -114
- 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/NamespaceSwitcher.tsx +6 -2
- package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
- package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
- package/src/components/applications/ApplicationsView.tsx +127 -173
- package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
- package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
- 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/HomeView.tsx +9 -1
- package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
- package/src/components/home/mcpToolCatalog.ts +1 -0
- package/src/components/issues/IssuesPane.render.test.tsx +78 -2
- package/src/components/issues/IssuesPane.tsx +49 -6
- 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/FormSaveActions.tsx +6 -2
- package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
- package/src/components/settings/MetricsBackendSwitch.tsx +165 -0
- package/src/components/settings/OpenObserveSetup.test.tsx +384 -0
- package/src/components/settings/OpenObserveSetup.tsx +328 -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 +103 -16
- package/src/components/workspace/WorkspaceConditions.tsx +56 -0
- package/src/components/workspace/layout.test.tsx +20 -0
- package/src/components/workspace/layout.tsx +1 -1
- package/src/context/TimelineNavigation.test.ts +59 -0
- package/src/context/TimelineNavigation.tsx +86 -0
- package/src/contexts/CapabilitiesContext.tsx +5 -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/utils/page-links.ts +15 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
|
@@ -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,10 @@ import {
|
|
|
27
28
|
isRolloutKind,
|
|
28
29
|
canSetWorkloadImages,
|
|
29
30
|
canPauseDeployment,
|
|
31
|
+
canSubmitWorkflowTemplate,
|
|
32
|
+
type WorkflowTemplateSubmission,
|
|
33
|
+
canSuspendCronJob,
|
|
34
|
+
canTriggerCronJob,
|
|
30
35
|
isCoreBatchJob,
|
|
31
36
|
type SetImageOwnership,
|
|
32
37
|
SET_IMAGE_WRITES,
|
|
@@ -68,6 +73,7 @@ import {
|
|
|
68
73
|
useTriggerCronJob,
|
|
69
74
|
useSuspendCronJob,
|
|
70
75
|
useResumeCronJob,
|
|
76
|
+
useSubmitWorkflowTemplate,
|
|
71
77
|
useRestartWorkload,
|
|
72
78
|
usePauseDeployment,
|
|
73
79
|
useResumeDeployment,
|
|
@@ -85,6 +91,7 @@ import {
|
|
|
85
91
|
useFluxSuspend,
|
|
86
92
|
useFluxResume,
|
|
87
93
|
useArgoSync,
|
|
94
|
+
useGitOpsActionCapabilities,
|
|
88
95
|
useArgoRefresh,
|
|
89
96
|
useArgoSuspend,
|
|
90
97
|
useArgoResume,
|
|
@@ -105,20 +112,24 @@ import { TIME_RANGES, PrometheusCharts, isPrometheusSupported } from '../resourc
|
|
|
105
112
|
import { RightsizingStrip } from '../resource/RightsizingStrip'
|
|
106
113
|
import { PrometheusChartsGrid } from '../resource/PrometheusChartsGrid'
|
|
107
114
|
import { DatadogSetupHint, DatadogWorkloadCharts, useDatadogWorkloadCharts, WorkloadCostRightsizing } from '../resource/DatadogWorkloadCharts'
|
|
115
|
+
import { PodDebugAction, usePodDetailAccess, type PodDebugTarget } from '../resources/PodDebugAction'
|
|
108
116
|
import { useNavCustomization } from '../../context/NavCustomization'
|
|
109
117
|
import { RestartEventLane } from '../resource/RestartChart'
|
|
110
118
|
import { WorkloadCostTab } from '../cost/WorkloadCostTab'
|
|
111
119
|
import { isOpenCostWorkloadKind } from '../cost/kinds'
|
|
112
120
|
import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
|
|
113
121
|
import { useTrafficAvailable } from '../../api/traffic'
|
|
122
|
+
import { useIssueExpansion, useIssueRowNotes } from '../issues/useIssueExpansion'
|
|
114
123
|
import { isNotFoundError, useResourceAudit, useResourceIssues, useSubjectIssues, useRadarFeature, useTrace, fetchTraceWithProbes, fetchInClusterCapability, runInClusterMerged } from '../../api/client'
|
|
115
124
|
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'
|
|
125
|
+
import { WorkloadLogsTab } from '../dock/WorkloadLogsTab'
|
|
116
126
|
import { WorkloadLogsViewer } from '../logs/WorkloadLogsViewer'
|
|
117
127
|
import { ScheduledWorkloadLogsViewer } from '../logs/ScheduledWorkloadLogsViewer'
|
|
118
128
|
import { LogsViewer } from '../logs/LogsViewer'
|
|
119
129
|
import { MultiPodLogsTab } from '../logs/MultiPodLogsTab'
|
|
120
130
|
import { RayClusterLogsTab } from '../logs/RayClusterLogsTab'
|
|
121
131
|
import { isKubeRayCluster } from '../logs/rayClusterPods'
|
|
132
|
+
import { useWorkflowStopAction } from '../../hooks/useWorkflowStopAction'
|
|
122
133
|
import { BatchExecutionFullscreen } from '../execution/BatchExecutionView'
|
|
123
134
|
import { workloadRunTimelineEvents } from '../execution/batch-timeline'
|
|
124
135
|
import {
|
|
@@ -151,11 +162,11 @@ import { recordUsageEvent } from '../../api/usage-data'
|
|
|
151
162
|
import { issueResourceOpener } from './issueResourceOpener'
|
|
152
163
|
import { isVeleroBackupKind } from '../velero/routes'
|
|
153
164
|
|
|
154
|
-
type TabType =
|
|
165
|
+
type TabType = WorkloadDetailTab
|
|
155
166
|
|
|
156
167
|
// The usage-report view a tab counts under. Timeline holds the resource's
|
|
157
168
|
// events (it replaced the Events tab), so it counts as panel:events.
|
|
158
|
-
const PANEL_USAGE_VIEWS: Readonly<Partial<Record<TabType
|
|
169
|
+
const PANEL_USAGE_VIEWS: Readonly<Partial<Record<TabType, string>>> = {
|
|
159
170
|
logs: 'panel:logs',
|
|
160
171
|
yaml: 'panel:yaml',
|
|
161
172
|
metrics: 'panel:metrics',
|
|
@@ -332,6 +343,7 @@ function useActionsBarProps(
|
|
|
332
343
|
group: string | undefined,
|
|
333
344
|
cascadeEnabled: boolean,
|
|
334
345
|
nodeUID: string,
|
|
346
|
+
pod?: PodDebugTarget,
|
|
335
347
|
) {
|
|
336
348
|
const [deletePreviewOpen, setDeletePreviewOpen] = useState(false)
|
|
337
349
|
const { showCopied } = useToast()
|
|
@@ -340,7 +352,9 @@ function useActionsBarProps(
|
|
|
340
352
|
const openLogs = useOpenLogs()
|
|
341
353
|
const openWorkloadLogs = useOpenWorkloadLogs()
|
|
342
354
|
const openNodeTerminal = useOpenNodeTerminal()
|
|
343
|
-
const
|
|
355
|
+
const nsCaps = useNamespacedCapabilities(namespace)
|
|
356
|
+
const { canViewLogs, canPortForward, workloadWrites, workloadWritesPending } = nsCaps
|
|
357
|
+
const { canExec, debugImage, unverifiedReview, debugDenial, reviewStatus } = usePodDetailAccess(pod, nsCaps)
|
|
344
358
|
const queryClient = useQueryClient()
|
|
345
359
|
// Live forward when local+RBAC; otherwise (in-cluster/Cloud) still surface the
|
|
346
360
|
// copy-paste kubectl command. The button picks live vs. copy by deployment mode.
|
|
@@ -359,6 +373,8 @@ function useActionsBarProps(
|
|
|
359
373
|
const triggerCronJobMutation = useTriggerCronJob()
|
|
360
374
|
const suspendCronJobMutation = useSuspendCronJob()
|
|
361
375
|
const resumeCronJobMutation = useResumeCronJob()
|
|
376
|
+
const workflowStop = useWorkflowStopAction(kind, group, namespace)
|
|
377
|
+
const submitWorkflowTemplateMutation = useSubmitWorkflowTemplate()
|
|
362
378
|
|
|
363
379
|
const isRolloutShape = isRolloutKind(kind)
|
|
364
380
|
const isRollout = isRolloutShape && group === 'argoproj.io'
|
|
@@ -373,9 +389,14 @@ function useActionsBarProps(
|
|
|
373
389
|
const canSetImages = isRolloutShape
|
|
374
390
|
? imageUpdatesSupported && isRollout && !rolloutCapabilitiesPending && rolloutCapabilities?.setImage === true
|
|
375
391
|
: !workloadWritesPending && canSetWorkloadImages({ name: kind, group }, workloadWrites, imageUpdatesSupported)
|
|
392
|
+
const { support: replicaSetLogSupport } = useRadarFeature('replicaSetLogs')
|
|
393
|
+
const isAppsReplicaSet = kind === 'replicasets' && group === 'apps'
|
|
376
394
|
const { support: deploymentPauseSupport } = useRadarFeature('deploymentPause')
|
|
377
395
|
const canPauseDeployments = !workloadWritesPending &&
|
|
378
396
|
canPauseDeployment({ name: kind, group }, workloadWrites, deploymentPauseSupport === 'supported')
|
|
397
|
+
const cronJobPermissionsReady = kind === 'cronjobs' && group === 'batch' && !workloadWritesPending
|
|
398
|
+
const allowCronJobTrigger = cronJobPermissionsReady && canTriggerCronJob(workloadWrites)
|
|
399
|
+
const allowCronJobSuspend = cronJobPermissionsReady && canSuspendCronJob(workloadWrites)
|
|
379
400
|
const loadImages = useCallback(
|
|
380
401
|
(params: { kind: string; namespace: string; name: string }) =>
|
|
381
402
|
queryClient.fetchQuery({
|
|
@@ -396,6 +417,7 @@ function useActionsBarProps(
|
|
|
396
417
|
const fluxSuspendMutation = useFluxSuspend()
|
|
397
418
|
const fluxResumeMutation = useFluxResume()
|
|
398
419
|
|
|
420
|
+
const { disabledReasons: gitOpsActionDisabledReasons } = useGitOpsActionCapabilities(kind, group, namespace, name)
|
|
399
421
|
const argoSyncMutation = useArgoSync()
|
|
400
422
|
const argoRefreshMutation = useArgoRefresh()
|
|
401
423
|
const argoSuspendMutation = useArgoSuspend()
|
|
@@ -403,6 +425,10 @@ function useActionsBarProps(
|
|
|
403
425
|
const { upgrade: argoResumeUpgrade, blockedReason: argoResumeBlockedReason } = useRadarFeature('argoAutoSyncEnable')
|
|
404
426
|
const { support: argoInheritanceSupport } = useRadarFeature('argoSyncInheritance')
|
|
405
427
|
const { support: cronJobJobNameSupport } = useRadarFeature('cronJobTriggerJobName')
|
|
428
|
+
const { support: workflowTemplateSubmitSupport, upgrade: workflowTemplateSubmitUpgrade } = useRadarFeature('workflowTemplateSubmit')
|
|
429
|
+
const isArgoWorkflowTemplate = kind === 'workflowtemplates' && group === 'argoproj.io'
|
|
430
|
+
const canSubmitTemplates = !workloadWritesPending &&
|
|
431
|
+
canSubmitWorkflowTemplate({ name: kind, group }, workloadWrites, workflowTemplateSubmitSupport === 'supported')
|
|
406
432
|
|
|
407
433
|
const {
|
|
408
434
|
data: cascadePreview,
|
|
@@ -430,8 +456,11 @@ function useActionsBarProps(
|
|
|
430
456
|
canViewLogs,
|
|
431
457
|
canPortForward: showPortForward,
|
|
432
458
|
onOpenTerminal: openTerminal,
|
|
459
|
+
podDebugAction: pod && <PodDebugAction key={pod.metadata.uid} pod={pod} defaultImage={debugImage} unverifiedReview={unverifiedReview} debugDenial={debugDenial} reviewStatus={reviewStatus} />,
|
|
433
460
|
onOpenLogs: openLogs,
|
|
434
461
|
onOpenWorkloadLogs: openWorkloadLogs,
|
|
462
|
+
replicaSetLogs: isAppsReplicaSet && replicaSetLogSupport === 'supported',
|
|
463
|
+
replicaSetLogTab: isAppsReplicaSet && replicaSetLogSupport !== 'unsupported',
|
|
435
464
|
onOpenNodeTerminal: openNodeTerminal,
|
|
436
465
|
onCopyCommand: (text: string, message: string, event: React.MouseEvent) =>
|
|
437
466
|
showCopied(text, message, event),
|
|
@@ -501,16 +530,23 @@ function useActionsBarProps(
|
|
|
501
530
|
rolloutDialogPromote.mutateAsync({ action: 'promote-full', ...params })
|
|
502
531
|
: undefined,
|
|
503
532
|
// mutateAsync, not mutate: the Job name dialog stays open when this rejects.
|
|
504
|
-
onTriggerCronJob:
|
|
505
|
-
triggerCronJobMutation.mutateAsync(params),
|
|
533
|
+
onTriggerCronJob: allowCronJobTrigger ? triggerCronJobMutation.mutateAsync : undefined,
|
|
506
534
|
isTriggeringCronJob: triggerCronJobMutation.isPending,
|
|
507
535
|
cronJobTriggerDialog: cronJobJobNameSupport === 'supported',
|
|
508
|
-
onSuspendCronJob:
|
|
509
|
-
suspendCronJobMutation.mutate(params),
|
|
536
|
+
onSuspendCronJob: allowCronJobSuspend ? suspendCronJobMutation.mutate : undefined,
|
|
510
537
|
isSuspendingCronJob: suspendCronJobMutation.isPending,
|
|
511
|
-
onResumeCronJob:
|
|
512
|
-
resumeCronJobMutation.mutate(params),
|
|
538
|
+
onResumeCronJob: allowCronJobSuspend ? resumeCronJobMutation.mutate : undefined,
|
|
513
539
|
isResumingCronJob: resumeCronJobMutation.isPending,
|
|
540
|
+
// mutateAsync, not mutate: the submit dialog stays open when this rejects.
|
|
541
|
+
onSubmitWorkflowTemplate: canSubmitTemplates
|
|
542
|
+
? (submission: WorkflowTemplateSubmission) => submitWorkflowTemplateMutation.mutateAsync(submission)
|
|
543
|
+
: undefined,
|
|
544
|
+
isSubmittingWorkflowTemplate: submitWorkflowTemplateMutation.isPending,
|
|
545
|
+
// Only a Radar known to lack the endpoint gets the upgrade note; a failed
|
|
546
|
+
// capabilities probe is not evidence of an old Radar.
|
|
547
|
+
workflowTemplateSubmitUpgrade: isArgoWorkflowTemplate && workflowTemplateSubmitSupport === 'unsupported' ? workflowTemplateSubmitUpgrade : null,
|
|
548
|
+
gitOpsActionDisabledReasons,
|
|
549
|
+
...workflowStop,
|
|
514
550
|
onFluxReconcile: (params: Parameters<typeof fluxReconcileMutation.mutate>[0]) =>
|
|
515
551
|
fluxReconcileMutation.mutate(params),
|
|
516
552
|
isFluxReconciling: fluxReconcileMutation.isPending,
|
|
@@ -596,8 +632,8 @@ export function WorkloadView({
|
|
|
596
632
|
// recount the same open tab: the drawer mounts hidden WorkloadView layers
|
|
597
633
|
// for expand-on-hover and crossfades.
|
|
598
634
|
const handleTabChange = useCallback(
|
|
599
|
-
(tab: TabType
|
|
600
|
-
const panel = PANEL_USAGE_VIEWS[tab]
|
|
635
|
+
(tab: TabType, opts?: { replace?: boolean }) => {
|
|
636
|
+
const panel = Object.hasOwn(PANEL_USAGE_VIEWS, tab) ? PANEL_USAGE_VIEWS[tab] : undefined
|
|
601
637
|
if (panel && tab !== migratedTab) recordUsageEvent({ type: 'view', name: panel })
|
|
602
638
|
const params = new URLSearchParams(searchParams)
|
|
603
639
|
if (tab === 'overview') {
|
|
@@ -632,9 +668,12 @@ export function WorkloadView({
|
|
|
632
668
|
const {
|
|
633
669
|
data: resourceResponse,
|
|
634
670
|
isLoading: resourceLoading,
|
|
671
|
+
isFetching: resourceFetching,
|
|
635
672
|
error: resourceError,
|
|
636
673
|
refetch: refetchResource,
|
|
637
|
-
} = useResourceWithRelationships<any>(apiKind, namespace, name, rest.group
|
|
674
|
+
} = useResourceWithRelationships<any>(apiKind, namespace, name, rest.group, {
|
|
675
|
+
pollPendingOwnership: rest.active !== false,
|
|
676
|
+
})
|
|
638
677
|
const resource = resourceResponse?.resource
|
|
639
678
|
const relationships = resourceResponse?.relationships
|
|
640
679
|
useRefreshRevisionsOnNewRollout(
|
|
@@ -686,6 +725,10 @@ export function WorkloadView({
|
|
|
686
725
|
await Promise.all([
|
|
687
726
|
refetchResource(),
|
|
688
727
|
onRefresh?.(),
|
|
728
|
+
...(apiKind === 'pods' && !effectiveGroup && resource?.metadata?.uid ? [
|
|
729
|
+
queryClient.invalidateQueries({queryKey: ['capabilities', namespace], exact: true}),
|
|
730
|
+
queryClient.invalidateQueries({queryKey: podDebugAccessKey(namespace, name, resource.metadata.uid)}),
|
|
731
|
+
] : []),
|
|
689
732
|
...(apiKind === 'rayjobs' && effectiveGroup === 'ray.io' ? [
|
|
690
733
|
queryClient.refetchQueries({ queryKey: ['resource', 'jobs', namespace, name, 'batch'], type: 'active' }),
|
|
691
734
|
...(resource?.spec?.clusterSelector?.['ray.io/cluster'] ? [queryClient.refetchQueries({ queryKey: ['resource', 'rayclusters', namespace, resource.spec.clusterSelector['ray.io/cluster'], 'ray.io'], type: 'active' })] : []),
|
|
@@ -699,7 +742,7 @@ export function WorkloadView({
|
|
|
699
742
|
...(apiKind === 'rayclusters' ? { type: 'active' as const } : {}),
|
|
700
743
|
}),
|
|
701
744
|
])
|
|
702
|
-
}, [apiKind, effectiveGroup, name, namespace, queryClient, refetchResource, resource?.spec?.clusterSelector, onRefresh])
|
|
745
|
+
}, [apiKind, effectiveGroup, name, namespace, queryClient, refetchResource, resource?.metadata?.uid, resource?.spec?.clusterSelector, onRefresh])
|
|
703
746
|
const podWorkloadOwner = useMemo(
|
|
704
747
|
() => podWorkloadOwnerFromRelationships(apiKind, namespace, relationships, resource),
|
|
705
748
|
[apiKind, namespace, relationships, resource],
|
|
@@ -893,6 +936,7 @@ export function WorkloadView({
|
|
|
893
936
|
effectiveGroup,
|
|
894
937
|
!resourceLoading && Boolean(resource),
|
|
895
938
|
apiKind === 'nodes' && !effectiveGroup ? resource?.metadata?.uid ?? '' : '',
|
|
939
|
+
apiKind === 'pods' && resource?.apiVersion === 'v1' && resource?.kind === 'Pod' ? resource : undefined,
|
|
896
940
|
)
|
|
897
941
|
const desktopDownload = useDesktopDownload()
|
|
898
942
|
|
|
@@ -913,6 +957,11 @@ export function WorkloadView({
|
|
|
913
957
|
rest.active !== false && !useReportCoverage && !isNotFoundError(resourceError), issueObservation)
|
|
914
958
|
const subjectIssues = useSubjectIssues(useReportCoverage ? { kind: isCoreNode ? 'Node' : 'CronJob', group: isCoreNode ? '' : 'batch', namespace, name, uid: resource?.metadata?.uid } : null, useReportCoverage && Boolean(resource))
|
|
915
959
|
const liveIssues = useReportCoverage ? subjectIssues.data?.issues : ordinaryIssues.data
|
|
960
|
+
const issueExpansion = useIssueExpansion(() => {
|
|
961
|
+
if (useReportCoverage) void subjectIssues.refetch()
|
|
962
|
+
else void ordinaryIssues.refetch()
|
|
963
|
+
})
|
|
964
|
+
const issueRowNotes = useIssueRowNotes()
|
|
916
965
|
const issuesPending = useReportCoverage ? subjectIssues.isPending : ordinaryIssues.isPending
|
|
917
966
|
const schedulingEvidence = isCronJob && subjectIssues.data?.scheduling_report?.uid === resource?.metadata?.uid ? subjectIssues.data?.scheduling_report : undefined
|
|
918
967
|
const certificateEvidence = isCoreNode && subjectIssues.data?.node_certificate_report?.uid === resource?.metadata?.uid ? subjectIssues.data?.node_certificate_report : undefined
|
|
@@ -1151,12 +1200,38 @@ export function WorkloadView({
|
|
|
1151
1200
|
imageOwnerVerified,
|
|
1152
1201
|
imageSelection,
|
|
1153
1202
|
])
|
|
1203
|
+
// A submitted run opens as a Workflow, as Argo's UI does: its full page from
|
|
1204
|
+
// the full page (the same run view, with the Workflow's own actions), and the
|
|
1205
|
+
// resource drawer from the drawer.
|
|
1206
|
+
const viewIdentity = `${apiKind}/${namespace}/${name}`
|
|
1207
|
+
const currentViewIdentity = useRef(viewIdentity)
|
|
1208
|
+
currentViewIdentity.current = viewIdentity
|
|
1209
|
+
useEffect(() => () => { currentViewIdentity.current = '' }, [])
|
|
1210
|
+
const navigateToResource = rest.onNavigateToResource
|
|
1211
|
+
const submitWorkflowTemplate = baseActionsBarProps.onSubmitWorkflowTemplate
|
|
1212
|
+
const submitAndOpenRun = useMemo(
|
|
1213
|
+
() => submitWorkflowTemplate
|
|
1214
|
+
? async (submission: WorkflowTemplateSubmission) => {
|
|
1215
|
+
const submittedFrom = currentViewIdentity.current
|
|
1216
|
+
const run = await submitWorkflowTemplate(submission)
|
|
1217
|
+
// The user moved on while the request ran: don't pull them back.
|
|
1218
|
+
if (currentViewIdentity.current === submittedFrom) {
|
|
1219
|
+
const target = { kind: 'workflows', namespace: run.namespace, name: run.name, group: 'argoproj.io' }
|
|
1220
|
+
if (expanded) navigateRouter(buildWorkloadPath(target))
|
|
1221
|
+
else navigateToResource?.(target)
|
|
1222
|
+
}
|
|
1223
|
+
return run
|
|
1224
|
+
}
|
|
1225
|
+
: undefined,
|
|
1226
|
+
[expanded, navigateRouter, navigateToResource, submitWorkflowTemplate],
|
|
1227
|
+
)
|
|
1154
1228
|
const actionsBarProps = useMemo(
|
|
1155
1229
|
() => ({
|
|
1156
1230
|
...baseActionsBarProps,
|
|
1157
1231
|
onLoadImages: baseActionsBarProps.onLoadImages
|
|
1158
1232
|
? loadImagesWithTargetOwnership
|
|
1159
1233
|
: undefined,
|
|
1234
|
+
onSubmitWorkflowTemplate: submitAndOpenRun,
|
|
1160
1235
|
onCompareTo,
|
|
1161
1236
|
onCompareAcrossClusters,
|
|
1162
1237
|
imageOwnership,
|
|
@@ -1164,6 +1239,7 @@ export function WorkloadView({
|
|
|
1164
1239
|
[
|
|
1165
1240
|
baseActionsBarProps,
|
|
1166
1241
|
loadImagesWithTargetOwnership,
|
|
1242
|
+
submitAndOpenRun,
|
|
1167
1243
|
imageOwnership,
|
|
1168
1244
|
onCompareTo,
|
|
1169
1245
|
onCompareAcrossClusters,
|
|
@@ -1271,6 +1347,7 @@ export function WorkloadView({
|
|
|
1271
1347
|
renderServicePortAction={renderServicePortAction}
|
|
1272
1348
|
renderServicePortPanel={renderServicePortPanel}
|
|
1273
1349
|
isLoading={resourceLoading}
|
|
1350
|
+
isFetching={resourceFetching}
|
|
1274
1351
|
resourceError={resourceError}
|
|
1275
1352
|
refetch={refetchResourceAndRuns}
|
|
1276
1353
|
// Timeline
|
|
@@ -1306,11 +1383,13 @@ export function WorkloadView({
|
|
|
1306
1383
|
yamlSchemaLoader={features?.yamlSchemas ? fetchYamlSchemas : undefined}
|
|
1307
1384
|
// Tab state (URL-synced)
|
|
1308
1385
|
activeTab={migratedTab}
|
|
1386
|
+
extraTabsComplete={migratedTab === 'deploys' ? true : undefined}
|
|
1309
1387
|
onTabChange={handleTabChange}
|
|
1310
1388
|
// Render props
|
|
1311
1389
|
renderLogsTab={(props) => (
|
|
1312
1390
|
<LogsTabContent
|
|
1313
1391
|
{...props}
|
|
1392
|
+
replicaSetLogs={baseActionsBarProps.replicaSetLogs || (baseActionsBarProps.replicaSetLogTab && props.pods.length === 0)}
|
|
1314
1393
|
resourceLoading={resourceLoading}
|
|
1315
1394
|
resourceError={resourceError}
|
|
1316
1395
|
group={effectiveGroup}
|
|
@@ -1459,6 +1538,11 @@ export function WorkloadView({
|
|
|
1459
1538
|
compact={!expanded}
|
|
1460
1539
|
subjectResource={{ kind: apiKind, namespace, name, group: identityGroup }}
|
|
1461
1540
|
onResourceClick={openIssueResource}
|
|
1541
|
+
onOpenIssueChange={issueExpansion.onOpenIssueChange}
|
|
1542
|
+
expandedIssue={issueExpansion.expandedIssue}
|
|
1543
|
+
timelineLinks={issueExpansion.timelineLinks}
|
|
1544
|
+
rowChanges={issueRowNotes.rowChanges}
|
|
1545
|
+
onVisibleIssuesChange={issueRowNotes.onVisibleIssuesChange}
|
|
1462
1546
|
/>
|
|
1463
1547
|
</div>
|
|
1464
1548
|
)}
|
|
@@ -1614,6 +1698,7 @@ const SCHEDULED_LOG_KINDS = new Set([
|
|
|
1614
1698
|
])
|
|
1615
1699
|
|
|
1616
1700
|
function LogsTabContent({
|
|
1701
|
+
replicaSetLogs,
|
|
1617
1702
|
kind,
|
|
1618
1703
|
apiKind,
|
|
1619
1704
|
group,
|
|
@@ -1631,6 +1716,7 @@ function LogsTabContent({
|
|
|
1631
1716
|
resourceLoading,
|
|
1632
1717
|
resourceError,
|
|
1633
1718
|
}: {
|
|
1719
|
+
replicaSetLogs: boolean
|
|
1634
1720
|
kind: string
|
|
1635
1721
|
apiKind: string
|
|
1636
1722
|
group?: string
|
|
@@ -1682,7 +1768,8 @@ function LogsTabContent({
|
|
|
1682
1768
|
)
|
|
1683
1769
|
}
|
|
1684
1770
|
|
|
1685
|
-
|
|
1771
|
+
if (replicaSetLogs) return <WorkloadLogsTab namespace={namespace} workloadKind={apiKind} workloadName={name} />
|
|
1772
|
+
|
|
1686
1773
|
if (WORKLOAD_LOG_KINDS.has(kind) && (kind !== 'Job' || isCoreBatchJob(apiKind, group))) {
|
|
1687
1774
|
return (
|
|
1688
1775
|
<div className="h-full">
|
|
@@ -1709,7 +1796,7 @@ function LogsTabContent({
|
|
|
1709
1796
|
)
|
|
1710
1797
|
}
|
|
1711
1798
|
|
|
1712
|
-
// Other
|
|
1799
|
+
// Other resources with associated Pods offer their individual logs.
|
|
1713
1800
|
return (
|
|
1714
1801
|
<MultiPodLogsTab
|
|
1715
1802
|
pods={pods}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Badge, FactGrid, FactRow, FoldSection, Tooltip, formatAge, WorkspaceCard } from '@skyhook-io/k8s-ui'
|
|
2
|
+
|
|
3
|
+
export function WorkspaceConditions({
|
|
4
|
+
conditions,
|
|
5
|
+
title = 'Conditions',
|
|
6
|
+
className,
|
|
7
|
+
sourcePath = 'status.conditions',
|
|
8
|
+
emptyMessage = `No ${sourcePath} reported.`,
|
|
9
|
+
framed = true,
|
|
10
|
+
}: {
|
|
11
|
+
title?: string
|
|
12
|
+
className?: string
|
|
13
|
+
framed?: boolean
|
|
14
|
+
sourcePath?: string
|
|
15
|
+
emptyMessage?: string
|
|
16
|
+
conditions: { type: string; status: string; reason?: string; message?: string; lastTransitionTime?: string }[]
|
|
17
|
+
}) {
|
|
18
|
+
const content = (
|
|
19
|
+
<FoldSection
|
|
20
|
+
title={title}
|
|
21
|
+
summary={conditions.length > 0 ? `${conditions.length} reported · ${sourcePath}` : 'No conditions reported'}
|
|
22
|
+
attention={false}
|
|
23
|
+
>
|
|
24
|
+
<FactGrid>
|
|
25
|
+
{conditions.map((c) => (
|
|
26
|
+
<FactRow
|
|
27
|
+
key={c.type}
|
|
28
|
+
label={
|
|
29
|
+
<span className="inline-flex flex-wrap items-center gap-2">
|
|
30
|
+
{c.type}
|
|
31
|
+
<Badge severity="neutral" size="sm">
|
|
32
|
+
{c.status}
|
|
33
|
+
</Badge>
|
|
34
|
+
</span>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
<div className="text-xs text-theme-text-secondary">Reason: {c.reason || 'Not reported'}</div>
|
|
38
|
+
<div className="break-words text-xs text-theme-text-secondary">{c.message || 'No message reported'}</div>
|
|
39
|
+
<div className="text-xs text-theme-text-tertiary">
|
|
40
|
+
Last transition:{' '}
|
|
41
|
+
{c.lastTransitionTime ? (
|
|
42
|
+
<Tooltip content={c.lastTransitionTime}>
|
|
43
|
+
<time dateTime={c.lastTransitionTime}>{formatAge(c.lastTransitionTime)} ago</time>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
) : (
|
|
46
|
+
'Not reported'
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
</FactRow>
|
|
50
|
+
))}
|
|
51
|
+
</FactGrid>
|
|
52
|
+
{conditions.length === 0 && <p className="text-sm text-theme-text-tertiary">{emptyMessage}</p>}
|
|
53
|
+
</FoldSection>
|
|
54
|
+
)
|
|
55
|
+
return <WorkspaceCard framed={framed} className={className}>{content}</WorkspaceCard>
|
|
56
|
+
}
|
|
@@ -3,6 +3,7 @@ import { act } from 'react'
|
|
|
3
3
|
import { createRoot } from 'react-dom/client'
|
|
4
4
|
import { expect, it, vi } from 'vitest'
|
|
5
5
|
import { Mono, SectionTable } from './layout'
|
|
6
|
+
import { ROW_HOVER } from './table'
|
|
6
7
|
|
|
7
8
|
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
8
9
|
|
|
@@ -55,3 +56,22 @@ it('opens a row from the keyboard the way a click does, and leaves keys on contr
|
|
|
55
56
|
act(() => root.unmount())
|
|
56
57
|
host.remove()
|
|
57
58
|
})
|
|
59
|
+
|
|
60
|
+
it('applies the row hover style only to rows that open a resource', () => {
|
|
61
|
+
const host = document.createElement('div')
|
|
62
|
+
const root = createRoot(host)
|
|
63
|
+
act(() => root.render(
|
|
64
|
+
<SectionTable
|
|
65
|
+
columns={[{ header: 'Name', cell: (name) => name }]}
|
|
66
|
+
rows={['inspectable', 'static']}
|
|
67
|
+
rowKey={(name) => name}
|
|
68
|
+
rowResource={(name) => name === 'inspectable' ? { kind: 'Pod', namespace: 'default', name } : null}
|
|
69
|
+
onInspect={vi.fn()}
|
|
70
|
+
empty="none"
|
|
71
|
+
/>,
|
|
72
|
+
))
|
|
73
|
+
const [inspectable, staticRow] = host.querySelectorAll('tbody tr')
|
|
74
|
+
expect(inspectable.className).toContain(ROW_HOVER)
|
|
75
|
+
expect(staticRow.className).not.toContain(ROW_HOVER)
|
|
76
|
+
act(() => root.unmount())
|
|
77
|
+
})
|
|
@@ -182,7 +182,7 @@ export function SectionTable<T>({
|
|
|
182
182
|
e.preventDefault()
|
|
183
183
|
open()
|
|
184
184
|
} : undefined}
|
|
185
|
-
className={clsx(open && 'cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent', ROW_HOVER, active && 'selection')}
|
|
185
|
+
className={clsx(open && ['cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent', ROW_HOVER], active && 'selection')}
|
|
186
186
|
aria-selected={res ? active : undefined}
|
|
187
187
|
>
|
|
188
188
|
{columns.map((c, i) => (
|
|
@@ -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
|
+
})
|