@skyhook-io/radar-app 1.21.7 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/App.tsx +26 -3
- package/src/api/client.ts +16 -3
- package/src/api/radarFeatures.ts +4 -0
- package/src/api/traefik.ts +33 -0
- package/src/api/traffic.ts +1 -0
- package/src/components/CloudFunnelButton.test.tsx +39 -1
- package/src/components/CloudFunnelButton.tsx +10 -3
- package/src/components/NamespaceSwitcher.tsx +6 -2
- package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
- package/src/components/applications/ApplicationsView.tsx +71 -142
- package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
- package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
- package/src/components/cnpg/CNPGOverview.test.tsx +75 -3
- package/src/components/cnpg/CNPGOverview.tsx +62 -4
- package/src/components/home/HomeView.tsx +9 -1
- package/src/components/home/NetworkPolicyCoverageCard.test.tsx +37 -0
- package/src/components/home/NetworkPolicyCoverageCard.tsx +26 -2
- package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
- package/src/components/issues/IssuesPane.render.test.tsx +78 -2
- package/src/components/issues/IssuesPane.tsx +38 -6
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.tsx +29 -0
- package/src/components/settings/FormSaveActions.tsx +6 -2
- package/src/components/settings/MetricsBackendSwitch.tsx +13 -15
- package/src/components/settings/OpenObserveSetup.test.tsx +68 -27
- package/src/components/settings/OpenObserveSetup.tsx +93 -123
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +23 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +5 -4
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +14 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +17 -0
- package/src/components/traffic/TrafficFlowList.tsx +5 -5
- package/src/components/traffic/TrafficGraph.test.tsx +11 -0
- package/src/components/traffic/TrafficGraph.tsx +31 -19
- package/src/components/traffic/TrafficView.tsx +17 -6
- package/src/components/traffic/traffic-export.test.ts +8 -0
- package/src/components/traffic/traffic-export.ts +7 -4
- package/src/components/traffic/trafficFilters.test.ts +51 -1
- package/src/components/traffic/trafficFilters.ts +39 -11
- package/src/components/ui/command-items-crd.test.tsx +23 -8
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.tsx +8 -6
- 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/contexts/CapabilitiesContext.tsx +2 -0
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +3 -0
- package/src/utils/page-links.ts +15 -1
|
@@ -27,7 +27,16 @@ export function NetworkPolicyCoverageCard({ data, onNavigate }: NetworkPolicyCov
|
|
|
27
27
|
// projection without any staged policies.
|
|
28
28
|
const stagedDeltaPercentage = hasStagedPolicies ? Math.abs(percentageIfStaged - percentage) : 0
|
|
29
29
|
const hasPolicies = data.totalPolicies > 0
|
|
30
|
-
const
|
|
30
|
+
const ignoredNamespaceWorkloads = data.ignoredNamespaceWorkloads ?? 0
|
|
31
|
+
const hostNetworkWorkloads = data.hostNetworkWorkloads ?? 0
|
|
32
|
+
const notCounted = ignoredNamespaceWorkloads + hostNetworkWorkloads
|
|
33
|
+
const notCountedReasons = [
|
|
34
|
+
ignoredNamespaceWorkloads > 0 && `${ignoredNamespaceWorkloads} in namespaces ignored in Checks settings.`,
|
|
35
|
+
hostNetworkWorkloads > 0 && `${hostNetworkWorkloads} on the host network, where network policies may not apply.`,
|
|
36
|
+
].filter(Boolean).join(' ')
|
|
37
|
+
// With nothing to count, 0% would read as a coverage failure.
|
|
38
|
+
const hasWorkloads = data.totalWorkloads > 0
|
|
39
|
+
const accentColor = !hasPolicies || !hasWorkloads
|
|
31
40
|
? 'text-theme-text-tertiary'
|
|
32
41
|
: percentage >= 75
|
|
33
42
|
? 'text-green-500'
|
|
@@ -59,6 +68,11 @@ export function NetworkPolicyCoverageCard({ data, onNavigate }: NetworkPolicyCov
|
|
|
59
68
|
<ShieldCheck className="w-8 h-8 text-theme-text-tertiary/40" />
|
|
60
69
|
<span className="text-xs text-theme-text-tertiary">No network policies configured</span>
|
|
61
70
|
</div>
|
|
71
|
+
) : !hasWorkloads ? (
|
|
72
|
+
<div className="flex flex-col items-center justify-center text-center gap-2">
|
|
73
|
+
<ShieldCheck className="w-8 h-8 text-theme-text-tertiary/40" />
|
|
74
|
+
<span className="text-xs text-theme-text-tertiary">No workloads counted</span>
|
|
75
|
+
</div>
|
|
62
76
|
) : (
|
|
63
77
|
<>
|
|
64
78
|
<div className="flex items-center gap-3 w-full">
|
|
@@ -118,7 +132,17 @@ export function NetworkPolicyCoverageCard({ data, onNavigate }: NetworkPolicyCov
|
|
|
118
132
|
)}
|
|
119
133
|
</div>
|
|
120
134
|
|
|
121
|
-
<div className=
|
|
135
|
+
<div className={clsx(
|
|
136
|
+
'px-4 py-1.5 border-t border-theme-border/50 flex items-center',
|
|
137
|
+
notCounted > 0 ? 'justify-between' : 'justify-end',
|
|
138
|
+
)}>
|
|
139
|
+
{notCounted > 0 && (
|
|
140
|
+
<Tooltip content={`Workloads not counted: ${notCountedReasons}`}>
|
|
141
|
+
<span className="text-[10px] text-theme-text-tertiary">
|
|
142
|
+
{notCounted} not counted
|
|
143
|
+
</span>
|
|
144
|
+
</Tooltip>
|
|
145
|
+
)}
|
|
122
146
|
<span className={clsx(
|
|
123
147
|
'flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider transition-colors',
|
|
124
148
|
accentColor,
|
|
@@ -42,7 +42,7 @@ let root: Root
|
|
|
42
42
|
let container: HTMLDivElement
|
|
43
43
|
const onResourceClick = vi.fn()
|
|
44
44
|
|
|
45
|
-
function render(rowIssue: Issue = issue) {
|
|
45
|
+
function render(rowIssue: Issue = issue, onNavigateToIssue?: (id: string) => void) {
|
|
46
46
|
act(() => {
|
|
47
47
|
root.render(
|
|
48
48
|
<ProblemsPanel
|
|
@@ -55,6 +55,7 @@ function render(rowIssue: Issue = issue) {
|
|
|
55
55
|
error={null}
|
|
56
56
|
totalReturned={1}
|
|
57
57
|
onNavigateToIssues={() => {}}
|
|
58
|
+
onNavigateToIssue={onNavigateToIssue}
|
|
58
59
|
onResourceClick={onResourceClick}
|
|
59
60
|
/>,
|
|
60
61
|
)
|
|
@@ -89,7 +90,16 @@ describe('Home Active Issues Investigate action', () => {
|
|
|
89
90
|
expect(onResourceClick).not.toHaveBeenCalled()
|
|
90
91
|
})
|
|
91
92
|
|
|
92
|
-
it('
|
|
93
|
+
it('opens the issue from the row when the Issues page handles links', () => {
|
|
94
|
+
const onNavigateToIssue = vi.fn()
|
|
95
|
+
render(issue, onNavigateToIssue)
|
|
96
|
+
const row = buttons().find((b) => b.textContent?.includes('checkout'))
|
|
97
|
+
act(() => row!.click())
|
|
98
|
+
expect(onNavigateToIssue).toHaveBeenCalledWith(issue.id)
|
|
99
|
+
expect(onResourceClick).not.toHaveBeenCalled()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('still opens the resource from the row when the host takes over Issues', () => {
|
|
93
103
|
render()
|
|
94
104
|
const row = buttons().find((b) => b.textContent?.includes('checkout'))
|
|
95
105
|
act(() => row!.click())
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
1
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
5
|
import { renderToString } from 'react-dom/server'
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom'
|
|
6
|
+
import { createMemoryRouter, MemoryRouter, RouterProvider } from 'react-router-dom'
|
|
7
|
+
import type { IssueAppInventoryRow } from '@skyhook-io/k8s-ui/components/issues'
|
|
4
8
|
import type { IssuesResponse, SubjectIssuesResponse } from '../../api/client'
|
|
5
9
|
import { IssuesPane } from './IssuesPane'
|
|
6
10
|
|
|
7
11
|
const state = vi.hoisted(() => ({
|
|
12
|
+
applications: vi.fn<() => { data?: { applications: IssueAppInventoryRow[] } }>(() => ({})),
|
|
8
13
|
fleet: { data: undefined as IssuesResponse | undefined, isLoading: false, error: null as Error | null, dataUpdatedAt: 0, refetch: vi.fn() },
|
|
9
14
|
subject: { data: undefined as SubjectIssuesResponse | undefined, isLoading: false, error: null as Error | null, dataUpdatedAt: 0, refetch: vi.fn() },
|
|
10
15
|
}))
|
|
11
|
-
vi.mock('../../api/client', () => ({ useIssues: () => state.fleet, useSubjectIssues: () => state.subject, useIssueCorrelation: () => ({ data: undefined, error: null, isFetching: false, dataUpdatedAt: 0, refetch: vi.fn() }), useIssueRowChanges: () => undefined }))
|
|
16
|
+
vi.mock('../../api/client', () => ({ useApplications: state.applications, useIssues: () => state.fleet, useSubjectIssues: () => state.subject, useIssueCorrelation: () => ({ data: undefined, error: null, isFetching: false, dataUpdatedAt: 0, refetch: vi.fn() }), useIssueRowChanges: () => undefined }))
|
|
12
17
|
vi.mock('../../api/apiResources', () => ({ useAPIResources: () => ({ data: undefined }), karpenterCapacityAvailable: () => false }))
|
|
13
18
|
vi.mock('../../contexts/CapabilitiesContext', () => ({ useCapabilitiesContext: () => ({}) }))
|
|
14
19
|
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
15
20
|
vi.mock('../diagnose/LocalDiagnoseAction', () => ({ IssueDiagnoseButton: () => null }))
|
|
16
21
|
|
|
22
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
23
|
+
|
|
17
24
|
const subjectUrl = '/issues?kind=Pod&resource=db%2Fpg-1'
|
|
18
25
|
const issue = {
|
|
19
26
|
id: 'pod-failed', severity: 'critical' as const, source: 'problem', category: 'workload', category_group: 'workload', grouping_scope: 'resource',
|
|
@@ -25,11 +32,80 @@ function render(url = subjectUrl, namespaces: string[] = []) {
|
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
beforeEach(() => {
|
|
35
|
+
state.applications.mockClear()
|
|
28
36
|
state.fleet = { data: undefined, isLoading: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() }
|
|
29
37
|
state.subject = { data: { issues: [issue], coverage: 'ok' }, isLoading: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() }
|
|
30
38
|
})
|
|
31
39
|
|
|
32
40
|
describe('Issues page query ownership', () => {
|
|
41
|
+
it('only requests scoped application inventory for lists that can group', () => {
|
|
42
|
+
state.fleet.data = { issues: [issue] }
|
|
43
|
+
render('/issues', ['db'])
|
|
44
|
+
expect(state.applications).toHaveBeenLastCalledWith(['db'], { enabled: false })
|
|
45
|
+
state.fleet.data.issues.push({ ...issue, id: 'other' })
|
|
46
|
+
render('/issues', ['db'])
|
|
47
|
+
expect(state.applications).toHaveBeenLastCalledWith(['db'], { enabled: true })
|
|
48
|
+
render(subjectUrl, ['db'])
|
|
49
|
+
expect(state.applications).toHaveBeenLastCalledWith(['db'], { enabled: false })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('links the panel to its exact application within the selected namespaces', () => {
|
|
53
|
+
const key = 'helm/db/checkout+api'
|
|
54
|
+
const workload = { kind: 'Deployment', name: 'checkout-api', namespace: 'db', group: 'apps' }
|
|
55
|
+
state.applications.mockReturnValueOnce({ data: { applications: [{ key, name: 'checkout', workloads: [workload] }] } })
|
|
56
|
+
const first = { ...issue, ...workload, grouping_scope: 'workload' }
|
|
57
|
+
state.fleet.data = { issues: [first, { ...first, id: 'other' }] }
|
|
58
|
+
|
|
59
|
+
const container = document.createElement('div')
|
|
60
|
+
container.innerHTML = render('/issues?issue=other', ['db', 'test'])
|
|
61
|
+
const link = container.querySelector<HTMLAnchorElement>('h2 a')!
|
|
62
|
+
expect(link.textContent).toBe('Open checkout application')
|
|
63
|
+
const url = new URL(link.href)
|
|
64
|
+
expect(url.pathname).toBe('/applications')
|
|
65
|
+
expect(Object.fromEntries(url.searchParams)).toEqual({ app: key, namespaces: 'db,test' })
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('replaces a link when triaging and reveals the next linked issue through an active filter', async () => {
|
|
69
|
+
state.fleet.data = { issues: [issue, { ...issue, id: 'replicas', severity: 'warning', reason: 'Unavailable' }] }
|
|
70
|
+
const router = createMemoryRouter([
|
|
71
|
+
{ path: '/', element: <div>Home</div> },
|
|
72
|
+
{ path: '/issues', element: <IssuesPane namespaces={['db']} onNavigateToResource={() => {}} /> },
|
|
73
|
+
], { initialEntries: ['/', '/issues?namespaces=db&issue=pod-failed'], initialIndex: 1 })
|
|
74
|
+
const container = document.createElement('div')
|
|
75
|
+
const root = createRoot(container)
|
|
76
|
+
const row = (id: string) => container.querySelector(`[data-app-issue-row=":${id}"]`)
|
|
77
|
+
const toggle = (id: string) => row(id)!.querySelector<HTMLElement>('[role=button][aria-expanded]')!
|
|
78
|
+
try {
|
|
79
|
+
await act(async () => { root.render(<RouterProvider router={router} />) })
|
|
80
|
+
expect(toggle('pod-failed').getAttribute('aria-expanded')).toBe('true')
|
|
81
|
+
await act(async () => { toggle('replicas').click() })
|
|
82
|
+
expect(router.state.location.search).toBe('?namespaces=db')
|
|
83
|
+
expect(toggle('replicas').getAttribute('aria-expanded')).toBe('true')
|
|
84
|
+
await act(async () => { await router.navigate(-1) })
|
|
85
|
+
expect(router.state.location.pathname).toBe('/')
|
|
86
|
+
|
|
87
|
+
await act(async () => { await router.navigate('/issues?namespaces=db&issue=replicas') })
|
|
88
|
+
const critical = [...container.querySelectorAll('button')].find(button => button.textContent === '1Critical')!
|
|
89
|
+
await act(async () => { critical.click() })
|
|
90
|
+
expect(row('replicas')).toBeNull()
|
|
91
|
+
expect(router.state.location.search).toBe('?namespaces=db')
|
|
92
|
+
await act(async () => { await router.navigate('/issues?namespaces=db&issue=replicas') })
|
|
93
|
+
expect(toggle('replicas').getAttribute('aria-expanded')).toBe('true')
|
|
94
|
+
expect(row('pod-failed')).toBeTruthy()
|
|
95
|
+
} finally {
|
|
96
|
+
await act(async () => { root.unmount() })
|
|
97
|
+
router.dispose()
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('explains a missing issue link while keeping the current issues visible', () => {
|
|
102
|
+
state.fleet.data = { issues: [issue] }
|
|
103
|
+
const html = render('/issues?issue=absent')
|
|
104
|
+
expect(html).toContain('The linked issue is outside the current results.')
|
|
105
|
+
expect(html).toContain(issue.message)
|
|
106
|
+
expect(render('/issues?issue=pod-failed')).not.toContain('outside the current results')
|
|
107
|
+
})
|
|
108
|
+
|
|
33
109
|
it.each(['loading', 'failed'] as const)('renders subject results while the fleet query is %s', (fleetState) => {
|
|
34
110
|
state.fleet.isLoading = fleetState === 'loading'
|
|
35
111
|
state.fleet.error = fleetState === 'failed' ? new Error('Fleet unavailable') : null
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo, useState } from "react";
|
|
2
|
-
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
3
|
-
import { useIssues, useSubjectIssues, type SubjectIssuesResponse } from "../../api/client";
|
|
2
|
+
import { Link, useNavigate, useSearchParams } from "react-router-dom";
|
|
3
|
+
import { useApplications, useIssues, useSubjectIssues, type SubjectIssuesResponse } from "../../api/client";
|
|
4
4
|
import {
|
|
5
5
|
useAPIResources,
|
|
6
6
|
karpenterCapacityAvailable,
|
|
@@ -22,12 +22,14 @@ import {
|
|
|
22
22
|
type IssueSeverity,
|
|
23
23
|
type SummaryTone,
|
|
24
24
|
} from "@skyhook-io/k8s-ui";
|
|
25
|
+
import { buildIssueAppIndex } from "@skyhook-io/k8s-ui/components/issues";
|
|
25
26
|
import { builtinGroupForKind } from "@skyhook-io/k8s-ui/utils/api-resources";
|
|
26
27
|
import { AlertTriangle } from "lucide-react";
|
|
27
28
|
import { IssueDiagnoseButton } from "../diagnose/LocalDiagnoseAction";
|
|
28
29
|
import { recordUsageEvent } from "../../api/usage-data";
|
|
29
30
|
import { uncheckedSourceLines, uncheckedSubjectWhy } from "./uncheckedSources";
|
|
30
31
|
import { UncheckedSourceHelp } from "./UncheckedSourceHelp";
|
|
32
|
+
import { useClearLinkedIssue } from "../../utils/page-links";
|
|
31
33
|
import { useIssueExpansion, useIssueRowNotes } from "./useIssueExpansion";
|
|
32
34
|
|
|
33
35
|
// A capacity-relevant issue links to its Karpenter diagnosis. Karpenter is
|
|
@@ -185,9 +187,16 @@ export function IssuesPane({
|
|
|
185
187
|
showNamespace,
|
|
186
188
|
}: IssuesPaneProps) {
|
|
187
189
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
190
|
+
const clearLinkedIssue = useClearLinkedIssue();
|
|
191
|
+
const linkedIssueId = searchParams.get("issue") || undefined;
|
|
188
192
|
const subject = useMemo(() => issueSubjectFromParams(searchParams), [searchParams]);
|
|
189
193
|
const { data, isLoading, isFetching, error, dataUpdatedAt, refetch } =
|
|
190
194
|
useIssues(namespaces, !subject);
|
|
195
|
+
const canGroup = !subject && (data?.issues.length ?? 0) > 1;
|
|
196
|
+
const { data: inventory } = useApplications(namespaces, { enabled: canGroup });
|
|
197
|
+
const appForIssue = useMemo(() => canGroup && inventory
|
|
198
|
+
? buildIssueAppIndex(inventory.applications, { complete: namespaces.length === 0 && inventory.access?.restricted === false })
|
|
199
|
+
: undefined, [canGroup, inventory, namespaces.length]);
|
|
191
200
|
const { connection } = useConnection();
|
|
192
201
|
const navigate = useNavigate();
|
|
193
202
|
const apiResources = useAPIResources();
|
|
@@ -199,6 +208,14 @@ export function IssuesPane({
|
|
|
199
208
|
new Set(),
|
|
200
209
|
);
|
|
201
210
|
|
|
211
|
+
// A new link reveals its target even if the last view filtered its severity.
|
|
212
|
+
// Removing the link after a click keeps the user's new choice intact.
|
|
213
|
+
const [previousLink, setPreviousLink] = useState(linkedIssueId);
|
|
214
|
+
if (previousLink !== linkedIssueId) {
|
|
215
|
+
setPreviousLink(linkedIssueId);
|
|
216
|
+
if (linkedIssueId && severityFilter.size) setSeverityFilter(new Set());
|
|
217
|
+
}
|
|
218
|
+
|
|
202
219
|
const subjectHidden =
|
|
203
220
|
!!subject?.namespace && namespaces.length > 0 && !namespaces.includes(subject.namespace);
|
|
204
221
|
const related = useSubjectIssues(subject, !subjectHidden);
|
|
@@ -228,6 +245,7 @@ export function IssuesPane({
|
|
|
228
245
|
setSearchParams(
|
|
229
246
|
(prev) => {
|
|
230
247
|
const next = new URLSearchParams(prev);
|
|
248
|
+
next.delete("issue");
|
|
231
249
|
next.delete("kind");
|
|
232
250
|
next.delete("apiGroup");
|
|
233
251
|
next.delete("resource");
|
|
@@ -236,13 +254,15 @@ export function IssuesPane({
|
|
|
236
254
|
{ replace: true },
|
|
237
255
|
);
|
|
238
256
|
|
|
239
|
-
const toggleSeverity = (s: IssueSeverity) =>
|
|
257
|
+
const toggleSeverity = (s: IssueSeverity) => {
|
|
258
|
+
clearLinkedIssue();
|
|
240
259
|
setSeverityFilter((prev) => {
|
|
241
260
|
const next = new Set(prev);
|
|
242
261
|
if (next.has(s)) next.delete(s);
|
|
243
262
|
else next.add(s);
|
|
244
263
|
return next;
|
|
245
264
|
});
|
|
265
|
+
};
|
|
246
266
|
|
|
247
267
|
const onResourceClick = (ref: IssueResourceRef) => {
|
|
248
268
|
recordUsageEvent({ type: "ui", name: "issue_action:open" });
|
|
@@ -271,7 +291,7 @@ export function IssuesPane({
|
|
|
271
291
|
<PageHeader
|
|
272
292
|
icon={AlertTriangle}
|
|
273
293
|
title="Issues"
|
|
274
|
-
description="Live cluster problems
|
|
294
|
+
description="Live cluster problems, with critical issues first."
|
|
275
295
|
actions={
|
|
276
296
|
<>
|
|
277
297
|
{subjectHidden ? null : <FreshnessControl
|
|
@@ -307,6 +327,10 @@ export function IssuesPane({
|
|
|
307
327
|
}
|
|
308
328
|
/>
|
|
309
329
|
|
|
330
|
+
{!subject && linkedIssueId && data && !pageIssues.some((issue) => issue.id === linkedIssueId) && (
|
|
331
|
+
<p className="text-sm text-theme-text-secondary">The linked issue is outside the current results.</p>
|
|
332
|
+
)}
|
|
333
|
+
|
|
310
334
|
{!subject && error && (
|
|
311
335
|
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
|
|
312
336
|
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-500" aria-hidden />
|
|
@@ -363,7 +387,7 @@ export function IssuesPane({
|
|
|
363
387
|
{showNamespace && (
|
|
364
388
|
<button
|
|
365
389
|
type="button"
|
|
366
|
-
onClick={() => showNamespace.show(subject.namespace)}
|
|
390
|
+
onClick={() => { clearLinkedIssue(); showNamespace.show(subject.namespace); }}
|
|
367
391
|
className="text-accent-text hover:underline"
|
|
368
392
|
>
|
|
369
393
|
{showNamespace.mode === "add" ? "Add" : "Switch to"}{" "}
|
|
@@ -402,7 +426,7 @@ export function IssuesPane({
|
|
|
402
426
|
<p>No issues match the selected severity.</p>
|
|
403
427
|
<button
|
|
404
428
|
type="button"
|
|
405
|
-
onClick={() => setSeverityFilter(new Set())}
|
|
429
|
+
onClick={() => { clearLinkedIssue(); setSeverityFilter(new Set()); }}
|
|
406
430
|
className="text-xs text-skyhook-600 hover:text-skyhook-500 dark:text-skyhook-400"
|
|
407
431
|
>
|
|
408
432
|
Clear filter
|
|
@@ -428,6 +452,14 @@ export function IssuesPane({
|
|
|
428
452
|
list then means "nothing broken" rather than "not connected". */
|
|
429
453
|
<IssuesView
|
|
430
454
|
issues={shown}
|
|
455
|
+
appForIssue={appForIssue}
|
|
456
|
+
renderAppLink={(key, label) => {
|
|
457
|
+
const params = new URLSearchParams({ app: key });
|
|
458
|
+
if (namespaces.length) params.set("namespaces", namespaces.join(","));
|
|
459
|
+
return <Link to={{ pathname: "/applications", search: params.toString() }}>{label}</Link>;
|
|
460
|
+
}}
|
|
461
|
+
linkedIssueId={linkedIssueId}
|
|
462
|
+
onManualIssueToggle={clearLinkedIssue}
|
|
431
463
|
anyData={subject ? !!related.data : !!data}
|
|
432
464
|
onResourceClick={onResourceClick}
|
|
433
465
|
onOpenIssueChange={expansion.onOpenIssueChange}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { expect, it } from 'vitest'
|
|
2
|
+
import { RadarFeatureUnsupportedError } from '../../../api/radarFeatures'
|
|
3
|
+
import { routeFactsProps } from './TraefikIngressRouteRenderer'
|
|
4
|
+
|
|
5
|
+
const answer = { installed: true, coverage: {}, truncated: false, routes: [{ rule: 0 } as any], middlewares: [{ namespace: 'shop', name: 'redirect', usedBy: 12 }] }
|
|
6
|
+
|
|
7
|
+
it('passes rule facts and middleware use to the drawer', () => {
|
|
8
|
+
expect(routeFactsProps({ data: answer, isError: false, support: 'supported' })).toMatchObject({ routeFacts: answer.routes, middlewareUse: { 'shop/redirect': 12 } })
|
|
9
|
+
})
|
|
10
|
+
it('keeps the drawer unchanged on an older Radar and while loading', () => {
|
|
11
|
+
expect(routeFactsProps({ isError: true, support: 'unsupported' }).routeFacts).toBeUndefined()
|
|
12
|
+
expect(routeFactsProps({ isError: false, support: 'supported' }).routeFacts).toBeUndefined()
|
|
13
|
+
})
|
|
14
|
+
it('says the facts could not be loaded when the request fails', () => {
|
|
15
|
+
expect(routeFactsProps({ isError: true, support: 'supported' }).routeFacts).toBeNull()
|
|
16
|
+
})
|
|
17
|
+
it('hides the section when a Radar of unknown version turns out not to have the route', () => {
|
|
18
|
+
expect(routeFactsProps({ isError: true, error: new RadarFeatureUnsupportedError('traefikRoutes', {}), support: 'unknown' }).routeFacts).toBeUndefined()
|
|
19
|
+
})
|
|
20
|
+
it('marks middleware counts partial unless the routes were read in full', () => {
|
|
21
|
+
expect(routeFactsProps({ data: { ...answer, coverage: { ingressroutes: { state: 'full' } } } as any, isError: false, support: 'supported' }).middlewareUsePartial).toBe(false)
|
|
22
|
+
expect(routeFactsProps({ data: { ...answer, coverage: { ingressroutes: { state: 'partial' } } } as any, isError: false, support: 'supported' }).middlewareUsePartial).toBe(true)
|
|
23
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { TraefikIngressRouteRenderer as BaseTraefikIngressRouteRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/TraefikIngressRouteRenderer'
|
|
3
|
+
import type { ResourceRef, TraefikRoutesResponse } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import { isRadarFeatureUnsupported } from '../../../api/radarFeatures'
|
|
5
|
+
import { useTraefikRouteFacts } from '../../../api/traefik'
|
|
6
|
+
|
|
7
|
+
// The answer as the drawer takes it: undefined on an older Radar or while
|
|
8
|
+
// loading (the drawer looks as before), null when the request failed.
|
|
9
|
+
export function routeFactsProps(query: { data?: TraefikRoutesResponse; isError: boolean; error?: unknown; support: string }) {
|
|
10
|
+
if (query.support === 'unsupported' || isRadarFeatureUnsupported(query.error, 'traefikRoutes')) return { routeFacts: undefined, middlewareUse: undefined }
|
|
11
|
+
if (query.isError) return { routeFacts: null, middlewareUse: undefined }
|
|
12
|
+
if (!query.data) return { routeFacts: undefined, middlewareUse: undefined }
|
|
13
|
+
const middlewareUse: Record<string, number> = {}
|
|
14
|
+
for (const m of query.data.middlewares) middlewareUse[`${m.namespace}/${m.name}`] = m.usedBy
|
|
15
|
+
return { routeFacts: query.data.routes, middlewareUse, middlewareUsePartial: query.data.coverage?.ingressroutes?.state !== 'full' }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Host wrapper: adds each rule's request path to the IngressRoute drawer. */
|
|
19
|
+
export function TraefikIngressRouteRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
|
|
20
|
+
const { data: facts, isError, error, support } = useTraefikRouteFacts(data?.metadata?.namespace ?? '', data?.metadata?.name ?? '', String(data?.apiVersion ?? '').split('/')[0])
|
|
21
|
+
const props = useMemo(() => routeFactsProps({ data: facts, isError, error, support }), [facts, isError, error, support])
|
|
22
|
+
return <BaseTraefikIngressRouteRenderer data={data} onNavigate={onNavigate} {...props} />
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { expect, it } from 'vitest'
|
|
2
|
+
import { RadarFeatureUnsupportedError } from '../../../api/radarFeatures'
|
|
3
|
+
import { middlewareUsers } from './TraefikMiddlewareRenderer'
|
|
4
|
+
|
|
5
|
+
const answer = (state: string) => ({ installed: true, truncated: false, middlewares: [], coverage: { ingressroutes: { state } }, routes: [{ ref: { group: 'traefik.io', namespace: 'shop', name: 'ui' } } as any] })
|
|
6
|
+
|
|
7
|
+
it('maps rows to routes and reads partial coverage', () => {
|
|
8
|
+
expect(middlewareUsers({ data: answer('full'), isError: false, support: 'supported' })).toEqual({ routes: [{ group: 'traefik.io', namespace: 'shop', name: 'ui' }], truncated: false, partial: false })
|
|
9
|
+
expect(middlewareUsers({ data: answer('partial'), isError: false, support: 'supported' })?.partial).toBe(true)
|
|
10
|
+
})
|
|
11
|
+
it('keeps the drawer unchanged on an older Radar and says when the request failed', () => {
|
|
12
|
+
expect(middlewareUsers({ isError: true, support: 'unsupported' })).toBeUndefined()
|
|
13
|
+
expect(middlewareUsers({ isError: true, support: 'supported' })).toBeNull()
|
|
14
|
+
})
|
|
15
|
+
it('hides the section when a Radar of unknown version turns out not to have the route', () => {
|
|
16
|
+
expect(middlewareUsers({ isError: true, error: new RadarFeatureUnsupportedError('traefikRoutes', {}), support: 'unknown' })).toBeUndefined()
|
|
17
|
+
})
|
|
18
|
+
it('never reads an unread IngressRoute answer as no route', () => {
|
|
19
|
+
expect(middlewareUsers({ data: answer('syncing'), isError: false, support: 'supported' })).toBeUndefined()
|
|
20
|
+
for (const state of ['denied', 'uncached', 'error', 'notInstalled']) {
|
|
21
|
+
expect(middlewareUsers({ data: answer(state), isError: false, support: 'supported' })).toBeNull()
|
|
22
|
+
}
|
|
23
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { TraefikMiddlewareRenderer as BaseTraefikMiddlewareRenderer, type TraefikMiddlewareUsers } from '@skyhook-io/k8s-ui/components/resources/renderers/TraefikMiddlewareRenderer'
|
|
3
|
+
import type { ResourceRef, TraefikRoutesResponse } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import { isRadarFeatureUnsupported } from '../../../api/radarFeatures'
|
|
5
|
+
import { useTraefikMiddlewareUsers } from '../../../api/traefik'
|
|
6
|
+
|
|
7
|
+
// undefined on an older Radar or while loading (IngressRoutes still syncing
|
|
8
|
+
// included); null when the request failed or Radar couldn't read
|
|
9
|
+
// IngressRoutes at all, so an unread answer never reads as "no route".
|
|
10
|
+
export function middlewareUsers(query: { data?: TraefikRoutesResponse; isError: boolean; error?: unknown; support: string }): TraefikMiddlewareUsers | null | undefined {
|
|
11
|
+
if (query.support === 'unsupported' || isRadarFeatureUnsupported(query.error, 'traefikRoutes')) return undefined
|
|
12
|
+
if (query.isError) return null
|
|
13
|
+
if (!query.data) return undefined
|
|
14
|
+
const state = query.data.coverage?.ingressroutes?.state
|
|
15
|
+
if (state === 'syncing') return undefined
|
|
16
|
+
if (state !== 'full' && state !== 'partial') return null
|
|
17
|
+
return {
|
|
18
|
+
routes: query.data.routes.map((r) => ({ group: r.ref.group, namespace: r.ref.namespace, name: r.ref.name })),
|
|
19
|
+
truncated: query.data.truncated,
|
|
20
|
+
partial: state === 'partial',
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Host wrapper: adds which IngressRoutes use the Middleware. */
|
|
25
|
+
export function TraefikMiddlewareRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
|
|
26
|
+
const { data: users, isError, error, support } = useTraefikMiddlewareUsers(data?.metadata?.namespace ?? '', data?.metadata?.name ?? '')
|
|
27
|
+
const usedBy = useMemo(() => middlewareUsers({ data: users, isError, error, support }), [users, isError, error, support])
|
|
28
|
+
return <BaseTraefikMiddlewareRenderer data={data} onNavigate={onNavigate} usedBy={usedBy} />
|
|
29
|
+
}
|
|
@@ -13,6 +13,8 @@ export function FormSaveActions({
|
|
|
13
13
|
onDiscard,
|
|
14
14
|
feedback,
|
|
15
15
|
error,
|
|
16
|
+
saveLabel = "Save changes",
|
|
17
|
+
canSave = dirty,
|
|
16
18
|
}: {
|
|
17
19
|
dirty: boolean;
|
|
18
20
|
busy: boolean;
|
|
@@ -20,6 +22,8 @@ export function FormSaveActions({
|
|
|
20
22
|
onDiscard: () => void;
|
|
21
23
|
feedback?: FormFeedback;
|
|
22
24
|
error?: string;
|
|
25
|
+
saveLabel?: string;
|
|
26
|
+
canSave?: boolean;
|
|
23
27
|
}) {
|
|
24
28
|
const success = !dirty && !busy && !error && feedback?.tone === "success";
|
|
25
29
|
const detail =
|
|
@@ -29,11 +33,11 @@ export function FormSaveActions({
|
|
|
29
33
|
<div className="flex min-h-8 flex-wrap items-center gap-3">
|
|
30
34
|
<button
|
|
31
35
|
type="button"
|
|
32
|
-
disabled={!
|
|
36
|
+
disabled={!canSave || busy}
|
|
33
37
|
onClick={onSave}
|
|
34
38
|
className="btn-brand min-w-28 px-3 py-2 text-xs"
|
|
35
39
|
>
|
|
36
|
-
{busy ? "Saving…" :
|
|
40
|
+
{busy ? "Saving…" : saveLabel}
|
|
37
41
|
</button>
|
|
38
42
|
{success && (
|
|
39
43
|
<span
|
|
@@ -80,18 +80,12 @@ export function MetricsBackendSwitch({
|
|
|
80
80
|
onBusyChange?.(next || reported.current.ooBusy || reported.current.releasing)
|
|
81
81
|
}, [onBusyChange])
|
|
82
82
|
|
|
83
|
-
const releaseCluster =
|
|
84
|
-
const next = await removeOpenObserveCluster(data?.cluster.uid)
|
|
85
|
-
setData(next)
|
|
86
|
-
setChoice('prometheus')
|
|
87
|
-
onChanged()
|
|
88
|
-
}, [data?.cluster.uid, onChanged])
|
|
89
|
-
|
|
90
|
-
const releaseFromPrometheusView = async () => {
|
|
83
|
+
const releaseCluster = async () => {
|
|
91
84
|
setReleasing(true)
|
|
92
85
|
setReleaseError('')
|
|
93
86
|
try {
|
|
94
|
-
await
|
|
87
|
+
setData(await removeOpenObserveCluster(data?.cluster.uid))
|
|
88
|
+
onChanged()
|
|
95
89
|
} catch (error) {
|
|
96
90
|
setReleaseError(error instanceof Error ? error.message : String(error))
|
|
97
91
|
} finally {
|
|
@@ -101,6 +95,8 @@ export function MetricsBackendSwitch({
|
|
|
101
95
|
|
|
102
96
|
const statusRow = status ? <div className="flex flex-wrap items-center gap-x-3 gap-y-1">{status}</div> : null
|
|
103
97
|
const matched = !!data?.cluster.match
|
|
98
|
+
// The status describes where metrics come from now, whichever view is open.
|
|
99
|
+
const active: Backend = matched ? 'openobserve' : 'prometheus'
|
|
104
100
|
|
|
105
101
|
return (
|
|
106
102
|
<div className="space-y-4">
|
|
@@ -133,25 +129,27 @@ export function MetricsBackendSwitch({
|
|
|
133
129
|
{matched && !locked && (
|
|
134
130
|
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs">
|
|
135
131
|
<span className="text-warning-text">This cluster still reads from OpenObserve.</span>
|
|
136
|
-
<button type="button" disabled={busy} onClick={() => void
|
|
132
|
+
<button type="button" disabled={busy} onClick={() => void releaseCluster()} className="text-accent-text hover:underline">
|
|
137
133
|
{releasing ? 'Switching…' : 'Use Prometheus for this cluster'}
|
|
138
134
|
</button>
|
|
139
135
|
{releaseError && <span role="alert" className="basis-full text-semantic-error">{releaseError}</span>}
|
|
140
136
|
</div>
|
|
141
137
|
)}
|
|
142
138
|
{locked
|
|
143
|
-
?
|
|
144
|
-
: prometheus({ status:
|
|
139
|
+
? active === 'prometheus' && statusRow
|
|
140
|
+
: prometheus({ status: active === 'prometheus' ? status : undefined, onDirtyChange: promDirtyChange, onBusyChange: promBusyChange })}
|
|
145
141
|
</div>
|
|
146
142
|
<div className={clsx(choice !== 'openobserve' && 'hidden')} inert={choice !== 'openobserve' || undefined}>
|
|
147
143
|
{data ? (
|
|
148
144
|
<OpenObserveSetup
|
|
149
145
|
state={data}
|
|
150
146
|
locked={locked}
|
|
151
|
-
status={
|
|
152
|
-
onStateChange={
|
|
147
|
+
status={active === 'openobserve' ? status : undefined}
|
|
148
|
+
onStateChange={(next) => {
|
|
149
|
+
setData(next)
|
|
150
|
+
if (!next.connection) setChoice('prometheus')
|
|
151
|
+
}}
|
|
153
152
|
onChanged={onChanged}
|
|
154
|
-
onUsePrometheus={releaseCluster}
|
|
155
153
|
onDirtyChange={setOoDirty}
|
|
156
154
|
onBusyChange={setOoBusy}
|
|
157
155
|
/>
|