@skyhook-io/radar-app 1.21.5 → 1.21.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/App.tsx +19 -1
- package/src/RadarApp.tsx +8 -2
- package/src/api/client.discoverMetrics.test.tsx +69 -0
- package/src/api/client.issueCorrelation.test.tsx +244 -0
- package/src/api/client.issueRowChanges.test.tsx +129 -0
- package/src/api/client.pendingOwnership.test.tsx +197 -0
- package/src/api/client.prometheusStatus.test.ts +4 -0
- package/src/api/client.restartError.test.ts +36 -1
- package/src/api/client.stopWorkflow.test.tsx +133 -0
- package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
- package/src/api/client.ts +572 -111
- package/src/api/connectionBinding.test.tsx +3 -1
- package/src/api/connectionBinding.ts +14 -2
- package/src/api/gitOpsPermissions.render.test.tsx +155 -0
- package/src/api/gitOpsPermissions.test.ts +90 -0
- package/src/api/gitOpsPermissions.ts +51 -0
- package/src/api/httpErrors.test.ts +30 -1
- package/src/api/httpErrors.ts +17 -0
- package/src/api/openobserveSetup.ts +85 -0
- package/src/api/podDebug.test.tsx +137 -0
- package/src/api/podDebug.ts +82 -0
- package/src/api/prometheusCharts.test.ts +23 -0
- package/src/api/prometheusCharts.ts +25 -0
- package/src/api/radarFeatures.render.test.tsx +43 -2
- package/src/api/radarFeatures.test.ts +18 -1
- package/src/api/radarFeatures.ts +17 -4
- package/src/api/reviewedActionMutation.ts +9 -2
- package/src/api/workloadMetrics.ts +2 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
- package/src/components/applications/ApplicationsView.tsx +56 -31
- package/src/components/cnpg/host.test.tsx +1 -1
- package/src/components/cnpg/host.tsx +0 -2
- package/src/components/dock/BottomDock.tsx +7 -3
- package/src/components/dock/MissingShellDebug.test.tsx +193 -0
- package/src/components/dock/MissingShellDebug.tsx +114 -0
- package/src/components/dock/PodDebugSession.test.tsx +60 -0
- package/src/components/dock/PodDebugSession.tsx +96 -0
- package/src/components/dock/TerminalTab.test.tsx +48 -4
- package/src/components/dock/TerminalTab.tsx +47 -25
- package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
- package/src/components/dock/WorkloadLogsTab.tsx +16 -0
- package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
- package/src/components/execution/BatchExecutionView.tsx +88 -5
- package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
- package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
- package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
- package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
- package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
- package/src/components/gitops/GitOpsView.tsx +93 -32
- package/src/components/helm/OwnedResources.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +1 -0
- package/src/components/issues/IssuesPane.render.test.tsx +1 -1
- package/src/components/issues/IssuesPane.tsx +11 -0
- package/src/components/issues/useIssueExpansion.ts +91 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
- package/src/components/resource/MetricsNotConnected.tsx +114 -0
- package/src/components/resource/PVCUsageBar.tsx +2 -1
- package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
- package/src/components/resource/PrometheusCharts.tsx +14 -2
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
- package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
- package/src/components/resource/RestartChart.tsx +4 -3
- package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
- package/src/components/resource/RightsizingStrip.tsx +5 -3
- package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
- package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
- package/src/components/resource/nameMatchedScope.ts +9 -3
- package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
- package/src/components/resources/PodDebugAction.test.tsx +157 -0
- package/src/components/resources/PodDebugAction.tsx +207 -0
- package/src/components/resources/PodDebugPermission.tsx +21 -0
- package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
- package/src/components/resources/ResourcesView.tsx +39 -5
- package/src/components/resources/namespaceHint.test.ts +34 -0
- package/src/components/resources/namespaceHint.ts +19 -0
- package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
- package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
- package/src/components/resources/renderers/PodRenderer.tsx +12 -5
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
- package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
- package/src/components/settings/MetricsBackendSwitch.tsx +167 -0
- package/src/components/settings/OpenObserveSetup.test.tsx +343 -0
- package/src/components/settings/OpenObserveSetup.tsx +358 -0
- package/src/components/settings/SettingsDialog.tsx +21 -7
- package/src/components/settings/openobserveStatus.test.ts +34 -0
- package/src/components/settings/openobserveStatus.ts +55 -0
- package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
- package/src/components/timeline/TimelineList.test.ts +18 -0
- package/src/components/timeline/TimelineList.tsx +19 -5
- package/src/components/timeline/TimelineView.tsx +2 -0
- package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
- package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +95 -10
- package/src/context/TimelineNavigation.test.ts +59 -0
- package/src/context/TimelineNavigation.tsx +86 -0
- package/src/contexts/CapabilitiesContext.tsx +3 -1
- package/src/hooks/useResourceCounts.ts +2 -1
- package/src/hooks/useWorkflowStopAction.ts +31 -0
- package/src/index.css +1 -0
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +4 -2
- package/src/k8s-ui-exports.test.ts +10 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
2
|
+
import { Collapse, ConfirmDialog, Disclosure, Input } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { Check, ExternalLink } from 'lucide-react'
|
|
4
|
+
import {
|
|
5
|
+
getOpenObserveState,
|
|
6
|
+
removeOpenObserveConnection,
|
|
7
|
+
setupOpenObserve,
|
|
8
|
+
type OpenObserveConnection,
|
|
9
|
+
type OpenObserveLabelValue,
|
|
10
|
+
type OpenObserveMatch,
|
|
11
|
+
type OpenObserveSetupNotes,
|
|
12
|
+
type OpenObserveSetupRequest,
|
|
13
|
+
type OpenObserveState,
|
|
14
|
+
} from '../../api/openobserveSetup'
|
|
15
|
+
import { missingFamiliesNote } from './openobserveStatus'
|
|
16
|
+
|
|
17
|
+
const SERVICE_ACCOUNT_DOCS = 'https://openobserve.ai/docs/user-guide/identity-and-access-management/service-accounts/'
|
|
18
|
+
const inputClass = 'block w-full min-w-0 px-3 py-2 text-sm bg-theme-elevated border border-theme-border rounded-md text-theme-text-primary placeholder:text-theme-text-tertiary focus:outline-none focus:border-skyhook-500'
|
|
19
|
+
|
|
20
|
+
interface Draft {
|
|
21
|
+
baseUrl: string
|
|
22
|
+
org: string
|
|
23
|
+
user: string
|
|
24
|
+
token: string
|
|
25
|
+
caCertFile: string
|
|
26
|
+
clusterLabel: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const draftFrom = (connection: OpenObserveConnection | null): Draft => ({
|
|
30
|
+
baseUrl: connection?.baseUrl ?? '',
|
|
31
|
+
org: connection?.org ?? 'default',
|
|
32
|
+
user: connection?.user ?? '',
|
|
33
|
+
token: '',
|
|
34
|
+
caCertFile: connection?.caCertFile ?? '',
|
|
35
|
+
clusterLabel: connection?.clusterLabel ?? '',
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const sameTarget = (a: Draft, b: Draft) =>
|
|
39
|
+
a.baseUrl.trim() === b.baseUrl.trim() && a.org.trim() === b.org.trim() && a.user.trim() === b.user.trim()
|
|
40
|
+
|
|
41
|
+
const sameDraft = (a: Draft, b: Draft) =>
|
|
42
|
+
(Object.keys(a) as (keyof Draft)[]).every((key) => a[key] === b[key])
|
|
43
|
+
|
|
44
|
+
type Result =
|
|
45
|
+
| { kind: 'saved'; notes?: OpenObserveSetupNotes; reloadFailed?: boolean }
|
|
46
|
+
| { kind: 'confirm'; reason?: string; suggestion: OpenObserveLabelValue; body: OpenObserveSetupRequest }
|
|
47
|
+
| { kind: 'not_found'; reason?: string; names: OpenObserveLabelValue[]; uid?: string }
|
|
48
|
+
| { kind: 'error'; message: string }
|
|
49
|
+
|
|
50
|
+
const pair = (value: OpenObserveLabelValue) => `${value.label}=${value.value}`
|
|
51
|
+
|
|
52
|
+
export const matchSummary = (match: OpenObserveMatch) =>
|
|
53
|
+
`Matched by ${match.by === 'id' ? 'cluster ID' : 'confirmed name'} (${pair(match)})`
|
|
54
|
+
|
|
55
|
+
const connectionLine = (connection: OpenObserveConnection) =>
|
|
56
|
+
`${connection.baseUrl} · organization ${connection.org} · user ${connection.user}`
|
|
57
|
+
|
|
58
|
+
export function OpenObserveSetup({
|
|
59
|
+
state,
|
|
60
|
+
locked = false,
|
|
61
|
+
status,
|
|
62
|
+
onStateChange,
|
|
63
|
+
onChanged,
|
|
64
|
+
onUsePrometheus,
|
|
65
|
+
onDirtyChange,
|
|
66
|
+
onBusyChange,
|
|
67
|
+
}: {
|
|
68
|
+
state: OpenObserveState
|
|
69
|
+
locked?: boolean
|
|
70
|
+
status?: ReactNode
|
|
71
|
+
onStateChange: (state: OpenObserveState) => void
|
|
72
|
+
onChanged: () => void
|
|
73
|
+
onUsePrometheus: () => Promise<void>
|
|
74
|
+
onDirtyChange?: (dirty: boolean) => void
|
|
75
|
+
onBusyChange?: (busy: boolean) => void
|
|
76
|
+
}) {
|
|
77
|
+
const id = useId()
|
|
78
|
+
const { connection, cluster } = state
|
|
79
|
+
const match = cluster.match
|
|
80
|
+
const [editing, setEditing] = useState(false)
|
|
81
|
+
const baseline = useMemo(() => draftFrom(connection), [connection])
|
|
82
|
+
const [draft, setDraft] = useState<Draft>(baseline)
|
|
83
|
+
const [busy, setBusy] = useState(false)
|
|
84
|
+
const [result, setResult] = useState<Result | null>(null)
|
|
85
|
+
const [confirmingRemove, setConfirmingRemove] = useState(false)
|
|
86
|
+
const mounted = useRef(true)
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
mounted.current = true
|
|
89
|
+
return () => { mounted.current = false }
|
|
90
|
+
}, [])
|
|
91
|
+
|
|
92
|
+
const showForm = !locked && (!connection || editing)
|
|
93
|
+
// A token from an environment variable is kept only for the same address,
|
|
94
|
+
// organization and user; the server never sends a saved secret elsewhere.
|
|
95
|
+
const envToken = !!connection && connection.tokenSource === 'env' && sameTarget(draft, baseline)
|
|
96
|
+
const dirty = showForm && !sameDraft(draft, baseline)
|
|
97
|
+
useEffect(() => onDirtyChange?.(dirty), [dirty, onDirtyChange])
|
|
98
|
+
useEffect(() => onBusyChange?.(busy), [busy, onBusyChange])
|
|
99
|
+
useEffect(() => () => {
|
|
100
|
+
onDirtyChange?.(false)
|
|
101
|
+
onBusyChange?.(false)
|
|
102
|
+
}, [onDirtyChange, onBusyChange])
|
|
103
|
+
|
|
104
|
+
const update = (changes: Partial<Draft>) => {
|
|
105
|
+
setDraft((value) => ({ ...value, ...changes }))
|
|
106
|
+
if (result?.kind === 'confirm') setResult(null)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const run = async (action: () => Promise<void>) => {
|
|
110
|
+
setBusy(true)
|
|
111
|
+
try {
|
|
112
|
+
await action()
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (mounted.current) setResult({ kind: 'error', message: error instanceof Error ? error.message : String(error) })
|
|
115
|
+
} finally {
|
|
116
|
+
if (mounted.current) setBusy(false)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const formBody = (): OpenObserveSetupRequest => ({
|
|
121
|
+
baseUrl: draft.baseUrl.trim(),
|
|
122
|
+
org: draft.org.trim(),
|
|
123
|
+
user: draft.user.trim(),
|
|
124
|
+
caCertFile: draft.caCertFile.trim(),
|
|
125
|
+
clusterLabel: draft.clusterLabel.trim(),
|
|
126
|
+
...(draft.token && !envToken ? { token: draft.token } : {}),
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const submit = (body: OpenObserveSetupRequest) => run(async () => {
|
|
130
|
+
setResult(null)
|
|
131
|
+
const response = await setupOpenObserve(cluster.uid ? { ...body, clusterUid: cluster.uid } : body)
|
|
132
|
+
if (!mounted.current) return
|
|
133
|
+
if (response.outcome === 'saved') {
|
|
134
|
+
setResult({ kind: 'saved', notes: response.notes })
|
|
135
|
+
setEditing(false)
|
|
136
|
+
onChanged()
|
|
137
|
+
let next: OpenObserveState
|
|
138
|
+
try {
|
|
139
|
+
next = await getOpenObserveState()
|
|
140
|
+
} catch {
|
|
141
|
+
if (mounted.current) setResult({ kind: 'saved', notes: response.notes, reloadFailed: true })
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
if (!mounted.current) return
|
|
145
|
+
setDraft(draftFrom(next.connection))
|
|
146
|
+
onStateChange(next)
|
|
147
|
+
} else if (response.outcome === 'confirm' && response.suggestion) {
|
|
148
|
+
setResult({ kind: 'confirm', reason: response.reason, suggestion: response.suggestion, body })
|
|
149
|
+
} else {
|
|
150
|
+
setResult({ kind: 'not_found', reason: response.reason, names: response.clusterNames ?? [], uid: response.clusterUid ?? cluster.uid })
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const testAndSave = () => {
|
|
155
|
+
if (result?.kind === 'confirm') void submit({ ...result.body, confirm: result.suggestion })
|
|
156
|
+
else void submit(showForm ? formBody() : { useSaved: true })
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const removeAll = () => {
|
|
160
|
+
setConfirmingRemove(false)
|
|
161
|
+
void run(async () => {
|
|
162
|
+
setResult(null)
|
|
163
|
+
const next = await removeOpenObserveConnection()
|
|
164
|
+
if (!mounted.current) return
|
|
165
|
+
setEditing(false)
|
|
166
|
+
setDraft(draftFrom(next.connection))
|
|
167
|
+
onStateChange(next)
|
|
168
|
+
onChanged()
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const startEditing = () => {
|
|
173
|
+
setDraft(baseline)
|
|
174
|
+
setResult(null)
|
|
175
|
+
setEditing(true)
|
|
176
|
+
}
|
|
177
|
+
const cancelEditing = () => {
|
|
178
|
+
setDraft(baseline)
|
|
179
|
+
setResult(null)
|
|
180
|
+
setEditing(false)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const shared = connection && connection.clusters.length > 1
|
|
184
|
+
? <p className="text-xs text-theme-text-secondary">Shared by {connection.clusters.length} clusters. Changes apply to all of them.</p>
|
|
185
|
+
: null
|
|
186
|
+
const contexts = connection?.clusters.map((c) => c.context).filter(Boolean) ?? []
|
|
187
|
+
|
|
188
|
+
const statusRow = status ? <div className="flex flex-wrap items-center gap-x-3 gap-y-1">{status}</div> : null
|
|
189
|
+
|
|
190
|
+
if (locked) {
|
|
191
|
+
return (
|
|
192
|
+
<div className="space-y-2 text-sm">
|
|
193
|
+
{statusRow}
|
|
194
|
+
{match && <p className="text-theme-text-primary">{matchSummary(match)}</p>}
|
|
195
|
+
{connection
|
|
196
|
+
? <p className="break-words text-xs text-theme-text-secondary">{connectionLine(connection)}</p>
|
|
197
|
+
: <p className="text-xs text-theme-text-secondary">No OpenObserve connection saved.</p>}
|
|
198
|
+
</div>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const notes = result?.kind === 'saved' ? [
|
|
203
|
+
result.notes?.collector && 'Data comes from the OpenObserve collector.',
|
|
204
|
+
// The live status line repeats the warning, version and coverage notes
|
|
205
|
+
// once the match settles; only say them here when that line isn't shown.
|
|
206
|
+
!status && result.notes?.missing?.length && missingFamiliesNote(result.notes.missing),
|
|
207
|
+
!status && result.notes?.warning,
|
|
208
|
+
!status && result.notes?.versionWarning,
|
|
209
|
+
result.reloadFailed && "Saved, but Radar couldn't reload this page. Reopen Settings to see the match.",
|
|
210
|
+
].filter((note): note is string => !!note) : []
|
|
211
|
+
|
|
212
|
+
const outcome = result && result.kind !== 'saved' ? (
|
|
213
|
+
result.kind === 'error' ? (
|
|
214
|
+
<p role="alert" className="text-xs text-semantic-error">{result.message}</p>
|
|
215
|
+
) : result.kind === 'confirm' ? (
|
|
216
|
+
<p role="status" className="text-xs text-warning-text">
|
|
217
|
+
{result.reason ?? `OpenObserve has metrics for ${pair(result.suggestion)}, matched only by name.`}
|
|
218
|
+
</p>
|
|
219
|
+
) : (
|
|
220
|
+
<div role="status" className="space-y-1 text-xs text-theme-text-secondary">
|
|
221
|
+
{result.reason && <p className="text-warning-text">{result.reason}</p>}
|
|
222
|
+
{result.names.length
|
|
223
|
+
? <p>{`OpenObserve has metrics for: ${result.names.map(pair).join(', ')}.`}</p>
|
|
224
|
+
// The reason already says what the Pod sample found in OpenObserve.
|
|
225
|
+
: !result.reason && <p>OpenObserve has no cluster metrics yet.</p>}
|
|
226
|
+
<p>If OpenObserve names clusters with another label, set it under Advanced.</p>
|
|
227
|
+
{result.uid && <p>To match by ID, add the label radar_cluster_uid={result.uid} to this cluster’s metrics.</p>}
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
) : null
|
|
231
|
+
|
|
232
|
+
const saveButton = (
|
|
233
|
+
<button type="button" onClick={testAndSave} disabled={busy} className="btn-brand min-w-28 px-3 py-2 text-xs">
|
|
234
|
+
{busy ? 'Testing…' : result?.kind === 'confirm' ? `Confirm '${result.suggestion.value}' and save` : 'Test and save'}
|
|
235
|
+
</button>
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<fieldset disabled={busy} aria-label="OpenObserve connection settings" className="min-w-0 space-y-4">
|
|
240
|
+
{statusRow}
|
|
241
|
+
{cluster.error && <p className="text-xs text-warning-text">{cluster.error}</p>}
|
|
242
|
+
{showForm ? (
|
|
243
|
+
<div className="space-y-4">
|
|
244
|
+
{shared}
|
|
245
|
+
<div className="space-y-1">
|
|
246
|
+
<label htmlFor={`${id}-url`} className="block text-sm font-medium text-theme-text-primary">Address</label>
|
|
247
|
+
<Input id={`${id}-url`} value={draft.baseUrl} onChange={(e) => update({ baseUrl: e.target.value })} placeholder="https://openobserve.example.com" spellCheck={false} className={inputClass} />
|
|
248
|
+
</div>
|
|
249
|
+
<div className="space-y-1">
|
|
250
|
+
<label htmlFor={`${id}-org`} className="block text-sm font-medium text-theme-text-primary">Organization</label>
|
|
251
|
+
<Input id={`${id}-org`} value={draft.org} onChange={(e) => update({ org: e.target.value })} spellCheck={false} className={inputClass} />
|
|
252
|
+
</div>
|
|
253
|
+
<div className="space-y-1">
|
|
254
|
+
<label htmlFor={`${id}-user`} className="block text-sm font-medium text-theme-text-primary">User or service account email</label>
|
|
255
|
+
<Input id={`${id}-user`} value={draft.user} onChange={(e) => update({ user: e.target.value })} autoComplete="off" spellCheck={false} className={inputClass} />
|
|
256
|
+
<a href={SERVICE_ACCOUNT_DOCS} target="_blank" rel="noopener noreferrer" className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
|
|
257
|
+
Create a service account in OpenObserve
|
|
258
|
+
<ExternalLink aria-hidden="true" className="h-3 w-3" />
|
|
259
|
+
</a>
|
|
260
|
+
</div>
|
|
261
|
+
<div className="space-y-1">
|
|
262
|
+
<label htmlFor={`${id}-token`} className="block text-sm font-medium text-theme-text-primary">Token</label>
|
|
263
|
+
{envToken ? (
|
|
264
|
+
<p id={`${id}-token`} className="text-sm text-theme-text-secondary">Token from ${connection.tokenEnv}</p>
|
|
265
|
+
) : (
|
|
266
|
+
<Input
|
|
267
|
+
id={`${id}-token`}
|
|
268
|
+
type="password"
|
|
269
|
+
autoComplete="new-password"
|
|
270
|
+
spellCheck={false}
|
|
271
|
+
value={draft.token}
|
|
272
|
+
onChange={(e) => update({ token: e.target.value })}
|
|
273
|
+
placeholder={connection?.tokenSource === 'saved' && sameTarget(draft, baseline) ? 'Saved — leave empty to keep' : undefined}
|
|
274
|
+
className={inputClass}
|
|
275
|
+
/>
|
|
276
|
+
)}
|
|
277
|
+
{connection && connection.tokenSource !== 'none' && !sameTarget(draft, baseline) && (
|
|
278
|
+
<p className="text-xs text-theme-text-secondary">A new address, organization or user needs its own token.</p>
|
|
279
|
+
)}
|
|
280
|
+
<p className="text-xs text-theme-text-tertiary">Saved in ~/.radar/config.json, readable only by you.</p>
|
|
281
|
+
</div>
|
|
282
|
+
<Disclosure
|
|
283
|
+
summary="Advanced"
|
|
284
|
+
summaryClassName="text-sm font-medium text-theme-text-secondary"
|
|
285
|
+
defaultOpen={!!(baseline.caCertFile || baseline.clusterLabel)}
|
|
286
|
+
>
|
|
287
|
+
<div className="space-y-4 pt-3">
|
|
288
|
+
<div className="space-y-1">
|
|
289
|
+
<label htmlFor={`${id}-ca`} className="block text-sm font-medium text-theme-text-primary">CA certificate file</label>
|
|
290
|
+
<Input id={`${id}-ca`} value={draft.caCertFile} onChange={(e) => update({ caCertFile: e.target.value })} placeholder="/path/to/ca.pem" spellCheck={false} className={inputClass} />
|
|
291
|
+
</div>
|
|
292
|
+
<div className="space-y-1">
|
|
293
|
+
<label htmlFor={`${id}-label`} className="block text-sm font-medium text-theme-text-primary">Cluster label</label>
|
|
294
|
+
<p className="text-xs text-theme-text-tertiary">Only when OpenObserve names clusters with a label Radar doesn’t know.</p>
|
|
295
|
+
<Input id={`${id}-label`} value={draft.clusterLabel} onChange={(e) => update({ clusterLabel: e.target.value })} spellCheck={false} className={inputClass} />
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
</Disclosure>
|
|
299
|
+
</div>
|
|
300
|
+
) : match && connection ? (
|
|
301
|
+
<div className="card-inner-lg space-y-2">
|
|
302
|
+
<p className="text-sm text-theme-text-primary">{matchSummary(match)}</p>
|
|
303
|
+
<p className="break-words text-xs text-theme-text-secondary">{connectionLine(connection)}</p>
|
|
304
|
+
{shared}
|
|
305
|
+
</div>
|
|
306
|
+
) : connection ? (
|
|
307
|
+
<p className="break-words text-sm text-theme-text-secondary">
|
|
308
|
+
Use the saved OpenObserve connection ({connection.baseUrl}, user {connection.user})
|
|
309
|
+
</p>
|
|
310
|
+
) : null}
|
|
311
|
+
<div className="space-y-2 border-t border-theme-border pt-4">
|
|
312
|
+
<div className="flex min-h-8 flex-wrap items-center gap-3">
|
|
313
|
+
{(showForm || !match) && saveButton}
|
|
314
|
+
{connection && !editing && (
|
|
315
|
+
<button type="button" onClick={startEditing} className="text-xs font-medium text-accent-text hover:underline">Edit connection</button>
|
|
316
|
+
)}
|
|
317
|
+
{editing && (
|
|
318
|
+
<button type="button" onClick={cancelEditing} className="text-xs text-theme-text-secondary hover:underline">Cancel</button>
|
|
319
|
+
)}
|
|
320
|
+
{match && !editing && (
|
|
321
|
+
<button type="button" onClick={() => void run(async () => { setResult(null); await onUsePrometheus() })} className="text-xs font-medium text-accent-text hover:underline">
|
|
322
|
+
Use Prometheus for this cluster
|
|
323
|
+
</button>
|
|
324
|
+
)}
|
|
325
|
+
{result?.kind === 'saved' && (
|
|
326
|
+
<span role="status" className="flex items-center gap-1.5 text-xs text-theme-text-secondary">
|
|
327
|
+
<Check aria-hidden="true" className="h-3.5 w-3.5 text-[var(--color-success-dark)] dark:text-[var(--color-success-light)]" />
|
|
328
|
+
Saved
|
|
329
|
+
</span>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
<Collapse open={notes.length > 0}>
|
|
333
|
+
<ul className="space-y-0.5 text-xs text-theme-text-secondary">
|
|
334
|
+
{notes.map((note) => <li key={note}>{note}</li>)}
|
|
335
|
+
</ul>
|
|
336
|
+
</Collapse>
|
|
337
|
+
<Collapse open={!!outcome}>{outcome}</Collapse>
|
|
338
|
+
{connection && !editing && (
|
|
339
|
+
<button type="button" onClick={() => setConfirmingRemove(true)} className="self-start text-xs font-medium text-semantic-error hover:underline">
|
|
340
|
+
Remove saved OpenObserve connection
|
|
341
|
+
</button>
|
|
342
|
+
)}
|
|
343
|
+
</div>
|
|
344
|
+
<ConfirmDialog
|
|
345
|
+
open={confirmingRemove}
|
|
346
|
+
onClose={() => setConfirmingRemove(false)}
|
|
347
|
+
onConfirm={removeAll}
|
|
348
|
+
title="Remove the saved OpenObserve connection?"
|
|
349
|
+
message={contexts.length
|
|
350
|
+
? `These clusters go back to their own Prometheus: ${contexts.join(', ')}.`
|
|
351
|
+
: 'No cluster reads from it yet.'}
|
|
352
|
+
confirmLabel="Remove"
|
|
353
|
+
variant="warning"
|
|
354
|
+
showWarning={false}
|
|
355
|
+
/>
|
|
356
|
+
</fieldset>
|
|
357
|
+
)
|
|
358
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasPrometheusCharts, metricsConnectionLabel, metricsSourceUnavailable } from '../../api/prometheusCharts'
|
|
1
2
|
import { useState, useEffect, useRef, useCallback, type ReactNode } from 'react'
|
|
2
3
|
import { createPortal } from 'react-dom'
|
|
3
4
|
import {
|
|
@@ -38,6 +39,7 @@ import { costSourceApplyLabel, pendingSectionLabels, pendingSections, shouldShow
|
|
|
38
39
|
import { PrometheusConfigField } from './PrometheusConfigField'
|
|
39
40
|
import { LocalConnectionSettings, type IntegrationProfiles, type IntegrationKind } from './LocalConnectionSettings'
|
|
40
41
|
import { LocalIntegrationStatus } from './LocalIntegrationStatus'
|
|
42
|
+
import { MetricsBackendSwitch } from './MetricsBackendSwitch'
|
|
41
43
|
import { LocalConfigurationDetails, SavedClusterConnections, PreviousIntegrationSettingsNotice } from './LocalConfigurationDetails'
|
|
42
44
|
import { useContextSwitch } from '../../context/ContextSwitchContext'
|
|
43
45
|
import { previousIntegrationSettingsKey, type IntegrationSettingsResponse } from '../../hooks/usePreviousIntegrationSettings'
|
|
@@ -183,6 +185,10 @@ export function SettingsDialog({
|
|
|
183
185
|
void queryClient.resetQueries({ queryKey: [previousIntegrationSettingsKey] })
|
|
184
186
|
void queryClient.invalidateQueries({ predicate: query => typeof query.queryKey[0] === 'string' && /^(prometheus|opencost|gitops|argo)/.test(query.queryKey[0]) })
|
|
185
187
|
}, [queryClient])
|
|
188
|
+
const openObserveChanged = useCallback(() => {
|
|
189
|
+
setConnectionsChangedAt(Date.now())
|
|
190
|
+
void queryClient.invalidateQueries({ predicate: query => typeof query.queryKey[0] === 'string' && /^(prometheus|opencost)/.test(query.queryKey[0]) })
|
|
191
|
+
}, [queryClient])
|
|
186
192
|
|
|
187
193
|
const [configData, setConfigData] = useState<ConfigResponse | null>(null)
|
|
188
194
|
const operatorManaged = configData?.management === 'operator'
|
|
@@ -267,6 +273,10 @@ export function SettingsDialog({
|
|
|
267
273
|
const settingsScope = `${settingsApiBase}:${settingsCluster?.context}`
|
|
268
274
|
const targetChangedWithDraft = open && metricsDraft.current.open && metricsDraft.current.dirty && (isSwitching || metricsDraft.current.scope !== settingsScope)
|
|
269
275
|
const showLocalStatus = open && !draftFrozen && !targetChangedWithDraft && !isSwitching
|
|
276
|
+
const metricsProfile = configData?.integrationProfiles?.metrics
|
|
277
|
+
const metricsStatus = metricsProfile && showLocalStatus && section === 'prometheus' && !['error', 'target_changed'].includes(metricsProfile.state)
|
|
278
|
+
? <LocalIntegrationStatus kind="metrics" profile={metricsProfile} argo={argoStatusQuery} busy={integrationBusy} changedAt={connectionsChangedAt} />
|
|
279
|
+
: undefined
|
|
270
280
|
useEffect(() => {
|
|
271
281
|
if (!open) {
|
|
272
282
|
setDraftFrozen(false)
|
|
@@ -761,9 +771,11 @@ export function SettingsDialog({
|
|
|
761
771
|
caption={configData?.integrationProfiles ? localIntegrationCaption : 'Connect and manage your metrics backend.'}
|
|
762
772
|
live
|
|
763
773
|
locked={!canEditConfig}
|
|
774
|
+
lockedContent={configData?.integrationProfiles ? <MetricsBackendSwitch key={`${discardGeneration}:${JSON.stringify(configData.integrationProfiles.metrics.target)}`} locked onChanged={openObserveChanged} status={metricsStatus} prometheus={() => null} /> : undefined}
|
|
764
775
|
>
|
|
765
|
-
{configData?.integrationProfiles ? <
|
|
766
|
-
status={
|
|
776
|
+
{configData?.integrationProfiles ? <MetricsBackendSwitch key={`${discardGeneration}:${JSON.stringify(configData.integrationProfiles.metrics.target)}`} onChanged={openObserveChanged} onDirtyChange={metricsDirtyChange} onBusyChange={metricsBusyChange}
|
|
777
|
+
status={metricsStatus}
|
|
778
|
+
prometheus={({ status, onDirtyChange, onBusyChange }) => <LocalConnectionSettings kind="metrics" profiles={configData.integrationProfiles!} onChange={connectionsChanged} onDirtyChange={onDirtyChange} onBusyChange={onBusyChange} status={status} />} /> : <PrometheusConfigField
|
|
767
779
|
key={`${settingsApiBase}:${discardGeneration}`}
|
|
768
780
|
onBusyChange={metricsBusyChange}
|
|
769
781
|
onDirtyChange={setPrometheusCredentialDirty}
|
|
@@ -1155,6 +1167,7 @@ function SectionPane({
|
|
|
1155
1167
|
caption,
|
|
1156
1168
|
live,
|
|
1157
1169
|
locked,
|
|
1170
|
+
lockedContent,
|
|
1158
1171
|
managed,
|
|
1159
1172
|
children,
|
|
1160
1173
|
}: {
|
|
@@ -1164,6 +1177,7 @@ function SectionPane({
|
|
|
1164
1177
|
caption?: string
|
|
1165
1178
|
live?: boolean
|
|
1166
1179
|
locked?: boolean
|
|
1180
|
+
lockedContent?: ReactNode
|
|
1167
1181
|
managed?: ReactNode
|
|
1168
1182
|
children: ReactNode
|
|
1169
1183
|
}) {
|
|
@@ -1173,7 +1187,7 @@ function SectionPane({
|
|
|
1173
1187
|
<h3 className="text-base font-semibold text-theme-text-primary">{title}</h3>
|
|
1174
1188
|
{!locked && caption && <SectionCaption live={live}>{caption}</SectionCaption>}
|
|
1175
1189
|
</div>
|
|
1176
|
-
{managed ?? (locked ? <LockWall /> : <div className="space-y-4">{children}</div>)}
|
|
1190
|
+
{managed ?? (locked ? <div className="space-y-4"><LockWall />{lockedContent}</div> : <div className="space-y-4">{children}</div>)}
|
|
1177
1191
|
</div>
|
|
1178
1192
|
)
|
|
1179
1193
|
}
|
|
@@ -1207,7 +1221,7 @@ function OperatorSettingsSummary({ section, config }: { section: SettingsSection
|
|
|
1207
1221
|
break
|
|
1208
1222
|
case 'prometheus':
|
|
1209
1223
|
rows = [
|
|
1210
|
-
['Status', promError ? 'Status unavailable' :
|
|
1224
|
+
['Status', promError ? 'Status unavailable' : metricsConnectionLabel(prom)],
|
|
1211
1225
|
['Endpoint', prom?.address || c.prometheusUrl || 'Auto-discovery'],
|
|
1212
1226
|
['Headers', config.prometheusHeaderKeys?.join(', ') || 'None configured'],
|
|
1213
1227
|
]
|
|
@@ -1326,9 +1340,9 @@ function OverviewPanel({ active, onNavigate }: { active: boolean; onNavigate: (s
|
|
|
1326
1340
|
},
|
|
1327
1341
|
{
|
|
1328
1342
|
id: 'prometheus', icon: Activity, label: 'Metrics',
|
|
1329
|
-
tone: prom
|
|
1330
|
-
value: prom
|
|
1331
|
-
detail: prom?.connected ? prom.address : prom?.discovering ? undefined : prom?.error ? 'Open Metrics for connection details.' : undefined,
|
|
1343
|
+
tone: hasPrometheusCharts(prom) ? 'ok' : metricsSourceUnavailable(prom) ? 'warn' : prom?.discovering ? 'unknown' : prom?.error ? 'warn' : 'off',
|
|
1344
|
+
value: prom ? metricsConnectionLabel(prom) : 'Not connected',
|
|
1345
|
+
detail: hasPrometheusCharts(prom) && prom?.connected ? prom.address : prom?.gkeSystemMetrics || prom?.discovering ? undefined : prom?.error || metricsSourceUnavailable(prom) ? 'Open Metrics for connection details.' : undefined,
|
|
1332
1346
|
},
|
|
1333
1347
|
{
|
|
1334
1348
|
id: costConfigurationAction(cost?.reason).section, icon: Coins, label: 'Cost',
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { metricsSourceLine, sourceNote } from './openobserveStatus'
|
|
3
|
+
|
|
4
|
+
describe('metricsSourceLine', () => {
|
|
5
|
+
it('names an ID match on the shared local connection', () => {
|
|
6
|
+
expect(metricsSourceLine({ kind: 'openobserve', via: 'local', matchedBy: 'id' })).toEqual({
|
|
7
|
+
status: 'OpenObserve · shared connection · matched by cluster ID', detail: undefined, tone: 'success',
|
|
8
|
+
})
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('keeps the standing warning, version warning and missing families for a name match', () => {
|
|
12
|
+
const line = metricsSourceLine({ kind: 'openobserve', via: 'local', matchedBy: 'name', versionWarning: 'Upgrade.', missingFamilies: ['throttling', 'hpa'] })
|
|
13
|
+
expect(line?.status).toBe('OpenObserve · shared connection · matched by confirmed name')
|
|
14
|
+
expect(line?.detail).toBe("Add the cluster ID label so this match can't break. Upgrade. No data in OpenObserve for: CPU throttling, HPA.")
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('shows the standing warning of an active match after saving', () => {
|
|
18
|
+
const warning = 'This cluster\'s OpenObserve collector sends the default cluster name "cluster1". Radar refuses its kube-state metrics.'
|
|
19
|
+
expect(metricsSourceLine({ kind: 'openobserve', via: 'local', matchedBy: 'id', warning })?.detail).toBe(warning)
|
|
20
|
+
expect(metricsSourceLine({ kind: 'openobserve', via: 'local', matchedBy: 'name', warning: 'Matched by cluster name.' })?.detail).toBe('Matched by cluster name.')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('reports unavailable without claiming a connection', () => {
|
|
24
|
+
expect(metricsSourceLine({ kind: 'openobserve', via: 'local', matchedBy: 'id', unavailable: true, error: 'OpenObserve unavailable: refused' }))
|
|
25
|
+
.toEqual({ status: 'OpenObserve unavailable', detail: 'refused', tone: 'warning' })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('leaves the Prometheus line for an unmatched context and explains why', () => {
|
|
29
|
+
const src = { kind: 'openobserve' as const, via: 'local' as const, error: "This context isn't matched in OpenObserve." }
|
|
30
|
+
expect(metricsSourceLine(src)).toBeUndefined()
|
|
31
|
+
expect(sourceNote(src)).toBe("This context isn't matched in OpenObserve.")
|
|
32
|
+
expect(metricsSourceLine(undefined)).toBeUndefined()
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { MetricsSource } from '../../api/client'
|
|
2
|
+
|
|
3
|
+
export interface MetricsSourceLine {
|
|
4
|
+
status: string
|
|
5
|
+
detail?: string
|
|
6
|
+
tone: 'success' | 'warning' | 'neutral'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// The one set of metric family names Radar shows (mirrored by FamilyLabel in
|
|
10
|
+
// pkg/prom/openobserve for the CLI). Each starts with a capital, even mid-list.
|
|
11
|
+
const FAMILY_LABELS: Record<string, string> = {
|
|
12
|
+
cpu: 'CPU', memory: 'Memory', throttling: 'CPU throttling', network: 'Network',
|
|
13
|
+
filesystem: 'Disk I/O', restarts: 'Restarts', volumes: 'Volumes', nodes: 'Nodes', hpa: 'HPA',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const familyLabel = (family: string) => FAMILY_LABELS[family] ?? family
|
|
17
|
+
|
|
18
|
+
/** The one phrase for metric families OpenObserve holds no data for. */
|
|
19
|
+
export const missingFamiliesNote = (families: string[]) => `No data in OpenObserve for: ${families.map(familyLabel).join(', ')}.`
|
|
20
|
+
|
|
21
|
+
/** An unavailable source's error without the "OpenObserve unavailable" its heading already says. */
|
|
22
|
+
export const unavailableReason = (error: string | undefined) => error?.replace(/^OpenObserve unavailable: /, '')
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The status line for a metrics source, or undefined when the source is not
|
|
26
|
+
* serving this context (the Prometheus line applies; see `sourceNote`).
|
|
27
|
+
*/
|
|
28
|
+
export function metricsSourceLine(source: MetricsSource | undefined): MetricsSourceLine | undefined {
|
|
29
|
+
if (!source || source.kind !== 'openobserve') return undefined
|
|
30
|
+
const shared = source.via === 'local' ? ' · shared connection' : ''
|
|
31
|
+
if (source.unavailable) {
|
|
32
|
+
return { status: 'OpenObserve unavailable', detail: unavailableReason(source.error), tone: 'warning' }
|
|
33
|
+
}
|
|
34
|
+
if (!source.matchedBy) return undefined
|
|
35
|
+
const details: string[] = []
|
|
36
|
+
// The backend's standing warning (name match, refused collector metrics)
|
|
37
|
+
// says why and what to fix; the short hint stands in only without one.
|
|
38
|
+
if (source.warning) details.push(source.warning)
|
|
39
|
+
else if (source.matchedBy === 'name') details.push("Add the cluster ID label so this match can't break.")
|
|
40
|
+
if (source.versionWarning) details.push(source.versionWarning)
|
|
41
|
+
if (source.missingFamilies?.length) {
|
|
42
|
+
details.push(missingFamiliesNote(source.missingFamilies))
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
status: `OpenObserve${shared} · matched by ${source.matchedBy === 'id' ? 'cluster ID' : 'confirmed name'}`,
|
|
46
|
+
detail: details.length ? details.join(' ') : undefined,
|
|
47
|
+
tone: 'success',
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Why a configured source isn't serving this context, if it says. */
|
|
52
|
+
export function sourceNote(source: MetricsSource | undefined): string | undefined {
|
|
53
|
+
if (!source || source.unavailable || source.matchedBy) return undefined
|
|
54
|
+
return source.error ?? source.warning
|
|
55
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import type { TimelineEvent } from '../../types'
|
|
6
|
+
|
|
7
|
+
const event = (id: string, minutesAgo: number): TimelineEvent => ({
|
|
8
|
+
id, timestamp: new Date(Date.now() - minutesAgo * 60_000).toISOString(), source: 'informer', kind: 'ConfigMap', apiVersion: 'v1',
|
|
9
|
+
namespace: 'shop', name: `cfg-${id}`, eventType: 'update', reason: 'update', message: `${id} changed`,
|
|
10
|
+
} as TimelineEvent)
|
|
11
|
+
const events = [event('ev-a', 5), event('ev-b', 9), event('ev-c', 14)]
|
|
12
|
+
|
|
13
|
+
vi.mock('../../context/TimelineSource', () => ({
|
|
14
|
+
useTimelineSource: () => ({ useEvents: () => ({ data: events, isLoading: false, isFetching: false, isError: false, error: null, refetch: vi.fn() }) }),
|
|
15
|
+
}))
|
|
16
|
+
vi.mock('../../contexts/CapabilitiesContext', () => ({ useHasLimitedAccess: () => false }))
|
|
17
|
+
vi.mock('./TimelineRetentionNote', () => ({ TimelineRetentionBanner: () => null }))
|
|
18
|
+
|
|
19
|
+
const { TimelineList } = await import('./TimelineList')
|
|
20
|
+
|
|
21
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
22
|
+
const roots: ReturnType<typeof createRoot>[] = []
|
|
23
|
+
afterEach(() => { roots.splice(0).forEach((root) => act(() => root.unmount())) })
|
|
24
|
+
|
|
25
|
+
describe('the Timeline list with an event selected', () => {
|
|
26
|
+
it('marks the selected event, so a link to it lands on it in list view too', async () => {
|
|
27
|
+
const host = document.createElement('div')
|
|
28
|
+
document.body.append(host)
|
|
29
|
+
const root = createRoot(host)
|
|
30
|
+
roots.push(root)
|
|
31
|
+
await act(async () => {
|
|
32
|
+
root.render(<TimelineList namespaces={['shop']} showDeleted onShowDeletedChange={() => {}} showRoutine={false} onShowRoutineChange={() => {}}
|
|
33
|
+
search="" onSearchChange={() => {}} activityFilter={[]} onActivityFilterChange={() => {}} kindFilter={[]} onKindFilterChange={() => {}}
|
|
34
|
+
selectedEventId="ev-b" onSelectEvent={() => {}} />)
|
|
35
|
+
})
|
|
36
|
+
const selected = [...host.querySelectorAll('[class*="ring-skyhook-500/60"]')]
|
|
37
|
+
expect(selected).toHaveLength(1)
|
|
38
|
+
expect(selected[0].textContent).toContain('cfg-ev-b')
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -72,3 +72,21 @@ describe('splitRoutineActivity', () => {
|
|
|
72
72
|
expect(routineTruncated).toBe(true)
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
|
+
|
|
76
|
+
describe('a linked event behind the list cap', () => {
|
|
77
|
+
it('keeps the selected event in the list even when newer rows fill the cap', () => {
|
|
78
|
+
const target = ev({ id: 'linked', kind: 'ConfigMap' })
|
|
79
|
+
const newer = Array.from({ length: 5 }, (_, i) => ev({ id: `newer-${i}`, kind: 'Deployment' }))
|
|
80
|
+
const rows = [...newer].reverse().concat(target)
|
|
81
|
+
const capped = splitRoutineActivity(rows, 3, 'linked')
|
|
82
|
+
expect(capped.withoutRoutine.map((e) => e.id)).toContain('linked')
|
|
83
|
+
expect(capped.withRoutine.map((e) => e.id)).toContain('linked')
|
|
84
|
+
expect(capped.truncated).toBe(true)
|
|
85
|
+
expect(splitRoutineActivity(rows, 3).withoutRoutine.map((e) => e.id)).not.toContain('linked')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('shows a linked routine child row with routine activity hidden', () => {
|
|
89
|
+
const routineRow = ev({ id: 'rs-linked', kind: 'ReplicaSet', owner: { kind: 'Deployment', name: 'web' } })
|
|
90
|
+
expect(splitRoutineActivity([routineRow], 10, 'rs-linked').withoutRoutine.map((e) => e.id)).toEqual(['rs-linked'])
|
|
91
|
+
})
|
|
92
|
+
})
|