@skyhook-io/radar-app 1.20.3 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -9
- package/src/App.tsx +54 -10
- package/src/api/client.audit-gating.test.tsx +105 -5
- package/src/api/client.auditBadgesSync.test.tsx +118 -0
- package/src/api/client.capabilitiesPoll.test.ts +61 -0
- package/src/api/client.ts +129 -5
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/radarFeatures.ts +7 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +201 -0
- package/src/api/vulnerabilities.ts +255 -0
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
- package/src/components/audit/ChecksViewTabs.tsx +11 -1
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +907 -0
- package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
- package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
- package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
- package/src/components/cnpg/CNPGView.tsx +43 -117
- package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
- package/src/components/cnpg/host.tsx +2 -2
- package/src/components/cnpg/routes.ts +3 -1
- package/src/components/cnpg/shared.tsx +5 -53
- package/src/components/cnpg/useCNPGNavigate.ts +1 -21
- package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
- package/src/components/community.tsx +42 -0
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/diagnose/investigationMetrics.test.ts +20 -0
- package/src/components/diagnose/investigationMetrics.ts +2 -1
- package/src/components/dock/BottomDock.tsx +1 -0
- package/src/components/dock/LogsTab.tsx +3 -0
- package/src/components/gitops/GitOpsView.tsx +1 -1
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmView.tsx +20 -16
- package/src/components/helm/OwnedResources.tsx +4 -3
- package/src/components/home/ClusterHealthCard.tsx +3 -1
- package/src/components/home/HomeAgentBlock.tsx +3 -0
- package/src/components/home/HomeView.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +19 -12
- package/src/components/home/MCPSetupDialog.tsx +4 -2
- package/src/components/home/mcpToolCatalog.ts +15 -2
- package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
- package/src/components/home/useVulnerabilitiesRow.ts +50 -0
- package/src/components/logs/LogsViewer.tsx +3 -1
- package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
- package/src/components/logs/MultiPodLogsTab.tsx +9 -5
- package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
- package/src/components/nav/PrimaryNavRail.tsx +174 -29
- package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
- package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
- package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
- package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
- package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
- package/src/components/resources/ResourcesView.tsx +12 -6
- package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
- package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
- package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
- package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +3 -2
- package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
- package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
- package/src/components/timeline/TimelineView.tsx +3 -1
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
- package/src/components/traffic/TrafficData.test.tsx +37 -0
- package/src/components/traffic/TrafficData.tsx +27 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -7
- package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
- package/src/components/traffic/TrafficGraph.test.tsx +269 -0
- package/src/components/traffic/TrafficGraph.tsx +135 -64
- package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
- package/src/components/traffic/TrafficView.tsx +46 -129
- package/src/components/traffic/trafficFilters.test.ts +172 -1
- package/src/components/traffic/trafficFilters.ts +139 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +31 -2
- package/src/components/ui/UpdateNotification.tsx +34 -17
- package/src/components/ui/command-items.ts +24 -1
- package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
- package/src/components/velero/VeleroBackupNow.tsx +143 -0
- package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
- package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
- package/src/components/velero/VeleroDetailPage.tsx +148 -0
- package/src/components/velero/VeleroKindLists.test.tsx +48 -0
- package/src/components/velero/VeleroKindLists.tsx +43 -0
- package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
- package/src/components/velero/VeleroLocations.test.tsx +86 -0
- package/src/components/velero/VeleroLocations.tsx +240 -0
- package/src/components/velero/VeleroOverview.test.tsx +311 -0
- package/src/components/velero/VeleroOverview.tsx +485 -0
- package/src/components/velero/VeleroPages.test.tsx +516 -0
- package/src/components/velero/VeleroPages.tsx +1056 -0
- package/src/components/velero/VeleroRunLists.tsx +309 -0
- package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
- package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
- package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
- package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
- package/src/components/velero/VeleroSchedules.tsx +255 -0
- package/src/components/velero/VeleroView.tsx +59 -0
- package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
- package/src/components/velero/attention.test.ts +178 -0
- package/src/components/velero/attention.ts +281 -0
- package/src/components/velero/backupDelete.test.tsx +91 -0
- package/src/components/velero/backupDelete.tsx +182 -0
- package/src/components/velero/coverage.test.ts +87 -0
- package/src/components/velero/coverage.ts +150 -0
- package/src/components/velero/host.tsx +86 -0
- package/src/components/velero/routes.ts +78 -0
- package/src/components/velero/runs.tsx +121 -0
- package/src/components/velero/shared.test.ts +84 -0
- package/src/components/velero/shared.tsx +423 -0
- package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
- package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
- package/src/components/velero/velero.fixtures.ts +61 -0
- package/src/components/velero/workspaceRoute.ts +21 -0
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/workload/WorkloadView.tsx +64 -27
- package/src/components/workspace/DrawerTrailBack.tsx +32 -0
- package/src/components/workspace/WorkspaceFrame.tsx +71 -0
- package/src/components/workspace/coverage.ts +61 -0
- package/src/components/workspace/layout.test.tsx +29 -1
- package/src/components/workspace/layout.tsx +15 -5
- package/src/components/workspace/sidebar.ts +9 -0
- package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
- package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
- package/src/desktop/AboutDialog.test.ts +12 -0
- package/src/desktop/AboutDialog.tsx +151 -0
- package/src/desktop/WindowsTitleBar.tsx +359 -0
- package/src/desktop/titleBar.test.ts +61 -0
- package/src/desktop/titleBar.ts +45 -0
- package/src/index.css +19 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +14 -2
- package/src/integrations/resourceHosts.tsx +22 -6
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.test.ts +11 -0
- package/src/integrations/workspaceRoutes.ts +3 -1
- package/src/integrations/workspaceScreens.tsx +2 -0
- package/src/main.tsx +8 -0
- package/src/utils/desktop-zoom.test.ts +53 -0
- package/src/utils/desktop-zoom.ts +30 -0
- package/src/utils/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { useMemo, useState, type ReactNode } from 'react'
|
|
2
|
+
import { Plus, Search } from 'lucide-react'
|
|
3
|
+
import { Tooltip, VELERO_MANUAL_RUN, VELERO_MANUAL_RUN_TITLE, toneTextClass } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import { useVeleroRuns, type VeleroRestoreRow, type VeleroRunRow } from '../../api/velero'
|
|
5
|
+
import { useMediaQuery } from '../../hooks/useMediaQuery'
|
|
6
|
+
import { ScreenBody, SectionTable, Segments, Sub, type TableColumn } from '../workspace/layout'
|
|
7
|
+
import { VELERO_WIDE, VeleroName, VeleroWorkspaceHeader, WholeNames, inInstallation, restoredIntoText, veleroResource, type VeleroScreenProps } from './shared'
|
|
8
|
+
import { Expires, RunCounts, RunOutcome, RunReason, RunsReadNotice, When, durationText, expired, runViewOptions, runsEmpty, useRunView } from './runs'
|
|
9
|
+
|
|
10
|
+
// Rows rendered at once; the rest are a click away, and search narrows first.
|
|
11
|
+
const PAGE = 200
|
|
12
|
+
|
|
13
|
+
function SearchBox({ value, onChange, placeholder }: { value: string; onChange: (v: string) => void; placeholder: string }) {
|
|
14
|
+
return (
|
|
15
|
+
<label className="flex min-w-[14rem] items-center gap-2 rounded-lg border border-theme-border bg-theme-surface px-2.5 py-1.5 text-sm">
|
|
16
|
+
<Search className="h-3.5 w-3.5 text-theme-text-tertiary" aria-hidden />
|
|
17
|
+
<input value={value} onChange={(e) => onChange(e.target.value)} placeholder={placeholder} aria-label={placeholder} className="min-w-0 flex-1 bg-transparent text-theme-text-primary outline-none placeholder:text-theme-text-tertiary" />
|
|
18
|
+
</label>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function RunTable<R extends VeleroRunRow>({ columns, rows, kind, onInspect, inspected, empty, footer, minWidth }: {
|
|
23
|
+
columns: TableColumn<R>[]
|
|
24
|
+
rows: R[]
|
|
25
|
+
kind: 'Backup' | 'Restore'
|
|
26
|
+
onInspect: VeleroScreenProps['onInspect']
|
|
27
|
+
inspected: VeleroScreenProps['inspected']
|
|
28
|
+
empty: string
|
|
29
|
+
footer?: ReactNode
|
|
30
|
+
minWidth: number
|
|
31
|
+
}) {
|
|
32
|
+
const [limit, setLimit] = useState(PAGE)
|
|
33
|
+
return (
|
|
34
|
+
<SectionTable
|
|
35
|
+
columns={columns}
|
|
36
|
+
rows={rows.slice(0, limit)}
|
|
37
|
+
rowKey={(r) => r.uid || `${r.namespace}/${r.name}`}
|
|
38
|
+
rowResource={(r) => veleroResource(kind, r.namespace, r.name)}
|
|
39
|
+
onInspect={onInspect}
|
|
40
|
+
inspected={inspected}
|
|
41
|
+
minWidth={minWidth}
|
|
42
|
+
empty={empty}
|
|
43
|
+
footer={
|
|
44
|
+
<>
|
|
45
|
+
{rows.length > limit && (
|
|
46
|
+
<button type="button" onClick={() => setLimit((l) => l + PAGE)} className="mr-3 text-accent hover:underline">
|
|
47
|
+
Show {Math.min(PAGE, rows.length - limit)} more of {rows.length - limit}
|
|
48
|
+
</button>
|
|
49
|
+
)}
|
|
50
|
+
{footer}
|
|
51
|
+
</>
|
|
52
|
+
}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function CreateButton({ onCreate, kind }: { onCreate?: () => void; kind: string }) {
|
|
58
|
+
if (!onCreate) return null
|
|
59
|
+
return (
|
|
60
|
+
<button type="button" onClick={onCreate} className="btn-secondary ml-auto inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium">
|
|
61
|
+
<Plus className="h-3.5 w-3.5" aria-hidden />
|
|
62
|
+
Create {kind}
|
|
63
|
+
</button>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function plural(n: number, word: string): string {
|
|
68
|
+
return `${n} ${word}${n === 1 ? '' : 's'}`
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The outcome and why; on a narrow screen also its errors and warnings, said only when there are some. */
|
|
72
|
+
export function OutcomeCell({ kind, run, counts }: { kind: 'Backup' | 'Restore'; run: VeleroRunRow; counts?: boolean }) {
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<RunOutcome kind={kind} phase={run.phase} />
|
|
76
|
+
<RunReason run={run} />
|
|
77
|
+
{counts && (run.errors > 0 || run.warnings > 0) && (
|
|
78
|
+
<Sub>
|
|
79
|
+
{run.errors > 0 && <span className={toneTextClass('unhealthy')}>{plural(run.errors, 'error')}</span>}
|
|
80
|
+
{run.errors > 0 && run.warnings > 0 && ' · '}
|
|
81
|
+
{run.warnings > 0 && <span className={toneTextClass('degraded')}>{plural(run.warnings, 'warning')}</span>}
|
|
82
|
+
</Sub>
|
|
83
|
+
)}
|
|
84
|
+
</>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Where a restore put things, as its page says it; nothing for one Velero rejected. */
|
|
89
|
+
export function RestoreIntoCell({ run }: { run: VeleroRestoreRow }) {
|
|
90
|
+
if (run.phase === 'FailedValidation') return <span className="text-theme-text-secondary">Nothing — rejected</span>
|
|
91
|
+
const text = restoredIntoText(run)
|
|
92
|
+
return (
|
|
93
|
+
<Tooltip content={text}>
|
|
94
|
+
<span className="line-clamp-2">
|
|
95
|
+
<WholeNames text={text} />
|
|
96
|
+
</span>
|
|
97
|
+
</Tooltip>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Started, and on a narrow screen how long it took, the items it processed,
|
|
103
|
+
* where it is stored and when Velero deletes it.
|
|
104
|
+
*/
|
|
105
|
+
export function StartedCell({ run, folded, items, storedIn, expires }: { run: VeleroRunRow; folded: boolean; items?: boolean; storedIn?: string; expires?: boolean }) {
|
|
106
|
+
const took = durationText(run.started, run.completed)
|
|
107
|
+
const extra = folded ? [took && `took ${took}`, items && run.itemsTotal ? `${run.itemsDone ?? 0} / ${run.itemsTotal} items` : ''].filter(Boolean) : []
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<When iso={run.started} fallback="not started" />
|
|
111
|
+
{extra.length > 0 && <Sub>{extra.join(' · ')}</Sub>}
|
|
112
|
+
{folded && storedIn && (
|
|
113
|
+
<Sub>
|
|
114
|
+
<WholeNames text={storedIn} />
|
|
115
|
+
</Sub>
|
|
116
|
+
)}
|
|
117
|
+
{folded && expires && run.expiration && (
|
|
118
|
+
<Sub>
|
|
119
|
+
{!expired(run.expiration) && 'expires '}
|
|
120
|
+
<Expires iso={run.expiration} />
|
|
121
|
+
</Sub>
|
|
122
|
+
)}
|
|
123
|
+
</>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Where a backup is stored, and whether that location is not available. */
|
|
128
|
+
function storedInText(r: VeleroRunRow, locations: VeleroScreenProps['data']['locations']): { name?: string; state?: string } {
|
|
129
|
+
if (!r.storageLocation) return { state: 'not assigned yet' }
|
|
130
|
+
const loc = locations.find((l) => l.namespace === r.namespace && l.name === r.storageLocation)
|
|
131
|
+
return { name: r.storageLocation, state: loc && loc.phase !== 'Available' ? (loc.phase ? loc.phase.toLowerCase() : 'not validated') : undefined }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The Backup kind's list: every run across the installations the caller can
|
|
136
|
+
* read, newest first, with the failed ones a segment away.
|
|
137
|
+
*/
|
|
138
|
+
export function VeleroBackups({ data, installation, onInstallation, onInspect, inspected, onCreate }: VeleroScreenProps) {
|
|
139
|
+
// The installation narrows the read on the server, so its cap counts only these.
|
|
140
|
+
const query = useVeleroRuns('backups', installation ?? undefined)
|
|
141
|
+
const wide = useMediaQuery(VELERO_WIDE)
|
|
142
|
+
const [search, setSearch] = useState('')
|
|
143
|
+
const rows = useMemo(
|
|
144
|
+
() => inInstallation(query.data?.runs ?? [], installation).filter((r) => !search || r.name.toLowerCase().includes(search.toLowerCase())),
|
|
145
|
+
[query.data, installation, search],
|
|
146
|
+
)
|
|
147
|
+
const { failed, view, setView, shown } = useRunView(rows)
|
|
148
|
+
const locations = data.locations
|
|
149
|
+
const columns: TableColumn<VeleroRunRow>[] = [
|
|
150
|
+
{
|
|
151
|
+
header: 'Backup',
|
|
152
|
+
cell: (r) => (
|
|
153
|
+
<>
|
|
154
|
+
<VeleroName name={r.name} middle />
|
|
155
|
+
<Sub>
|
|
156
|
+
{r.schedule ? <WholeNames text={`schedule ${r.schedule}`} /> : 'On demand'}
|
|
157
|
+
{r.manual && (
|
|
158
|
+
<Tooltip content={VELERO_MANUAL_RUN_TITLE}>
|
|
159
|
+
<span>{` · ${VELERO_MANUAL_RUN}`}</span>
|
|
160
|
+
</Tooltip>
|
|
161
|
+
)}
|
|
162
|
+
</Sub>
|
|
163
|
+
</>
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
{ header: 'Outcome', width: wide ? '170px' : '180px', cell: (r) => <OutcomeCell kind="Backup" run={r} counts={!wide} /> },
|
|
167
|
+
{
|
|
168
|
+
header: 'Started',
|
|
169
|
+
width: wide ? '100px' : '190px',
|
|
170
|
+
cell: (r) => {
|
|
171
|
+
const stored = storedInText(r, locations)
|
|
172
|
+
return <StartedCell run={r} folded={!wide} items expires storedIn={stored.name ? `in ${stored.name}${stored.state ? ` · ${stored.state}` : ''}` : stored.state} />
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
...(wide
|
|
176
|
+
? [
|
|
177
|
+
{ header: 'Took', width: '75px', cell: (r: VeleroRunRow) => durationText(r.started, r.completed) ?? '—' },
|
|
178
|
+
{ header: 'Items', width: '80px', cell: (r: VeleroRunRow) => (r.itemsTotal ? `${r.itemsDone ?? 0} / ${r.itemsTotal}` : '—') },
|
|
179
|
+
]
|
|
180
|
+
: []),
|
|
181
|
+
...(wide
|
|
182
|
+
? [
|
|
183
|
+
{ header: 'Errors · warnings', width: '130px', cell: (r: VeleroRunRow) => <RunCounts errors={r.errors} warnings={r.warnings} /> },
|
|
184
|
+
{
|
|
185
|
+
header: 'Stored in',
|
|
186
|
+
width: '140px',
|
|
187
|
+
cell: (r: VeleroRunRow) => {
|
|
188
|
+
const stored = storedInText(r, locations)
|
|
189
|
+
if (!stored.name) return <span className="text-theme-text-tertiary">{stored.state}</span>
|
|
190
|
+
return (
|
|
191
|
+
<>
|
|
192
|
+
<VeleroName name={stored.name} />
|
|
193
|
+
{stored.state && <Sub>{stored.state}</Sub>}
|
|
194
|
+
</>
|
|
195
|
+
)
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{ header: 'Expires', width: '90px', cell: (r: VeleroRunRow) => <Expires iso={r.expiration} /> },
|
|
199
|
+
]
|
|
200
|
+
: []),
|
|
201
|
+
]
|
|
202
|
+
return (
|
|
203
|
+
<div className="flex min-h-0 flex-1 flex-col">
|
|
204
|
+
<VeleroWorkspaceHeader title="Backups" data={data} installation={installation} onInstallation={onInstallation} />
|
|
205
|
+
<ScreenBody>
|
|
206
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
207
|
+
<Segments label="Backups" value={view} onChange={setView} options={runViewOptions(failed.length, rows.length, query)} />
|
|
208
|
+
<SearchBox value={search} onChange={setSearch} placeholder="Search backups" />
|
|
209
|
+
<CreateButton onCreate={onCreate} kind="Backup" />
|
|
210
|
+
</div>
|
|
211
|
+
<RunsReadNotice query={query} noun="backups" />
|
|
212
|
+
<RunTable
|
|
213
|
+
columns={columns}
|
|
214
|
+
rows={shown}
|
|
215
|
+
kind="Backup"
|
|
216
|
+
onInspect={onInspect}
|
|
217
|
+
inspected={inspected}
|
|
218
|
+
minWidth={wide ? 1000 : 520}
|
|
219
|
+
empty={runsEmpty(query, 'backups', view === 'failed' ? 'No failed backups' : 'No backups match')}
|
|
220
|
+
footer="Failed counts runs that failed, partially failed or were rejected. Expired backups are eligible for garbage collection."
|
|
221
|
+
/>
|
|
222
|
+
</ScreenBody>
|
|
223
|
+
</div>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The Restore kind's list: every restore, newest first, with the failed ones a segment away. */
|
|
228
|
+
export function VeleroRestores({ data, installation, onInstallation, onInspect, inspected, onCreate }: VeleroScreenProps) {
|
|
229
|
+
const query = useVeleroRuns('restores', installation ?? undefined)
|
|
230
|
+
const wide = useMediaQuery(VELERO_WIDE)
|
|
231
|
+
const [search, setSearch] = useState('')
|
|
232
|
+
const rows = useMemo(
|
|
233
|
+
() => inInstallation(query.data?.runs ?? [], installation).filter((r) => !search || r.name.toLowerCase().includes(search.toLowerCase()) || (r.backupName ?? '').toLowerCase().includes(search.toLowerCase())),
|
|
234
|
+
[query.data, installation, search],
|
|
235
|
+
)
|
|
236
|
+
const { failed, view, setView, shown } = useRunView(rows)
|
|
237
|
+
const fromBackup = (r: VeleroRunRow) =>
|
|
238
|
+
r.backupName ? (
|
|
239
|
+
<button
|
|
240
|
+
type="button"
|
|
241
|
+
onClick={(e) => {
|
|
242
|
+
e.stopPropagation()
|
|
243
|
+
onInspect(veleroResource('Backup', r.namespace, r.backupName!))
|
|
244
|
+
}}
|
|
245
|
+
className="block max-w-full text-left text-accent-text hover:underline"
|
|
246
|
+
>
|
|
247
|
+
<VeleroName name={r.backupName} middle />
|
|
248
|
+
</button>
|
|
249
|
+
) : r.scheduleName ? (
|
|
250
|
+
<WholeNames text={`newest of ${r.scheduleName}`} />
|
|
251
|
+
) : (
|
|
252
|
+
'—'
|
|
253
|
+
)
|
|
254
|
+
// Narrow: the backup goes under the restore's name, and errors and warnings under its outcome.
|
|
255
|
+
const columns: TableColumn<VeleroRestoreRow>[] = [
|
|
256
|
+
{
|
|
257
|
+
header: 'Restore',
|
|
258
|
+
cell: (r) => (
|
|
259
|
+
<>
|
|
260
|
+
<VeleroName name={r.name} middle />
|
|
261
|
+
{!wide && (
|
|
262
|
+
<Sub>
|
|
263
|
+
<span className="flex min-w-0 items-baseline gap-1">
|
|
264
|
+
<span className="shrink-0">from</span>
|
|
265
|
+
<span className="min-w-0">{fromBackup(r)}</span>
|
|
266
|
+
</span>
|
|
267
|
+
</Sub>
|
|
268
|
+
)}
|
|
269
|
+
</>
|
|
270
|
+
),
|
|
271
|
+
},
|
|
272
|
+
{ header: 'Outcome', width: '170px', cell: (r) => <OutcomeCell kind="Restore" run={r} counts={!wide} /> },
|
|
273
|
+
...(wide ? [{ header: 'From backup', cell: fromBackup }] : []),
|
|
274
|
+
{
|
|
275
|
+
header: 'Into',
|
|
276
|
+
width: wide ? '170px' : '150px',
|
|
277
|
+
cell: (r) => <RestoreIntoCell run={r} />,
|
|
278
|
+
},
|
|
279
|
+
{ header: 'Started', width: wide ? '100px' : '120px', cell: (r) => <StartedCell run={r} folded={!wide} /> },
|
|
280
|
+
...(wide
|
|
281
|
+
? [
|
|
282
|
+
{ header: 'Took', width: '75px', cell: (r: VeleroRunRow) => durationText(r.started, r.completed) ?? '—' },
|
|
283
|
+
{ header: 'Errors · warnings', width: '130px', cell: (r: VeleroRunRow) => <RunCounts errors={r.errors} warnings={r.warnings} /> },
|
|
284
|
+
]
|
|
285
|
+
: []),
|
|
286
|
+
]
|
|
287
|
+
return (
|
|
288
|
+
<div className="flex min-h-0 flex-1 flex-col">
|
|
289
|
+
<VeleroWorkspaceHeader title="Restores" data={data} installation={installation} onInstallation={onInstallation} />
|
|
290
|
+
<ScreenBody>
|
|
291
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
292
|
+
<Segments label="Restores" value={view} onChange={setView} options={runViewOptions(failed.length, rows.length, query)} />
|
|
293
|
+
<SearchBox value={search} onChange={setSearch} placeholder="Search restores" />
|
|
294
|
+
<CreateButton onCreate={onCreate} kind="Restore" />
|
|
295
|
+
</div>
|
|
296
|
+
<RunsReadNotice query={query} noun="restores" />
|
|
297
|
+
<RunTable
|
|
298
|
+
columns={columns}
|
|
299
|
+
rows={shown}
|
|
300
|
+
kind="Restore"
|
|
301
|
+
onInspect={onInspect}
|
|
302
|
+
inspected={inspected}
|
|
303
|
+
minWidth={wide ? 1000 : 560}
|
|
304
|
+
empty={runsEmpty(query, 'restores', view === 'failed' ? 'No failed restores' : 'No restores match')}
|
|
305
|
+
/>
|
|
306
|
+
</ScreenBody>
|
|
307
|
+
</div>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
vi.mock('../../api/policy', () => ({ useVeleroRunMessages: () => ({ isPending: false, mutate: vi.fn() }) }))
|
|
5
|
+
|
|
6
|
+
const { VeleroRunIssueMessages, veleroMessagesInIssue } = await import('./VeleroRunMessagesHost')
|
|
7
|
+
|
|
8
|
+
const run = (phase: string) => ({ metadata: { namespace: 'velero', name: 'nightly-1' }, status: { phase, errors: 9, warnings: 3 } })
|
|
9
|
+
|
|
10
|
+
// The messages are what is wrong with a failed run, so they sit in its issue;
|
|
11
|
+
// only one place shows them.
|
|
12
|
+
describe('where a Velero run’s messages go', () => {
|
|
13
|
+
it('goes in the issue when the drawer shows it, in Status otherwise', () => {
|
|
14
|
+
expect(veleroMessagesInIssue(run('PartiallyFailed'), true)).toBe(true)
|
|
15
|
+
expect(veleroMessagesInIssue(run('PartiallyFailed'), false)).toBe(false)
|
|
16
|
+
// A completed run with warnings raises no issue.
|
|
17
|
+
expect(veleroMessagesInIssue(run('Completed'), true)).toBe(false)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('renders under a failed run’s issue only', () => {
|
|
21
|
+
const html = renderToStaticMarkup(<VeleroRunIssueMessages issue={{ reason: 'BackupPartiallyFailed' }} resource={run('PartiallyFailed')} />)
|
|
22
|
+
expect(html).toContain('Show 9 errors and 3 warnings')
|
|
23
|
+
expect(renderToStaticMarkup(<VeleroRunIssueMessages issue={{ reason: 'VeleroRunStalled' }} resource={run('PartiallyFailed')} />)).toBe('')
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
|
|
2
|
+
import { VeleroRunMessages, type VeleroRunMessagesFetch } from '@skyhook-io/k8s-ui/components/resources/renderers/VeleroRunMessages'
|
|
3
|
+
import { getBackupErrors, getBackupWarnings, getRestoreErrors, getRestoreWarnings } from '@skyhook-io/k8s-ui/components/resources/resource-utils-velero'
|
|
4
|
+
import { useVeleroRunMessages } from '../../api/policy'
|
|
5
|
+
|
|
6
|
+
type RunKind = 'backups' | 'restores'
|
|
7
|
+
|
|
8
|
+
// The phases Velero's issues are raised for (veleroPartialPhases and Failed in
|
|
9
|
+
// internal/issues/source_velero.go).
|
|
10
|
+
const FAILED_PHASES = new Set(['Failed', 'PartiallyFailed', 'FinalizingPartiallyFailed', 'WaitingForPluginOperationsPartiallyFailed'])
|
|
11
|
+
|
|
12
|
+
const ISSUE_REASONS: Record<string, RunKind> = {
|
|
13
|
+
BackupFailed: 'backups',
|
|
14
|
+
BackupPartiallyFailed: 'backups',
|
|
15
|
+
RestoreFailed: 'restores',
|
|
16
|
+
RestorePartiallyFailed: 'restores',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Where a run's messages go: inside its issue's "What's wrong" when the drawer
|
|
21
|
+
* shows that issue, since they are what is wrong; in Status otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export function veleroMessagesInIssue(data: any, issuesShown: boolean): boolean {
|
|
24
|
+
return issuesShown && FAILED_PHASES.has(data?.status?.phase ?? '')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Nothing is fetched until the operator asks: reading the messages makes
|
|
28
|
+
// Velero create a DownloadRequest and pulls an object out of storage.
|
|
29
|
+
export function useVeleroRunMessagesFetch(kind: RunKind, data: any): VeleroRunMessagesFetch {
|
|
30
|
+
const namespace = data?.metadata?.namespace ?? ''
|
|
31
|
+
const name = data?.metadata?.name ?? ''
|
|
32
|
+
const fetcher = useVeleroRunMessages(kind, namespace, name)
|
|
33
|
+
return {
|
|
34
|
+
messages: fetcher.data,
|
|
35
|
+
loading: fetcher.isPending,
|
|
36
|
+
lookupNote: fetcher.error ? <LookupFailureNote errors={[fetcher.error]} what="the messages behind these counts" /> : undefined,
|
|
37
|
+
onFetch: namespace && name ? () => fetcher.mutate() : undefined,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A run's errors and warnings behind its counts, fetched on request. */
|
|
42
|
+
export function RunMessages({ kind, resource }: { kind: RunKind; resource: any }) {
|
|
43
|
+
const fetch = useVeleroRunMessagesFetch(kind, resource)
|
|
44
|
+
const errors = kind === 'backups' ? getBackupErrors(resource) : getRestoreErrors(resource)
|
|
45
|
+
const warnings = kind === 'backups' ? getBackupWarnings(resource) : getRestoreWarnings(resource)
|
|
46
|
+
return <VeleroRunMessages {...fetch} errors={errors} warnings={warnings} />
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A failed run's messages, under its issue in the drawer. */
|
|
50
|
+
export function VeleroRunIssueMessages({ issue, resource }: { issue: { kind?: string; reason?: string }; resource: any }) {
|
|
51
|
+
const kind = ISSUE_REASONS[issue.reason ?? '']
|
|
52
|
+
if (!kind || !resource || !veleroMessagesInIssue(resource, true)) return null
|
|
53
|
+
return <RunMessages kind={kind} resource={resource} />
|
|
54
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { schedule } from './velero.fixtures'
|
|
4
|
+
|
|
5
|
+
const state = vi.hoisted(() => ({ support: 'supported' as string, data: undefined as unknown }))
|
|
6
|
+
vi.mock('../../api/client', () => ({ useRadarFeature: () => ({ support: state.support }) }))
|
|
7
|
+
vi.mock('../../api/velero', () => ({ useVeleroScheduleActivity: () => ({ data: state.data }) }))
|
|
8
|
+
|
|
9
|
+
const { VeleroScheduleStatusBadge } = await import('./VeleroScheduleStatusBadge')
|
|
10
|
+
|
|
11
|
+
const enabled = { apiVersion: 'velero.io/v1', kind: 'Schedule', metadata: { namespace: 'velero', name: 'nightly' }, spec: { schedule: '0 1 * * *' }, status: { phase: 'Enabled' } }
|
|
12
|
+
|
|
13
|
+
describe('Velero Schedule header chip', () => {
|
|
14
|
+
it('says what the schedule is doing, not that Velero accepted it', () => {
|
|
15
|
+
state.support = 'supported'
|
|
16
|
+
state.data = { reading: schedule({ state: 'late', attention: true }) }
|
|
17
|
+
const html = renderToStaticMarkup(<VeleroScheduleStatusBadge resource={enabled} />)
|
|
18
|
+
expect(html).toContain('Late')
|
|
19
|
+
expect(html).not.toContain('Enabled')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('falls back to the phase until the reading arrives, and on an older Radar', () => {
|
|
23
|
+
state.data = undefined
|
|
24
|
+
expect(renderToStaticMarkup(<VeleroScheduleStatusBadge resource={enabled} />)).toContain('Enabled')
|
|
25
|
+
state.support = 'unsupported'
|
|
26
|
+
expect(renderToStaticMarkup(<VeleroScheduleStatusBadge resource={enabled} />)).toContain('Enabled')
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { VeleroScheduleStateBadge, getResourceStatus } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useRadarFeature } from '../../api/client'
|
|
4
|
+
import { useVeleroScheduleActivity } from '../../api/velero'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Velero Schedule's header chip: what the schedule is doing (late, held, on
|
|
8
|
+
* schedule) rather than Velero's phase, which only says Velero accepted it. A
|
|
9
|
+
* schedule can be Enabled and hours late. Until the reading arrives, or on a
|
|
10
|
+
* Radar without it, the phase stands in.
|
|
11
|
+
*/
|
|
12
|
+
export function VeleroScheduleStatusBadge({ resource }: { resource: any }) {
|
|
13
|
+
const namespace = resource?.metadata?.namespace ?? ''
|
|
14
|
+
const name = resource?.metadata?.name ?? ''
|
|
15
|
+
const { support } = useRadarFeature('veleroWorkspace')
|
|
16
|
+
const activity = useVeleroScheduleActivity(namespace, name, { enabled: support === 'supported' })
|
|
17
|
+
const reading = activity.data?.reading
|
|
18
|
+
if (reading) return <VeleroScheduleStateBadge reading={reading} />
|
|
19
|
+
const phase = getResourceStatus('schedules', resource)
|
|
20
|
+
return phase ? <span className={clsx('badge', phase.color)}>{phase.text}</span> : null
|
|
21
|
+
}
|