@skyhook-io/k8s-ui 1.14.6 → 1.14.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/package.json +1 -1
- package/src/components/applications/ApplicationDetail.tsx +36 -4
- package/src/components/applications/ApplicationsView.tsx +2 -1
- package/src/components/audit/AuditAlerts.tsx +35 -37
- package/src/components/audit/AuditFindingsTable.tsx +23 -27
- package/src/components/charts/PrometheusChartsView.tsx +29 -10
- package/src/components/checks/ChecksView.tsx +56 -26
- package/src/components/gitops/GitOpsDetailLayout.tsx +12 -9
- package/src/components/issues/IssuesView.tsx +35 -54
- package/src/components/logs/LogCore.tsx +40 -9
- package/src/components/resources/ResourcesSidebar.tsx +66 -78
- package/src/components/resources/renderers/ClusterComplianceReportRenderer.tsx +21 -15
- package/src/components/resources/renderers/CompositionRenderer.tsx +30 -10
- package/src/components/resources/renderers/ConfigAuditReportRenderer.tsx +16 -12
- package/src/components/resources/renderers/ExposedSecretReportRenderer.tsx +10 -4
- package/src/components/resources/renderers/GenericRenderer.tsx +13 -7
- package/src/components/resources/renderers/KyvernoPolicyReportRenderer.tsx +6 -4
- package/src/components/resources/renderers/PolicyCoverageSection.tsx +7 -4
- package/src/components/resources/renderers/PrometheusRuleRenderer.tsx +13 -15
- package/src/components/resources/renderers/SbomReportRenderer.tsx +10 -4
- package/src/components/resources/renderers/VulnerabilityReportRenderer.tsx +10 -4
- package/src/components/resources/renderers/rollout/ReplicaSetProgression.tsx +13 -6
- package/src/components/shared/CreateResourceDialog.tsx +7 -4
- package/src/components/timeline/TimelineList.tsx +14 -11
- package/src/components/timeline/TimelineStrip.tsx +26 -4
- package/src/components/timeline/TimelineSwimlanes.tsx +3 -5
- package/src/components/timeline/TimelineToolbar.tsx +43 -10
- package/src/components/topology/TopologyControls.tsx +27 -8
- package/src/components/topology/TopologyGraph.tsx +14 -5
- package/src/components/trace/ReachabilityView.tsx +17 -16
- package/src/components/ui/CardSection.tsx +79 -35
- package/src/components/ui/Collapse.test.tsx +74 -0
- package/src/components/ui/Collapse.tsx +115 -29
- package/src/components/ui/DialogPortal.tsx +7 -2
- package/src/components/ui/ForceDeleteConfirmDialog.tsx +7 -4
- package/src/components/ui/RestrictedState.tsx +7 -4
- package/src/components/ui/RowActionMenu.tsx +20 -8
- package/src/components/ui/SelectMenu.tsx +18 -6
- package/src/components/ui/YamlEditor.tsx +7 -9
- package/src/components/ui/drawer-components.tsx +14 -21
- package/src/components/ui/index.ts +30 -22
- package/src/components/workload/WorkloadView.tsx +6 -10
- package/src/hooks/useAnimatedUnmount.ts +21 -3
- package/src/theme/components.css +4 -1
- package/src/utils/animation.ts +93 -13
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AlertOctagon, AlertTriangle, ArrowRight,
|
|
1
|
+
import { useMemo, useState, type ComponentType, type ReactNode } from 'react';
|
|
2
|
+
import { AlertOctagon, AlertTriangle, ArrowRight, CircleCheck, Clock, ExternalLink, Layers, Terminal, Workflow } from 'lucide-react';
|
|
3
3
|
import { CardBody, CardSection, ClusterName, EmptyState, KIND_CHIP_CLASS, TerminalBlock } from '../ui';
|
|
4
|
+
import { Collapse, CollapseChevron, useDisclosure } from '../ui/Collapse';
|
|
4
5
|
import { Tooltip } from '../ui/Tooltip';
|
|
5
6
|
import { formatCompactAge, formatRelativeAgeTime } from '../../utils/format';
|
|
6
7
|
import { diagnosticRoleLabel, diagnosticFactLabel, confidenceTitle, incidentParentLabel } from './diagnostic';
|
|
@@ -207,7 +208,7 @@ export function IssueRow({
|
|
|
207
208
|
const cluster = clusterLabel?.(issue);
|
|
208
209
|
const affected = affectedSummary(issue.affected);
|
|
209
210
|
const { headline } = issueMessageParts(issue);
|
|
210
|
-
const
|
|
211
|
+
const { panelId, buttonProps } = useDisclosure(open);
|
|
211
212
|
const Container = as;
|
|
212
213
|
const severity = normalizeIssueSeverity(issue.severity);
|
|
213
214
|
const SeverityIcon = ISSUE_SEVERITY_ICON[severity];
|
|
@@ -244,17 +245,6 @@ export function IssueRow({
|
|
|
244
245
|
</div>
|
|
245
246
|
);
|
|
246
247
|
|
|
247
|
-
useEffect(() => {
|
|
248
|
-
if (open) {
|
|
249
|
-
setRenderDetails(true);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (!renderDetails) return;
|
|
253
|
-
|
|
254
|
-
const timeout = window.setTimeout(() => setRenderDetails(false), 200);
|
|
255
|
-
return () => window.clearTimeout(timeout);
|
|
256
|
-
}, [open, renderDetails]);
|
|
257
|
-
|
|
258
248
|
return (
|
|
259
249
|
<Container
|
|
260
250
|
className={[
|
|
@@ -276,9 +266,9 @@ export function IssueRow({
|
|
|
276
266
|
be invalid). Collapsed: neutral row + rail. Expanded: severity-tinted
|
|
277
267
|
band + solid pill — the tint is a focus signal, not per-row alarm. */}
|
|
278
268
|
<div
|
|
269
|
+
{...buttonProps}
|
|
279
270
|
role="button"
|
|
280
271
|
tabIndex={0}
|
|
281
|
-
aria-expanded={open}
|
|
282
272
|
onClick={onToggle}
|
|
283
273
|
onKeyDown={(e) => {
|
|
284
274
|
if (e.target !== e.currentTarget) return;
|
|
@@ -357,50 +347,41 @@ export function IssueRow({
|
|
|
357
347
|
<div className="flex shrink-0 items-center gap-3">
|
|
358
348
|
{metaChips('hidden @2xl/issue:flex')}
|
|
359
349
|
{renderActions?.(slotCtx)}
|
|
360
|
-
<
|
|
350
|
+
<CollapseChevron open={open} className="h-4 w-4" />
|
|
361
351
|
</div>
|
|
362
352
|
</div>
|
|
363
353
|
|
|
364
|
-
{
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
<ResourceLine refForLink={memberRef(issue, issue.incident_parent.ref)} resourceHref={resourceHref} onResourceClick={onResourceClick} ResourceLinkIcon={ResourceLinkIcon} />
|
|
393
|
-
</ul>
|
|
394
|
-
</section>
|
|
395
|
-
) : null}
|
|
396
|
-
<DiagnosticContext issue={issue} resourceHref={resourceHref} onResourceClick={onResourceClick} ResourceLinkIcon={ResourceLinkIcon} />
|
|
397
|
-
<AffectedResources issue={issue} hideSubject={hideSubject} resourceHref={resourceHref} onResourceClick={onResourceClick} ResourceLinkIcon={ResourceLinkIcon} />
|
|
398
|
-
{renderDetailSection?.(slotCtx)}
|
|
399
|
-
</div>
|
|
400
|
-
</div>
|
|
354
|
+
{/* Details unmount after the close transition: a list can hold hundreds
|
|
355
|
+
of rows and the body is the expensive part, so closed rows stay light. */}
|
|
356
|
+
<Collapse open={open} unmountOnExit id={panelId}>
|
|
357
|
+
{/* Body sits on the card surface (not a recessed grey panel) so its
|
|
358
|
+
text keeps enough contrast. */}
|
|
359
|
+
<div className="border-t border-theme-border bg-theme-surface py-4 pl-6 pr-4">
|
|
360
|
+
<div className="flex flex-col divide-y divide-theme-border/70 [&>*]:py-4 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
|
|
361
|
+
<Diagnosis issue={issue} source={diagnosisSource} />
|
|
362
|
+
{issue.incident_parent ? (
|
|
363
|
+
<section className="flex flex-col gap-1">
|
|
364
|
+
<h4 className="text-[11px] font-semibold uppercase tracking-wide text-theme-text-tertiary">
|
|
365
|
+
{incidentParentLabel(issue.incident_parent.fact_type, issue.incident_parent.confidence)}
|
|
366
|
+
{issue.incident_parent.confidence ? (
|
|
367
|
+
<Tooltip content={confidenceTitle(issue.incident_parent.confidence)} delay={200}>
|
|
368
|
+
<span className="ml-2 badge-sm text-[10px] font-normal text-theme-text-tertiary">
|
|
369
|
+
{issue.incident_parent.confidence} confidence
|
|
370
|
+
</span>
|
|
371
|
+
</Tooltip>
|
|
372
|
+
) : null}
|
|
373
|
+
</h4>
|
|
374
|
+
<ul className="flex flex-col gap-px">
|
|
375
|
+
<ResourceLine refForLink={memberRef(issue, issue.incident_parent.ref)} resourceHref={resourceHref} onResourceClick={onResourceClick} ResourceLinkIcon={ResourceLinkIcon} />
|
|
376
|
+
</ul>
|
|
377
|
+
</section>
|
|
378
|
+
) : null}
|
|
379
|
+
<DiagnosticContext issue={issue} resourceHref={resourceHref} onResourceClick={onResourceClick} ResourceLinkIcon={ResourceLinkIcon} />
|
|
380
|
+
<AffectedResources issue={issue} hideSubject={hideSubject} resourceHref={resourceHref} onResourceClick={onResourceClick} ResourceLinkIcon={ResourceLinkIcon} />
|
|
381
|
+
{renderDetailSection?.(slotCtx)}
|
|
401
382
|
</div>
|
|
402
383
|
</div>
|
|
403
|
-
|
|
384
|
+
</Collapse>
|
|
404
385
|
</Container>
|
|
405
386
|
);
|
|
406
387
|
}
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
} from '../../utils/log-format'
|
|
18
18
|
import { getLogPalette, getLogLevelColor, type LogPalette } from './log-palette'
|
|
19
19
|
import { copyText } from '../../utils/clipboard'
|
|
20
|
+
import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
|
|
21
|
+
import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../utils/animation'
|
|
20
22
|
import {
|
|
21
23
|
LOG_EXPORT_FORMAT_LABELS,
|
|
22
24
|
LOG_EXPORT_FORMATS,
|
|
@@ -202,6 +204,7 @@ export function LogCore({
|
|
|
202
204
|
new Set(['error', 'warn', 'info', 'debug'])
|
|
203
205
|
)
|
|
204
206
|
const [showDownloadMenu, setShowDownloadMenu] = useState(false)
|
|
207
|
+
const downloadMenu = useAnimatedUnmount(showDownloadMenu, overlayExitMs('menu'))
|
|
205
208
|
const [exportScope, setExportScope] = useState<'visible' | 'all'>('visible')
|
|
206
209
|
const [exportFormat, setExportFormat] = useState<LogExportFormat>(() => {
|
|
207
210
|
try {
|
|
@@ -210,7 +213,9 @@ export function LogCore({
|
|
|
210
213
|
} catch { return 'txt' }
|
|
211
214
|
})
|
|
212
215
|
const [showTsMenu, setShowTsMenu] = useState(false)
|
|
216
|
+
const tsMenu = useAnimatedUnmount(showTsMenu, overlayExitMs('menu'))
|
|
213
217
|
const [showStructuredMenu, setShowStructuredMenu] = useState(false)
|
|
218
|
+
const structuredMenu = useAnimatedUnmount(showStructuredMenu, overlayExitMs('menu'))
|
|
214
219
|
const [structuredMode, setStructuredMode] = useState<StructuredMode>(() => {
|
|
215
220
|
try {
|
|
216
221
|
const v = localStorage.getItem('radar-logs-structured-mode') as StructuredMode | null
|
|
@@ -297,9 +302,11 @@ export function LogCore({
|
|
|
297
302
|
() => ({ format: exportFormat, showTimestamps, showPodName }),
|
|
298
303
|
[exportFormat, showTimestamps, showPodName],
|
|
299
304
|
)
|
|
305
|
+
// Keyed on presence, not logical open, so the preview doesn't flip to
|
|
306
|
+
// "nothing to export" while the popover is still fading out.
|
|
300
307
|
const exportPreview = useMemo(
|
|
301
|
-
() =>
|
|
302
|
-
[
|
|
308
|
+
() => downloadMenu.shouldRender ? previewLogExport(exportEntries, exportOptions) : [],
|
|
309
|
+
[downloadMenu.shouldRender, exportEntries, exportOptions],
|
|
303
310
|
)
|
|
304
311
|
// Offering a scope that resolves to the same lines is a choice about nothing.
|
|
305
312
|
const scopeIsMeaningful = displayEntries.length !== bufferEntries.length
|
|
@@ -309,8 +316,12 @@ export function LogCore({
|
|
|
309
316
|
// silently exporting the whole buffer on a later visit.
|
|
310
317
|
const toggleExportMenu = useCallback(() => {
|
|
311
318
|
setShowDownloadMenu(prev => !prev)
|
|
312
|
-
setExportScope('visible')
|
|
313
319
|
}, [])
|
|
320
|
+
// The reset lands once the popover has left the DOM, not at logical close,
|
|
321
|
+
// so the preview doesn't re-scope while the popover is still fading out.
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
if (!downloadMenu.shouldRender) setExportScope('visible')
|
|
324
|
+
}, [downloadMenu.shouldRender])
|
|
314
325
|
|
|
315
326
|
const handleExportCopy = useCallback(() => {
|
|
316
327
|
closeExportMenu()
|
|
@@ -620,8 +631,14 @@ export function LogCore({
|
|
|
620
631
|
</span>
|
|
621
632
|
</button>
|
|
622
633
|
</Tooltip>
|
|
623
|
-
{
|
|
624
|
-
<div
|
|
634
|
+
{structuredMenu.shouldRender && (
|
|
635
|
+
<div
|
|
636
|
+
inert={!showStructuredMenu}
|
|
637
|
+
className={`absolute top-full right-0 mt-1 w-56 origin-top-right ${palette.menuBg} border ${palette.border} rounded-lg shadow-lg z-50 ${TRANSITION_MENU} ${
|
|
638
|
+
structuredMenu.isOpen ? 'opacity-100 translate-y-0 scale-100' : 'opacity-0 -translate-y-1 scale-[0.97]'
|
|
639
|
+
} ${showStructuredMenu ? '' : 'pointer-events-none'}`}
|
|
640
|
+
style={overlayTransitionStyle(structuredMenu.isOpen, 'menu')}
|
|
641
|
+
>
|
|
625
642
|
<div className={`px-3 py-1.5 text-[10px] uppercase tracking-wide ${palette.textTertiary} border-b ${palette.border}`}>
|
|
626
643
|
Structured display
|
|
627
644
|
</div>
|
|
@@ -673,8 +690,14 @@ export function LogCore({
|
|
|
673
690
|
</span>
|
|
674
691
|
</button>
|
|
675
692
|
</Tooltip>
|
|
676
|
-
{
|
|
677
|
-
<div
|
|
693
|
+
{tsMenu.shouldRender && (
|
|
694
|
+
<div
|
|
695
|
+
inert={!showTsMenu}
|
|
696
|
+
className={`absolute top-full right-0 mt-1 w-44 origin-top-right ${palette.menuBg} border ${palette.border} rounded-lg shadow-lg z-50 ${TRANSITION_MENU} ${
|
|
697
|
+
tsMenu.isOpen ? 'opacity-100 translate-y-0 scale-100' : 'opacity-0 -translate-y-1 scale-[0.97]'
|
|
698
|
+
} ${showTsMenu ? '' : 'pointer-events-none'}`}
|
|
699
|
+
style={overlayTransitionStyle(tsMenu.isOpen, 'menu')}
|
|
700
|
+
>
|
|
678
701
|
<div className={`px-3 py-1.5 text-[10px] uppercase tracking-wide ${palette.textTertiary} border-b ${palette.border}`}>
|
|
679
702
|
Timestamp format
|
|
680
703
|
</div>
|
|
@@ -769,8 +792,16 @@ export function LogCore({
|
|
|
769
792
|
<Download className="w-4 h-4" />
|
|
770
793
|
</button>
|
|
771
794
|
</Tooltip>
|
|
772
|
-
{
|
|
773
|
-
<div
|
|
795
|
+
{downloadMenu.shouldRender && (
|
|
796
|
+
<div
|
|
797
|
+
role="dialog"
|
|
798
|
+
aria-label="Export logs"
|
|
799
|
+
inert={!showDownloadMenu}
|
|
800
|
+
className={`absolute top-full right-0 mt-1 w-[23rem] origin-top-right ${palette.menuBg} border ${palette.border} rounded-lg shadow-lg z-50 p-3 space-y-2.5 ${TRANSITION_MENU} ${
|
|
801
|
+
downloadMenu.isOpen ? 'opacity-100 translate-y-0 scale-100' : 'opacity-0 -translate-y-1 scale-[0.97]'
|
|
802
|
+
} ${showDownloadMenu ? '' : 'pointer-events-none'}`}
|
|
803
|
+
style={overlayTransitionStyle(downloadMenu.isOpen, 'menu')}
|
|
804
|
+
>
|
|
774
805
|
<div className="flex items-center gap-3">
|
|
775
806
|
<span id="log-export-scope-label" className={exportLabelCls}>Lines</span>
|
|
776
807
|
{scopeIsMeaningful ? (
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { useState, useMemo, useEffect, useRef, useCallback, forwardRef } from 'react'
|
|
1
|
+
import { useState, useMemo, useEffect, useRef, useCallback, useId, forwardRef } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
Search,
|
|
4
|
-
ChevronDown,
|
|
5
|
-
ChevronRight,
|
|
6
4
|
Eye,
|
|
7
5
|
EyeOff,
|
|
8
6
|
Pin,
|
|
@@ -10,6 +8,7 @@ import {
|
|
|
10
8
|
X,
|
|
11
9
|
} from 'lucide-react'
|
|
12
10
|
import { clsx } from 'clsx'
|
|
11
|
+
import { Collapse, CollapseChevron, useDisclosure, disclosurePanelId } from '../ui/Collapse'
|
|
13
12
|
import type { APIResource } from '../../types'
|
|
14
13
|
import { categorizeResources, CORE_RESOURCES } from '../../utils/api-resources'
|
|
15
14
|
import { getResourceIcon } from '../../utils/resource-icons'
|
|
@@ -213,6 +212,10 @@ export function ResourcesSidebar({
|
|
|
213
212
|
useEffect(() => { persistedExpandedCategories = expandedCategories }, [expandedCategories])
|
|
214
213
|
const [showEmptyKinds, setShowEmptyKinds] = useState(false)
|
|
215
214
|
const [favoritesExpanded, setFavoritesExpanded] = useState(() => pinned.length > 0)
|
|
215
|
+
const favoritesDisclosure = useDisclosure(favoritesExpanded)
|
|
216
|
+
// Category sections are mapped inline, so they can't each call useDisclosure;
|
|
217
|
+
// one generated prefix plus the category name keeps aria-controls unique.
|
|
218
|
+
const categoryPanelBase = useId()
|
|
216
219
|
|
|
217
220
|
// Ref to selected sidebar item for scrolling into view on deeplink
|
|
218
221
|
const selectedSidebarRef = useRef<HTMLButtonElement>(null)
|
|
@@ -499,14 +502,11 @@ export function ResourcesSidebar({
|
|
|
499
502
|
{/* Favorites (pinned kinds) section — always visible */}
|
|
500
503
|
<div className="mb-2">
|
|
501
504
|
<button
|
|
505
|
+
{...favoritesDisclosure.buttonProps}
|
|
502
506
|
onClick={() => setFavoritesExpanded((v) => !v)}
|
|
503
507
|
className="w-full flex items-center gap-2 px-2 py-1.5 text-xs font-medium text-theme-text-tertiary hover:text-theme-text-secondary uppercase tracking-wide"
|
|
504
508
|
>
|
|
505
|
-
{favoritesExpanded
|
|
506
|
-
<ChevronDown className="w-3 h-3" />
|
|
507
|
-
) : (
|
|
508
|
-
<ChevronRight className="w-3 h-3" />
|
|
509
|
-
)}
|
|
509
|
+
<CollapseChevron open={favoritesExpanded} className="w-3 h-3" />
|
|
510
510
|
<span className="flex-1 text-left">Favorites</span>
|
|
511
511
|
{!favoritesExpanded && pinned.length > 0 && (
|
|
512
512
|
<span className={clsx('text-xs py-0.5 rounded bg-theme-elevated text-theme-text-secondary font-normal normal-case text-center font-mono', pinned.length < 1000 ? 'w-8' : 'w-9')}>
|
|
@@ -514,41 +514,36 @@ export function ResourcesSidebar({
|
|
|
514
514
|
</span>
|
|
515
515
|
)}
|
|
516
516
|
</button>
|
|
517
|
-
<
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
/>
|
|
546
|
-
)
|
|
547
|
-
})
|
|
548
|
-
)}
|
|
549
|
-
</div>
|
|
517
|
+
<Collapse open={favoritesExpanded} id={favoritesDisclosure.panelId}>
|
|
518
|
+
<div className="space-y-0.5">
|
|
519
|
+
{pinned.length === 0 ? (
|
|
520
|
+
<div className="px-3 py-2 text-xs text-theme-text-disabled">
|
|
521
|
+
No pinned resources. Click <Pin className="w-3 h-3 inline" /> on any resource type to pin it here.
|
|
522
|
+
</div>
|
|
523
|
+
) : (
|
|
524
|
+
pinned.map((p) => {
|
|
525
|
+
const isResourceSelected =
|
|
526
|
+
(effectiveSelectedKind.name === p.name && effectiveSelectedKind.group === p.group) ||
|
|
527
|
+
(effectiveSelectedKind.kind.toLowerCase() === p.kind.toLowerCase() && effectiveSelectedKind.group === p.group)
|
|
528
|
+
const highlighted = isKindHighlighted(p.name, p.group)
|
|
529
|
+
return (
|
|
530
|
+
<ResourceTypeButton
|
|
531
|
+
key={`${p.name}-${p.group}`}
|
|
532
|
+
ref={highlighted ? highlightedRef : (isResourceSelected ? selectedSidebarRef : null)}
|
|
533
|
+
resource={{ name: p.name, kind: p.kind, group: p.group, version: '', namespaced: true, isCrd: false, verbs: [] }}
|
|
534
|
+
count={counts[p.group ? `${p.group}/${p.kind}` : p.kind] ?? null}
|
|
535
|
+
isSelected={isResourceSelected}
|
|
536
|
+
isHighlighted={highlighted}
|
|
537
|
+
isForbidden={forbiddenKinds.has(p.group ? `${p.group}/${p.kind}` : p.kind)}
|
|
538
|
+
isPinned={true}
|
|
539
|
+
onTogglePin={() => togglePin(p)}
|
|
540
|
+
onClick={() => selectKind({ name: p.name, kind: p.kind, group: p.group })}
|
|
541
|
+
/>
|
|
542
|
+
)
|
|
543
|
+
})
|
|
544
|
+
)}
|
|
550
545
|
</div>
|
|
551
|
-
</
|
|
546
|
+
</Collapse>
|
|
552
547
|
</div>
|
|
553
548
|
{filteredCategories ? (
|
|
554
549
|
// Dynamic categories from API
|
|
@@ -558,14 +553,12 @@ export function ResourcesSidebar({
|
|
|
558
553
|
return (
|
|
559
554
|
<div key={category.name} className="mb-2">
|
|
560
555
|
<button
|
|
556
|
+
aria-expanded={isExpanded}
|
|
557
|
+
aria-controls={disclosurePanelId(categoryPanelBase, category.name)}
|
|
561
558
|
onClick={() => toggleCategory(category.name)}
|
|
562
559
|
className="w-full flex items-center gap-2 px-2 py-1.5 text-xs font-semibold text-theme-text-tertiary hover:text-theme-text-secondary uppercase tracking-wide"
|
|
563
560
|
>
|
|
564
|
-
{isExpanded
|
|
565
|
-
<ChevronDown className="w-3 h-3" />
|
|
566
|
-
) : (
|
|
567
|
-
<ChevronRight className="w-3 h-3" />
|
|
568
|
-
)}
|
|
561
|
+
<CollapseChevron open={isExpanded} className="w-3 h-3" />
|
|
569
562
|
<span className="flex-1 text-left truncate" title={rawGroupTitle}>{category.name}</span>
|
|
570
563
|
{!isExpanded && (
|
|
571
564
|
<span className={clsx('text-xs py-0.5 rounded bg-theme-elevated text-theme-text-secondary font-normal normal-case text-center font-mono', category.total < 1000 ? 'w-8' : 'w-9')}>
|
|
@@ -573,38 +566,33 @@ export function ResourcesSidebar({
|
|
|
573
566
|
</span>
|
|
574
567
|
)}
|
|
575
568
|
</button>
|
|
576
|
-
<
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
onClick={() => selectKind({ name: resource.name, kind: resource.kind, group: resource.group })}
|
|
602
|
-
/>
|
|
603
|
-
)
|
|
604
|
-
})}
|
|
605
|
-
</div>
|
|
569
|
+
<Collapse open={isExpanded} id={disclosurePanelId(categoryPanelBase, category.name)}>
|
|
570
|
+
<div className="space-y-0.5">
|
|
571
|
+
{category.visibleResources.map((resource) => {
|
|
572
|
+
const resourceIsPinned = isPinned(resource.name, resource.group)
|
|
573
|
+
const isResourceSelected =
|
|
574
|
+
(effectiveSelectedKind.name === resource.name && effectiveSelectedKind.group === resource.group) ||
|
|
575
|
+
(effectiveSelectedKind.kind.toLowerCase() === resource.kind.toLowerCase() && effectiveSelectedKind.group === resource.group)
|
|
576
|
+
// If the resource is pinned, let the Favorites section own the highlight
|
|
577
|
+
const showSelected = isResourceSelected && !resourceIsPinned
|
|
578
|
+
const highlighted = isKindHighlighted(resource.name, resource.group)
|
|
579
|
+
return (
|
|
580
|
+
<ResourceTypeButton
|
|
581
|
+
key={resource.name}
|
|
582
|
+
ref={highlighted ? highlightedRef : (isResourceSelected ? selectedSidebarRef : null)}
|
|
583
|
+
resource={resource}
|
|
584
|
+
count={counts[resource.group ? `${resource.group}/${resource.kind}` : resource.kind] ?? null}
|
|
585
|
+
isSelected={showSelected}
|
|
586
|
+
isHighlighted={highlighted}
|
|
587
|
+
isForbidden={forbiddenKinds.has(resource.group ? `${resource.group}/${resource.kind}` : resource.kind)}
|
|
588
|
+
isPinned={resourceIsPinned}
|
|
589
|
+
onTogglePin={() => togglePin({ name: resource.name, kind: resource.kind, group: resource.group })}
|
|
590
|
+
onClick={() => selectKind({ name: resource.name, kind: resource.kind, group: resource.group })}
|
|
591
|
+
/>
|
|
592
|
+
)
|
|
593
|
+
})}
|
|
606
594
|
</div>
|
|
607
|
-
</
|
|
595
|
+
</Collapse>
|
|
608
596
|
</div>
|
|
609
597
|
)
|
|
610
598
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useState, useMemo } from 'react'
|
|
2
|
-
import { ShieldCheck,
|
|
1
|
+
import { useState, useMemo, useId } from 'react'
|
|
2
|
+
import { ShieldCheck, CheckCircle2, XCircle, Search } from 'lucide-react'
|
|
3
3
|
import { clsx } from 'clsx'
|
|
4
4
|
import { Section, PropertyList, Property, AlertBanner } from '../../ui/drawer-components'
|
|
5
|
+
import { Collapse, CollapseChevron, useDisclosure, disclosurePanelId } from '../../ui/Collapse'
|
|
5
6
|
import { Input } from '../../ui/Input'
|
|
6
7
|
import { formatAge } from '../resource-utils'
|
|
7
8
|
import { SEVERITY_BADGE_COLORS, SEVERITY_ORDER } from './trivy-shared'
|
|
@@ -15,6 +16,10 @@ interface ClusterComplianceReportRendererProps {
|
|
|
15
16
|
export function ClusterComplianceReportRenderer({ data }: ClusterComplianceReportRendererProps) {
|
|
16
17
|
const [expandedSection, setExpandedSection] = useState(true)
|
|
17
18
|
const [expandedControls, setExpandedControls] = useState<Set<string>>(new Set())
|
|
19
|
+
const sectionDisclosure = useDisclosure(expandedSection)
|
|
20
|
+
// Control rows are mapped inline, so they can't each call useDisclosure;
|
|
21
|
+
// one generated prefix plus the control id keeps aria-controls unique.
|
|
22
|
+
const controlPanelBase = useId()
|
|
18
23
|
const [searchTerm, setSearchTerm] = useState('')
|
|
19
24
|
const [showFailedOnly, setShowFailedOnly] = useState(false)
|
|
20
25
|
|
|
@@ -127,13 +132,14 @@ export function ClusterComplianceReportRenderer({ data }: ClusterComplianceRepor
|
|
|
127
132
|
{sortedChecks.length > 0 && (
|
|
128
133
|
<Section title="Controls">
|
|
129
134
|
<button
|
|
135
|
+
{...sectionDisclosure.buttonProps}
|
|
130
136
|
onClick={() => setExpandedSection(!expandedSection)}
|
|
131
137
|
className="flex items-center gap-1 text-xs text-theme-text-secondary hover:text-theme-text-primary mb-2"
|
|
132
138
|
>
|
|
133
|
-
|
|
139
|
+
<CollapseChevron open={expandedSection} className="w-3.5 h-3.5" />
|
|
134
140
|
{sortedChecks.length} controls
|
|
135
141
|
</button>
|
|
136
|
-
{expandedSection
|
|
142
|
+
<Collapse open={expandedSection} unmountOnExit id={sectionDisclosure.panelId}>
|
|
137
143
|
<>
|
|
138
144
|
{/* Search and filter */}
|
|
139
145
|
<div className="flex items-center gap-2 mb-2">
|
|
@@ -174,10 +180,14 @@ export function ClusterComplianceReportRenderer({ data }: ClusterComplianceRepor
|
|
|
174
180
|
{filteredChecks.map((check: any) => {
|
|
175
181
|
const hasFail = (check.totalFail || 0) > 0
|
|
176
182
|
const controlDef = controlMap.get(check.id)
|
|
177
|
-
|
|
183
|
+
// One predicate for header, caret and panel: a control with no
|
|
184
|
+
// definition has nothing to show, so it never reads as expanded.
|
|
185
|
+
const isExpanded = expandedControls.has(check.id) && !!controlDef
|
|
178
186
|
return (
|
|
179
187
|
<div key={check.id}>
|
|
180
188
|
<button
|
|
189
|
+
aria-expanded={isExpanded}
|
|
190
|
+
aria-controls={disclosurePanelId(controlPanelBase, check.id)}
|
|
181
191
|
onClick={() => toggleControl(check.id)}
|
|
182
192
|
className="w-full flex items-center gap-2 py-1.5 px-1 rounded hover:bg-theme-hover/50 text-left"
|
|
183
193
|
>
|
|
@@ -193,22 +203,18 @@ export function ClusterComplianceReportRenderer({ data }: ClusterComplianceRepor
|
|
|
193
203
|
<span className="text-[10px] text-theme-text-tertiary shrink-0">
|
|
194
204
|
{check.totalFail || 0}F / {check.totalPass || 0}P
|
|
195
205
|
</span>
|
|
196
|
-
{isExpanded
|
|
197
|
-
<ChevronDown className="w-3 h-3 text-theme-text-tertiary shrink-0" />
|
|
198
|
-
) : (
|
|
199
|
-
<ChevronRight className="w-3 h-3 text-theme-text-tertiary shrink-0" />
|
|
200
|
-
)}
|
|
206
|
+
<CollapseChevron open={isExpanded} className="w-3 h-3" />
|
|
201
207
|
</button>
|
|
202
|
-
{isExpanded
|
|
208
|
+
<Collapse open={isExpanded} mountLazily id={disclosurePanelId(controlPanelBase, check.id)}>
|
|
203
209
|
<div className="ml-6 mr-1 mb-2 p-2.5 bg-theme-elevated/50 rounded border border-theme-border/50 space-y-2">
|
|
204
210
|
<div className="text-[10px] font-mono text-theme-text-tertiary">{check.id}</div>
|
|
205
|
-
{controlDef
|
|
211
|
+
{controlDef?.description && (
|
|
206
212
|
<div>
|
|
207
213
|
<div className="text-[10px] font-medium text-theme-text-tertiary uppercase tracking-wider mb-0.5">Description</div>
|
|
208
214
|
<div className="text-xs text-theme-text-secondary">{controlDef.description}</div>
|
|
209
215
|
</div>
|
|
210
216
|
)}
|
|
211
|
-
{controlDef
|
|
217
|
+
{controlDef?.checks?.length > 0 && (
|
|
212
218
|
<div>
|
|
213
219
|
<div className="text-[10px] font-medium text-theme-text-tertiary uppercase tracking-wider mb-0.5">Check IDs</div>
|
|
214
220
|
<div className="flex flex-wrap gap-1">
|
|
@@ -219,7 +225,7 @@ export function ClusterComplianceReportRenderer({ data }: ClusterComplianceRepor
|
|
|
219
225
|
</div>
|
|
220
226
|
)}
|
|
221
227
|
</div>
|
|
222
|
-
|
|
228
|
+
</Collapse>
|
|
223
229
|
</div>
|
|
224
230
|
)
|
|
225
231
|
})}
|
|
@@ -230,7 +236,7 @@ export function ClusterComplianceReportRenderer({ data }: ClusterComplianceRepor
|
|
|
230
236
|
)}
|
|
231
237
|
</div>
|
|
232
238
|
</>
|
|
233
|
-
|
|
239
|
+
</Collapse>
|
|
234
240
|
</Section>
|
|
235
241
|
)}
|
|
236
242
|
</>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
1
2
|
import { clsx } from 'clsx'
|
|
2
3
|
import { Layers, GitBranch, FileText, Boxes, ScrollText } from 'lucide-react'
|
|
3
4
|
import { Section, PropertyList, Property, AlertBanner, ResourceLink } from '../../ui/drawer-components'
|
|
5
|
+
import { Collapse, CollapseChevron, useDisclosure } from '../../ui/Collapse'
|
|
4
6
|
import { CodeViewer } from '../../ui/CodeViewer'
|
|
5
7
|
import { kindToPlural } from '../../../utils/navigation'
|
|
6
8
|
|
|
@@ -122,16 +124,7 @@ function CompositionBody({ data, onNavigate, revision }: CompositionRendererProp
|
|
|
122
124
|
/>
|
|
123
125
|
)}
|
|
124
126
|
</PropertyList>
|
|
125
|
-
{step.input &&
|
|
126
|
-
<details className="mt-2">
|
|
127
|
-
<summary className="text-xs text-theme-text-tertiary cursor-pointer hover:text-theme-text-secondary">
|
|
128
|
-
Show input
|
|
129
|
-
</summary>
|
|
130
|
-
<div className="mt-1">
|
|
131
|
-
<CodeViewer code={JSON.stringify(step.input, null, 2)} language="json" maxHeight="200px" />
|
|
132
|
-
</div>
|
|
133
|
-
</details>
|
|
134
|
-
)}
|
|
127
|
+
{step.input && <StepInputDisclosure input={step.input} />}
|
|
135
128
|
</div>
|
|
136
129
|
)
|
|
137
130
|
})}
|
|
@@ -216,3 +209,30 @@ export function CompositionRevisionRenderer({ data, onNavigate }: CompositionRev
|
|
|
216
209
|
</>
|
|
217
210
|
)
|
|
218
211
|
}
|
|
212
|
+
|
|
213
|
+
// Per-step input viewer. A native <details> looked nothing like the rest of
|
|
214
|
+
// the drawer's disclosures and skipped the shared open/close motion. The
|
|
215
|
+
// viewer renders on first open: one highlighted JSON pane per pipeline step
|
|
216
|
+
// is real work to do for steps nobody expands.
|
|
217
|
+
function StepInputDisclosure({ input }: { input: unknown }) {
|
|
218
|
+
const [open, setOpen] = useState(false)
|
|
219
|
+
const { panelId, buttonProps } = useDisclosure(open)
|
|
220
|
+
return (
|
|
221
|
+
<div className="mt-2">
|
|
222
|
+
<button
|
|
223
|
+
{...buttonProps}
|
|
224
|
+
type="button"
|
|
225
|
+
onClick={() => setOpen((v) => !v)}
|
|
226
|
+
className="flex items-center gap-1 text-xs text-theme-text-tertiary hover:text-theme-text-secondary"
|
|
227
|
+
>
|
|
228
|
+
<CollapseChevron open={open} className="h-3 w-3" />
|
|
229
|
+
Show input
|
|
230
|
+
</button>
|
|
231
|
+
<Collapse open={open} mountLazily id={panelId}>
|
|
232
|
+
<div className="mt-1">
|
|
233
|
+
<CodeViewer code={JSON.stringify(input, null, 2)} language="json" maxHeight="200px" />
|
|
234
|
+
</div>
|
|
235
|
+
</Collapse>
|
|
236
|
+
</div>
|
|
237
|
+
)
|
|
238
|
+
}
|