@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
|
@@ -6,7 +6,7 @@ import { ResourceRendererDispatch } from '@skyhook-io/k8s-ui'
|
|
|
6
6
|
import { encodeDrawerTrail } from '../utils/drawer-trail'
|
|
7
7
|
import { kindToPluralWithGroup } from '../utils/navigation'
|
|
8
8
|
import {
|
|
9
|
-
decorateResourceDiagnose, renderResourceKindList, resourceKindListMode, resourceKindListTitle, ResourceDrawerNavigation,
|
|
9
|
+
decorateResourceDiagnose, renderResourceKindList, resourceKindListMode, resourceKindListNamespaceFilterTooltip, resourceKindListTitle, ResourceDrawerNavigation,
|
|
10
10
|
resourceDetailRedirect, resourceDetailSlots, resourceExpandedPath,
|
|
11
11
|
resourceLogs, resourceRendererOverrides, resourceHosts,
|
|
12
12
|
} from './resourceHosts'
|
|
@@ -55,7 +55,7 @@ describe('application resource hosts', () => {
|
|
|
55
55
|
'RolloutRenderer', 'KyvernoPolicyCoverage', 'KyvernoPolicyQueued', 'CNPGObjectStoreRenderer',
|
|
56
56
|
'VeleroBSLRenderer', 'VeleroBackupRenderer', 'VeleroRestoreRenderer', 'CNPGClusterRenderer',
|
|
57
57
|
'CNPGDatabaseRenderer', 'CNPGPublicationRenderer', 'CNPGSubscriptionRenderer', 'CNPGImageCatalogRenderer',
|
|
58
|
-
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer', 'SecretProviderClassRenderer',
|
|
58
|
+
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer', 'SecretProviderClassRenderer', 'UpgradePlanRenderer',
|
|
59
59
|
].sort())
|
|
60
60
|
const inherited = [{ id: 'local', label: 'Local', render: () => null }]
|
|
61
61
|
expect(resourceDetailSlots({ kind: 'Pod', group: '', namespace: 'db', name: 'pg-1' }, inherited).extraTabs).toEqual(inherited)
|
|
@@ -135,6 +135,18 @@ describe('application resource hosts', () => {
|
|
|
135
135
|
expect(resourceKindListTitle(cnpgKind)).toBe('CloudNativePG Clusters')
|
|
136
136
|
})
|
|
137
137
|
|
|
138
|
+
it('disables the namespace filter only while a list that ignores it is on screen', () => {
|
|
139
|
+
for (const name of ['backups', 'restores', 'schedules', 'backupstoragelocations']) {
|
|
140
|
+
const kind = { name, group: 'velero.io' }
|
|
141
|
+
expect(resourceKindListNamespaceFilterTooltip(kind, { veleroWorkspace: 'supported' }, false)).toContain('namespace filter doesn’t apply')
|
|
142
|
+
// The generic table that an older Radar shows does honour the filter.
|
|
143
|
+
expect(resourceKindListNamespaceFilterTooltip(kind, { veleroWorkspace: 'unsupported' }, false)).toBeUndefined()
|
|
144
|
+
expect(resourceKindListNamespaceFilterTooltip(kind, { veleroWorkspace: 'unknown' }, false)).toBeUndefined()
|
|
145
|
+
}
|
|
146
|
+
expect(resourceKindListNamespaceFilterTooltip({ name: 'deletebackuprequests', group: 'velero.io' }, { veleroWorkspace: 'supported' }, false)).toBeUndefined()
|
|
147
|
+
expect(resourceKindListNamespaceFilterTooltip(cnpgKind, supported, false)).toBeUndefined()
|
|
148
|
+
})
|
|
149
|
+
|
|
138
150
|
it('decorates Diagnose only for the integration-owned resource context', () => {
|
|
139
151
|
const render = vi.fn(() => <span>diagnose</span>)
|
|
140
152
|
const decorated = decorateResourceDiagnose(render)!
|
|
@@ -6,6 +6,7 @@ import type { RenderDiagnoseAction } from '../context/DiagnoseCustomization'
|
|
|
6
6
|
import { apiVersionToGroup } from '../utils/navigation'
|
|
7
7
|
import type { SelectedResource } from '../types'
|
|
8
8
|
import { cnpgResourceHost } from '../components/cnpg/host'
|
|
9
|
+
import { veleroResourceHost } from '../components/velero/host'
|
|
9
10
|
import { crdResourceHost } from '../components/resources/crd/host'
|
|
10
11
|
import {
|
|
11
12
|
composeDetailSlots, composeResourceHosts, hostsForResource, hostSupport, resourceHostForSlot,
|
|
@@ -36,11 +37,9 @@ import { HTTPRouteRenderer } from '../components/resources/renderers/HTTPRouteRe
|
|
|
36
37
|
import { RolloutRenderer } from '../components/resources/renderers/RolloutRenderer'
|
|
37
38
|
import { KyvernoPolicyCoverage } from '../components/resources/renderers/KyvernoPolicyCoverage'
|
|
38
39
|
import { KyvernoPolicyQueued } from '../components/resources/renderers/KyvernoPolicyQueued'
|
|
39
|
-
import { VeleroBSLRenderer } from '../components/resources/renderers/VeleroBSLRenderer'
|
|
40
|
-
import { VeleroBackupRenderer } from '../components/resources/renderers/VeleroBackupRenderer'
|
|
41
|
-
import { VeleroRestoreRenderer } from '../components/resources/renderers/VeleroRestoreRenderer'
|
|
42
40
|
import { FluxHelmReleaseRenderer } from '../components/resources/renderers/FluxHelmReleaseRenderer'
|
|
43
41
|
import { SecretProviderClassRenderer } from '../components/resources/renderers/SecretProviderClassRenderer'
|
|
42
|
+
import { UpgradePlanRenderer } from '../components/resources/renderers/UpgradePlanRenderer'
|
|
44
43
|
import {
|
|
45
44
|
ValidatingAdmissionPolicyBindingRenderer,
|
|
46
45
|
ValidatingAdmissionPolicyRenderer,
|
|
@@ -50,6 +49,7 @@ export const resourceHosts: readonly ResourceHost[] = [
|
|
|
50
49
|
{ id: 'kubernetes', renderers: { PodRenderer, NodeRenderer, ServiceRenderer, WorkloadRenderer, HPARenderer, PVCRenderer } },
|
|
51
50
|
{ id: 'gateway-api', renderers: { HTTPRouteRenderer } },
|
|
52
51
|
{ id: 'rbac', renderers: { ServiceAccountRenderer, RoleRenderer, RoleBindingRenderer, NamespaceRenderer } },
|
|
52
|
+
{ id: 'system-upgrade', renderers: { UpgradePlanRenderer } },
|
|
53
53
|
{ id: 'batch-and-admission', renderers: { JobRenderer, JobSetRenderer, KueueWorkloadRenderer } },
|
|
54
54
|
{
|
|
55
55
|
id: 'kueue-queues',
|
|
@@ -65,7 +65,7 @@ export const resourceHosts: readonly ResourceHost[] = [
|
|
|
65
65
|
{ id: 'crossplane', renderers: { CompositeRenderer } },
|
|
66
66
|
{ id: 'rollouts', renderers: { RolloutRenderer } },
|
|
67
67
|
{ id: 'kyverno', renderers: { KyvernoPolicyCoverage, KyvernoPolicyQueued } },
|
|
68
|
-
|
|
68
|
+
veleroResourceHost,
|
|
69
69
|
{ id: 'flux', renderers: { FluxHelmReleaseRenderer } },
|
|
70
70
|
{ id: 'secrets-store-csi', renderers: { SecretProviderClassRenderer } },
|
|
71
71
|
{ id: 'admission-policy', renderers: { ValidatingAdmissionPolicyRenderer, ValidatingAdmissionPolicyBindingRenderer } },
|
|
@@ -83,6 +83,14 @@ export function resourceDetailRedirect(resource: HostResource, search: URLSearch
|
|
|
83
83
|
return resourceHostForSlot(resourceHosts, resource, 'destination')?.detailRedirect?.(resource, search) ?? null
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export function resourceIssueDetail(resource: HostResource, props: { issue: { kind?: string; reason?: string }; resource: any }) {
|
|
87
|
+
for (const host of hostsForResource(resourceHosts, resource)) {
|
|
88
|
+
const detail = host.issueDetail?.(props)
|
|
89
|
+
if (detail) return detail
|
|
90
|
+
}
|
|
91
|
+
return null
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
export function resourceDetailSlots(resource: HostResource, inheritedTabs?: WorkloadExtraTab[]): DetailSlots {
|
|
87
95
|
const slots = hostsForResource(resourceHosts, resource)
|
|
88
96
|
.map(host => ({ id: host.id, slots: host.detailSlots?.(resource) }))
|
|
@@ -107,8 +115,9 @@ export function ResourceDrawerNavigation({ resource }: { resource: SelectedResou
|
|
|
107
115
|
|
|
108
116
|
export function useResourceHostFeatures(): HostFeatures {
|
|
109
117
|
// Hook order is fixed here; selected adapters mount components that own their data hooks.
|
|
110
|
-
const { support } = useRadarFeature('cnpgWorkspace')
|
|
111
|
-
|
|
118
|
+
const { support: cnpgWorkspace } = useRadarFeature('cnpgWorkspace')
|
|
119
|
+
const { support: veleroWorkspace } = useRadarFeature('veleroWorkspace')
|
|
120
|
+
return useMemo(() => ({ cnpgWorkspace, veleroWorkspace }), [cnpgWorkspace, veleroWorkspace])
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
|
|
@@ -127,6 +136,13 @@ export function resourceKindListMode(kind: Pick<HostKind, 'name' | 'group'> | nu
|
|
|
127
136
|
return contribution?.list.mode(hostSupport(contribution.host, features), pending) ?? 'table'
|
|
128
137
|
}
|
|
129
138
|
|
|
139
|
+
/** The disabled picker's tooltip while a kind's own list, which ignores the namespace filter, is on screen. */
|
|
140
|
+
export function resourceKindListNamespaceFilterTooltip(kind: Pick<HostKind, 'name' | 'group'> | null, features: HostFeatures, pending: boolean): string | undefined {
|
|
141
|
+
const contribution = kindListHost(kind)
|
|
142
|
+
if (!contribution?.list.namespaceFilterTooltip) return undefined
|
|
143
|
+
return contribution.list.mode(hostSupport(contribution.host, features), pending) === 'view' ? contribution.list.namespaceFilterTooltip : undefined
|
|
144
|
+
}
|
|
145
|
+
|
|
130
146
|
export function resourceKindListTitle(kind: Pick<HostKind, 'name' | 'group'>): string | null {
|
|
131
147
|
return kindListHost(kind)?.list.title ?? null
|
|
132
148
|
}
|
|
@@ -17,6 +17,14 @@ describe('workspace route ownership', () => {
|
|
|
17
17
|
expect(capacity.pageTitle('/capacity/demand')).toBe('Capacity Demand')
|
|
18
18
|
expect(capacity.pageTitle('/capacity/activity')).toBe('Capacity Activity')
|
|
19
19
|
expect(capacity.pageTitle('/capacity/unknown')).toBe('Capacity')
|
|
20
|
+
const velero = workspaceForPath('/velero')!
|
|
21
|
+
expect(velero.id).toBe('velero')
|
|
22
|
+
expect(velero.navView).toBe('resources')
|
|
23
|
+
expect(velero.namespaceScope).toBe('cluster')
|
|
24
|
+
expect(velero.namespaceFilterTooltip).toBeTruthy()
|
|
25
|
+
expect(velero.pageTitle('/velero')).toBe('Velero overview')
|
|
26
|
+
expect(velero.pageTitle('/velero/unknown')).toBe('Velero overview')
|
|
27
|
+
expect(workspaceForView('velero')).toBe(velero)
|
|
20
28
|
})
|
|
21
29
|
|
|
22
30
|
it('only owns whole route prefixes inside either OSS or an embedded router basename', () => {
|
|
@@ -24,6 +32,8 @@ describe('workspace route ownership', () => {
|
|
|
24
32
|
expect(workspaceForPath('/cnpg/')).toBeDefined()
|
|
25
33
|
expect(workspaceForPath('/cnpg-other')).toBeUndefined()
|
|
26
34
|
expect(workspaceForPath('/capacity-other')).toBeUndefined()
|
|
35
|
+
expect(workspaceForPath('/velero')?.id).toBe('velero')
|
|
36
|
+
expect(workspaceForPath('/velero-other')).toBeUndefined()
|
|
27
37
|
expect(workspaceForPath('/workload/clusters/db/pg')).toBeUndefined()
|
|
28
38
|
// React Router supplies basename-relative locations to the application.
|
|
29
39
|
expect(workspaceForPath('/c/demo/cnpg')).toBeUndefined()
|
|
@@ -34,6 +44,7 @@ describe('workspace route ownership', () => {
|
|
|
34
44
|
expect(workspaceContextSwitchSearch('/cnpg/clusters/db/pg', search).toString()).toBe('ctx=old-cluster')
|
|
35
45
|
expect(workspaceContextSwitchSearch('/cnpg', search).toString()).toBe('')
|
|
36
46
|
expect(workspaceContextSwitchSearch('/capacity/pools/default', search).toString()).toBe('')
|
|
47
|
+
expect(workspaceContextSwitchSearch('/velero', search).toString()).toBe('')
|
|
37
48
|
expect(workspaceContextSwitchSearch('/resources/pods', search).toString()).toBe('')
|
|
38
49
|
expect(search.get('tab')).toBe('storage')
|
|
39
50
|
})
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { capacityWorkspaceRoute } from '../components/capacity/workspaceRoute'
|
|
2
2
|
import { cnpgWorkspaceRoute } from '../components/cnpg/workspaceRoute'
|
|
3
|
+
import { veleroWorkspaceRoute } from '../components/velero/workspaceRoute'
|
|
3
4
|
import type { WorkspaceRoute } from './workspaceRoute'
|
|
4
5
|
|
|
5
|
-
export const workspaceRoutes = [cnpgWorkspaceRoute, capacityWorkspaceRoute] as const
|
|
6
|
+
export const workspaceRoutes = [cnpgWorkspaceRoute, capacityWorkspaceRoute, veleroWorkspaceRoute] as const
|
|
6
7
|
|
|
7
8
|
export const workspaceLabels = {
|
|
8
9
|
cnpg: cnpgWorkspaceRoute.label,
|
|
9
10
|
capacity: capacityWorkspaceRoute.label,
|
|
11
|
+
velero: veleroWorkspaceRoute.label,
|
|
10
12
|
} satisfies Record<WorkspaceRoute['id'], string>
|
|
11
13
|
|
|
12
14
|
export function workspaceForPath(pathname: string) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ComponentType } from 'react'
|
|
2
2
|
import { CapacityView } from '../components/capacity/CapacityView'
|
|
3
3
|
import { CNPGView } from '../components/cnpg/CNPGView'
|
|
4
|
+
import { VeleroView } from '../components/velero/VeleroView'
|
|
4
5
|
import type { WorkspaceRoute, WorkspaceScreenProps } from './workspaceRoute'
|
|
5
6
|
|
|
6
7
|
const screens: Record<WorkspaceRoute['id'], ComponentType<WorkspaceScreenProps>> = {
|
|
7
8
|
cnpg: CNPGView,
|
|
8
9
|
capacity: ({ onOpenResource }) => <CapacityView onOpenResource={onOpenResource} />,
|
|
10
|
+
velero: VeleroView,
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export function WorkspaceScreen({ workspace, ...props }: WorkspaceScreenProps & { workspace: WorkspaceRoute }) {
|
package/src/main.tsx
CHANGED
|
@@ -4,6 +4,9 @@ import { RadarApp } from './RadarApp'
|
|
|
4
4
|
import { setAutomaticRequestMarking } from './api/config'
|
|
5
5
|
import { openExternal } from './utils/navigation'
|
|
6
6
|
import { installWailsClipboardShim } from './utils/wails-clipboard'
|
|
7
|
+
import { installWindowsTitleBar } from './desktop/WindowsTitleBar'
|
|
8
|
+
import { installDesktopZoomShortcuts } from './utils/desktop-zoom'
|
|
9
|
+
import { installStaleAssetPrompt } from './utils/staleAssetPrompt'
|
|
7
10
|
import './index.css'
|
|
8
11
|
|
|
9
12
|
// Automatic requests can beat the usage status to the server, and a recording
|
|
@@ -26,6 +29,11 @@ window.addEventListener('click', (e: MouseEvent) => {
|
|
|
26
29
|
// Wails desktop clipboard shim — see web/src/utils/wails-clipboard.ts for the
|
|
27
30
|
// full WKWebView background and what each interception exists for.
|
|
28
31
|
installWailsClipboardShim()
|
|
32
|
+
installWindowsTitleBar()
|
|
33
|
+
installDesktopZoomShortcuts()
|
|
34
|
+
// Embedding hosts serve their own assets and own their notices, so the prompt
|
|
35
|
+
// lives here rather than in RadarApp.
|
|
36
|
+
installStaleAssetPrompt()
|
|
29
37
|
|
|
30
38
|
// Mouse back/forward button navigation (button 3 = back, button 4 = forward).
|
|
31
39
|
// Uses 'mouseup' in capture phase to intercept before the browser's native handler.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { installDesktopZoomShortcuts, zoomStep } from './desktop-zoom'
|
|
5
|
+
|
|
6
|
+
const key = (k: string, mods: Partial<KeyboardEventInit> = {}) =>
|
|
7
|
+
({ key: k, ctrlKey: true, altKey: false, metaKey: false, ...mods }) as KeyboardEvent
|
|
8
|
+
|
|
9
|
+
describe('zoomStep', () => {
|
|
10
|
+
it('maps Ctrl+= / Ctrl++ to zoom in and Ctrl+- / Ctrl+_ to zoom out', () => {
|
|
11
|
+
expect(zoomStep(key('='))).toBeCloseTo(0.1)
|
|
12
|
+
expect(zoomStep(key('+'))).toBeCloseTo(0.1)
|
|
13
|
+
expect(zoomStep(key('-'))).toBeCloseTo(-0.1)
|
|
14
|
+
expect(zoomStep(key('_'))).toBeCloseTo(-0.1)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('ignores other keys and modifier combinations', () => {
|
|
18
|
+
expect(zoomStep(key('0'))).toBe(0)
|
|
19
|
+
expect(zoomStep(key('=', { ctrlKey: false }))).toBe(0)
|
|
20
|
+
expect(zoomStep(key('=', { altKey: true }))).toBe(0)
|
|
21
|
+
expect(zoomStep(key('=', { metaKey: true }))).toBe(0)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('installDesktopZoomShortcuts', () => {
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
document.body.style.zoom = ''
|
|
28
|
+
document.body.innerHTML = ''
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const press = (target: EventTarget, k: string) =>
|
|
32
|
+
target.dispatchEvent(new KeyboardEvent('keydown', { key: k, ctrlKey: true, bubbles: true, cancelable: true }))
|
|
33
|
+
|
|
34
|
+
it('zooms the page inside WebView2, clamped to the menu range, but not from a terminal', () => {
|
|
35
|
+
;(window as unknown as { chrome: unknown }).chrome = { webview: {} }
|
|
36
|
+
installDesktopZoomShortcuts()
|
|
37
|
+
|
|
38
|
+
press(document.body, '=')
|
|
39
|
+
expect(document.body.style.zoom).toBe('1.1')
|
|
40
|
+
for (let i = 0; i < 20; i++) press(document.body, '=')
|
|
41
|
+
expect(document.body.style.zoom).toBe('2')
|
|
42
|
+
for (let i = 0; i < 30; i++) press(document.body, '-')
|
|
43
|
+
expect(document.body.style.zoom).toBe('0.5')
|
|
44
|
+
|
|
45
|
+
const term = document.createElement('div')
|
|
46
|
+
term.className = 'xterm'
|
|
47
|
+
const input = document.createElement('textarea')
|
|
48
|
+
term.appendChild(input)
|
|
49
|
+
document.body.appendChild(term)
|
|
50
|
+
press(input, '=')
|
|
51
|
+
expect(document.body.style.zoom).toBe('0.5')
|
|
52
|
+
})
|
|
53
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Ctrl+= / Ctrl+- for the Windows desktop app. The View menu registers these
|
|
2
|
+
// accelerators, but Wails' Windows key table has no entry for "=" or "-", so
|
|
3
|
+
// they are silently dropped, and WebView2's own zoom keys are off. The page
|
|
4
|
+
// applies the same zoom the menu items do. Elsewhere the native accelerators
|
|
5
|
+
// work, so this only runs inside WebView2.
|
|
6
|
+
//
|
|
7
|
+
// Inside a terminal Ctrl+- is readline's undo, so the key is left to xterm
|
|
8
|
+
// there; View → Zoom still works.
|
|
9
|
+
|
|
10
|
+
const STEP = 0.1
|
|
11
|
+
const MIN = 0.5
|
|
12
|
+
const MAX = 2
|
|
13
|
+
|
|
14
|
+
export function zoomStep(e: Pick<KeyboardEvent, 'key' | 'ctrlKey' | 'altKey' | 'metaKey'>): number {
|
|
15
|
+
if (!e.ctrlKey || e.altKey || e.metaKey) return 0
|
|
16
|
+
if (e.key === '=' || e.key === '+') return STEP
|
|
17
|
+
if (e.key === '-' || e.key === '_') return -STEP
|
|
18
|
+
return 0
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function installDesktopZoomShortcuts() {
|
|
22
|
+
if (!(window as unknown as { chrome?: { webview?: unknown } }).chrome?.webview) return
|
|
23
|
+
window.addEventListener('keydown', (e) => {
|
|
24
|
+
const step = zoomStep(e)
|
|
25
|
+
if (!step || (e.target as Element | null)?.closest?.('.xterm')) return
|
|
26
|
+
e.preventDefault()
|
|
27
|
+
const z = parseFloat(document.body.style.zoom || '1')
|
|
28
|
+
document.body.style.zoom = String(Math.min(MAX, Math.max(MIN, Math.round((z + step) * 10) / 10)))
|
|
29
|
+
}, true)
|
|
30
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { ToastProvider } from '../components/ui/Toast'
|
|
6
|
+
import { installStaleAssetPrompt } from './staleAssetPrompt'
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
9
|
+
|
|
10
|
+
let container: HTMLDivElement
|
|
11
|
+
let root: Root
|
|
12
|
+
let uninstall: () => void
|
|
13
|
+
const reload = vi.fn()
|
|
14
|
+
|
|
15
|
+
function preloadError(): Event {
|
|
16
|
+
const event = Object.assign(new Event('vite:preloadError', { cancelable: true }), { payload: new Error('Failed to fetch dynamically imported module') })
|
|
17
|
+
act(() => {
|
|
18
|
+
window.dispatchEvent(event)
|
|
19
|
+
})
|
|
20
|
+
return event
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
25
|
+
reload.mockReset()
|
|
26
|
+
container = document.createElement('div')
|
|
27
|
+
document.body.appendChild(container)
|
|
28
|
+
root = createRoot(container)
|
|
29
|
+
act(() => root.render(<ToastProvider><div /></ToastProvider>))
|
|
30
|
+
uninstall = installStaleAssetPrompt(window, reload)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
uninstall()
|
|
35
|
+
act(() => root.unmount())
|
|
36
|
+
container.remove()
|
|
37
|
+
vi.restoreAllMocks()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const prompts = () => Array.from(document.querySelectorAll('[role="status"]')).filter(el => el.textContent?.includes('Part of Radar failed to load'))
|
|
41
|
+
|
|
42
|
+
describe('installStaleAssetPrompt', () => {
|
|
43
|
+
it('offers a reload that stays until used, without taking over the failed import', () => {
|
|
44
|
+
vi.useFakeTimers()
|
|
45
|
+
const event = preloadError()
|
|
46
|
+
|
|
47
|
+
expect(event.defaultPrevented).toBe(false)
|
|
48
|
+
expect(prompts()).toHaveLength(1)
|
|
49
|
+
act(() => {
|
|
50
|
+
vi.advanceTimersByTime(60_000)
|
|
51
|
+
})
|
|
52
|
+
expect(prompts()).toHaveLength(1)
|
|
53
|
+
expect(reload).not.toHaveBeenCalled()
|
|
54
|
+
|
|
55
|
+
const button = Array.from(prompts()[0].querySelectorAll('button')).find(b => b.textContent?.includes('Reload'))
|
|
56
|
+
act(() => button!.click())
|
|
57
|
+
expect(reload).toHaveBeenCalledTimes(1)
|
|
58
|
+
vi.useRealTimers()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('shows one prompt however many chunks fail, and leaves it dismissed', () => {
|
|
62
|
+
vi.useFakeTimers()
|
|
63
|
+
preloadError()
|
|
64
|
+
preloadError()
|
|
65
|
+
expect(prompts()).toHaveLength(1)
|
|
66
|
+
|
|
67
|
+
const dismiss = Array.from(prompts()[0].querySelectorAll('button')).find(b => !b.textContent?.includes('Reload'))
|
|
68
|
+
act(() => dismiss!.click())
|
|
69
|
+
act(() => {
|
|
70
|
+
vi.advanceTimersByTime(1_000)
|
|
71
|
+
})
|
|
72
|
+
preloadError()
|
|
73
|
+
expect(prompts()).toHaveLength(0)
|
|
74
|
+
vi.useRealTimers()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RotateCw } from 'lucide-react'
|
|
2
|
+
import { showApiNotice } from '../components/ui/Toast'
|
|
3
|
+
|
|
4
|
+
export const STALE_ASSET_TOAST_ID = 'stale-asset'
|
|
5
|
+
|
|
6
|
+
// A tab opened before Radar was upgraded asks for chunks under hashes the new
|
|
7
|
+
// build no longer serves, and Chromium keeps a failed dynamic import failed
|
|
8
|
+
// until the page reloads, so a reload is the only thing that brings the
|
|
9
|
+
// feature back. The event is not prevented: the feature's own fallback (the
|
|
10
|
+
// YAML editor's plain textarea, say) still runs, and the page never reloads
|
|
11
|
+
// by itself because the user may have unsaved edits. Views retry their chunk
|
|
12
|
+
// on every refresh, so the prompt is shown once and stays dismissed.
|
|
13
|
+
export function installStaleAssetPrompt(target: Window = window, reload: () => void = () => window.location.reload()): () => void {
|
|
14
|
+
let shown = false
|
|
15
|
+
const onPreloadError = (event: VitePreloadErrorEvent) => {
|
|
16
|
+
console.error('[Radar] Failed to load part of the app:', event.payload)
|
|
17
|
+
if (shown) return
|
|
18
|
+
shown = true
|
|
19
|
+
showApiNotice(
|
|
20
|
+
'Part of Radar failed to load',
|
|
21
|
+
'Radar may have been updated since this page was opened. Reload to get the current version; unsaved edits on this page will be lost.',
|
|
22
|
+
'warning',
|
|
23
|
+
{
|
|
24
|
+
id: STALE_ASSET_TOAST_ID,
|
|
25
|
+
duration: 0,
|
|
26
|
+
action: { label: 'Reload', icon: <RotateCw className="w-3.5 h-3.5" />, onClick: reload },
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
target.addEventListener('vite:preloadError', onPreloadError)
|
|
31
|
+
return () => target.removeEventListener('vite:preloadError', onPreloadError)
|
|
32
|
+
}
|