@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,102 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
7
|
+
import type { GitOpsRow } from '@skyhook-io/k8s-ui'
|
|
8
|
+
import type { ArgoSyncOpts } from '@skyhook-io/k8s-ui/components/gitops/SyncOptionsDialog'
|
|
9
|
+
import { GitOpsView } from './GitOpsView'
|
|
10
|
+
|
|
11
|
+
const harness = vi.hoisted(() => ({ sync: vi.fn(), confirm: undefined as undefined | ((opts: ArgoSyncOpts) => void) }))
|
|
12
|
+
const row = { id: 'demo', kindName: 'applications', group: 'argoproj.io', namespace: 'argocd', name: 'demo', tool: 'argo' } as GitOpsRow
|
|
13
|
+
|
|
14
|
+
vi.mock('@skyhook-io/k8s-ui', async importOriginal => {
|
|
15
|
+
const actual = await importOriginal<typeof import('@skyhook-io/k8s-ui')>()
|
|
16
|
+
return {
|
|
17
|
+
...actual,
|
|
18
|
+
GitOpsTableView: ({ onRowAction }: { onRowAction: (row: GitOpsRow, action: 'sync') => void }) => <button onClick={() => onRowAction(row, 'sync')}>Open sync</button>,
|
|
19
|
+
SyncOptionsDialog: (props: Parameters<typeof actual.SyncOptionsDialog>[0]) => {
|
|
20
|
+
harness.confirm = props.onConfirm
|
|
21
|
+
return <actual.SyncOptionsDialog {...props} />
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
vi.mock('../../api/client', async importOriginal => {
|
|
26
|
+
const actual = await importOriginal<typeof import('../../api/client')>()
|
|
27
|
+
const idle = () => ({ mutate: vi.fn(), isPending: false })
|
|
28
|
+
return {
|
|
29
|
+
...actual,
|
|
30
|
+
useArgoSync: () => ({ mutate: harness.sync, reset: vi.fn(), isPending: false }),
|
|
31
|
+
useArgoRefresh: idle, useArgoTerminate: idle, useArgoSuspend: idle, useArgoResume: idle,
|
|
32
|
+
useFluxReconcile: idle, useFluxSyncWithSource: idle, useFluxSuspend: idle, useFluxResume: idle,
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
vi.mock('../../api/apiResources', async (importOriginal) => ({
|
|
36
|
+
...(await importOriginal<typeof import('../../api/apiResources')>()),
|
|
37
|
+
useAPIResources: () => ({ data: [], isLoading: false }),
|
|
38
|
+
}))
|
|
39
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
40
|
+
vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
|
|
41
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
42
|
+
let client: QueryClient
|
|
43
|
+
let host: HTMLDivElement
|
|
44
|
+
let root: ReturnType<typeof createRoot>
|
|
45
|
+
let allowed: boolean
|
|
46
|
+
const requests = vi.fn(async (input: RequestInfo | URL) => {
|
|
47
|
+
if (String(input).includes('/gitops/capabilities/')) {
|
|
48
|
+
return Response.json({ actions: { sync: allowed ? { allowed } : { allowed, denied: [{ verb: 'patch', resource: 'applications', group: 'argoproj.io', namespace: 'argocd', kind: 'Application', name: 'demo' }] } } })
|
|
49
|
+
}
|
|
50
|
+
return Response.json({ counts: {} })
|
|
51
|
+
})
|
|
52
|
+
const flush = async () => { await act(async () => { await new Promise(resolve => setTimeout(resolve, 0)) }) }
|
|
53
|
+
beforeEach(async () => {
|
|
54
|
+
allowed = true
|
|
55
|
+
harness.sync.mockClear()
|
|
56
|
+
requests.mockClear()
|
|
57
|
+
vi.stubGlobal('fetch', requests)
|
|
58
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
59
|
+
client.setQueryData(['capabilities'], { features: { gitopsActionCapabilities: true } })
|
|
60
|
+
client.setQueryData(['gitops-rows-main', [], 0], { coverageStatus: 'complete', rows: [row] })
|
|
61
|
+
host = document.createElement('div')
|
|
62
|
+
document.body.append(host)
|
|
63
|
+
root = createRoot(host)
|
|
64
|
+
await act(async () => root.render(<MemoryRouter><QueryClientProvider client={client}><GitOpsView namespaces={[]} onOpenResource={() => {}} /></QueryClientProvider></MemoryRouter>))
|
|
65
|
+
await flush()
|
|
66
|
+
})
|
|
67
|
+
afterEach(async () => {
|
|
68
|
+
await act(async () => root.unmount())
|
|
69
|
+
client.clear()
|
|
70
|
+
host.remove()
|
|
71
|
+
vi.unstubAllGlobals()
|
|
72
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
73
|
+
})
|
|
74
|
+
it('keeps capabilities active while table Sync is open and blocks a later denial at the button and callback', async () => {
|
|
75
|
+
const count = () => requests.mock.calls.filter(([url]) => String(url).includes('/gitops/capabilities/')).length
|
|
76
|
+
expect(count()).toBe(0)
|
|
77
|
+
await act(async () => host.querySelector<HTMLButtonElement>('button')!.click())
|
|
78
|
+
await flush()
|
|
79
|
+
expect(count()).toBe(1)
|
|
80
|
+
const confirm = () => [...document.querySelectorAll<HTMLButtonElement>('[role="dialog"] button')].find(button => button.textContent === 'Sync now')!
|
|
81
|
+
expect(confirm().disabled).toBe(false)
|
|
82
|
+
allowed = false
|
|
83
|
+
await act(async () => { await client.refetchQueries({ queryKey: ['gitops-action-capabilities'], type: 'active' }) })
|
|
84
|
+
await flush()
|
|
85
|
+
expect(count()).toBe(2)
|
|
86
|
+
expect(confirm().disabled).toBe(true)
|
|
87
|
+
expect(document.querySelector('[role="dialog"]')!.textContent).toContain("Kubernetes denied permission to patch Argo CD Application demo in argocd.")
|
|
88
|
+
await act(async () => harness.confirm!({ prune: false, dryRun: false, force: false, applyOnly: false, syncOptions: [] }))
|
|
89
|
+
expect(harness.sync).not.toHaveBeenCalled()
|
|
90
|
+
const cancel = [...document.querySelectorAll<HTMLButtonElement>('[role="dialog"] button')].find(button => button.textContent === 'Cancel')!
|
|
91
|
+
expect(cancel.disabled).toBe(false)
|
|
92
|
+
await act(async () => cancel.click())
|
|
93
|
+
await act(async () => { await client.refetchQueries({ queryKey: ['gitops-action-capabilities'], type: 'active' }) })
|
|
94
|
+
expect(count()).toBe(2)
|
|
95
|
+
})
|
|
96
|
+
it('submits an allowed table Sync with the selected object', async () => {
|
|
97
|
+
await act(async () => host.querySelector<HTMLButtonElement>('button')!.click())
|
|
98
|
+
await flush()
|
|
99
|
+
const confirm = [...document.querySelectorAll<HTMLButtonElement>('[role="dialog"] button')].find(button => button.textContent === 'Sync now')!
|
|
100
|
+
await act(async () => confirm.click())
|
|
101
|
+
expect(harness.sync).toHaveBeenCalledWith(expect.objectContaining({ namespace: 'argocd', name: 'demo' }), expect.any(Object))
|
|
102
|
+
})
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
import { act } from 'react'
|
|
3
3
|
import { createRoot } from 'react-dom/client'
|
|
4
|
-
import { MemoryRouter } from 'react-router-dom'
|
|
4
|
+
import { MemoryRouter, useNavigate } from 'react-router-dom'
|
|
5
5
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
7
7
|
import { normalizeArgoApplication } from '@skyhook-io/k8s-ui'
|
|
8
8
|
import type { ArgoActionHandlers, GitOpsInsight, GitOpsInsightRef, GitOpsRow, GitOpsRowAction } from '@skyhook-io/k8s-ui'
|
|
9
9
|
import { GitOpsView } from './GitOpsView'
|
|
10
|
+
import { isShownInline } from '../../api/httpErrors'
|
|
11
|
+
import { observeConnectionStatus, resetConnectionBindingForTest } from '../../api/connectionBinding'
|
|
10
12
|
|
|
11
13
|
// The requests the Sync dialog builds, sent by the real useArgoSync and
|
|
12
14
|
// useArgoResourceValidation: only a Radar advertising argoSyncInheritance is
|
|
@@ -29,23 +31,26 @@ vi.mock('@skyhook-io/k8s-ui', async (importOriginal) => {
|
|
|
29
31
|
const actual = await importOriginal<typeof import('@skyhook-io/k8s-ui')>()
|
|
30
32
|
return {
|
|
31
33
|
...actual,
|
|
32
|
-
useToast: () => ({ showError:
|
|
34
|
+
useToast: () => ({ showError: toast.error, showSuccess: vi.fn(), showToast: vi.fn() }),
|
|
33
35
|
GitOpsTableView: (props: { rows: GitOpsRow[]; onRowAction: (row: GitOpsRow, action: GitOpsRowAction) => void }) => (
|
|
34
36
|
<button type="button" onClick={() => props.onRowAction(props.rows[0], 'sync')}>Open sync</button>
|
|
35
37
|
),
|
|
36
|
-
GitOpsDetailLayout: (props: { argo?: ArgoActionHandlers; renderTabBody: (ctx: { tab: 'changes'; fullscreen: boolean }) => React.ReactNode; children?: React.ReactNode }) =>
|
|
37
|
-
|
|
38
|
+
GitOpsDetailLayout: (props: { argo?: ArgoActionHandlers; onRemediate?: (remediation: { kind: 'create-namespace'; target: string }) => void; renderTabBody: (ctx: { tab: 'changes'; fullscreen: boolean }) => React.ReactNode; children?: React.ReactNode }) => {
|
|
39
|
+
const navigate = useNavigate()
|
|
40
|
+
return <div data-resume-settings={JSON.stringify(props.argo?.resumeSettings ?? null)}>
|
|
38
41
|
<button type="button" onClick={() => props.argo?.onSyncRequested()}>Open sync</button>
|
|
42
|
+
<button type="button" onClick={() => navigate('/gitops/detail/applications/argocd/other?apiGroup=argoproj.io')}>Open other Application</button>
|
|
43
|
+
<button type="button" onClick={() => props.onRemediate?.({kind: 'create-namespace', target: 'sandbox'})}>Create namespace and retry</button>
|
|
39
44
|
{props.renderTabBody({ tab: 'changes', fullscreen: false })}
|
|
40
45
|
{props.children}
|
|
41
46
|
</div>
|
|
42
|
-
|
|
47
|
+
},
|
|
43
48
|
GitOpsChangesView: (props: { onSyncResource?: (ref: GitOpsInsightRef) => void }) => (
|
|
44
49
|
<button type="button" onClick={() => props.onSyncResource?.(deployment)}>Open resource sync</button>
|
|
45
50
|
),
|
|
46
51
|
}
|
|
47
52
|
})
|
|
48
|
-
const toast = vi.hoisted(() => ({ success: vi.fn() }))
|
|
53
|
+
const toast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn() }))
|
|
49
54
|
vi.mock('../ui/Toast', async (importOriginal) => ({
|
|
50
55
|
...(await importOriginal<typeof import('../ui/Toast')>()),
|
|
51
56
|
showApiSuccess: toast.success,
|
|
@@ -59,7 +64,7 @@ vi.mock('../../api/client', async (importOriginal) => {
|
|
|
59
64
|
useGitOpsTree: () => ({ data: undefined, isLoading: false, error: null }),
|
|
60
65
|
useGitOpsInsights: () => ({ data: insight, isLoading: false, error: null }),
|
|
61
66
|
useArgoRollback: idle, useArgoRefresh: idle, useArgoTerminate: idle,
|
|
62
|
-
useArgoSuspend: idle, useArgoResume: idle,
|
|
67
|
+
useArgoSuspend: idle, useArgoResume: idle,
|
|
63
68
|
useFluxReconcile: idle, useFluxSyncWithSource: idle, useFluxSuspend: idle, useFluxResume: idle,
|
|
64
69
|
}
|
|
65
70
|
})
|
|
@@ -79,13 +84,28 @@ let client: QueryClient
|
|
|
79
84
|
let host: HTMLDivElement
|
|
80
85
|
let root: ReturnType<typeof createRoot>
|
|
81
86
|
let requests: Array<{ path: string; body: Record<string, unknown> }>
|
|
87
|
+
let syncDenial: { error: string; error_code: string; summary: string } | undefined
|
|
88
|
+
let pendingSyncResponse: Promise<Response> | undefined
|
|
89
|
+
let pendingNamespaceResponse: Promise<Response> | undefined
|
|
82
90
|
|
|
83
91
|
beforeEach(async () => {
|
|
84
92
|
requests = []
|
|
93
|
+
syncDenial = undefined
|
|
94
|
+
pendingSyncResponse = undefined
|
|
95
|
+
pendingNamespaceResponse = undefined
|
|
96
|
+
toast.error.mockClear()
|
|
85
97
|
vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL, init?: RequestInit) => {
|
|
86
98
|
const path = String(input)
|
|
87
99
|
if (init?.method === 'POST') {
|
|
100
|
+
if (path.includes('/resources/apply')) {
|
|
101
|
+
requests.push({ path, body: {} })
|
|
102
|
+
return pendingNamespaceResponse ?? Promise.resolve(Response.json([]))
|
|
103
|
+
}
|
|
88
104
|
requests.push({ path, body: JSON.parse(String(init.body)) })
|
|
105
|
+
if (path.endsWith('/sync') && pendingSyncResponse) return pendingSyncResponse
|
|
106
|
+
if (path.endsWith('/sync') && syncDenial) {
|
|
107
|
+
return Promise.resolve(Response.json(syncDenial, { status: 403 }))
|
|
108
|
+
}
|
|
89
109
|
const answer = path.endsWith('/validate-resource') ? { outcome: 'succeeded', message: 'ok' } : { message: 'Sync initiated' }
|
|
90
110
|
return Promise.resolve(new Response(JSON.stringify(answer), { status: 200, headers: { 'Content-Type': 'application/json' } }))
|
|
91
111
|
}
|
|
@@ -102,6 +122,7 @@ beforeEach(async () => {
|
|
|
102
122
|
afterEach(async () => {
|
|
103
123
|
await act(async () => root.unmount())
|
|
104
124
|
client.clear()
|
|
125
|
+
resetConnectionBindingForTest()
|
|
105
126
|
host.remove()
|
|
106
127
|
document.body.innerHTML = ''
|
|
107
128
|
app.spec.source = {}
|
|
@@ -367,3 +388,70 @@ it.each([
|
|
|
367
388
|
const settings = document.querySelector('[data-resume-settings]')!.getAttribute('data-resume-settings')!
|
|
368
389
|
expect(JSON.parse(settings)).toEqual(expected)
|
|
369
390
|
})
|
|
391
|
+
|
|
392
|
+
it.each([
|
|
393
|
+
'/gitops',
|
|
394
|
+
'/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io',
|
|
395
|
+
])('keeps the failed sync and its original denial in the dialog from %s', async (path) => {
|
|
396
|
+
syncDenial = {
|
|
397
|
+
error: 'admission webhook "change-window" denied the request: frozen',
|
|
398
|
+
error_code: 'admission_denied',
|
|
399
|
+
summary: 'Rejected by admission webhook change-window: frozen',
|
|
400
|
+
}
|
|
401
|
+
await renderView(path)
|
|
402
|
+
await click(button('Open sync'))
|
|
403
|
+
await click(toggle('Prune'))
|
|
404
|
+
await click(button('Sync now'))
|
|
405
|
+
expect(toggle('Prune').checked).toBe(true)
|
|
406
|
+
expect(document.querySelector('[role="dialog"] [role="alert"]')?.textContent).toContain(syncDenial.summary)
|
|
407
|
+
expect(isShownInline(client.getMutationCache().getAll().at(-1)?.state.error)).toBe(true)
|
|
408
|
+
await click(button('Error details'))
|
|
409
|
+
expect(document.querySelector('[role="dialog"] pre')?.textContent).toBe(syncDenial.error)
|
|
410
|
+
await click(button('Cancel'))
|
|
411
|
+
await click(button('Open sync'))
|
|
412
|
+
expect(document.querySelector('[role="dialog"] [role="alert"]')).toBeNull()
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
it('closes a failed sync when the detail page changes Applications', async () => {
|
|
416
|
+
syncDenial = { error: 'denied', error_code: 'admission_denied', summary: 'Change window is closed' }
|
|
417
|
+
await click(button('Open sync'))
|
|
418
|
+
await click(button('Sync now'))
|
|
419
|
+
expect(document.querySelector('[role="dialog"] [role="alert"]')?.textContent).toContain(syncDenial.summary)
|
|
420
|
+
await click(button('Open other Application'))
|
|
421
|
+
const dialog = document.querySelector('[role="dialog"]')
|
|
422
|
+
expect(!dialog || dialog.closest('[inert]')).toBeTruthy()
|
|
423
|
+
await click(button('Open sync'))
|
|
424
|
+
expect(document.querySelector('[role="dialog"]')?.textContent).toContain('argocd/other')
|
|
425
|
+
expect(document.querySelector('[role="dialog"] [role="alert"]')).toBeNull()
|
|
426
|
+
})
|
|
427
|
+
|
|
428
|
+
it('keeps global error reporting for a rejection after leaving the originating Application', async () => {
|
|
429
|
+
let respond!: (response: Response) => void
|
|
430
|
+
pendingSyncResponse = new Promise(resolve => { respond = resolve })
|
|
431
|
+
await click(button('Open sync'))
|
|
432
|
+
await click(button('Sync now'))
|
|
433
|
+
await click(button('Open other Application'))
|
|
434
|
+
await act(async () => respond(Response.json({
|
|
435
|
+
error: 'denied', error_code: 'admission_denied', summary: 'Change window is closed',
|
|
436
|
+
}, { status: 403 })))
|
|
437
|
+
await settle()
|
|
438
|
+
const mutation = client.getMutationCache().getAll().at(-1)
|
|
439
|
+
expect(mutation?.state.status).toBe('error')
|
|
440
|
+
expect(mutation?.options.meta?.errorMessage).toBe('Failed to trigger sync')
|
|
441
|
+
expect(isShownInline(mutation?.state.error)).toBe(false)
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
it('skips automatic Sync if the connection changes after namespace creation starts', async () => {
|
|
445
|
+
let applied!: (response: Response) => void
|
|
446
|
+
pendingNamespaceResponse = new Promise<Response>(resolve => { applied = resolve })
|
|
447
|
+
observeConnectionStatus({ connectionId: 'first-connection' })
|
|
448
|
+
await click(button('Create namespace and retry'))
|
|
449
|
+
expect(requests.map(({ path }) => path)).toEqual([expect.stringContaining('/resources/apply')])
|
|
450
|
+
|
|
451
|
+
observeConnectionStatus({ connectionId: 'next-connection' })
|
|
452
|
+
await act(async () => applied(Response.json([])))
|
|
453
|
+
await settle()
|
|
454
|
+
|
|
455
|
+
expect(requests).toHaveLength(1)
|
|
456
|
+
expect(toast.error).toHaveBeenCalledWith('Created namespace sandbox, but sync failed', expect.stringContaining('cluster connection changed'))
|
|
457
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResourceCoverage } from '@skyhook-io/k8s-ui'
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
3
3
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
4
4
|
import { useQuery } from '@tanstack/react-query'
|
|
5
5
|
import yaml from 'yaml'
|
|
@@ -57,6 +57,8 @@ import {
|
|
|
57
57
|
type GitOpsTreePreset,
|
|
58
58
|
type SelectedResource,
|
|
59
59
|
} from '@skyhook-io/k8s-ui'
|
|
60
|
+
import { GitOpsActionError } from '../../api/httpErrors'
|
|
61
|
+
import { GitOpsPermissionRowActions } from './GitOpsPermissionRowActions'
|
|
60
62
|
import { useToast } from '../ui/Toast'
|
|
61
63
|
import { useContextSwitchFlow } from '../useContextSwitchFlow'
|
|
62
64
|
import { FluxOperatorCard } from './FluxOperatorCard'
|
|
@@ -75,6 +77,7 @@ import {
|
|
|
75
77
|
useArgoRollback,
|
|
76
78
|
useArgoSuspend,
|
|
77
79
|
useArgoSync,
|
|
80
|
+
useGitOpsActionCapabilities,
|
|
78
81
|
useArgoTerminate,
|
|
79
82
|
useFluxReconcile,
|
|
80
83
|
useFluxResume,
|
|
@@ -86,6 +89,8 @@ import {
|
|
|
86
89
|
useResource,
|
|
87
90
|
} from '../../api/client'
|
|
88
91
|
import { useAPIResources, GITOPS_KINDS } from '../../api/apiResources'
|
|
92
|
+
import { getApiBase } from '../../api/config'
|
|
93
|
+
import { connectionHeaderValue } from '../../api/connectionBinding'
|
|
89
94
|
import { combinedListStatus, lowerBound } from '../../api/resourceLists'
|
|
90
95
|
import { useConnection } from '../../context/ConnectionContext'
|
|
91
96
|
import { useRegisterShortcut } from '../../hooks/useKeyboardShortcuts'
|
|
@@ -102,6 +107,15 @@ type ArgoSyncDialogTarget =
|
|
|
102
107
|
| { scope: 'application' }
|
|
103
108
|
| { scope: 'resource'; resource: GitOpsInsightRef }
|
|
104
109
|
|
|
110
|
+
function useActiveSyncDialog<T>(dialog: T | null) {
|
|
111
|
+
const active = useRef<T | null>(null)
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
active.current = dialog
|
|
114
|
+
return () => { active.current = null }
|
|
115
|
+
}, [dialog])
|
|
116
|
+
return active
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
const KIND_BY_NAME = new Map(GITOPS_KINDS.map((k) => [k.name, k]))
|
|
106
120
|
|
|
107
121
|
// Fallback poll for the rows; SSE changes to row kinds refetch them within 15s (App.tsx slow tier).
|
|
@@ -150,7 +164,10 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
150
164
|
const { upgrade: argoResumeUpgrade, blockedReason: argoResumeBlockedReason } = useRadarFeature('argoAutoSyncEnable')
|
|
151
165
|
const { support: argoInheritanceSupport } = useRadarFeature('argoSyncInheritance')
|
|
152
166
|
|
|
153
|
-
const
|
|
167
|
+
const clusterKey = JSON.stringify([getApiBase(), connection.context])
|
|
168
|
+
const [syncSelection, setSyncSelection] = useState<{ rowId: string; clusterKey: string } | null>(null)
|
|
169
|
+
if (syncSelection && syncSelection.clusterKey !== clusterKey) setSyncSelection(null)
|
|
170
|
+
const syncDialogRowId = syncSelection?.clusterKey === clusterKey ? syncSelection.rowId : null
|
|
154
171
|
const [pendingActions, setPendingActions] = useState<Map<string, Set<GitOpsRowAction>>>(new Map())
|
|
155
172
|
|
|
156
173
|
// Mark an action as in-flight (or done) for a given row. Cloning the
|
|
@@ -250,8 +267,12 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
250
267
|
})
|
|
251
268
|
|
|
252
269
|
const syncDialogRow = rowsQuery.data?.rows.find((row) => row.id === syncDialogRowId)
|
|
270
|
+
const activeSyncDialog = useActiveSyncDialog(syncDialogRow ? syncSelection : null)
|
|
271
|
+
const { disabledReasons: syncDialogDisabledReasons } = useGitOpsActionCapabilities(
|
|
272
|
+
syncDialogRow?.kindName ?? '', syncDialogRow?.group, syncDialogRow?.namespace ?? '', syncDialogRow?.name ?? '', !!syncDialogRow,
|
|
273
|
+
)
|
|
253
274
|
useEffect(() => {
|
|
254
|
-
if (syncDialogRowId && !syncDialogRow)
|
|
275
|
+
if (syncDialogRowId && !syncDialogRow) setSyncSelection(null)
|
|
255
276
|
}, [syncDialogRowId, syncDialogRow])
|
|
256
277
|
|
|
257
278
|
// Row mutations invalidate granular keys (['resource', …], ['gitops-tree', …])
|
|
@@ -304,7 +325,8 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
304
325
|
// detail page uses. The mutation fires from onConfirm; clear the
|
|
305
326
|
// in-flight flag here since the dialog now owns the lifecycle.
|
|
306
327
|
markAction(id, action, false)
|
|
307
|
-
|
|
328
|
+
argoSync.reset()
|
|
329
|
+
setSyncSelection({ rowId: id, clusterKey })
|
|
308
330
|
return
|
|
309
331
|
case 'refresh':
|
|
310
332
|
argoRefresh.mutate({ namespace, name, hard: false }, settle)
|
|
@@ -361,6 +383,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
361
383
|
params.set('apiGroup', row.group)
|
|
362
384
|
navigate({ pathname: gitOpsDetailPath(row.kindName, ns, row.name), search: params.toString() })
|
|
363
385
|
}}
|
|
386
|
+
renderRowActions={(row, items) => <GitOpsPermissionRowActions row={row} items={items} />}
|
|
364
387
|
onRowAction={handleRowAction}
|
|
365
388
|
pendingRowActions={pendingActions}
|
|
366
389
|
argoResumeUpgrade={argoResumeUpgrade}
|
|
@@ -371,6 +394,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
371
394
|
/>
|
|
372
395
|
<SyncOptionsDialog
|
|
373
396
|
open={!!syncDialogRow}
|
|
397
|
+
disabledReason={syncDialogDisabledReasons.sync}
|
|
374
398
|
appLabel={syncDialogRow ? `${syncDialogRow.namespace}/${syncDialogRow.name}` : ''}
|
|
375
399
|
multiSource={isArgoMultiSource(syncDialogRow?.raw)}
|
|
376
400
|
comparedRevision={syncDialogRow?.raw?.status?.sync?.revision}
|
|
@@ -378,16 +402,22 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
378
402
|
applicationSyncOptions={argoApplicationSyncOptions(syncDialogRow?.raw)}
|
|
379
403
|
autoSyncEnabled={!!syncDialogRow && isArgoAutoSyncEnabled(syncDialogRow.raw)}
|
|
380
404
|
pending={argoSync.isPending}
|
|
381
|
-
|
|
405
|
+
syncError={argoSync.error?.message}
|
|
406
|
+
syncRawError={argoSync.error?.rawDetail}
|
|
407
|
+
onCancel={() => setSyncSelection(null)}
|
|
382
408
|
onConfirm={(opts) => {
|
|
383
|
-
if (!syncDialogRow) return
|
|
409
|
+
if (!syncDialogRow || syncDialogDisabledReasons.sync) return
|
|
384
410
|
const { namespace, name } = syncDialogRow
|
|
385
411
|
argoSync.mutate(
|
|
386
|
-
{
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
412
|
+
{
|
|
413
|
+
namespace, name, ...opts,
|
|
414
|
+
applicationSyncOptions: argoApplicationSyncOptions(syncDialogRow.raw),
|
|
415
|
+
isErrorShownInline: () => activeSyncDialog.current === syncSelection,
|
|
416
|
+
},
|
|
417
|
+
{ onSuccess: () => {
|
|
418
|
+
refetchTableAfterMutation()
|
|
419
|
+
setSyncSelection(null)
|
|
420
|
+
} },
|
|
391
421
|
)
|
|
392
422
|
}}
|
|
393
423
|
/>
|
|
@@ -398,6 +428,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
398
428
|
function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOpsViewProps) {
|
|
399
429
|
const location = useLocation()
|
|
400
430
|
const navigate = useNavigate()
|
|
431
|
+
const { connection } = useConnection()
|
|
401
432
|
const { showError, showSuccess, showToast } = useToast()
|
|
402
433
|
const parts = location.pathname.split('/').filter(Boolean)
|
|
403
434
|
const kind = parts[2] || 'applications'
|
|
@@ -490,7 +521,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
490
521
|
const [graphFullscreen, setGraphFullscreen] = useState(false)
|
|
491
522
|
const [helmValuesOpen, setHelmValuesOpen] = useState(false)
|
|
492
523
|
|
|
524
|
+
const { permissions: actionPermissions, disabledReasons: actionDisabledReasons, permissionCheckUnavailable } = useGitOpsActionCapabilities(kind, effectiveGroup, namespace, name)
|
|
493
525
|
const argoSync = useArgoSync()
|
|
526
|
+
const remediationSync = useArgoSync({ reportErrors: false })
|
|
494
527
|
const argoResourceValidation = useArgoResourceValidation()
|
|
495
528
|
const argoRefresh = useArgoRefresh()
|
|
496
529
|
const argoTerminate = useArgoTerminate()
|
|
@@ -507,7 +540,12 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
507
540
|
const fluxSuspend = useFluxSuspend()
|
|
508
541
|
const fluxResume = useFluxResume()
|
|
509
542
|
|
|
510
|
-
const [
|
|
543
|
+
const appKey = JSON.stringify([getApiBase(), connection.context, kind, effectiveGroup, namespace, name])
|
|
544
|
+
const [syncDialog, setSyncDialog] = useState<{ appKey: string; target: ArgoSyncDialogTarget } | null>(null)
|
|
545
|
+
if (syncDialog && syncDialog.appKey !== appKey) setSyncDialog(null)
|
|
546
|
+
const syncDialogTarget = syncDialog?.appKey === appKey ? syncDialog.target : null
|
|
547
|
+
const activeSyncDialog = useActiveSyncDialog(syncDialogTarget ? syncDialog : null)
|
|
548
|
+
const argoSyncBusy = argoSync.isPending || remediationSync.isPending || applyResource.isPending
|
|
511
549
|
const [validatedTargetKey, setValidatedTargetKey] = useState<string | null>(null)
|
|
512
550
|
const validationStale = validatedTargetKey !== null && validatedTargetKey !== deployTargetKey
|
|
513
551
|
// Doubles as the "open" flag (truthy = dialog open) and the data carrier
|
|
@@ -517,13 +555,15 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
517
555
|
const [refreshKind, setRefreshKind] = useState<'normal' | 'hard'>('normal')
|
|
518
556
|
|
|
519
557
|
function openArgoSyncDialog(target: ArgoSyncDialogTarget) {
|
|
558
|
+
if (argoSyncBusy) return
|
|
559
|
+
argoSync.reset()
|
|
520
560
|
argoResourceValidation.reset()
|
|
521
|
-
|
|
561
|
+
setSyncDialog({ appKey, target })
|
|
522
562
|
}
|
|
523
563
|
|
|
524
564
|
function closeArgoSyncDialog() {
|
|
525
565
|
argoResourceValidation.reset()
|
|
526
|
-
|
|
566
|
+
setSyncDialog(null)
|
|
527
567
|
}
|
|
528
568
|
|
|
529
569
|
const detailRow = tool && resourceQ.data ? normalizeDetailResource(kind, effectiveGroup, tool, resourceQ.data) : null
|
|
@@ -631,11 +671,13 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
631
671
|
category: 'GitOps',
|
|
632
672
|
scope: 'gitops',
|
|
633
673
|
handler: () => {
|
|
674
|
+
const reason = actionDisabledReasons[isArgoApp ? 'sync' : 'reconcile']
|
|
675
|
+
if (reason) { showToast(reason, { type: 'info', id: `gitops-denied:${reason}` }); return }
|
|
634
676
|
if (effectiveSuspended || terminating || operationInProgress) return
|
|
635
677
|
if (isArgoApp) openArgoSyncDialog({ scope: 'application' })
|
|
636
678
|
else if (isFlux) fluxReconcile.mutate({ kind, namespace, name })
|
|
637
679
|
},
|
|
638
|
-
enabled: shortcutsEnabled && (isArgoApp || isFlux) && !effectiveSuspended && !terminating && !(isArgoApp && operationInProgress),
|
|
680
|
+
enabled: shortcutsEnabled && (isArgoApp || isFlux) && !effectiveSuspended && !terminating && !(isArgoApp && (operationInProgress || argoSyncBusy)),
|
|
639
681
|
})
|
|
640
682
|
useRegisterShortcut({
|
|
641
683
|
id: 'gitops-detail-refresh',
|
|
@@ -645,6 +687,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
645
687
|
scope: 'gitops',
|
|
646
688
|
handler: () => {
|
|
647
689
|
if (!isArgoApp) return
|
|
690
|
+
if (actionDisabledReasons.refresh) { showToast(actionDisabledReasons.refresh, { type: 'info', id: `gitops-denied:${actionDisabledReasons.refresh}` }); return }
|
|
648
691
|
setRefreshKind('normal')
|
|
649
692
|
argoRefresh.mutate({ namespace, name, hard: false })
|
|
650
693
|
},
|
|
@@ -658,6 +701,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
658
701
|
scope: 'gitops',
|
|
659
702
|
handler: () => {
|
|
660
703
|
if (!isArgoApp) return
|
|
704
|
+
if (actionDisabledReasons.refresh) { showToast(actionDisabledReasons.refresh, { type: 'info', id: `gitops-denied:${actionDisabledReasons.refresh}` }); return }
|
|
661
705
|
setRefreshKind('hard')
|
|
662
706
|
argoRefresh.mutate({ namespace, name, hard: true })
|
|
663
707
|
},
|
|
@@ -670,6 +714,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
670
714
|
category: 'GitOps',
|
|
671
715
|
scope: 'gitops',
|
|
672
716
|
handler: () => {
|
|
717
|
+
if (actionDisabledReasons.terminate) { showToast(actionDisabledReasons.terminate, { type: 'info', id: `gitops-denied:${actionDisabledReasons.terminate}` }); return }
|
|
673
718
|
if (isArgoApp && isRunning) argoTerminate.mutate({ namespace, name })
|
|
674
719
|
},
|
|
675
720
|
enabled: shortcutsEnabled && isArgoApp && isRunning,
|
|
@@ -707,7 +752,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
707
752
|
if (isArgoAutoSyncSwitchedOff(resourceQ.data) && (argoResumeUpgrade || argoResumeBlockedReason)) return
|
|
708
753
|
argoResume.mutate({ namespace, name })
|
|
709
754
|
},
|
|
710
|
-
syncing:
|
|
755
|
+
syncing: argoSyncBusy,
|
|
711
756
|
refreshing: argoRefresh.isPending,
|
|
712
757
|
refreshingKind: refreshKind,
|
|
713
758
|
terminating: argoTerminate.isPending,
|
|
@@ -775,10 +820,12 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
775
820
|
// away and back.
|
|
776
821
|
window.setTimeout(() => setChangesFocusKey(null), 4000)
|
|
777
822
|
}}
|
|
778
|
-
remediationPending={
|
|
823
|
+
remediationPending={argoSyncBusy}
|
|
779
824
|
onRemediate={(remediation) => {
|
|
780
825
|
if (remediation.kind === 'create-namespace' && remediation.target) {
|
|
781
826
|
const nsName = remediation.target
|
|
827
|
+
const apiBase = getApiBase()
|
|
828
|
+
const expectedConnection = { apiBase, connectionId: connectionHeaderValue(apiBase) }
|
|
782
829
|
const yamlManifest = `apiVersion: v1\nkind: Namespace\nmetadata:\n name: ${nsName}\n`
|
|
783
830
|
applyResource.mutate(
|
|
784
831
|
{ yaml: yamlManifest, mode: 'apply' },
|
|
@@ -788,15 +835,15 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
788
835
|
// sync was triggered, so a successful create-namespace + sync
|
|
789
836
|
// failure doesn't yield a misleading "sync triggered" toast.
|
|
790
837
|
if (isArgoApp) {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
{
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
838
|
+
void remediationSync.mutateAsync({ namespace, name, applicationSyncOptions: appSyncOptions, expectedConnection }).then(
|
|
839
|
+
() => showSuccess(`Created namespace ${nsName}`, 'Sync triggered to retry the apply.'),
|
|
840
|
+
(error: Error) => {
|
|
841
|
+
const title = `Created namespace ${nsName}, but sync failed`
|
|
842
|
+
if (error instanceof GitOpsActionError) {
|
|
843
|
+
showError(title, `${error.notificationDetail}\nCheck the application’s status before retrying Sync.`, error.rawDetail)
|
|
844
|
+
} else {
|
|
845
|
+
showError(title, error.message)
|
|
846
|
+
}
|
|
800
847
|
},
|
|
801
848
|
)
|
|
802
849
|
} else {
|
|
@@ -823,6 +870,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
823
870
|
isArgoApp={isArgoApp}
|
|
824
871
|
isFlux={isFlux}
|
|
825
872
|
isFluxWorkload={isFluxWorkload}
|
|
873
|
+
actionDisabledReasons={actionDisabledReasons}
|
|
874
|
+
actionPermissions={actionPermissions}
|
|
875
|
+
permissionCheckUnavailable={permissionCheckUnavailable}
|
|
826
876
|
argo={argoHandlers}
|
|
827
877
|
flux={fluxHandlers}
|
|
828
878
|
activeTab={appView}
|
|
@@ -868,6 +918,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
868
918
|
<GitOpsActivityInsightView
|
|
869
919
|
insight={insightsQ.data}
|
|
870
920
|
error={insightsQ.error as Error | null}
|
|
921
|
+
rollbackDisabledReason={actionDisabledReasons.rollback}
|
|
871
922
|
onRollback={isArgoApp && !operationInProgress ? (item) => {
|
|
872
923
|
if (argoRollbackUpgrade || argoRollbackBlockedReason || parseArgoRollbackID(item.id) == null) return
|
|
873
924
|
setRollbackTarget(item)
|
|
@@ -889,9 +940,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
889
940
|
? terminatingActionTooltip
|
|
890
941
|
: effectiveSuspended
|
|
891
942
|
? 'Resume the Application before syncing a resource.'
|
|
892
|
-
: operationInProgress ||
|
|
943
|
+
: operationInProgress || argoSyncBusy
|
|
893
944
|
? 'Wait for the current sync operation to finish.'
|
|
894
|
-
:
|
|
945
|
+
: actionDisabledReasons.sync
|
|
895
946
|
) : undefined}
|
|
896
947
|
focusKey={changesFocusKey}
|
|
897
948
|
tree={tree}
|
|
@@ -952,6 +1003,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
952
1003
|
multiSource={isArgoMultiSource(resourceQ.data)}
|
|
953
1004
|
pinsComparedRevision={argoInheritanceSupport === 'supported' && argoComparedRevisionCurrent(resourceQ.data)}
|
|
954
1005
|
resource={syncDialogTarget?.scope === 'resource' ? syncDialogTarget.resource : undefined}
|
|
1006
|
+
disabledReason={actionDisabledReasons.sync}
|
|
955
1007
|
comparedRevision={resourceQ.data?.status?.sync?.revision}
|
|
956
1008
|
applicationSyncOptions={appSyncOptions}
|
|
957
1009
|
pending={argoSync.isPending}
|
|
@@ -960,20 +1012,27 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
960
1012
|
operationInProgress={operationInProgress}
|
|
961
1013
|
validationResult={validationStale ? null : argoResourceValidation.data}
|
|
962
1014
|
validationError={validationStale ? undefined : argoResourceValidation.error?.message}
|
|
1015
|
+
validationRawError={validationStale ? undefined : argoResourceValidation.error?.rawDetail}
|
|
1016
|
+
syncError={argoSync.error?.message}
|
|
1017
|
+
syncRawError={argoSync.error?.rawDetail}
|
|
963
1018
|
onCancel={closeArgoSyncDialog}
|
|
964
1019
|
onValidationReset={() => argoResourceValidation.reset()}
|
|
965
1020
|
onValidate={syncDialogTarget?.scope === 'resource' ? (opts) => {
|
|
1021
|
+
if (actionDisabledReasons.validate) return
|
|
1022
|
+
argoSync.reset()
|
|
966
1023
|
setValidatedTargetKey(deployTargetKey)
|
|
967
1024
|
argoResourceValidation.mutate(buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts, appSyncOptions))
|
|
968
1025
|
} : undefined}
|
|
969
1026
|
onConfirm={(opts) => {
|
|
970
|
-
if (!syncDialogTarget) return
|
|
1027
|
+
if (!syncDialogTarget || actionDisabledReasons.sync) return
|
|
1028
|
+
if (argoResourceValidation.isError) argoResourceValidation.reset()
|
|
971
1029
|
const variables = syncDialogTarget.scope === 'resource'
|
|
972
1030
|
? buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts, appSyncOptions)
|
|
973
1031
|
: { namespace, name, ...opts, applicationSyncOptions: appSyncOptions }
|
|
974
|
-
argoSync.mutate(
|
|
975
|
-
|
|
976
|
-
|
|
1032
|
+
argoSync.mutate({
|
|
1033
|
+
...variables,
|
|
1034
|
+
isErrorShownInline: () => activeSyncDialog.current === syncDialog,
|
|
1035
|
+
}, { onSuccess: closeArgoSyncDialog })
|
|
977
1036
|
}}
|
|
978
1037
|
/>
|
|
979
1038
|
<RollbackDialog
|
|
@@ -981,6 +1040,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
981
1040
|
appLabel={`${namespace}/${name}`}
|
|
982
1041
|
revision={rollbackTarget?.revision || ''}
|
|
983
1042
|
historyId={rollbackTarget?.id}
|
|
1043
|
+
disabledReason={actionDisabledReasons.rollback}
|
|
984
1044
|
source={rollbackTarget?.source}
|
|
985
1045
|
multiSourceWarning={rollbackTarget?.rollbackMultiSourceWarning}
|
|
986
1046
|
pending={argoRollback.isPending}
|
|
@@ -992,6 +1052,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
992
1052
|
setRollbackTarget(null)
|
|
993
1053
|
return
|
|
994
1054
|
}
|
|
1055
|
+
if (actionDisabledReasons.rollback) return
|
|
995
1056
|
const id = parseArgoRollbackID(rollbackTarget?.id)
|
|
996
1057
|
if (id == null) {
|
|
997
1058
|
showError('Rollback target became invalid', 'The history entry changed while the dialog was open. Reselect a target and try again.')
|
|
@@ -414,6 +414,7 @@ function PodQuickActions({ namespace, podName, isRunning }: PodQuickActionsProps
|
|
|
414
414
|
const containers = data.resource?.spec?.containers || []
|
|
415
415
|
if (containers.length > 0) {
|
|
416
416
|
openTerminal({
|
|
417
|
+
podUID: data.resource?.metadata?.uid,
|
|
417
418
|
namespace,
|
|
418
419
|
podName,
|
|
419
420
|
containerName: containers[0].name,
|