@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,151 @@
|
|
|
1
|
+
// Help → About Radar in the Windows desktop app. macOS keeps its native About
|
|
2
|
+
// panel; the desktop app opens this one by dispatching 'radar:open-about' with
|
|
3
|
+
// the exact build version and platform (cmd/desktop/menu.go).
|
|
4
|
+
import { useId, useState } from 'react'
|
|
5
|
+
import { Check, Copy, X } from 'lucide-react'
|
|
6
|
+
import { DialogPortal, assetUrl } from '@skyhook-io/k8s-ui'
|
|
7
|
+
import { useVersionCheck } from '../api/client'
|
|
8
|
+
import { openExternal } from '../utils/navigation'
|
|
9
|
+
import { hasDesktopMenu, runDesktopMenuItem } from './WindowsTitleBar'
|
|
10
|
+
import { COMMUNITY_SLACK_URL } from '../components/community'
|
|
11
|
+
|
|
12
|
+
export type AboutInfo = { version: string; platform: string }
|
|
13
|
+
|
|
14
|
+
const LINKS = [
|
|
15
|
+
{ label: 'Website', url: 'https://radarhq.io' },
|
|
16
|
+
{ label: 'Documentation', url: 'https://radarhq.io/docs' },
|
|
17
|
+
{ label: 'GitHub', url: 'https://github.com/skyhook-io/radar' },
|
|
18
|
+
{ label: 'Slack', url: COMMUNITY_SLACK_URL },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const CHANNEL_LABEL: Record<string, string> = {
|
|
22
|
+
prerelease: 'pre-release',
|
|
23
|
+
development: 'development build',
|
|
24
|
+
custom: 'custom build',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function aboutVersionText(info: AboutInfo, channel?: string): string {
|
|
28
|
+
const label = channel ? CHANNEL_LABEL[channel] : undefined
|
|
29
|
+
return `Radar ${info.version.replace(/^v/, '')}${label ? ` (${label})` : ''}\n${info.platform} · desktop app`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function AboutDialog({
|
|
33
|
+
info,
|
|
34
|
+
onClose,
|
|
35
|
+
onShowWhatsNew,
|
|
36
|
+
onReportIssue,
|
|
37
|
+
}: {
|
|
38
|
+
info: AboutInfo | null
|
|
39
|
+
onClose: () => void
|
|
40
|
+
onShowWhatsNew?: () => void
|
|
41
|
+
onReportIssue: () => void
|
|
42
|
+
}) {
|
|
43
|
+
const titleId = useId()
|
|
44
|
+
const { data: versionInfo } = useVersionCheck()
|
|
45
|
+
const [copied, setCopied] = useState(false)
|
|
46
|
+
// Keep the last info through the exit animation.
|
|
47
|
+
const [shown, setShown] = useState<AboutInfo | null>(info)
|
|
48
|
+
if (info && info !== shown) setShown(info)
|
|
49
|
+
const current = info ?? shown
|
|
50
|
+
|
|
51
|
+
const channel = versionInfo?.buildChannel
|
|
52
|
+
const version = current?.version.replace(/^v/, '') ?? ''
|
|
53
|
+
const status = versionInfo?.updateAvailable
|
|
54
|
+
? `Radar ${versionInfo.latestVersion?.replace(/^v/, '')} is available`
|
|
55
|
+
: versionInfo?.latestVersion && channel === 'stable'
|
|
56
|
+
? "You're up to date"
|
|
57
|
+
: null
|
|
58
|
+
|
|
59
|
+
const copyVersion = async () => {
|
|
60
|
+
if (!current) return
|
|
61
|
+
try {
|
|
62
|
+
await navigator.clipboard.writeText(aboutVersionText(current, channel))
|
|
63
|
+
setCopied(true)
|
|
64
|
+
window.setTimeout(() => setCopied(false), 2000)
|
|
65
|
+
} catch {
|
|
66
|
+
console.warn('Failed to copy version info')
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const then = (action: () => void) => () => {
|
|
71
|
+
onClose()
|
|
72
|
+
action()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<DialogPortal open={!!info} onClose={onClose} className="w-full max-w-md" ariaLabelledBy={titleId}>
|
|
77
|
+
<div className="flex items-start gap-3 p-5 pb-4">
|
|
78
|
+
<span className="w-11 h-11 shrink-0 rounded-xl overflow-hidden bg-emerald-500/10 border border-emerald-500/20">
|
|
79
|
+
<img src={assetUrl('/images/radar/radar-icon.svg')} alt="" aria-hidden className="w-full h-full p-1" />
|
|
80
|
+
</span>
|
|
81
|
+
<div className="flex-1 min-w-0">
|
|
82
|
+
<h2 id={titleId} className="text-lg font-semibold tracking-tight text-theme-text-primary">Radar</h2>
|
|
83
|
+
<p className="text-sm text-theme-text-secondary">The open-source Kubernetes UI</p>
|
|
84
|
+
<p className="text-xs text-theme-text-tertiary">by Skyhook</p>
|
|
85
|
+
</div>
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
onClick={onClose}
|
|
89
|
+
aria-label="Close"
|
|
90
|
+
className="p-1 -m-1 rounded text-theme-text-tertiary hover:text-theme-text-primary hover:bg-theme-hover"
|
|
91
|
+
>
|
|
92
|
+
<X className="w-4 h-4" />
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<dl className="mx-5 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm">
|
|
97
|
+
<dt className="text-theme-text-tertiary">Version</dt>
|
|
98
|
+
<dd className="text-theme-text-primary">
|
|
99
|
+
{version}
|
|
100
|
+
{channel && CHANNEL_LABEL[channel] && <span className="text-theme-text-tertiary"> · {CHANNEL_LABEL[channel]}</span>}
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
onClick={copyVersion}
|
|
104
|
+
aria-label="Copy version info"
|
|
105
|
+
className="ml-2 inline-flex items-center gap-1 align-middle text-xs text-theme-text-tertiary hover:text-theme-text-primary"
|
|
106
|
+
>
|
|
107
|
+
{copied ? <Check className="w-3.5 h-3.5" /> : <Copy className="w-3.5 h-3.5" />}
|
|
108
|
+
{copied ? 'Copied' : 'Copy'}
|
|
109
|
+
</button>
|
|
110
|
+
{status && <div className="text-xs text-theme-text-secondary mt-0.5">{status}</div>}
|
|
111
|
+
</dd>
|
|
112
|
+
<dt className="text-theme-text-tertiary">Platform</dt>
|
|
113
|
+
<dd className="text-theme-text-primary">{current?.platform}</dd>
|
|
114
|
+
<dt className="text-theme-text-tertiary">License</dt>
|
|
115
|
+
<dd className="text-theme-text-primary">Apache 2.0</dd>
|
|
116
|
+
</dl>
|
|
117
|
+
|
|
118
|
+
{(hasDesktopMenu() || onShowWhatsNew) && (
|
|
119
|
+
<div className="mx-5 mt-4 flex flex-wrap gap-2">
|
|
120
|
+
{hasDesktopMenu() && (
|
|
121
|
+
<button type="button" className="btn-brand text-sm px-3 py-1.5" onClick={then(() => runDesktopMenuItem('Help/Check for Updates...'))}>
|
|
122
|
+
Check for updates
|
|
123
|
+
</button>
|
|
124
|
+
)}
|
|
125
|
+
{onShowWhatsNew && (
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
className="text-sm px-3 py-1.5 rounded-md border border-theme-border text-theme-text-primary hover:bg-theme-hover"
|
|
129
|
+
onClick={then(onShowWhatsNew)}
|
|
130
|
+
>
|
|
131
|
+
What's new
|
|
132
|
+
</button>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
|
|
137
|
+
<div className="mt-5 px-5 py-3 border-t border-theme-border text-sm">
|
|
138
|
+
<div className="flex flex-wrap gap-x-4 gap-y-1">
|
|
139
|
+
{LINKS.map((l) => (
|
|
140
|
+
<button key={l.url} type="button" className="text-accent hover:underline" onClick={() => openExternal(l.url)}>
|
|
141
|
+
{l.label}
|
|
142
|
+
</button>
|
|
143
|
+
))}
|
|
144
|
+
<button type="button" className="text-accent hover:underline" onClick={then(onReportIssue)}>
|
|
145
|
+
Report an issue
|
|
146
|
+
</button>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</DialogPortal>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
// Title bar for the Windows desktop app. The window is frameless there and the
|
|
2
|
+
// page draws the icon, menus, title and window buttons in one row; see
|
|
3
|
+
// cmd/desktop/titlebar.go. It activates only inside WebView2 once the desktop
|
|
4
|
+
// app answers the hello, so browsers, Radar Hub and the macOS / Linux apps
|
|
5
|
+
// never render it.
|
|
6
|
+
//
|
|
7
|
+
// The page is served by Radar's local server, not the Wails origin, so the
|
|
8
|
+
// Wails JS runtime isn't injected. The bar posts raw Wails messages instead:
|
|
9
|
+
// "drag", "resize:<edge>", "Wm" (minimise), "Wt" (toggle maximise), "Q" (quit)
|
|
10
|
+
// and "EE{...}" events.
|
|
11
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
12
|
+
import ReactDOM from 'react-dom/client'
|
|
13
|
+
import { clsx } from 'clsx'
|
|
14
|
+
import { useAnimatedUnmount } from '../hooks/useAnimatedUnmount'
|
|
15
|
+
import { Tooltip } from '../components/ui/Tooltip'
|
|
16
|
+
import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../utils/animation'
|
|
17
|
+
import {
|
|
18
|
+
type Press,
|
|
19
|
+
type TitleBarMenu,
|
|
20
|
+
type TitleBarState,
|
|
21
|
+
isDoublePress,
|
|
22
|
+
looksMaximised,
|
|
23
|
+
mnemonicMenuIndex,
|
|
24
|
+
resizeEdgeAt,
|
|
25
|
+
} from './titleBar'
|
|
26
|
+
|
|
27
|
+
const TITLEBAR_HEIGHT = 32
|
|
28
|
+
const HELLO_INTERVAL_MS = 250
|
|
29
|
+
const HELLO_TRIES = 120
|
|
30
|
+
|
|
31
|
+
type WebView = { postMessage: (message: string) => void }
|
|
32
|
+
|
|
33
|
+
function webview(): WebView | null {
|
|
34
|
+
return (window as unknown as { chrome?: { webview?: WebView } }).chrome?.webview ?? null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function post(message: string) {
|
|
38
|
+
webview()?.postMessage(message)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function emit(name: string, ...data: unknown[]) {
|
|
42
|
+
post('EE' + JSON.stringify({ name, data }))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True inside the Windows desktop app, where the page can run native menu items. */
|
|
46
|
+
export function hasDesktopMenu(): boolean {
|
|
47
|
+
return webview() !== null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Runs a native menu item by its "Menu/Label" path (cmd/desktop/titlebar.go). */
|
|
51
|
+
export function runDesktopMenuItem(path: string) {
|
|
52
|
+
emit('radar:titlebar:invoke', path)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isMaximised() {
|
|
56
|
+
return looksMaximised(window.outerWidth, window.outerHeight, screen.availWidth, screen.availHeight)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Caption glyphs: Segoe Fluent Icons on Windows 11, Segoe MDL2 Assets on Windows 10.
|
|
60
|
+
const GLYPH = { minimise: '', maximise: '', restore: '', close: '' }
|
|
61
|
+
|
|
62
|
+
function TitleBar({ title, menus }: TitleBarState) {
|
|
63
|
+
const [open, setOpen] = useState<number | null>(null)
|
|
64
|
+
const [maximised, setMaximised] = useState(isMaximised)
|
|
65
|
+
const lastPress = useRef<Press>({ t: 0, x: 0, y: 0 })
|
|
66
|
+
const triggers = useRef<(HTMLButtonElement | null)[]>([])
|
|
67
|
+
// Where focus was before Alt or a mnemonic moved it into the bar.
|
|
68
|
+
const returnFocus = useRef<HTMLElement | null>(null)
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const onResize = () => setMaximised(isMaximised())
|
|
72
|
+
window.addEventListener('resize', onResize)
|
|
73
|
+
return () => window.removeEventListener('resize', onResize)
|
|
74
|
+
}, [])
|
|
75
|
+
|
|
76
|
+
const leaveBar = useCallback(() => {
|
|
77
|
+
setOpen(null)
|
|
78
|
+
const prev = returnFocus.current
|
|
79
|
+
returnFocus.current = null
|
|
80
|
+
if (prev?.isConnected) prev.focus()
|
|
81
|
+
else (document.activeElement as HTMLElement | null)?.blur()
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
const enterBar = useCallback(() => {
|
|
85
|
+
if (!(document.activeElement as HTMLElement | null)?.closest?.('[data-radar-titlebar]')) {
|
|
86
|
+
returnFocus.current = document.activeElement as HTMLElement | null
|
|
87
|
+
}
|
|
88
|
+
}, [])
|
|
89
|
+
|
|
90
|
+
const invoke = useCallback((path: string) => {
|
|
91
|
+
leaveBar()
|
|
92
|
+
runDesktopMenuItem(path)
|
|
93
|
+
}, [leaveBar])
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
let altAlone = false
|
|
97
|
+
const inBar = () => !!(document.activeElement as HTMLElement | null)?.closest?.('[data-radar-titlebar]')
|
|
98
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
99
|
+
if (e.key === 'Alt') {
|
|
100
|
+
altAlone = !e.repeat
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
altAlone = false
|
|
104
|
+
const mnemonic = mnemonicMenuIndex(menus, e)
|
|
105
|
+
if (mnemonic >= 0) {
|
|
106
|
+
e.preventDefault()
|
|
107
|
+
enterBar()
|
|
108
|
+
triggers.current[mnemonic]?.focus()
|
|
109
|
+
setOpen(mnemonic)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
// Consume Escape here, at the first capture listener, so drawers and
|
|
113
|
+
// dialogs underneath don't also close.
|
|
114
|
+
if (e.key === 'Escape' && (open !== null || inBar())) {
|
|
115
|
+
e.preventDefault()
|
|
116
|
+
e.stopPropagation()
|
|
117
|
+
if (open !== null) {
|
|
118
|
+
const i = open
|
|
119
|
+
setOpen(null)
|
|
120
|
+
triggers.current[i]?.focus()
|
|
121
|
+
} else {
|
|
122
|
+
leaveBar()
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const onKeyUp = (e: KeyboardEvent) => {
|
|
127
|
+
if (e.key !== 'Alt' || !altAlone) return
|
|
128
|
+
altAlone = false
|
|
129
|
+
e.preventDefault()
|
|
130
|
+
if (inBar()) {
|
|
131
|
+
leaveBar()
|
|
132
|
+
} else {
|
|
133
|
+
enterBar()
|
|
134
|
+
triggers.current[0]?.focus()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
window.addEventListener('keydown', onKeyDown, true)
|
|
138
|
+
window.addEventListener('keyup', onKeyUp, true)
|
|
139
|
+
return () => {
|
|
140
|
+
window.removeEventListener('keydown', onKeyDown, true)
|
|
141
|
+
window.removeEventListener('keyup', onKeyUp, true)
|
|
142
|
+
}
|
|
143
|
+
}, [menus, open, enterBar, leaveBar])
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (open === null) return
|
|
147
|
+
const onDown = (e: MouseEvent) => {
|
|
148
|
+
if (!(e.target as HTMLElement).closest?.('[data-radar-titlebar]')) setOpen(null)
|
|
149
|
+
}
|
|
150
|
+
window.addEventListener('mousedown', onDown, true)
|
|
151
|
+
return () => window.removeEventListener('mousedown', onDown, true)
|
|
152
|
+
}, [open])
|
|
153
|
+
|
|
154
|
+
const onBarMouseDown = (e: React.MouseEvent) => {
|
|
155
|
+
if (e.button !== 0 || (e.target as HTMLElement).closest('[data-no-drag]')) return
|
|
156
|
+
const press = { t: performance.now(), x: e.screenX, y: e.screenY }
|
|
157
|
+
const double = isDoublePress(lastPress.current, press)
|
|
158
|
+
lastPress.current = double ? { t: 0, x: 0, y: 0 } : press
|
|
159
|
+
setOpen(null)
|
|
160
|
+
post(double ? 'Wt' : 'drag')
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const moveTo = (j: number) => {
|
|
164
|
+
triggers.current[j]?.focus()
|
|
165
|
+
if (open !== null) setOpen(j)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const onTriggerKey = (i: number) => (e: React.KeyboardEvent) => {
|
|
169
|
+
const n = menus.length
|
|
170
|
+
if (e.key === 'ArrowRight') { e.preventDefault(); moveTo((i + 1) % n) }
|
|
171
|
+
else if (e.key === 'ArrowLeft') { e.preventDefault(); moveTo((i + n - 1) % n) }
|
|
172
|
+
else if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setOpen(i) }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<div
|
|
177
|
+
data-radar-titlebar
|
|
178
|
+
onMouseDown={onBarMouseDown}
|
|
179
|
+
className="fixed inset-x-0 top-0 flex items-stretch select-none text-xs bg-theme-base border-b border-theme-border/50 text-theme-text-secondary"
|
|
180
|
+
style={{ height: TITLEBAR_HEIGHT, zIndex: 2147483000, fontFamily: '"Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif' }}
|
|
181
|
+
>
|
|
182
|
+
<div className="flex items-center pl-3 pr-1">
|
|
183
|
+
<img src="/favicon.svg" alt="" width={16} height={16} draggable={false} />
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div className="flex items-stretch" data-no-drag role="menubar" aria-label="Application menu">
|
|
187
|
+
{menus.map((m, i) => (
|
|
188
|
+
<div key={m.label} className="relative flex">
|
|
189
|
+
<button
|
|
190
|
+
ref={(el) => { triggers.current[i] = el }}
|
|
191
|
+
type="button"
|
|
192
|
+
role="menuitem"
|
|
193
|
+
aria-haspopup="menu"
|
|
194
|
+
aria-expanded={open === i}
|
|
195
|
+
className={clsx(
|
|
196
|
+
'px-2.5 my-1 rounded outline-none hover:bg-theme-hover hover:text-theme-text-primary focus-visible:bg-theme-hover focus-visible:text-theme-text-primary',
|
|
197
|
+
open === i && 'bg-theme-hover text-theme-text-primary',
|
|
198
|
+
)}
|
|
199
|
+
// Keep focus (and any text selection) where it is, so Edit → Copy / Paste act on it.
|
|
200
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
201
|
+
onClick={() => { if (open === i) { setOpen(null) } else { enterBar(); setOpen(i) } }}
|
|
202
|
+
onMouseEnter={() => { if (open !== null && open !== i) setOpen(i) }}
|
|
203
|
+
onKeyDown={onTriggerKey(i)}
|
|
204
|
+
>
|
|
205
|
+
{m.label}
|
|
206
|
+
</button>
|
|
207
|
+
<MenuDropdown
|
|
208
|
+
menu={m}
|
|
209
|
+
open={open === i}
|
|
210
|
+
onInvoke={invoke}
|
|
211
|
+
onMove={(dir) => moveTo((i + dir + menus.length) % menus.length)}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
))}
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<div className="flex-1 min-w-0 flex items-center justify-center px-4">
|
|
218
|
+
<span className="truncate">{title}</span>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<div className="flex items-stretch" data-no-drag>
|
|
222
|
+
<CaptionButton glyph={GLYPH.minimise} label="Minimize" onClick={() => post('Wm')} />
|
|
223
|
+
<CaptionButton glyph={maximised ? GLYPH.restore : GLYPH.maximise} label={maximised ? 'Restore' : 'Maximize'} onClick={() => post('Wt')} />
|
|
224
|
+
<CaptionButton glyph={GLYPH.close} label="Close" onClick={() => post('Q')} close />
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function MenuDropdown({ menu, open, onInvoke, onMove }: { menu: TitleBarMenu; open: boolean; onInvoke: (path: string) => void; onMove: (dir: 1 | -1) => void }) {
|
|
231
|
+
const { shouldRender, isOpen } = useAnimatedUnmount(open, overlayExitMs('menu'))
|
|
232
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
233
|
+
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
if (open && shouldRender) ref.current?.querySelector<HTMLButtonElement>('button')?.focus({ preventScroll: true })
|
|
236
|
+
}, [open, shouldRender])
|
|
237
|
+
|
|
238
|
+
if (!shouldRender) return null
|
|
239
|
+
|
|
240
|
+
const onKey = (e: React.KeyboardEvent) => {
|
|
241
|
+
const items = Array.from(ref.current?.querySelectorAll<HTMLButtonElement>('button') ?? [])
|
|
242
|
+
const idx = items.indexOf(document.activeElement as HTMLButtonElement)
|
|
243
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); items[(idx + 1) % items.length]?.focus() }
|
|
244
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); items[(idx - 1 + items.length) % items.length]?.focus() }
|
|
245
|
+
else if (e.key === 'ArrowRight') { e.preventDefault(); onMove(1) }
|
|
246
|
+
else if (e.key === 'ArrowLeft') { e.preventDefault(); onMove(-1) }
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<div
|
|
251
|
+
ref={ref}
|
|
252
|
+
role="menu"
|
|
253
|
+
aria-label={menu.label}
|
|
254
|
+
inert={!open}
|
|
255
|
+
onKeyDown={onKey}
|
|
256
|
+
className={clsx(
|
|
257
|
+
'absolute left-0 top-full mt-0.5 min-w-[220px] py-1 rounded-md origin-top-left',
|
|
258
|
+
'border border-theme-border bg-theme-elevated shadow-theme-md text-theme-text-primary',
|
|
259
|
+
TRANSITION_MENU,
|
|
260
|
+
isOpen ? 'opacity-100 translate-y-0 scale-100' : 'opacity-0 -translate-y-1 scale-[0.97]',
|
|
261
|
+
!open && 'pointer-events-none',
|
|
262
|
+
)}
|
|
263
|
+
style={overlayTransitionStyle(isOpen, 'menu')}
|
|
264
|
+
>
|
|
265
|
+
{menu.items.map((item, i) =>
|
|
266
|
+
item.separator ? (
|
|
267
|
+
<div key={i} role="separator" className="my-1 border-t border-theme-border" />
|
|
268
|
+
) : (
|
|
269
|
+
<button
|
|
270
|
+
key={item.label}
|
|
271
|
+
type="button"
|
|
272
|
+
role="menuitem"
|
|
273
|
+
className="w-full flex items-center justify-between gap-6 px-3 py-1.5 text-left outline-none hover:bg-theme-hover focus:bg-theme-hover"
|
|
274
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
275
|
+
onClick={() => onInvoke(menu.label + '/' + item.label)}
|
|
276
|
+
>
|
|
277
|
+
<span>{item.label}</span>
|
|
278
|
+
{item.shortcut && <span className="text-theme-text-tertiary">{item.shortcut}</span>}
|
|
279
|
+
</button>
|
|
280
|
+
),
|
|
281
|
+
)}
|
|
282
|
+
</div>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function CaptionButton({ glyph, label, onClick, close }: { glyph: string; label: string; onClick: () => void; close?: boolean }) {
|
|
287
|
+
return (
|
|
288
|
+
<Tooltip content={label} position="bottom" wrapperClassName="items-stretch">
|
|
289
|
+
<button
|
|
290
|
+
type="button"
|
|
291
|
+
aria-label={label}
|
|
292
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
293
|
+
onClick={onClick}
|
|
294
|
+
className={clsx(
|
|
295
|
+
'w-[46px] text-[10px] outline-none',
|
|
296
|
+
// Red on hover is the Windows close-button convention, not a theme colour.
|
|
297
|
+
close ? 'hover:bg-[#c42b1c] hover:text-white' : 'hover:bg-theme-hover hover:text-theme-text-primary',
|
|
298
|
+
)}
|
|
299
|
+
style={{ fontFamily: '"Segoe Fluent Icons", "Segoe MDL2 Assets"' }}
|
|
300
|
+
>
|
|
301
|
+
{glyph}
|
|
302
|
+
</button>
|
|
303
|
+
</Tooltip>
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// A frameless window has no native resize border, so the page edges start the resize.
|
|
308
|
+
function installResizeEdges() {
|
|
309
|
+
const edgeFor = (e: MouseEvent) => resizeEdgeAt(e.clientX, e.clientY, window.innerWidth, window.innerHeight, isMaximised())
|
|
310
|
+
let cursor: string | null = null
|
|
311
|
+
const setCursor = (next: string | null) => {
|
|
312
|
+
if (next === cursor) return
|
|
313
|
+
cursor = next
|
|
314
|
+
document.documentElement.style.cursor = next ?? ''
|
|
315
|
+
}
|
|
316
|
+
window.addEventListener('mousemove', (e) => setCursor(edgeFor(e)), true)
|
|
317
|
+
window.addEventListener('resize', () => setCursor(null))
|
|
318
|
+
window.addEventListener('blur', () => setCursor(null))
|
|
319
|
+
// Recompute from this press: the window may have been maximised or resized
|
|
320
|
+
// since the pointer last moved.
|
|
321
|
+
window.addEventListener('mousedown', (e) => {
|
|
322
|
+
const edge = e.button === 0 ? edgeFor(e) : null
|
|
323
|
+
if (!edge) return
|
|
324
|
+
e.preventDefault()
|
|
325
|
+
e.stopPropagation()
|
|
326
|
+
post('resize:' + edge)
|
|
327
|
+
}, true)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export function installWindowsTitleBar() {
|
|
331
|
+
if (!webview()) return
|
|
332
|
+
let root: ReactDOM.Root | null = null
|
|
333
|
+
let rev = -1
|
|
334
|
+
window.addEventListener('radar:titlebar', (e) => {
|
|
335
|
+
const detail = (e as CustomEvent<TitleBarState & { rev: number }>).detail
|
|
336
|
+
// Pushes can arrive out of order; an older one would show a stale title.
|
|
337
|
+
if (detail.rev <= rev) return
|
|
338
|
+
rev = detail.rev
|
|
339
|
+
const { title, menus } = detail
|
|
340
|
+
if (!root) {
|
|
341
|
+
document.documentElement.classList.add('radar-custom-titlebar')
|
|
342
|
+
document.documentElement.style.setProperty('--radar-titlebar-h', `${TITLEBAR_HEIGHT}px`)
|
|
343
|
+
const host = document.createElement('div')
|
|
344
|
+
document.body.prepend(host)
|
|
345
|
+
root = ReactDOM.createRoot(host)
|
|
346
|
+
installResizeEdges()
|
|
347
|
+
}
|
|
348
|
+
root.render(<TitleBar title={title || 'Radar'} menus={menus ?? []} />)
|
|
349
|
+
})
|
|
350
|
+
// The desktop app registers its handler at startup, which can finish after
|
|
351
|
+
// the page loads; repeat the hello until the first answer arrives.
|
|
352
|
+
let tries = 0
|
|
353
|
+
const hello = () => {
|
|
354
|
+
if (root || tries++ >= HELLO_TRIES) return
|
|
355
|
+
emit('radar:titlebar:hello')
|
|
356
|
+
window.setTimeout(hello, HELLO_INTERVAL_MS)
|
|
357
|
+
}
|
|
358
|
+
hello()
|
|
359
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { RESIZE_EDGE_PX, isDoublePress, looksMaximised, mnemonicMenuIndex, resizeEdgeAt } from './titleBar'
|
|
4
|
+
|
|
5
|
+
describe('resizeEdgeAt', () => {
|
|
6
|
+
const W = 1000
|
|
7
|
+
const H = 800
|
|
8
|
+
it('names edges and corners within the resize band', () => {
|
|
9
|
+
expect(resizeEdgeAt(0, 0, W, H, false)).toBe('nw-resize')
|
|
10
|
+
expect(resizeEdgeAt(W - 1, 0, W, H, false)).toBe('ne-resize')
|
|
11
|
+
expect(resizeEdgeAt(0, H - 1, W, H, false)).toBe('sw-resize')
|
|
12
|
+
expect(resizeEdgeAt(W - 1, H - 1, W, H, false)).toBe('se-resize')
|
|
13
|
+
expect(resizeEdgeAt(500, 2, W, H, false)).toBe('n-resize')
|
|
14
|
+
expect(resizeEdgeAt(500, H - 2, W, H, false)).toBe('s-resize')
|
|
15
|
+
expect(resizeEdgeAt(2, 400, W, H, false)).toBe('w-resize')
|
|
16
|
+
expect(resizeEdgeAt(W - 2, 400, W, H, false)).toBe('e-resize')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('is null inside the window and whenever the window is maximised', () => {
|
|
20
|
+
expect(resizeEdgeAt(RESIZE_EDGE_PX, 400, W, H, false)).toBeNull()
|
|
21
|
+
expect(resizeEdgeAt(500, 400, W, H, false)).toBeNull()
|
|
22
|
+
expect(resizeEdgeAt(0, 0, W, H, true)).toBeNull()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('mnemonicMenuIndex', () => {
|
|
27
|
+
const menus = ['File', 'Edit', 'View', 'Help'].map((label) => ({ label, items: [] }))
|
|
28
|
+
const ev = (key: string, mods: Partial<KeyboardEvent> = {}) =>
|
|
29
|
+
({ key, altKey: true, ctrlKey: false, metaKey: false, shiftKey: false, ...mods }) as KeyboardEvent
|
|
30
|
+
|
|
31
|
+
it('maps Alt+first letter to the menu, in either case', () => {
|
|
32
|
+
expect(mnemonicMenuIndex(menus, ev('f'))).toBe(0)
|
|
33
|
+
expect(mnemonicMenuIndex(menus, ev('E'))).toBe(1)
|
|
34
|
+
expect(mnemonicMenuIndex(menus, ev('v'))).toBe(2)
|
|
35
|
+
expect(mnemonicMenuIndex(menus, ev('h'))).toBe(3)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('ignores other letters, plain keys and other modifiers', () => {
|
|
39
|
+
expect(mnemonicMenuIndex(menus, ev('x'))).toBe(-1)
|
|
40
|
+
expect(mnemonicMenuIndex(menus, ev('f', { altKey: false }))).toBe(-1)
|
|
41
|
+
expect(mnemonicMenuIndex(menus, ev('f', { ctrlKey: true }))).toBe(-1)
|
|
42
|
+
expect(mnemonicMenuIndex(menus, ev('f', { shiftKey: true }))).toBe(-1)
|
|
43
|
+
expect(mnemonicMenuIndex(menus, ev('ArrowDown'))).toBe(-1)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe('isDoublePress', () => {
|
|
48
|
+
it('needs both a short gap and almost no movement', () => {
|
|
49
|
+
const first = { t: 1000, x: 100, y: 10 }
|
|
50
|
+
expect(isDoublePress(first, { t: 1300, x: 101, y: 11 })).toBe(true)
|
|
51
|
+
expect(isDoublePress(first, { t: 1600, x: 100, y: 10 })).toBe(false)
|
|
52
|
+
expect(isDoublePress(first, { t: 1100, x: 140, y: 10 })).toBe(false)
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe('looksMaximised', () => {
|
|
57
|
+
it('compares the window with the work area', () => {
|
|
58
|
+
expect(looksMaximised(1920, 1040, 1920, 1040)).toBe(true)
|
|
59
|
+
expect(looksMaximised(1440, 900, 1920, 1040)).toBe(false)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Pure helpers for the Windows desktop title bar (WindowsTitleBar.tsx).
|
|
2
|
+
|
|
3
|
+
export type TitleBarItem = { label?: string; shortcut?: string; separator?: boolean }
|
|
4
|
+
export type TitleBarMenu = { label: string; items: TitleBarItem[] }
|
|
5
|
+
export type TitleBarState = { title: string; menus: TitleBarMenu[] }
|
|
6
|
+
|
|
7
|
+
export const RESIZE_EDGE_PX = 6
|
|
8
|
+
|
|
9
|
+
/** Edge names are the cursor values Wails maps to resize hit-tests ("resize:<edge>"). */
|
|
10
|
+
export function resizeEdgeAt(x: number, y: number, width: number, height: number, maximised: boolean): string | null {
|
|
11
|
+
if (maximised) return null
|
|
12
|
+
const top = y < RESIZE_EDGE_PX
|
|
13
|
+
const bottom = y >= height - RESIZE_EDGE_PX
|
|
14
|
+
const left = x < RESIZE_EDGE_PX
|
|
15
|
+
const right = x >= width - RESIZE_EDGE_PX
|
|
16
|
+
if (top && left) return 'nw-resize'
|
|
17
|
+
if (top && right) return 'ne-resize'
|
|
18
|
+
if (bottom && left) return 'sw-resize'
|
|
19
|
+
if (bottom && right) return 'se-resize'
|
|
20
|
+
if (top) return 'n-resize'
|
|
21
|
+
if (bottom) return 's-resize'
|
|
22
|
+
if (left) return 'w-resize'
|
|
23
|
+
if (right) return 'e-resize'
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Alt+<first letter> opens that menu, as in native Windows menu bars. */
|
|
28
|
+
export function mnemonicMenuIndex(menus: TitleBarMenu[], e: Pick<KeyboardEvent, 'key' | 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'>): number {
|
|
29
|
+
if (!e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.key.length !== 1) return -1
|
|
30
|
+
const k = e.key.toLowerCase()
|
|
31
|
+
return menus.findIndex((m) => m.label.charAt(0).toLowerCase() === k)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type Press = { t: number; x: number; y: number }
|
|
35
|
+
|
|
36
|
+
/** The native move loop swallows the browser's click sequence, so a double
|
|
37
|
+
* click on the drag area is detected by time and distance instead. */
|
|
38
|
+
export function isDoublePress(prev: Press, next: Press, windowMs = 500, slopPx = 4): boolean {
|
|
39
|
+
return next.t - prev.t < windowMs && Math.abs(next.x - prev.x) < slopPx && Math.abs(next.y - prev.y) < slopPx
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A frameless window maximised by Windows fills the monitor's work area. */
|
|
43
|
+
export function looksMaximised(outerWidth: number, outerHeight: number, availWidth: number, availHeight: number): boolean {
|
|
44
|
+
return outerWidth >= availWidth - 1 && outerHeight >= availHeight - 1
|
|
45
|
+
}
|
package/src/index.css
CHANGED
|
@@ -146,6 +146,25 @@ body {
|
|
|
146
146
|
flex-direction: column;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/* The Windows desktop app draws its own title bar above the app shell
|
|
150
|
+
(desktop/WindowsTitleBar.tsx); the shell gives up that height. */
|
|
151
|
+
html.radar-custom-titlebar body {
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
}
|
|
154
|
+
html.radar-custom-titlebar #radar {
|
|
155
|
+
margin-top: var(--radar-titlebar-h);
|
|
156
|
+
height: calc(100vh - var(--radar-titlebar-h));
|
|
157
|
+
}
|
|
158
|
+
html.radar-custom-titlebar #radar .h-screen {
|
|
159
|
+
height: calc(100vh - var(--radar-titlebar-h));
|
|
160
|
+
}
|
|
161
|
+
/* Full-window overlays (dialogs, fullscreen views) start below the title bar
|
|
162
|
+
so their own top controls stay reachable. */
|
|
163
|
+
html.radar-custom-titlebar .fixed.inset-0:not([data-radar-titlebar]),
|
|
164
|
+
html.radar-custom-titlebar .fixed.top-0:not([data-radar-titlebar]) {
|
|
165
|
+
top: var(--radar-titlebar-h);
|
|
166
|
+
}
|
|
167
|
+
|
|
149
168
|
/* ============================================
|
|
150
169
|
REACT FLOW CUSTOMIZATIONS
|
|
151
170
|
============================================ */
|
|
@@ -15,7 +15,7 @@ export interface KindListProps {
|
|
|
15
15
|
inspected: SelectedResource | null
|
|
16
16
|
onInspect: (resource: SelectedResource) => void
|
|
17
17
|
onClearNamespaces: () => void
|
|
18
|
-
onCreate: (kind: HostKind) => void
|
|
18
|
+
onCreate: (kind: HostKind, initialYaml?: string) => void
|
|
19
19
|
}
|
|
20
20
|
type ExclusiveDetailSlot = 'summary' | 'destination' | 'logs'
|
|
21
21
|
export interface ResourceHost {
|
|
@@ -27,12 +27,16 @@ export interface ResourceHost {
|
|
|
27
27
|
title: string
|
|
28
28
|
mode: (support: RadarFeatureSupport, pending: boolean) => KindListMode
|
|
29
29
|
Component: ComponentType<KindListProps>
|
|
30
|
+
/** Set when the list ignores the namespace filter: the header's picker is disabled with this tooltip while the list shows. */
|
|
31
|
+
namespaceFilterTooltip?: string
|
|
30
32
|
}[]
|
|
31
33
|
renderers?: RendererOverrides
|
|
32
34
|
resources?: readonly { name: string; group: string }[]
|
|
33
35
|
expandedPath?: (resource: HostResource, context?: string, tab?: 'yaml') => string | null
|
|
34
36
|
detailRedirect?: (resource: HostResource, search: URLSearchParams) => string | null
|
|
35
37
|
detailSlots?: (resource: HostResource) => DetailSlots
|
|
38
|
+
/** More for one of the resource's issues, inside that issue's "What's wrong" in the drawer. */
|
|
39
|
+
issueDetail?: (props: { issue: { kind?: string; reason?: string }; resource: any }) => ReactNode
|
|
36
40
|
detailOwnership?: readonly ExclusiveDetailSlot[]
|
|
37
41
|
logs?: (resource: HostResource, data: { apiVersion?: string } | null | undefined) => ReactNode
|
|
38
42
|
drawerNavigation?: {
|