@skyhook-io/radar-app 1.20.1 → 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 +65 -16
- 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.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +347 -16
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +10 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -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/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- 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/cost/CostView.tsx +27 -9
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -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/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +2 -10
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
- package/src/components/helm/HelmView.tsx +25 -19
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +69 -11
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +25 -11
- package/src/components/home/HelmSummary.tsx +15 -15
- 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 +17 -4
- 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/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- 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/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/ResourcesView.tsx +12 -6
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- 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 +19 -3
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -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 +72 -155
- package/src/components/traffic/trafficFilters.test.ts +189 -1
- package/src/components/traffic/trafficFilters.ts +169 -1
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +54 -3
- package/src/components/ui/UpdateNotification.tsx +60 -19
- package/src/components/ui/command-items.ts +24 -1
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -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/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +114 -37
- 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/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- 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 +15 -3
- package/src/integrations/resourceHosts.tsx +26 -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/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
- package/src/utils/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -181,7 +181,9 @@ export function CNPGInvestigationAction({ namespace, name, render, context }: {
|
|
|
181
181
|
namespace: string; name: string; render: RenderDiagnoseAction; context: Parameters<RenderDiagnoseAction>[0]
|
|
182
182
|
}): ReactNode {
|
|
183
183
|
const { row, dimensions } = useCNPGClusterAssessment(namespace, name)
|
|
184
|
-
|
|
184
|
+
// Posture findings describe the setup, as they do everywhere in the
|
|
185
|
+
// workspace (no attention, no category); a degraded dimension still counts.
|
|
186
|
+
const problem = !!row?.problems.some((p) => p.severity !== 'posture') || dimensions?.some((d) => ['degraded', 'alert', 'unhealthy'].includes(d.tone))
|
|
185
187
|
const assessed = !!row && !!dimensions && dimensions.every((d) => d.tone !== 'unknown')
|
|
186
188
|
return render({ ...context, health: problem ? 'problem' : assessed ? 'healthy' : 'unknown' })
|
|
187
189
|
}
|
|
@@ -1,37 +1,16 @@
|
|
|
1
|
-
import { useLocation, useSearchParams } from 'react-router-dom'
|
|
2
|
-
import { ArrowLeft } from 'lucide-react'
|
|
3
1
|
import { CNPG_KIND_BY_KEY } from '@skyhook-io/k8s-ui'
|
|
4
2
|
import type { SelectedResource } from '../../types'
|
|
5
|
-
import {
|
|
3
|
+
import { DrawerTrailBack } from '../workspace/DrawerTrailBack'
|
|
6
4
|
|
|
7
5
|
const KIND_BY_PLURAL: Record<string, string> = Object.fromEntries(
|
|
8
6
|
Object.values(CNPG_KIND_BY_KEY).map((k) => [k.plural, k.kind]),
|
|
9
7
|
)
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
|
-
* On a CloudNativePG workspace screen the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* object included).
|
|
10
|
+
* On a CloudNativePG workspace screen, the step back to the previous object in
|
|
11
|
+
* the drawer trail, shown for whatever kind is open (a Pod or Secret reached
|
|
12
|
+
* from a CNPG object included).
|
|
16
13
|
*/
|
|
17
14
|
export function CNPGDrawerTrailBack({ resource }: { resource: SelectedResource }) {
|
|
18
|
-
|
|
19
|
-
const [searchParams, setSearchParams] = useSearchParams()
|
|
20
|
-
if (!location.pathname.startsWith('/cnpg')) return null
|
|
21
|
-
const trail = decodeDrawerTrail(searchParams.get('drawer'))
|
|
22
|
-
if (trail.length < 2 || !sameSelectedResource(trail[trail.length - 1], resource)) return null
|
|
23
|
-
const prev = trail[trail.length - 2]
|
|
24
|
-
const back = () => {
|
|
25
|
-
const params = new URLSearchParams(searchParams)
|
|
26
|
-
params.set('drawer', encodeDrawerTrail(trail.slice(0, -1)))
|
|
27
|
-
setSearchParams(params, { replace: true, state: location.state })
|
|
28
|
-
}
|
|
29
|
-
return (
|
|
30
|
-
<div className="shrink-0 border-b border-theme-border px-4 py-2">
|
|
31
|
-
<button type="button" onClick={back} className="inline-flex items-center gap-1 text-xs font-medium text-accent-text hover:underline">
|
|
32
|
-
<ArrowLeft className="h-3.5 w-3.5" />
|
|
33
|
-
{KIND_BY_PLURAL[prev.kind] ?? prev.kind} {prev.name}
|
|
34
|
-
</button>
|
|
35
|
-
</div>
|
|
36
|
-
)
|
|
15
|
+
return <DrawerTrailBack resource={resource} pathPrefix="/cnpg" kindLabel={(plural) => KIND_BY_PLURAL[plural]} />
|
|
37
16
|
}
|
|
@@ -17,14 +17,35 @@ it('labels investigation for any CNPG problem or degraded dimension including a
|
|
|
17
17
|
expect(render).toHaveBeenLastCalledWith(expect.objectContaining({ health: 'unknown', name: 'payments' }))
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const draw = (render: any) => renderToStaticMarkup(<CNPGInvestigationAction namespace="db" name="payments" render={render} context={{ kind: 'Cluster', group: 'postgresql.cnpg.io', namespace: 'db', name: 'payments', health: 'healthy' }} />)
|
|
21
|
+
const POSTURE_CHECKS = ['cnpgNoDeclarativeBackup', 'cnpgSingleInstance', 'cnpgNoBackupDestination', 'cnpgNoWALArchiving', 'cnpgInTreeBackupDeprecated']
|
|
22
|
+
|
|
23
|
+
it('leaves every posture check without a problem mark, as the rest of the workspace does', () => {
|
|
21
24
|
const render = vi.fn(() => null)
|
|
22
|
-
state.row = { attention: false, problems: [{ id: 'audit:cnpgNoDeclarativeBackup', severity: 'posture' }] }
|
|
23
25
|
state.dimensions = [{ tone: 'healthy' }]
|
|
24
|
-
|
|
26
|
+
for (const id of POSTURE_CHECKS) {
|
|
27
|
+
state.row = { attention: false, problems: [{ id: `audit:${id}:db/payments`, severity: 'posture' }] }
|
|
28
|
+
draw(render)
|
|
29
|
+
expect(render).toHaveBeenLastCalledWith(expect.objectContaining({ health: 'healthy' }))
|
|
30
|
+
}
|
|
31
|
+
state.row = { attention: false, problems: POSTURE_CHECKS.map((id) => ({ id: `audit:${id}:db/payments`, severity: 'posture' })) }
|
|
32
|
+
draw(render)
|
|
33
|
+
expect(render).toHaveBeenLastCalledWith(expect.objectContaining({ health: 'healthy' }))
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('still investigates posture beside a degraded dimension or a real problem, and stays unknown when unassessed', () => {
|
|
37
|
+
const render = vi.fn(() => null)
|
|
38
|
+
const posture = { id: 'audit:cnpgNoBackupDestination:db/payments', severity: 'posture' }
|
|
39
|
+
state.row = { attention: false, problems: [posture] }
|
|
40
|
+
state.dimensions = [{ tone: 'healthy' }, { tone: 'degraded' }]
|
|
41
|
+
draw(render)
|
|
25
42
|
expect(render).toHaveBeenLastCalledWith(expect.objectContaining({ health: 'problem' }))
|
|
26
|
-
|
|
27
|
-
state.
|
|
28
|
-
|
|
43
|
+
state.row = { attention: true, problems: [posture, { id: 'issue:x', severity: 'warning' }] }
|
|
44
|
+
state.dimensions = [{ tone: 'healthy' }]
|
|
45
|
+
draw(render)
|
|
29
46
|
expect(render).toHaveBeenLastCalledWith(expect.objectContaining({ health: 'problem' }))
|
|
47
|
+
state.row = { attention: false, problems: [posture] }
|
|
48
|
+
state.dimensions = [{ tone: 'unknown' }]
|
|
49
|
+
draw(render)
|
|
50
|
+
expect(render).toHaveBeenLastCalledWith(expect.objectContaining({ health: 'unknown' }))
|
|
30
51
|
})
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useLocation
|
|
3
|
-
import { DialogPortal, ResourcesSidebar, type SelectedKindInfo } from '@skyhook-io/k8s-ui'
|
|
4
|
-
import { PanelLeft, X } from 'lucide-react'
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { useLocation } from 'react-router-dom'
|
|
5
3
|
import type { SelectedResource } from '../../types'
|
|
6
4
|
import { useAPIResources } from '../../api/apiResources'
|
|
7
|
-
import { usePinnedKinds } from '../../hooks/useFavorites'
|
|
8
|
-
import { useResourceCounts } from '../../hooks/useResourceCounts'
|
|
9
5
|
import { CNPGOverview } from './CNPGOverview'
|
|
10
6
|
import { CNPGProtection } from './CNPGProtection'
|
|
11
7
|
import { CNPGDeclarations } from './CNPGDeclarations'
|
|
@@ -16,10 +12,12 @@ import { CNPGCreateClusterDialog } from './CNPGCreateClusterDialog'
|
|
|
16
12
|
import { CNPGDetailPage } from './CNPGDetailPage'
|
|
17
13
|
import { parseCNPGRoute } from './routes'
|
|
18
14
|
import { useCNPGFleet, useCNPGSidebarWorkspace } from './useCNPGSidebarWorkspace'
|
|
19
|
-
import { decodeDrawerTrail, encodeDrawerTrail, sameSelectedResource } from '../../utils/drawer-trail'
|
|
20
|
-
import { useCNPGNavigate } from './useCNPGNavigate'
|
|
21
15
|
import { useCNPGScreenParams } from './useCNPGScreenParams'
|
|
22
16
|
import { useMediaQuery } from '../../hooks/useMediaQuery'
|
|
17
|
+
import { useVeleroSidebarWorkspace } from '../velero/useVeleroSidebarWorkspace'
|
|
18
|
+
import { WorkspaceFrame } from '../workspace/WorkspaceFrame'
|
|
19
|
+
import { useMergedSidebarWorkspaces } from '../workspace/sidebar'
|
|
20
|
+
import { useWorkspaceDrawer } from '../workspace/useWorkspaceDrawer'
|
|
23
21
|
|
|
24
22
|
interface CNPGViewProps {
|
|
25
23
|
namespaces: string[]
|
|
@@ -39,132 +37,60 @@ interface CNPGViewProps {
|
|
|
39
37
|
*/
|
|
40
38
|
export function CNPGView({ namespaces, selectedResource, onOpenResource, onCloseResource, onClearNamespaces }: CNPGViewProps) {
|
|
41
39
|
const location = useLocation()
|
|
42
|
-
const navigate = useCNPGNavigate()
|
|
43
|
-
const [searchParams, setSearchParams] = useSearchParams()
|
|
44
40
|
const route = parseCNPGRoute(location.pathname)
|
|
45
41
|
const laptop = useMediaQuery('(max-width: 1300px)')
|
|
46
42
|
const narrow = useMediaQuery('(max-width: 1100px)')
|
|
47
43
|
const compactNavigation = narrow || (laptop && !!route.detail)
|
|
48
|
-
const [navigationOpen, setNavigationOpen] = useState(false)
|
|
49
|
-
useEffect(() => setNavigationOpen(false), [location.pathname, location.search, compactNavigation])
|
|
50
44
|
const { data: apiResources } = useAPIResources()
|
|
51
|
-
const
|
|
52
|
-
const { pinned, togglePin, isPinned } = usePinnedKinds()
|
|
53
|
-
const sidebarWorkspace = useCNPGSidebarWorkspace({
|
|
45
|
+
const cnpgSidebar = useCNPGSidebarWorkspace({
|
|
54
46
|
apiResources,
|
|
55
47
|
namespaces,
|
|
56
48
|
active: { screen: route.screen, child: route.detail ? { label: route.detail.name, title: `${route.detail.plural} ${route.detail.namespace}/${route.detail.name}` } : undefined },
|
|
57
49
|
})
|
|
50
|
+
const veleroSidebar = useVeleroSidebarWorkspace({ apiResources })
|
|
51
|
+
const sidebarWorkspace = useMergedSidebarWorkspaces(cnpgSidebar, veleroSidebar)
|
|
58
52
|
const { query, fleet } = useCNPGFleet(namespaces)
|
|
59
|
-
|
|
60
|
-
const drawerParam = searchParams.get('drawer')
|
|
61
|
-
const trail = useMemo(() => decodeDrawerTrail(drawerParam), [drawerParam])
|
|
62
|
-
const drawerTarget = trail.length > 0 ? trail[trail.length - 1] : null
|
|
63
|
-
|
|
64
|
-
// Two-way sync between ?drawer= and the app drawer. Whichever side changed
|
|
65
|
-
// since the last sync wins, so URL navigation (Back, a pasted link) opens the
|
|
66
|
-
// drawer and drawer navigation (close, a link inside it) rewrites the URL.
|
|
67
|
-
const lastSynced = useRef<string | null>(null)
|
|
68
|
-
const selectedKey = selectedResource ? encodeDrawerTrail([selectedResource]) : ''
|
|
69
|
-
const targetKey = drawerTarget ? encodeDrawerTrail([drawerTarget]) : ''
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (targetKey !== (lastSynced.current ?? '')) {
|
|
72
|
-
lastSynced.current = targetKey
|
|
73
|
-
if (drawerTarget && !sameSelectedResource(drawerTarget, selectedResource)) onOpenResource(drawerTarget)
|
|
74
|
-
else if (!drawerTarget && selectedResource) onCloseResource()
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
if (selectedKey !== targetKey) {
|
|
78
|
-
lastSynced.current = selectedKey
|
|
79
|
-
const params = new URLSearchParams(searchParams)
|
|
80
|
-
if (!selectedResource) {
|
|
81
|
-
params.delete('drawer')
|
|
82
|
-
} else {
|
|
83
|
-
const idx = trail.findIndex((r) => sameSelectedResource(r, selectedResource))
|
|
84
|
-
const next = idx >= 0 ? trail.slice(0, idx + 1) : [...trail, selectedResource]
|
|
85
|
-
params.set('drawer', encodeDrawerTrail(next))
|
|
86
|
-
}
|
|
87
|
-
setSearchParams(params, { replace: true, state: location.state })
|
|
88
|
-
}
|
|
89
|
-
}, [targetKey, selectedKey]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
90
|
-
|
|
91
|
-
const inspect = useCallback(
|
|
92
|
-
(resource: SelectedResource) => {
|
|
93
|
-
const params = new URLSearchParams(searchParams)
|
|
94
|
-
params.set('drawer', encodeDrawerTrail([resource]))
|
|
95
|
-
setSearchParams(params, { replace: true, state: location.state })
|
|
96
|
-
},
|
|
97
|
-
[searchParams, setSearchParams, location.state],
|
|
98
|
-
)
|
|
53
|
+
const { drawerTarget, inspect, searchParams } = useWorkspaceDrawer({ selectedResource, onOpenResource, onCloseResource })
|
|
99
54
|
|
|
100
55
|
const [, setParams] = useCNPGScreenParams()
|
|
101
56
|
const [creating, setCreating] = useState(false)
|
|
102
57
|
|
|
103
|
-
const selectKind = useCallback(
|
|
104
|
-
(kind: SelectedKindInfo) => {
|
|
105
|
-
navigate(`/resources/${kind.name}${kind.group ? `?apiGroup=${encodeURIComponent(kind.group)}` : ''}`)
|
|
106
|
-
},
|
|
107
|
-
[navigate],
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
const sidebar = <ResourcesSidebar
|
|
111
|
-
selectedKind={null}
|
|
112
|
-
onSelectedKindChange={selectKind}
|
|
113
|
-
apiResources={apiResources}
|
|
114
|
-
resourceCounts={counts?.counts}
|
|
115
|
-
resourceCoverage={counts?.coverage}
|
|
116
|
-
resourceForbidden={counts?.forbidden}
|
|
117
|
-
resourceUnavailable={counts?.unavailable}
|
|
118
|
-
pinned={pinned}
|
|
119
|
-
togglePin={togglePin}
|
|
120
|
-
isPinned={(kind: string, group?: string) => isPinned(kind, group ?? '')}
|
|
121
|
-
categoryWorkspaces={sidebarWorkspace}
|
|
122
|
-
className={compactNavigation ? '!w-full !border-r-0' : undefined}
|
|
123
|
-
/>
|
|
124
58
|
return (
|
|
125
|
-
<
|
|
126
|
-
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return <CNPGOperator {...props} />
|
|
158
|
-
default:
|
|
159
|
-
return <CNPGOverview {...props} />
|
|
160
|
-
}
|
|
161
|
-
}}
|
|
162
|
-
</CNPGScreenGate>
|
|
163
|
-
)}
|
|
164
|
-
</div>
|
|
59
|
+
<WorkspaceFrame namespaces={namespaces} categoryWorkspaces={sidebarWorkspace} compactNavigation={compactNavigation}>
|
|
60
|
+
{route.detail ? (
|
|
61
|
+
<CNPGDetailPage target={route.detail} namespaces={namespaces} onOpenResource={onOpenResource} />
|
|
62
|
+
) : (
|
|
63
|
+
<CNPGScreenGate query={query} fleet={fleet}>
|
|
64
|
+
{(data, readyFleet) => {
|
|
65
|
+
const props = {
|
|
66
|
+
data,
|
|
67
|
+
fleet: readyFleet,
|
|
68
|
+
namespaces,
|
|
69
|
+
searchParams,
|
|
70
|
+
onSetParams: setParams,
|
|
71
|
+
onInspect: inspect,
|
|
72
|
+
inspected: drawerTarget,
|
|
73
|
+
onClearNamespaces,
|
|
74
|
+
onCreate: () => setCreating(true),
|
|
75
|
+
}
|
|
76
|
+
switch (route.screen) {
|
|
77
|
+
case 'protection':
|
|
78
|
+
return <CNPGProtection {...props} />
|
|
79
|
+
case 'declarations':
|
|
80
|
+
return <CNPGDeclarations {...props} />
|
|
81
|
+
case 'pooling':
|
|
82
|
+
return <CNPGPooling {...props} />
|
|
83
|
+
case 'operator':
|
|
84
|
+
return <CNPGOperator {...props} />
|
|
85
|
+
default:
|
|
86
|
+
return <CNPGOverview {...props} />
|
|
87
|
+
}
|
|
88
|
+
}}
|
|
89
|
+
</CNPGScreenGate>
|
|
90
|
+
)}
|
|
165
91
|
{creating && (
|
|
166
92
|
<CNPGCreateClusterDialog namespaces={namespaces} onClose={() => setCreating(false)} onCreated={inspect} />
|
|
167
93
|
)}
|
|
168
|
-
</
|
|
94
|
+
</WorkspaceFrame>
|
|
169
95
|
)
|
|
170
96
|
}
|
|
@@ -88,3 +88,33 @@ it('outside the CloudNativePG views the Clusters badge is a lower bound, and its
|
|
|
88
88
|
expect(badge(flagged)).toMatch(/≥(<!-- -->)?1/)
|
|
89
89
|
expect(overview(true)).toMatchObject({ count: 1, countLowerBound: false })
|
|
90
90
|
})
|
|
91
|
+
|
|
92
|
+
it('Clusters is the Cluster kind\'s list where its route renders the Clusters view, so the kind highlights it and leaves Other kinds', () => {
|
|
93
|
+
const crd = (group: string, kind: string, name: string) => ({ group, version: 'v1', kind, name, namespaced: true, isCrd: true, verbs: ['list'] })
|
|
94
|
+
const apiResources = [crd('postgresql.cnpg.io', 'Cluster', 'clusters'), crd('postgresql.cnpg.io', 'Backup', 'backups'), crd('cluster.x-k8s.io', 'Cluster', 'clusters')] as any
|
|
95
|
+
const cnpgCluster = { name: 'clusters', kind: 'Cluster', group: 'postgresql.cnpg.io' }
|
|
96
|
+
const capiCluster = { name: 'clusters', kind: 'Cluster', group: 'cluster.x-k8s.io' }
|
|
97
|
+
function Sidebar({ selectedKind }: { selectedKind: typeof cnpgCluster }) {
|
|
98
|
+
const workspaces = useCNPGSidebarWorkspace({ apiResources, namespaces: [] })
|
|
99
|
+
state.result = workspaces
|
|
100
|
+
return <ResourcesSidebar selectedKind={selectedKind} onSelectedKindChange={() => {}} apiResources={apiResources} categoryWorkspaces={workspaces} />
|
|
101
|
+
}
|
|
102
|
+
const clustersHighlighted = /aria-current="page"[^>]*>(?:(?!<\/button>).)*Clusters/
|
|
103
|
+
|
|
104
|
+
state.capabilities = { features: { cnpgWorkspace: true } }
|
|
105
|
+
let html = renderToStaticMarkup(<Sidebar selectedKind={cnpgCluster} />)
|
|
106
|
+
expect(state.result.CloudNativePG.destinations.find((d: any) => d.id === 'overview').kind).toEqual(cnpgCluster)
|
|
107
|
+
expect(html).toMatch(clustersHighlighted)
|
|
108
|
+
expect(html).toMatch(/Other kinds \((<!-- -->)?1(<!-- -->)?\)/)
|
|
109
|
+
|
|
110
|
+
// Cluster API's Cluster kind shares the plural, not the destination.
|
|
111
|
+
html = renderToStaticMarkup(<Sidebar selectedKind={capiCluster} />)
|
|
112
|
+
expect(html).not.toMatch(clustersHighlighted)
|
|
113
|
+
|
|
114
|
+
// A Radar without the Clusters view keeps the generic table reachable under Other kinds.
|
|
115
|
+
state.capabilities = { features: { resourceIssues: true } }
|
|
116
|
+
html = renderToStaticMarkup(<Sidebar selectedKind={cnpgCluster} />)
|
|
117
|
+
expect(state.result.CloudNativePG.destinations.find((d: any) => d.id === 'overview').kind).toBeUndefined()
|
|
118
|
+
expect(html).not.toMatch(clustersHighlighted)
|
|
119
|
+
expect(html).toMatch(/Other kinds \((<!-- -->)?2(<!-- -->)?\)/)
|
|
120
|
+
})
|
|
@@ -9,7 +9,7 @@ import { CNPGDrawerTrailBack } from './CNPGDrawerTrail'
|
|
|
9
9
|
import { CNPGInvestigationAction } from './CNPGClusterTabs'
|
|
10
10
|
import { renderCNPGSummary } from './CNPGSummaryHost'
|
|
11
11
|
import { renderCNPGHeaderActions } from './actions/renderCNPGHeaderActions'
|
|
12
|
-
import { CNPG_DETAIL_KINDS, cnpgClusterKindListMode, cnpgDetailKindFor, cnpgDetailPath } from './routes'
|
|
12
|
+
import { CNPG_CLUSTER_KIND, CNPG_DETAIL_KINDS, cnpgClusterKindListMode, cnpgDetailKindFor, cnpgDetailPath } from './routes'
|
|
13
13
|
import type { DetailSlots, HostResource, KindListProps, ResourceHost } from '../../integrations/resourceHost'
|
|
14
14
|
import { kindToPluralWithGroup } from '../../utils/navigation'
|
|
15
15
|
import { CNPGObjectStoreRenderer } from '../resources/renderers/CNPGObjectStoreRenderer'
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from '../resources/renderers/CNPGDeclarativeRenderer'
|
|
23
23
|
|
|
24
24
|
export const cnpgHost = {
|
|
25
|
-
clusterKind:
|
|
25
|
+
clusterKind: CNPG_CLUSTER_KIND,
|
|
26
26
|
|
|
27
27
|
expandedPath(resource: HostResource, context?: string, tab?: 'yaml'): string | null {
|
|
28
28
|
const plural = cnpgDetailKindFor(kindToPluralWithGroup(resource.kind, resource.group ?? ''), resource.group)
|
|
@@ -62,8 +62,10 @@ export function cnpgViewNamedForKind(plural: string): boolean {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/** The CloudNativePG Cluster kind, whose list is the Clusters view. */
|
|
65
|
+
export const CNPG_CLUSTER_KIND = { name: 'clusters', kind: 'Cluster', group: 'postgresql.cnpg.io' }
|
|
66
|
+
|
|
65
67
|
export function isCNPGClusterKind(kind: { name: string; group: string } | null | undefined): boolean {
|
|
66
|
-
return !!kind && kind.name ===
|
|
68
|
+
return !!kind && kind.name === CNPG_CLUSTER_KIND.name && kind.group === CNPG_CLUSTER_KIND.group
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
/**
|
|
@@ -18,6 +18,9 @@ import {
|
|
|
18
18
|
import type { SelectedResource } from '../../types'
|
|
19
19
|
import { useConnection } from '../../context/ConnectionContext'
|
|
20
20
|
import { Notice, RefreshFailedNotice, ScreenEmptyState } from '../workspace/layout'
|
|
21
|
+
import { INCOMPLETE_COVERAGE_STATES, coverageLabel } from '../workspace/coverage'
|
|
22
|
+
|
|
23
|
+
export { coverageEmpty, coverageLabel } from '../workspace/coverage'
|
|
21
24
|
|
|
22
25
|
export interface CNPGScreenProps {
|
|
23
26
|
data: CNPGWorkspaceResponse
|
|
@@ -32,14 +35,6 @@ export interface CNPGScreenProps {
|
|
|
32
35
|
onCreate?: () => void
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
const COVERAGE_LABEL: Record<string, string> = {
|
|
36
|
-
denied: 'no access',
|
|
37
|
-
partial: 'not read in some namespaces',
|
|
38
|
-
uncached: 'not cached by Radar',
|
|
39
|
-
syncing: 'still loading',
|
|
40
|
-
error: 'could not be read',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
// The workspace name sits on the title line, as on the CloudNativePG detail
|
|
44
39
|
// pages; it is not a link, since on Clusters it would lead to itself.
|
|
45
40
|
export function CNPGWorkspaceHeader({ title, subtitle, actions }: { title: string; subtitle?: ReactNode; actions?: ReactNode }) {
|
|
@@ -63,26 +58,6 @@ export function CNPGWorkspaceHeader({ title, subtitle, actions }: { title: strin
|
|
|
63
58
|
)
|
|
64
59
|
}
|
|
65
60
|
|
|
66
|
-
// The causes the server named for the namespaces it left unread. A partial or
|
|
67
|
-
// uncached read can name both kinds of namespace at once.
|
|
68
|
-
function namedCauses(cov: CNPGKindCoverage | undefined, uncachedNoun: string): { denied?: string; uncached?: string } {
|
|
69
|
-
return {
|
|
70
|
-
denied: cov?.deniedNamespaces?.length ? cov.deniedNamespaces.join(', ') : undefined,
|
|
71
|
-
uncached: cov?.uncachedNamespaces?.length ? `${uncachedNoun} in ${cov.uncachedNamespaces.join(', ')}` : undefined,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** How much of a kind was read, in a few words ("not cached by Radar in pg"). */
|
|
76
|
-
export function coverageLabel(cov: CNPGKindCoverage | undefined): string {
|
|
77
|
-
if (!cov) return 'not read by this Radar'
|
|
78
|
-
const { denied, uncached } = namedCauses(cov, 'not cached by Radar')
|
|
79
|
-
const named = [denied && `no access in ${denied}`, uncached].filter(Boolean)
|
|
80
|
-
if (named.length > 0) return named.join('; ')
|
|
81
|
-
return COVERAGE_LABEL[cov?.state ?? ''] ?? cov?.state ?? 'unknown'
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const INCOMPLETE_STATES = new Set(['partial', 'denied', 'syncing', 'error', 'uncached'])
|
|
85
|
-
|
|
86
61
|
/**
|
|
87
62
|
* The incomplete kinds grouped by what was left unread, each reason said once.
|
|
88
63
|
* Jobs count when their coverage is incomplete: a Cluster's initdb, join and
|
|
@@ -95,13 +70,13 @@ export function incompleteKindsText(kinds: CNPGFleet['incompleteKinds'], coverag
|
|
|
95
70
|
byLabel.set(label, [...(byLabel.get(label) ?? []), kind])
|
|
96
71
|
}
|
|
97
72
|
for (const k of kinds) add(CNPG_KIND_BY_KEY[k].kind, coverage[k])
|
|
98
|
-
if (jobCoverage &&
|
|
73
|
+
if (jobCoverage && INCOMPLETE_COVERAGE_STATES.has(jobCoverage.state)) add('Job', jobCoverage)
|
|
99
74
|
return [...byLabel].map(([label, names]) => `${names.join(', ')} (${label})`).join('; ')
|
|
100
75
|
}
|
|
101
76
|
|
|
102
77
|
export function CoverageNotice({ fleet, data, kinds, namespace, includeJobs = false }: { fleet: CNPGFleet; data: CNPGWorkspaceResponse; kinds: readonly CNPGWorkspaceKey[]; namespace?: string; includeJobs?: boolean }) {
|
|
103
78
|
const incomplete = fleet.incompleteKinds.filter((k) => { const coverage = data.coverage[k]; return kinds.includes(k) && (!coverage || !coverageReadable(coverage, namespace)) })
|
|
104
|
-
const jobsIncomplete = includeJobs && !!data.jobCoverage &&
|
|
79
|
+
const jobsIncomplete = includeJobs && !!data.jobCoverage && INCOMPLETE_COVERAGE_STATES.has(data.jobCoverage.state) && !coverageReadable(data.jobCoverage, namespace)
|
|
105
80
|
if (incomplete.length === 0 && !jobsIncomplete) return null
|
|
106
81
|
return (
|
|
107
82
|
<Notice>
|
|
@@ -170,29 +145,6 @@ export function CNPGScreenGate({
|
|
|
170
145
|
return <><RefreshFailedNotice queries={[query]} className="px-5 pt-3 xl:px-7" />{children(data, fleet)}</>
|
|
171
146
|
}
|
|
172
147
|
|
|
173
|
-
/** Empty-state text for a collection, derived from how much of it was readable. */
|
|
174
|
-
export function coverageEmpty(cov: CNPGKindCoverage | undefined, noun: string): string {
|
|
175
|
-
switch (cov?.state) {
|
|
176
|
-
case 'full':
|
|
177
|
-
return `No ${noun} in this scope.`
|
|
178
|
-
case 'partial':
|
|
179
|
-
case 'uncached': {
|
|
180
|
-
const { denied, uncached } = namedCauses(cov, `Radar does not cache ${noun}`)
|
|
181
|
-
const causes = [denied && `no access in ${denied}`, uncached].filter(Boolean)
|
|
182
|
-
if (causes.length > 0) return `No ${noun} visible: ${causes.join('; ')}.`
|
|
183
|
-
return cov.state === 'uncached' ? `Radar does not cache ${noun} in this scope.` : `No ${noun} visible. Some namespaces were not read.`
|
|
184
|
-
}
|
|
185
|
-
case 'denied':
|
|
186
|
-
return `No access to ${noun}.`
|
|
187
|
-
case 'syncing':
|
|
188
|
-
return `${noun[0].toUpperCase()}${noun.slice(1)} are still loading.`
|
|
189
|
-
case 'error':
|
|
190
|
-
return `${noun[0].toUpperCase()}${noun.slice(1)} could not be read.`
|
|
191
|
-
default:
|
|
192
|
-
return `This kind is not installed.`
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
148
|
/** The less complete of two coverages, for collections built from several kinds. */
|
|
197
149
|
export function worstCoverage(...covs: (CNPGKindCoverage | undefined)[]): CNPGKindCoverage | undefined {
|
|
198
150
|
const rank: Record<string, number> = { error: 0, denied: 1, uncached: 2, syncing: 3, partial: 4, full: 5, notInstalled: 6 }
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useLocation, useNavigate, type NavigateOptions, type To } from 'react-router-dom'
|
|
3
|
-
import { withCrossViewParams } from '../../utils/navigation'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* navigate() for the CloudNativePG screens: a string path keeps the current
|
|
7
|
-
* cross-view params (the namespace filter, an open investigation), as the
|
|
8
|
-
* app's own navigation does. Without them the app reads the missing
|
|
9
|
-
* ?namespaces= as "All namespaces" and saves that as the user's choice.
|
|
10
|
-
*/
|
|
11
|
-
export function useCNPGNavigate() {
|
|
12
|
-
const navigate = useNavigate()
|
|
13
|
-
const { search } = useLocation()
|
|
14
|
-
return useCallback(
|
|
15
|
-
(to: To | number, options?: NavigateOptions) => {
|
|
16
|
-
if (typeof to === 'number') return navigate(to)
|
|
17
|
-
return navigate(typeof to === 'string' ? withCrossViewParams(to, search) : to, options)
|
|
18
|
-
},
|
|
19
|
-
[navigate, search],
|
|
20
|
-
)
|
|
21
|
-
}
|
|
1
|
+
export { useWorkspaceNavigate as useCNPGNavigate } from '../workspace/useWorkspaceNavigate'
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
|
-
import { Database
|
|
2
|
+
import { Database } from 'lucide-react'
|
|
3
3
|
import { applyCNPGDisk, applyCNPGFleetMetrics, buildCNPGFleet, type CNPGDiskReading, type CNPGFleet, type SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
4
4
|
import type { APIResource } from '../../types'
|
|
5
5
|
import { useCNPGWorkspace } from '../../api/cnpg'
|
|
6
6
|
import { useRadarFeature } from '../../api/client'
|
|
7
7
|
import { useCNPGFleetDisk } from '../../api/cnpg-storage'
|
|
8
8
|
import { useCNPGFleetMetrics } from '../../api/cnpg-history'
|
|
9
|
-
import { CNPG_SCREENS, type CNPGScreen } from './routes'
|
|
9
|
+
import { CNPG_CLUSTER_KIND, CNPG_SCREENS, cnpgClusterKindListMode, type CNPGScreen } from './routes'
|
|
10
10
|
import { useCNPGNavigate } from './useCNPGNavigate'
|
|
11
11
|
|
|
12
12
|
export const CNPG_SIDEBAR_CATEGORY = 'CloudNativePG'
|
|
13
13
|
|
|
14
|
-
const ICONS: Record<CNPGScreen, SidebarCategoryWorkspace['destinations'][number]['icon']> = {
|
|
15
|
-
overview: Database,
|
|
16
|
-
protection: ShieldCheck,
|
|
17
|
-
declarations: FileCheck2,
|
|
18
|
-
pooling: Waypoints,
|
|
19
|
-
operator: Settings2,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
14
|
export function cnpgDiscovered(apiResources: APIResource[] | undefined): boolean {
|
|
23
15
|
return !!apiResources?.some((r) => r.group === 'postgresql.cnpg.io')
|
|
24
16
|
}
|
|
@@ -109,6 +101,11 @@ export function useCNPGSidebarWorkspace({
|
|
|
109
101
|
const navigate = useCNPGNavigate()
|
|
110
102
|
const available = cnpgDiscovered(apiResources)
|
|
111
103
|
const { fleet } = useCNPGFleet(namespaces, available, withMetrics)
|
|
104
|
+
const { support } = useRadarFeature('cnpgWorkspace')
|
|
105
|
+
// Clusters is the Cluster kind's list only where its Resources route renders
|
|
106
|
+
// the Clusters view; elsewhere, and until capabilities load, the kind keeps
|
|
107
|
+
// its generic table under Other kinds.
|
|
108
|
+
const clustersIsKindList = cnpgClusterKindListMode(CNPG_CLUSTER_KIND, support, false) === 'view'
|
|
112
109
|
const nsKey = namespaces.join(',')
|
|
113
110
|
|
|
114
111
|
return useMemo(() => {
|
|
@@ -118,7 +115,7 @@ export function useCNPGSidebarWorkspace({
|
|
|
118
115
|
return {
|
|
119
116
|
id: s.id,
|
|
120
117
|
label: s.label,
|
|
121
|
-
|
|
118
|
+
kind: s.id === 'overview' && clustersIsKindList ? CNPG_CLUSTER_KIND : undefined,
|
|
122
119
|
count,
|
|
123
120
|
countLowerBound: lowerBound,
|
|
124
121
|
countTitle: title,
|
|
@@ -127,12 +124,18 @@ export function useCNPGSidebarWorkspace({
|
|
|
127
124
|
onSelect: () => navigate(s.path),
|
|
128
125
|
}
|
|
129
126
|
})
|
|
127
|
+
// Every screen counts clusters, and Clusters counts each one that needs attention once, so it is the total.
|
|
128
|
+
const clusters = destinations.find((d) => d.id === 'overview')
|
|
130
129
|
return {
|
|
131
130
|
[CNPG_SIDEBAR_CATEGORY]: {
|
|
131
|
+
label: 'Databases',
|
|
132
|
+
icon: Database,
|
|
133
|
+
count: clusters?.count,
|
|
134
|
+
countLowerBound: clusters?.countLowerBound,
|
|
135
|
+
countTitle: clusters?.countTitle,
|
|
132
136
|
destinations,
|
|
133
|
-
defaultKindsCollapsed: !!active,
|
|
134
137
|
scopeNote: nsKey ? `Counts for namespace ${nsKey.split(',').join(', ')}` : undefined,
|
|
135
138
|
},
|
|
136
139
|
}
|
|
137
|
-
}, [available, fleet, withMetrics, active?.screen, active?.child?.label, active?.child?.title, navigate, nsKey]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
140
|
+
}, [available, fleet, withMetrics, clustersIsKindList, active?.screen, active?.child?.label, active?.child?.title, navigate, nsKey]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
138
141
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// A radarhq.io redirect rather than the Slack invite itself: invite links
|
|
2
|
+
// expire, and shipped binaries keep this URL for months.
|
|
3
|
+
export const COMMUNITY_SLACK_URL = "https://radarhq.io/slack";
|
|
4
|
+
|
|
5
|
+
export const COMMUNITY_HINT =
|
|
6
|
+
"Join our Slack to ask questions, get help and share feedback with the Radar team";
|
|
7
|
+
|
|
8
|
+
// The mark stays one theme color and takes Slack's colors only on hover, so it
|
|
9
|
+
// doesn't outshout the rail. Paths read --slack-* and fall back to currentColor;
|
|
10
|
+
// these set them. Literal strings so Tailwind's scanner sees them.
|
|
11
|
+
export const SLACK_COLORS_ON_ROW_HOVER =
|
|
12
|
+
"group-hover/item:[--slack-red:#E01E5A] group-hover/item:[--slack-blue:#36C5F0] group-hover/item:[--slack-green:#2EB67D] group-hover/item:[--slack-yellow:#ECB22E]";
|
|
13
|
+
export const SLACK_COLORS_ON_HOVER =
|
|
14
|
+
"group-hover:[--slack-red:#E01E5A] group-hover:[--slack-blue:#36C5F0] group-hover:[--slack-green:#2EB67D] group-hover:[--slack-yellow:#ECB22E]";
|
|
15
|
+
|
|
16
|
+
// lucide-react no longer ships brand marks.
|
|
17
|
+
export function SlackIcon({ className }: { className?: string }) {
|
|
18
|
+
return (
|
|
19
|
+
<svg className={className} viewBox="0 0 24 24" aria-hidden>
|
|
20
|
+
<path
|
|
21
|
+
className="transition-colors"
|
|
22
|
+
fill="var(--slack-red, currentColor)"
|
|
23
|
+
d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313z"
|
|
24
|
+
/>
|
|
25
|
+
<path
|
|
26
|
+
className="transition-colors"
|
|
27
|
+
fill="var(--slack-blue, currentColor)"
|
|
28
|
+
d="M8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312z"
|
|
29
|
+
/>
|
|
30
|
+
<path
|
|
31
|
+
className="transition-colors"
|
|
32
|
+
fill="var(--slack-green, currentColor)"
|
|
33
|
+
d="M18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312z"
|
|
34
|
+
/>
|
|
35
|
+
<path
|
|
36
|
+
className="transition-colors"
|
|
37
|
+
fill="var(--slack-yellow, currentColor)"
|
|
38
|
+
d="M15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
}
|