@skyhook-io/radar-app 1.21.7 → 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 +2 -2
- package/src/App.tsx +12 -3
- package/src/api/client.ts +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/home/HomeView.tsx +9 -1
- 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/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/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/utils/page-links.ts +15 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
2
2
|
import { Collapse, ConfirmDialog, Disclosure, Input } from '@skyhook-io/k8s-ui'
|
|
3
|
-
import {
|
|
3
|
+
import { ExternalLink } from 'lucide-react'
|
|
4
4
|
import {
|
|
5
5
|
getOpenObserveState,
|
|
6
6
|
removeOpenObserveConnection,
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
type OpenObserveState,
|
|
14
14
|
} from '../../api/openobserveSetup'
|
|
15
15
|
import { missingFamiliesNote } from './openobserveStatus'
|
|
16
|
+
import { FormSaveActions } from './FormSaveActions'
|
|
16
17
|
|
|
17
|
-
const SERVICE_ACCOUNT_DOCS = 'https://openobserve.ai/docs/user-guide/identity-and-access-management/service-accounts/'
|
|
18
|
+
const SERVICE_ACCOUNT_DOCS = 'https://openobserve.ai/docs/user-guide/account-administration/identity-and-access-management/service-accounts/'
|
|
18
19
|
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
|
|
|
20
21
|
interface Draft {
|
|
@@ -28,7 +29,7 @@ interface Draft {
|
|
|
28
29
|
|
|
29
30
|
const draftFrom = (connection: OpenObserveConnection | null): Draft => ({
|
|
30
31
|
baseUrl: connection?.baseUrl ?? '',
|
|
31
|
-
org: connection?.org ?? '
|
|
32
|
+
org: connection?.org ?? '',
|
|
32
33
|
user: connection?.user ?? '',
|
|
33
34
|
token: '',
|
|
34
35
|
caCertFile: connection?.caCertFile ?? '',
|
|
@@ -61,7 +62,6 @@ export function OpenObserveSetup({
|
|
|
61
62
|
status,
|
|
62
63
|
onStateChange,
|
|
63
64
|
onChanged,
|
|
64
|
-
onUsePrometheus,
|
|
65
65
|
onDirtyChange,
|
|
66
66
|
onBusyChange,
|
|
67
67
|
}: {
|
|
@@ -70,14 +70,12 @@ export function OpenObserveSetup({
|
|
|
70
70
|
status?: ReactNode
|
|
71
71
|
onStateChange: (state: OpenObserveState) => void
|
|
72
72
|
onChanged: () => void
|
|
73
|
-
onUsePrometheus: () => Promise<void>
|
|
74
73
|
onDirtyChange?: (dirty: boolean) => void
|
|
75
74
|
onBusyChange?: (busy: boolean) => void
|
|
76
75
|
}) {
|
|
77
76
|
const id = useId()
|
|
78
77
|
const { connection, cluster } = state
|
|
79
78
|
const match = cluster.match
|
|
80
|
-
const [editing, setEditing] = useState(false)
|
|
81
79
|
const baseline = useMemo(() => draftFrom(connection), [connection])
|
|
82
80
|
const [draft, setDraft] = useState<Draft>(baseline)
|
|
83
81
|
const [busy, setBusy] = useState(false)
|
|
@@ -89,11 +87,10 @@ export function OpenObserveSetup({
|
|
|
89
87
|
return () => { mounted.current = false }
|
|
90
88
|
}, [])
|
|
91
89
|
|
|
92
|
-
const showForm = !locked && (!connection || editing)
|
|
93
90
|
// A token from an environment variable is kept only for the same address,
|
|
94
91
|
// organization and user; the server never sends a saved secret elsewhere.
|
|
95
92
|
const envToken = !!connection && connection.tokenSource === 'env' && sameTarget(draft, baseline)
|
|
96
|
-
const dirty =
|
|
93
|
+
const dirty = !locked && !sameDraft(draft, baseline)
|
|
97
94
|
useEffect(() => onDirtyChange?.(dirty), [dirty, onDirtyChange])
|
|
98
95
|
useEffect(() => onBusyChange?.(busy), [busy, onBusyChange])
|
|
99
96
|
useEffect(() => () => {
|
|
@@ -101,6 +98,16 @@ export function OpenObserveSetup({
|
|
|
101
98
|
onBusyChange?.(false)
|
|
102
99
|
}, [onDirtyChange, onBusyChange])
|
|
103
100
|
|
|
101
|
+
// Switching this cluster back to Prometheus happens outside this form.
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!match) setResult((current) => current?.kind === 'saved' ? null : current)
|
|
104
|
+
}, [match])
|
|
105
|
+
|
|
106
|
+
// Switching this cluster back to Prometheus happens outside this form.
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!match) setResult((current) => current?.kind === 'saved' ? null : current)
|
|
109
|
+
}, [match])
|
|
110
|
+
|
|
104
111
|
const update = (changes: Partial<Draft>) => {
|
|
105
112
|
setDraft((value) => ({ ...value, ...changes }))
|
|
106
113
|
if (result?.kind === 'confirm') setResult(null)
|
|
@@ -132,7 +139,6 @@ export function OpenObserveSetup({
|
|
|
132
139
|
if (!mounted.current) return
|
|
133
140
|
if (response.outcome === 'saved') {
|
|
134
141
|
setResult({ kind: 'saved', notes: response.notes })
|
|
135
|
-
setEditing(false)
|
|
136
142
|
onChanged()
|
|
137
143
|
let next: OpenObserveState
|
|
138
144
|
try {
|
|
@@ -153,7 +159,7 @@ export function OpenObserveSetup({
|
|
|
153
159
|
|
|
154
160
|
const testAndSave = () => {
|
|
155
161
|
if (result?.kind === 'confirm') void submit({ ...result.body, confirm: result.suggestion })
|
|
156
|
-
else void submit(
|
|
162
|
+
else void submit(dirty || !connection ? formBody() : { useSaved: true })
|
|
157
163
|
}
|
|
158
164
|
|
|
159
165
|
const removeAll = () => {
|
|
@@ -162,22 +168,15 @@ export function OpenObserveSetup({
|
|
|
162
168
|
setResult(null)
|
|
163
169
|
const next = await removeOpenObserveConnection()
|
|
164
170
|
if (!mounted.current) return
|
|
165
|
-
setEditing(false)
|
|
166
171
|
setDraft(draftFrom(next.connection))
|
|
167
172
|
onStateChange(next)
|
|
168
173
|
onChanged()
|
|
169
174
|
})
|
|
170
175
|
}
|
|
171
176
|
|
|
172
|
-
const
|
|
177
|
+
const discard = () => {
|
|
173
178
|
setDraft(baseline)
|
|
174
179
|
setResult(null)
|
|
175
|
-
setEditing(true)
|
|
176
|
-
}
|
|
177
|
-
const cancelEditing = () => {
|
|
178
|
-
setDraft(baseline)
|
|
179
|
-
setResult(null)
|
|
180
|
-
setEditing(false)
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
const shared = connection && connection.clusters.length > 1
|
|
@@ -209,10 +208,8 @@ export function OpenObserveSetup({
|
|
|
209
208
|
result.reloadFailed && "Saved, but Radar couldn't reload this page. Reopen Settings to see the match.",
|
|
210
209
|
].filter((note): note is string => !!note) : []
|
|
211
210
|
|
|
212
|
-
const outcome = result && result.kind !== 'saved' ? (
|
|
213
|
-
result.kind === '
|
|
214
|
-
<p role="alert" className="text-xs text-semantic-error">{result.message}</p>
|
|
215
|
-
) : result.kind === 'confirm' ? (
|
|
211
|
+
const outcome = result && result.kind !== 'saved' && result.kind !== 'error' ? (
|
|
212
|
+
result.kind === 'confirm' ? (
|
|
216
213
|
<p role="status" className="text-xs text-warning-text">
|
|
217
214
|
{result.reason ?? `OpenObserve has metrics for ${pair(result.suggestion)}, matched only by name.`}
|
|
218
215
|
</p>
|
|
@@ -229,115 +226,89 @@ export function OpenObserveSetup({
|
|
|
229
226
|
)
|
|
230
227
|
) : null
|
|
231
228
|
|
|
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
229
|
return (
|
|
239
230
|
<fieldset disabled={busy} aria-label="OpenObserve connection settings" className="min-w-0 space-y-4">
|
|
240
231
|
{statusRow}
|
|
241
232
|
{cluster.error && <p className="text-xs text-warning-text">{cluster.error}</p>}
|
|
242
|
-
{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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>
|
|
233
|
+
{match && <p className="text-sm text-theme-text-primary">{matchSummary(match)}</p>}
|
|
234
|
+
{shared}
|
|
235
|
+
<div className="space-y-4">
|
|
236
|
+
<div className="space-y-1">
|
|
237
|
+
<label htmlFor={`${id}-url`} className="block text-sm font-medium text-theme-text-primary">Address</label>
|
|
238
|
+
<Input id={`${id}-url`} value={draft.baseUrl} onChange={(e) => update({ baseUrl: e.target.value })} placeholder="https://openobserve.example.com" spellCheck={false} className={inputClass} />
|
|
299
239
|
</div>
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
<
|
|
303
|
-
<p className="
|
|
304
|
-
{shared}
|
|
240
|
+
<div className="space-y-1">
|
|
241
|
+
<label htmlFor={`${id}-org`} className="block text-sm font-medium text-theme-text-primary">Organization</label>
|
|
242
|
+
<Input id={`${id}-org`} value={draft.org} onChange={(e) => update({ org: e.target.value })} placeholder="2Zp8kQ1vXcR7mN4tLwYb9HsA3eD" spellCheck={false} className={inputClass} />
|
|
243
|
+
<p className="text-xs text-theme-text-tertiary">The organization ID from OpenObserve. Leave empty for default.</p>
|
|
305
244
|
</div>
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
245
|
+
<div className="space-y-1">
|
|
246
|
+
<label htmlFor={`${id}-user`} className="block text-sm font-medium text-theme-text-primary">User or service account email</label>
|
|
247
|
+
<Input id={`${id}-user`} value={draft.user} onChange={(e) => update({ user: e.target.value })} autoComplete="off" spellCheck={false} className={inputClass} />
|
|
248
|
+
<a href={SERVICE_ACCOUNT_DOCS} target="_blank" rel="noopener noreferrer" className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
|
|
249
|
+
Create a service account in OpenObserve
|
|
250
|
+
<ExternalLink aria-hidden="true" className="h-3 w-3" />
|
|
251
|
+
</a>
|
|
252
|
+
</div>
|
|
253
|
+
<div className="space-y-1">
|
|
254
|
+
<label htmlFor={`${id}-token`} className="block text-sm font-medium text-theme-text-primary">Token</label>
|
|
255
|
+
{envToken ? (
|
|
256
|
+
<p id={`${id}-token`} className="text-sm text-theme-text-secondary">Token from ${connection.tokenEnv}</p>
|
|
257
|
+
) : (
|
|
258
|
+
<Input
|
|
259
|
+
id={`${id}-token`}
|
|
260
|
+
type="password"
|
|
261
|
+
autoComplete="new-password"
|
|
262
|
+
spellCheck={false}
|
|
263
|
+
value={draft.token}
|
|
264
|
+
onChange={(e) => update({ token: e.target.value })}
|
|
265
|
+
placeholder={connection?.tokenSource === 'saved' && sameTarget(draft, baseline) ? 'Saved — leave empty to keep' : undefined}
|
|
266
|
+
className={inputClass}
|
|
267
|
+
/>
|
|
324
268
|
)}
|
|
325
|
-
{
|
|
326
|
-
<
|
|
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>
|
|
269
|
+
{connection && connection.tokenSource !== 'none' && !sameTarget(draft, baseline) && (
|
|
270
|
+
<p className="text-xs text-theme-text-secondary">A new address, organization or user needs its own token.</p>
|
|
330
271
|
)}
|
|
272
|
+
<p className="text-xs text-theme-text-tertiary">Saved in ~/.radar/config.json, readable only by you.</p>
|
|
331
273
|
</div>
|
|
274
|
+
<Disclosure
|
|
275
|
+
summary="Advanced"
|
|
276
|
+
summaryClassName="text-sm font-medium text-theme-text-secondary"
|
|
277
|
+
defaultOpen={!!(baseline.caCertFile || baseline.clusterLabel)}
|
|
278
|
+
>
|
|
279
|
+
<div className="space-y-4 pt-3">
|
|
280
|
+
<div className="space-y-1">
|
|
281
|
+
<label htmlFor={`${id}-ca`} className="block text-sm font-medium text-theme-text-primary">CA certificate file</label>
|
|
282
|
+
<Input id={`${id}-ca`} value={draft.caCertFile} onChange={(e) => update({ caCertFile: e.target.value })} placeholder="/path/to/ca.pem" spellCheck={false} className={inputClass} />
|
|
283
|
+
</div>
|
|
284
|
+
<div className="space-y-1">
|
|
285
|
+
<label htmlFor={`${id}-label`} className="block text-sm font-medium text-theme-text-primary">Cluster label</label>
|
|
286
|
+
<p className="text-xs text-theme-text-tertiary">Only when OpenObserve names clusters with a label Radar doesn’t know.</p>
|
|
287
|
+
<Input id={`${id}-label`} value={draft.clusterLabel} onChange={(e) => update({ clusterLabel: e.target.value })} spellCheck={false} className={inputClass} />
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
</Disclosure>
|
|
291
|
+
</div>
|
|
292
|
+
<div>
|
|
293
|
+
<FormSaveActions
|
|
294
|
+
dirty={dirty}
|
|
295
|
+
busy={busy}
|
|
296
|
+
canSave={dirty || result?.kind === 'confirm' || (!!connection && !match)}
|
|
297
|
+
saveLabel={result?.kind === 'confirm' ? `Confirm '${result.suggestion.value}' and save` : !dirty && connection && !match ? 'Use for this cluster' : 'Save changes'}
|
|
298
|
+
onSave={testAndSave}
|
|
299
|
+
onDiscard={discard}
|
|
300
|
+
feedback={result?.kind === 'saved' ? { tone: 'success', message: 'Saved' } : undefined}
|
|
301
|
+
error={result?.kind === 'error' ? result.message : undefined}
|
|
302
|
+
/>
|
|
332
303
|
<Collapse open={notes.length > 0}>
|
|
333
|
-
<ul className="space-y-0.5 text-xs text-theme-text-secondary">
|
|
304
|
+
<ul className="space-y-0.5 pt-2 text-xs text-theme-text-secondary">
|
|
334
305
|
{notes.map((note) => <li key={note}>{note}</li>)}
|
|
335
306
|
</ul>
|
|
336
307
|
</Collapse>
|
|
337
|
-
<Collapse open={!!outcome}>{outcome}</Collapse>
|
|
338
|
-
{connection &&
|
|
339
|
-
<button type="button" onClick={() => setConfirmingRemove(true)} className="
|
|
340
|
-
Remove
|
|
308
|
+
<Collapse open={!!outcome}><div className="pt-2">{outcome}</div></Collapse>
|
|
309
|
+
{connection && (
|
|
310
|
+
<button type="button" onClick={() => setConfirmingRemove(true)} className="mt-3 text-xs text-accent-text hover:underline">
|
|
311
|
+
Remove OpenObserve connection
|
|
341
312
|
</button>
|
|
342
313
|
)}
|
|
343
314
|
</div>
|
|
@@ -346,11 +317,10 @@ export function OpenObserveSetup({
|
|
|
346
317
|
onClose={() => setConfirmingRemove(false)}
|
|
347
318
|
onConfirm={removeAll}
|
|
348
319
|
title="Remove the saved OpenObserve connection?"
|
|
349
|
-
message={contexts.length
|
|
350
|
-
? `These clusters go back to their
|
|
351
|
-
: 'No cluster reads from it yet.'}
|
|
352
|
-
confirmLabel="Remove"
|
|
353
|
-
variant="warning"
|
|
320
|
+
message={`${contexts.length
|
|
321
|
+
? `These clusters go back to their Prometheus settings: ${contexts.join(', ')}.`
|
|
322
|
+
: 'No cluster reads from it yet.'} Nothing is deleted in OpenObserve or Kubernetes.`}
|
|
323
|
+
confirmLabel="Remove connection"
|
|
354
324
|
showWarning={false}
|
|
355
325
|
/>
|
|
356
326
|
</fieldset>
|
|
@@ -30,6 +30,8 @@ import {
|
|
|
30
30
|
canPauseDeployment,
|
|
31
31
|
canSubmitWorkflowTemplate,
|
|
32
32
|
type WorkflowTemplateSubmission,
|
|
33
|
+
canSuspendCronJob,
|
|
34
|
+
canTriggerCronJob,
|
|
33
35
|
isCoreBatchJob,
|
|
34
36
|
type SetImageOwnership,
|
|
35
37
|
SET_IMAGE_WRITES,
|
|
@@ -392,6 +394,9 @@ function useActionsBarProps(
|
|
|
392
394
|
const { support: deploymentPauseSupport } = useRadarFeature('deploymentPause')
|
|
393
395
|
const canPauseDeployments = !workloadWritesPending &&
|
|
394
396
|
canPauseDeployment({ name: kind, group }, workloadWrites, deploymentPauseSupport === 'supported')
|
|
397
|
+
const cronJobPermissionsReady = kind === 'cronjobs' && group === 'batch' && !workloadWritesPending
|
|
398
|
+
const allowCronJobTrigger = cronJobPermissionsReady && canTriggerCronJob(workloadWrites)
|
|
399
|
+
const allowCronJobSuspend = cronJobPermissionsReady && canSuspendCronJob(workloadWrites)
|
|
395
400
|
const loadImages = useCallback(
|
|
396
401
|
(params: { kind: string; namespace: string; name: string }) =>
|
|
397
402
|
queryClient.fetchQuery({
|
|
@@ -525,15 +530,12 @@ function useActionsBarProps(
|
|
|
525
530
|
rolloutDialogPromote.mutateAsync({ action: 'promote-full', ...params })
|
|
526
531
|
: undefined,
|
|
527
532
|
// mutateAsync, not mutate: the Job name dialog stays open when this rejects.
|
|
528
|
-
onTriggerCronJob:
|
|
529
|
-
triggerCronJobMutation.mutateAsync(params),
|
|
533
|
+
onTriggerCronJob: allowCronJobTrigger ? triggerCronJobMutation.mutateAsync : undefined,
|
|
530
534
|
isTriggeringCronJob: triggerCronJobMutation.isPending,
|
|
531
535
|
cronJobTriggerDialog: cronJobJobNameSupport === 'supported',
|
|
532
|
-
onSuspendCronJob:
|
|
533
|
-
suspendCronJobMutation.mutate(params),
|
|
536
|
+
onSuspendCronJob: allowCronJobSuspend ? suspendCronJobMutation.mutate : undefined,
|
|
534
537
|
isSuspendingCronJob: suspendCronJobMutation.isPending,
|
|
535
|
-
onResumeCronJob:
|
|
536
|
-
resumeCronJobMutation.mutate(params),
|
|
538
|
+
onResumeCronJob: allowCronJobSuspend ? resumeCronJobMutation.mutate : undefined,
|
|
537
539
|
isResumingCronJob: resumeCronJobMutation.isPending,
|
|
538
540
|
// mutateAsync, not mutate: the submit dialog stays open when this rejects.
|
|
539
541
|
onSubmitWorkflowTemplate: canSubmitTemplates
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Badge, FactGrid, FactRow, FoldSection, Tooltip, formatAge, WorkspaceCard } from '@skyhook-io/k8s-ui'
|
|
2
|
+
|
|
3
|
+
export function WorkspaceConditions({
|
|
4
|
+
conditions,
|
|
5
|
+
title = 'Conditions',
|
|
6
|
+
className,
|
|
7
|
+
sourcePath = 'status.conditions',
|
|
8
|
+
emptyMessage = `No ${sourcePath} reported.`,
|
|
9
|
+
framed = true,
|
|
10
|
+
}: {
|
|
11
|
+
title?: string
|
|
12
|
+
className?: string
|
|
13
|
+
framed?: boolean
|
|
14
|
+
sourcePath?: string
|
|
15
|
+
emptyMessage?: string
|
|
16
|
+
conditions: { type: string; status: string; reason?: string; message?: string; lastTransitionTime?: string }[]
|
|
17
|
+
}) {
|
|
18
|
+
const content = (
|
|
19
|
+
<FoldSection
|
|
20
|
+
title={title}
|
|
21
|
+
summary={conditions.length > 0 ? `${conditions.length} reported · ${sourcePath}` : 'No conditions reported'}
|
|
22
|
+
attention={false}
|
|
23
|
+
>
|
|
24
|
+
<FactGrid>
|
|
25
|
+
{conditions.map((c) => (
|
|
26
|
+
<FactRow
|
|
27
|
+
key={c.type}
|
|
28
|
+
label={
|
|
29
|
+
<span className="inline-flex flex-wrap items-center gap-2">
|
|
30
|
+
{c.type}
|
|
31
|
+
<Badge severity="neutral" size="sm">
|
|
32
|
+
{c.status}
|
|
33
|
+
</Badge>
|
|
34
|
+
</span>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
<div className="text-xs text-theme-text-secondary">Reason: {c.reason || 'Not reported'}</div>
|
|
38
|
+
<div className="break-words text-xs text-theme-text-secondary">{c.message || 'No message reported'}</div>
|
|
39
|
+
<div className="text-xs text-theme-text-tertiary">
|
|
40
|
+
Last transition:{' '}
|
|
41
|
+
{c.lastTransitionTime ? (
|
|
42
|
+
<Tooltip content={c.lastTransitionTime}>
|
|
43
|
+
<time dateTime={c.lastTransitionTime}>{formatAge(c.lastTransitionTime)} ago</time>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
) : (
|
|
46
|
+
'Not reported'
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
</FactRow>
|
|
50
|
+
))}
|
|
51
|
+
</FactGrid>
|
|
52
|
+
{conditions.length === 0 && <p className="text-sm text-theme-text-tertiary">{emptyMessage}</p>}
|
|
53
|
+
</FoldSection>
|
|
54
|
+
)
|
|
55
|
+
return <WorkspaceCard framed={framed} className={className}>{content}</WorkspaceCard>
|
|
56
|
+
}
|
|
@@ -3,6 +3,7 @@ import { act } from 'react'
|
|
|
3
3
|
import { createRoot } from 'react-dom/client'
|
|
4
4
|
import { expect, it, vi } from 'vitest'
|
|
5
5
|
import { Mono, SectionTable } from './layout'
|
|
6
|
+
import { ROW_HOVER } from './table'
|
|
6
7
|
|
|
7
8
|
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
8
9
|
|
|
@@ -55,3 +56,22 @@ it('opens a row from the keyboard the way a click does, and leaves keys on contr
|
|
|
55
56
|
act(() => root.unmount())
|
|
56
57
|
host.remove()
|
|
57
58
|
})
|
|
59
|
+
|
|
60
|
+
it('applies the row hover style only to rows that open a resource', () => {
|
|
61
|
+
const host = document.createElement('div')
|
|
62
|
+
const root = createRoot(host)
|
|
63
|
+
act(() => root.render(
|
|
64
|
+
<SectionTable
|
|
65
|
+
columns={[{ header: 'Name', cell: (name) => name }]}
|
|
66
|
+
rows={['inspectable', 'static']}
|
|
67
|
+
rowKey={(name) => name}
|
|
68
|
+
rowResource={(name) => name === 'inspectable' ? { kind: 'Pod', namespace: 'default', name } : null}
|
|
69
|
+
onInspect={vi.fn()}
|
|
70
|
+
empty="none"
|
|
71
|
+
/>,
|
|
72
|
+
))
|
|
73
|
+
const [inspectable, staticRow] = host.querySelectorAll('tbody tr')
|
|
74
|
+
expect(inspectable.className).toContain(ROW_HOVER)
|
|
75
|
+
expect(staticRow.className).not.toContain(ROW_HOVER)
|
|
76
|
+
act(() => root.unmount())
|
|
77
|
+
})
|
|
@@ -182,7 +182,7 @@ export function SectionTable<T>({
|
|
|
182
182
|
e.preventDefault()
|
|
183
183
|
open()
|
|
184
184
|
} : undefined}
|
|
185
|
-
className={clsx(open && 'cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent', ROW_HOVER, active && 'selection')}
|
|
185
|
+
className={clsx(open && ['cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent', ROW_HOVER], active && 'selection')}
|
|
186
186
|
aria-selected={res ? active : undefined}
|
|
187
187
|
>
|
|
188
188
|
{columns.map((c, i) => (
|
package/src/utils/page-links.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useLocation, useNavigate } from 'react-router-dom'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The label for "← back" on the page a push lands on: the title of the page
|
|
3
5
|
* being left, which Radar keeps in the document title.
|
|
@@ -7,7 +9,7 @@ export function currentPageLabel(): string {
|
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
|
-
* Radar's Issues page narrowed to
|
|
12
|
+
* Radar's Issues page narrowed to all issues for one subject.
|
|
11
13
|
* The subject travels as `resource=ns/name`, never `namespace=`: App reads a bare
|
|
12
14
|
* `namespace` as the view filter, and a URL without `namespaces` clears it.
|
|
13
15
|
*/
|
|
@@ -20,6 +22,18 @@ export function issuesPathForSubject(subject: { kind: string; group?: string; na
|
|
|
20
22
|
return `/issues?${params}`
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
// A manual selection replaces the deep link so Back still returns to its origin.
|
|
26
|
+
export function useClearLinkedIssue() {
|
|
27
|
+
const location = useLocation()
|
|
28
|
+
const navigate = useNavigate()
|
|
29
|
+
return () => {
|
|
30
|
+
const params = new URLSearchParams(location.search)
|
|
31
|
+
if (!params.has('issue')) return
|
|
32
|
+
params.delete('issue')
|
|
33
|
+
navigate({ pathname: location.pathname, search: params.toString(), hash: location.hash }, { replace: true, state: location.state })
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
export const RIGHTSIZING_SCAN_PATH = '/cost/rightsizing'
|
|
24
38
|
|
|
25
39
|
export function isRightsizingScanPath(pathname: string): boolean {
|