547 lines
25 KiB
TypeScript
547 lines
25 KiB
TypeScript
import * as Menu from '@radix-ui/react-dropdown-menu'
|
|
import {
|
|
AppWindow,
|
|
Archive,
|
|
Camera,
|
|
Check,
|
|
ChevronDown,
|
|
CopyPlus,
|
|
Cpu,
|
|
FolderOpen,
|
|
Keyboard,
|
|
LifeBuoy,
|
|
Maximize2,
|
|
Minimize2,
|
|
Pause,
|
|
Pencil,
|
|
Play,
|
|
Power,
|
|
RotateCw,
|
|
Settings,
|
|
Square,
|
|
Terminal,
|
|
Trash,
|
|
Upload,
|
|
} from 'lucide-react'
|
|
import React, { useEffect, useId, useRef, useState } from 'react'
|
|
import { I18nKey, localeDir, locText, t } from '../i18n'
|
|
import { formatUptime } from '../lib/format'
|
|
import {
|
|
defaultEndpointAction,
|
|
endpointKey,
|
|
guestFamilyOf,
|
|
isMacOSDriver as isMacOSDriverID,
|
|
splitEndpoints,
|
|
vmFeatures,
|
|
} from '../lib/endpoints'
|
|
import { useVMStats } from '../lib/vmStats'
|
|
import { HostReport, Locale, PendingChange, PluginUIContributions, VMAction, VMBusyAction, VMDetail, VMInfo } from '../types'
|
|
import { api } from '../wails'
|
|
import { Button, StatusShape, Tip, statusKind } from '../ui/controls'
|
|
import { ActionMenu } from '../ui/menu'
|
|
import { HostIcon } from '../ui/themeVisuals'
|
|
import { VersionArt } from '../macos/VersionArt'
|
|
import { GuestArt, hasGuestArt } from './GuestIcon'
|
|
import { ConnectionSection } from './vmPage/connections'
|
|
import { endpointIcon, EndpointSection, useEndpointActions } from './vmPage/endpoints'
|
|
import { useHostDNS } from './vmPage/hostDNS'
|
|
import { InstallCard } from './vmPage/installCard'
|
|
import { VMNotices } from './vmPage/notices'
|
|
import { useVMThumbnail, VMScreen } from './vmPage/screen'
|
|
import { SnapshotSection } from './vmPage/snapshots'
|
|
import { SSHUserDialog, useSSHAccess } from './vmPage/ssh'
|
|
import { VMSummary } from './vmPage/summary'
|
|
import { TechInfo } from './vmPage/techInfo'
|
|
|
|
const PRIMARY_SHORTCUT = 'Ctrl+Enter'
|
|
|
|
interface Props {
|
|
locale: Locale
|
|
/** The VM's identifier (folder, CLI, reims-ctl). */
|
|
name: string
|
|
driverID: string
|
|
/** What the user calls it (its note); empty shows `name`. */
|
|
displayName: string
|
|
onDisplayNameSaved: (displayName: string) => void
|
|
/** macOS major version (26, 15, …) for the artwork shown before a first frame; null if unknown. */
|
|
macosMajor: number | null
|
|
state: string
|
|
/** Whether this VM can suspend and resume (the runtime for macOS VMs, the `suspend` capability for others). */
|
|
canSuspend: boolean
|
|
currentAgentVersion: number
|
|
/** Whether the native VM-window installation guide is currently active for this boot. */
|
|
guideActive: boolean
|
|
/** Whether the VM-window install guide setting on builtin.guest.macos is enabled. */
|
|
installGuideEnabled: boolean
|
|
/** macOS VMs only: their full detail. */
|
|
detail: VMDetail | null
|
|
/** Non-macOS VMs: the cross-driver model (capabilities, guest OS, phase, readiness, endpoints). */
|
|
vmInfo?: VMInfo | null
|
|
host: HostReport
|
|
pending: PendingChange[]
|
|
busyAction?: VMBusyAction
|
|
onAction: (action: VMAction) => void
|
|
onPluginCommand: (pluginID: string, command: string, title: string) => void
|
|
onSettings: () => void
|
|
onOpenAffinity: () => void
|
|
onDelete: () => void
|
|
onViewLogs: () => void
|
|
onCopy: (text: string) => void
|
|
onTypeText: (text: string) => void
|
|
onTogglePreventSleep: (enabled: boolean) => void
|
|
onDeliverFile: () => void
|
|
onToast: (title: string) => void
|
|
onError: (title: string, e: unknown) => void
|
|
/** Active global fullscreen toggle shortcut when enabled, else undefined. */
|
|
fullscreenHotkey?: string
|
|
dropping?: boolean
|
|
pluginUI?: PluginUIContributions | null
|
|
}
|
|
|
|
function ShutdownButton({ locale, busyAction, onAction }: Pick<Props, 'locale' | 'busyAction' | 'onAction'>) {
|
|
const [mode, setMode] = useState<'stop' | 'forceStop'>('stop')
|
|
const forced = mode === 'forceStop'
|
|
const variant = forced ? 'danger' : 'secondary'
|
|
const label = t(locale, 'shutdownMode')
|
|
const Icon = forced ? Power : Square
|
|
|
|
return (
|
|
<div className="shutdown-button" role="group" aria-label={label}>
|
|
<Button variant={variant} icon={<Icon size={13} aria-hidden="true" />} busy={busyAction === mode}
|
|
disabled={!!busyAction} onClick={() => onAction(mode)}>{t(locale, mode)}</Button>
|
|
<Menu.Root dir={localeDir(locale)}>
|
|
<Menu.Trigger asChild>
|
|
<Button variant={variant} disabled={!!busyAction} aria-label={label} title={label}>
|
|
<ChevronDown size={13} aria-hidden="true" />
|
|
</Button>
|
|
</Menu.Trigger>
|
|
<Menu.Portal>
|
|
<Menu.Content className="menu rg-p-menu" align="end" sideOffset={4} collisionPadding={8}>
|
|
<Menu.RadioGroup value={mode} onValueChange={(v) => setMode(v === 'forceStop' ? 'forceStop' : 'stop')}>
|
|
{(['stop', 'forceStop'] as const).map((action) => (
|
|
<Menu.RadioItem key={action} value={action} className={`menu-item rg-p-menu-item menu-item-check${action === 'forceStop' ? ' danger' : ''}`}>
|
|
<Menu.ItemIndicator className="menu-check"><Check size={13} /></Menu.ItemIndicator>
|
|
{t(locale, action)}
|
|
</Menu.RadioItem>
|
|
))}
|
|
</Menu.RadioGroup>
|
|
</Menu.Content>
|
|
</Menu.Portal>
|
|
</Menu.Root>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const VMPage: React.FC<Props> = ({
|
|
locale, name, driverID, displayName, onDisplayNameSaved, macosMajor, state, canSuspend, currentAgentVersion, guideActive, installGuideEnabled, detail, vmInfo, host, pending, busyAction, onAction, onPluginCommand, onSettings, onOpenAffinity, onDelete, onViewLogs, onCopy, onTypeText, onTogglePreventSleep, onDeliverFile, onToast, onError, dropping, pluginUI, fullscreenHotkey,
|
|
}) => {
|
|
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
|
const busy = busyAction !== undefined
|
|
const running = state === 'running'
|
|
const suspended = state === 'suspended'
|
|
const guestToolsLocked = suspended || state === 'suspending' || state === 'resuming'
|
|
const resumeHintId = useId()
|
|
const installing = !!detail && (detail.has_installer || detail.recovery_mode)
|
|
const vmKey = `${driverID}:${name}`
|
|
const transitioning = state === 'starting' || state === 'stopping' || state === 'suspending' || state === 'resuming'
|
|
const isMacOSDriver = isMacOSDriverID(driverID)
|
|
const toolbarMenus = (pluginUI?.menus ?? []).filter(({ slot, when }) => {
|
|
if (slot !== 'vm.toolbar') return false
|
|
switch (when) {
|
|
case undefined:
|
|
case '': return true
|
|
case 'vm.running': return running
|
|
case 'vm.stopped': return state === 'stopped'
|
|
case 'vm.macos.running': return running && isMacOSDriver && detail?.name === name && !installing && !guideActive
|
|
default: return false
|
|
}
|
|
})
|
|
const canUseHostDNS = !!detail && !installing && !detail.guest_tools_disabled && isMacOSDriver && state !== 'broken'
|
|
// What this VM's driver lets the UI offer (macOS VMs keep everything), and what it runs on.
|
|
const features = vmFeatures({ driver_id: driverID, capabilities: vmInfo?.capabilities })
|
|
const guestFamily = guestFamilyOf({ driver_id: driverID, guest_os: vmInfo?.guest_os })
|
|
const guestArt = !isMacOSDriver && hasGuestArt(guestFamily)
|
|
const phase = vmInfo?.phase
|
|
const waitingForGuest = running && vmInfo?.ready === false
|
|
// A running hosted VM has no window: its best ready endpoint is the header action.
|
|
const { primary: bestEndpoint } = splitEndpoints(vmInfo?.endpoints)
|
|
const promotedEndpoint = features.hosted && running ? bestEndpoint : undefined
|
|
const endpoints = useEndpointActions({ locale, driverID, name, onCopy, onError })
|
|
const { endpointBusy, runEndpointAction, endpointActionLabel, endpointKindLabel } = endpoints
|
|
// Polled here rather than in App so each tick re-renders only this page.
|
|
const stats = useVMStats(driverID, name, running)
|
|
const hostDNS = useHostDNS({ locale, driverID, name, state, detail, available: canUseHostDNS, locked: guestToolsLocked, onToast, onError })
|
|
const thumb = useVMThumbnail(driverID, name, running, features.screenshot)
|
|
|
|
// Display name, stored as the VM's note (.reims-go-note). Clicking the title
|
|
// edits it in place; clearing it (or typing the name) falls back to the name.
|
|
const shownName = displayName || name
|
|
const [editingName, setEditingName] = useState(false)
|
|
const [nameDraft, setNameDraft] = useState('')
|
|
const startRename = () => { setNameDraft(shownName); setEditingName(true) }
|
|
// From the More menu: keep the menu from pulling focus back to its button,
|
|
// which would blur (and so save) the name field or pop the trigger's tooltip.
|
|
const renameFromMenu = useRef(false)
|
|
const nameInputRef = useRef<HTMLInputElement>(null)
|
|
const saveName = async () => {
|
|
setEditingName(false)
|
|
let next = nameDraft.trim()
|
|
if (next === name) next = ''
|
|
if (next === displayName) return
|
|
try {
|
|
await api.SetVMNote(driverID, name, next)
|
|
onDisplayNameSaved(next)
|
|
} catch (e) {
|
|
onError(tr('failGeneric'), e)
|
|
}
|
|
}
|
|
|
|
useEffect(() => { setEditingName(false) }, [driverID, name])
|
|
const ssh = useSSHAccess({ locale, driverID, name, enabled: isMacOSDriver, onToast, onError })
|
|
|
|
// Offline qcow2 restore points (snapshot_flow.go); other drivers offer them when they report `snapshot`.
|
|
const isQcow2 = !!detail && /\.qcow2$/i.test(detail.disk ?? '')
|
|
const showSnapshots = isMacOSDriver
|
|
? !!detail && !detail.has_installer && !detail.recovery_mode && isQcow2
|
|
: features.snapshot && state !== 'broken' && state !== 'driver_unavailable'
|
|
|
|
// One primary action per state (see docs/design-guidelines.md): Start while
|
|
// stopped, Resume while suspended, Show Window while running. Ctrl+Enter triggers it (App.tsx).
|
|
let primary: React.ReactNode = null
|
|
let secondary: React.ReactNode = null
|
|
if (state === 'stopped') {
|
|
primary = (
|
|
<Tip label={tr('start')} shortcut={PRIMARY_SHORTCUT}>
|
|
<Button variant="primary" icon={<Play size={14} aria-hidden="true" />} busy={busyAction === 'start'} disabled={busy} onClick={() => onAction('start')}>
|
|
{tr('start')}
|
|
</Button>
|
|
</Tip>
|
|
)
|
|
} else if (suspended) {
|
|
primary = (
|
|
<Tip label={tr('resume')} shortcut={PRIMARY_SHORTCUT} disabled={!canSuspend}>
|
|
<Button
|
|
variant={canSuspend ? 'primary' : 'secondary'}
|
|
icon={<Play size={14} aria-hidden="true" />}
|
|
busy={busyAction === 'resume'}
|
|
disabled={busy || !canSuspend}
|
|
aria-describedby={!canSuspend ? resumeHintId : undefined}
|
|
onClick={() => onAction('resume')}
|
|
>
|
|
{tr('resume')}
|
|
</Button>
|
|
</Tip>
|
|
)
|
|
} else if (state === 'starting') {
|
|
primary = <Button variant="primary" busy>{tr('state_starting')}</Button>
|
|
} else if (state === 'stopping') {
|
|
primary = <Button busy>{tr('state_stopping')}</Button>
|
|
} else if (state === 'suspending') {
|
|
primary = <Button busy>{tr('state_suspending')}</Button>
|
|
} else if (state === 'resuming') {
|
|
primary = <Button variant="primary" busy>{tr('state_resuming')}</Button>
|
|
} else if (running) {
|
|
const showLabel = tr(guideActive ? 'showInstallGuide' : 'showWindow')
|
|
if (features.hosted) {
|
|
// No window to show: the header action is the best ready endpoint, and with none ready there is no
|
|
// primary action at all (a disabled button never takes the primary slot).
|
|
if (promotedEndpoint) {
|
|
const action = defaultEndpointAction(promotedEndpoint.kind)
|
|
const label = action ? endpointActionLabel(promotedEndpoint.kind, action) : endpointKindLabel(promotedEndpoint.kind)
|
|
primary = (
|
|
<Tip label={label} shortcut={PRIMARY_SHORTCUT}>
|
|
<Button
|
|
variant="primary"
|
|
icon={endpointIcon(promotedEndpoint.kind, 14)}
|
|
busy={endpointBusy === `${endpointKey(promotedEndpoint)}:`}
|
|
disabled={busy}
|
|
onClick={() => runEndpointAction(promotedEndpoint, '')}
|
|
>
|
|
{label}
|
|
</Button>
|
|
</Tip>
|
|
)
|
|
}
|
|
} else {
|
|
primary = (
|
|
<Tip label={showLabel} shortcut={PRIMARY_SHORTCUT}>
|
|
<Button variant="primary" icon={<AppWindow size={14} aria-hidden="true" />} busy={busyAction === 'focus'} disabled={busy} onClick={() => onAction('focus')}>
|
|
{showLabel}
|
|
</Button>
|
|
</Tip>
|
|
)
|
|
}
|
|
secondary = (
|
|
<>
|
|
{canSuspend && (
|
|
<Button icon={<Pause size={13} aria-hidden="true" />} busy={busyAction === 'suspend'} disabled={busy} onClick={() => onAction('suspend')}>
|
|
{tr('suspend')}
|
|
</Button>
|
|
)}
|
|
<ShutdownButton key={name} locale={locale} busyAction={busyAction} onAction={onAction} />
|
|
</>
|
|
)
|
|
} else if (state === 'broken') {
|
|
primary = <Button variant="primary" icon={<Terminal size={14} aria-hidden="true" />} onClick={onViewLogs}>{tr('viewLogs')}</Button>
|
|
}
|
|
|
|
// "More" menu, grouped by purpose with destructive items last (see docs/design-guidelines.md).
|
|
const menu = (
|
|
<ActionMenu key={vmKey} locale={locale} label={tr('more')} onCloseFocus={() => {
|
|
if (!renameFromMenu.current) return false
|
|
renameFromMenu.current = false
|
|
nameInputRef.current?.focus()
|
|
return true
|
|
}}>
|
|
{running && (
|
|
<>
|
|
{features.fullscreen && detail?.graphics !== 'vmware-svga' && (
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('fullscreen')}>
|
|
{stats?.window_fullscreen ? <Minimize2 size={14} /> : <Maximize2 size={14} />}
|
|
<span className="menu-label">{tr(stats?.window_fullscreen ? 'exitFullscreen' : 'enterFullscreen')}</span>
|
|
{fullscreenHotkey && <kbd className="menu-shortcut">{fullscreenHotkey}</kbd>}
|
|
</Menu.Item>
|
|
)}
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('restart')}>
|
|
<HostIcon name="restart"><RotateCw size={14} /></HostIcon> {tr('restart')}
|
|
</Menu.Item>
|
|
{features.sendText && (
|
|
<>
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('sendText')}>
|
|
<Keyboard size={14} /> {tr('sendText')}
|
|
</Menu.Item>
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('type')}>
|
|
<Keyboard size={14} /> {tr('typeClipboard')}
|
|
</Menu.Item>
|
|
</>
|
|
)}
|
|
{features.screenshot && (
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('screenshot')}>
|
|
<HostIcon name="screenshot"><Camera size={14} /></HostIcon> {tr('copyScreenshot')}
|
|
</Menu.Item>
|
|
)}
|
|
<Menu.Separator className="menu-sep" />
|
|
</>
|
|
)}
|
|
{!isMacOSDriver && (
|
|
<>
|
|
{features.clone && (
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={running || suspended || transitioning || busy} onSelect={() => onAction('cloneVM')}>
|
|
<HostIcon name="clone"><CopyPlus size={14} /></HostIcon> {tr('cloneVM')}
|
|
</Menu.Item>
|
|
)}
|
|
{features.affinity && (
|
|
<Menu.Item className="menu-item rg-p-menu-item" onSelect={onOpenAffinity}>
|
|
<Cpu size={14} /> {tr('affinityMenu')}
|
|
</Menu.Item>
|
|
)}
|
|
<Menu.Item className="menu-item rg-p-menu-item" onSelect={() => { renameFromMenu.current = true; startRename() }}>
|
|
<Pencil size={14} /> {tr('displayNameEditEllipsis')}
|
|
</Menu.Item>
|
|
<Menu.Separator className="menu-sep" />
|
|
</>
|
|
)}
|
|
{detail && (
|
|
<>
|
|
{installing ? (
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy || suspended || transitioning} onSelect={() => onAction('finishInstall')}>
|
|
<LifeBuoy size={14} /> {tr('finishInstall')}
|
|
</Menu.Item>
|
|
) : (
|
|
<>
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy || suspended || transitioning} onSelect={() => onAction('enterRecovery')}>
|
|
<LifeBuoy size={14} /> {tr('enterRecovery')}
|
|
</Menu.Item>
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={running || suspended || transitioning || busy} onSelect={() => onAction('cloneVM')}>
|
|
<HostIcon name="clone"><CopyPlus size={14} /></HostIcon> {tr('cloneVM')}
|
|
</Menu.Item>
|
|
</>
|
|
)}
|
|
<Menu.Item className="menu-item rg-p-menu-item" onSelect={onOpenAffinity}>
|
|
<Cpu size={14} /> {tr('affinityMenu')}
|
|
</Menu.Item>
|
|
<Menu.Item className="menu-item rg-p-menu-item" onSelect={() => { renameFromMenu.current = true; startRename() }}>
|
|
<Pencil size={14} /> {tr('displayNameEditEllipsis')}
|
|
</Menu.Item>
|
|
<Menu.Separator className="menu-sep" />
|
|
</>
|
|
)}
|
|
{isMacOSDriver && (
|
|
<Menu.Item className="menu-item rg-p-menu-item" onSelect={() => onAction('openFolder')}>
|
|
<HostIcon name="folder"><FolderOpen size={14} /></HostIcon> {tr('openFolder')}
|
|
</Menu.Item>
|
|
)}
|
|
<Menu.Item className="menu-item rg-p-menu-item" onSelect={onViewLogs}>
|
|
<HostIcon name="logs"><Terminal size={14} /></HostIcon> {tr('viewLogs')}
|
|
</Menu.Item>
|
|
<Menu.Item className="menu-item rg-p-menu-item" disabled={busy} onSelect={() => onAction('exportDiagnostics')}>
|
|
<Archive size={14} /> {tr('exportDiagnostics')}
|
|
</Menu.Item>
|
|
{toolbarMenus.map((m) => {
|
|
const title = locText(m.title, locale, m.id)
|
|
return (
|
|
<Menu.Item
|
|
key={`${m.pluginId}:${m.id}`}
|
|
className="menu-item rg-p-menu-item"
|
|
disabled={busy}
|
|
onSelect={() => onPluginCommand(m.pluginId ?? '', m.command, title)}
|
|
>
|
|
{title}
|
|
</Menu.Item>
|
|
)
|
|
})}
|
|
<Menu.Separator className="menu-sep" />
|
|
{suspended && (
|
|
<Menu.Item className="menu-item rg-p-menu-item danger" disabled={busy} onSelect={() => onAction('discardSuspend')}>
|
|
<Power size={14} /> {tr('discardSuspend')}
|
|
</Menu.Item>
|
|
)}
|
|
{(running || transitioning) && (
|
|
<Menu.Item className="menu-item rg-p-menu-item danger" disabled={busyAction === 'forceStop'} onSelect={() => onAction('forceStop')}>
|
|
<HostIcon name="force-stop"><Power size={14} /></HostIcon> {tr('forceStop')}
|
|
</Menu.Item>
|
|
)}
|
|
<Menu.Item className="menu-item rg-p-menu-item danger" disabled={running || suspended || transitioning || busy} onSelect={onDelete}>
|
|
<HostIcon name="delete"><Trash size={14} /></HostIcon> {tr('delete')}
|
|
</Menu.Item>
|
|
</ActionMenu>
|
|
)
|
|
|
|
const pillClass = running ? ' is-running' : suspended ? ' is-suspended' : state === 'broken' ? ' is-broken' : transitioning ? ' is-busy' : ''
|
|
const dropStyle = detail && !installing
|
|
? ({ '--wails-drop-target': 'drop' } as React.CSSProperties)
|
|
: undefined
|
|
|
|
return (
|
|
<div className="page vm-page vm-page-drop rg-p-vm-page" data-vm-state={state} data-driver={driverID} data-guest-family={guestFamily} style={dropStyle}>
|
|
{dropping && (
|
|
<div className="drop-banner" role="status" aria-live="polite">
|
|
<Upload size={16} aria-hidden="true" />
|
|
<span>{tr('dropFilesHint')}</span>
|
|
</div>
|
|
)}
|
|
{/* Screen + summary: stacked, or side by side when the column is wide (container query in app.css). */}
|
|
<div className="vm-top">
|
|
<section className="vm-hero rg-p-vm-header" aria-labelledby="vm-name">
|
|
<div className="rg-p-vm-preview" style={{ position: 'relative' }}>
|
|
<span data-rg-slot="vm.preview.tl" className="rg-preview-anchor tl" />
|
|
<span data-rg-slot="vm.preview.tr" className="rg-preview-anchor tr" />
|
|
<span data-rg-slot="vm.preview.bl" className="rg-preview-anchor bl" />
|
|
<span data-rg-slot="vm.preview.br" className="rg-preview-anchor br" />
|
|
<VMScreen
|
|
thumb={thumb}
|
|
art={guestArt
|
|
? <GuestArt family={guestFamily} shape="screen" className="vm-screen-art" />
|
|
: <VersionArt shape="screen" className="vm-screen-art" major={macosMajor} name={shownName} />}
|
|
running={running}
|
|
startLabel={suspended ? tr('resume') : tr('start')}
|
|
showLabel={tr('showWindow')}
|
|
shotLabel={tr('copyScreenshot')}
|
|
onStart={!busy && (state === 'stopped' || (suspended && canSuspend)) ? () => onAction(suspended ? 'resume' : 'start') : undefined}
|
|
onShow={running && !busy && features.window ? () => onAction('focus') : undefined}
|
|
onScreenshot={running && !busy && features.screenshot ? () => onAction('screenshot') : undefined}
|
|
/>
|
|
</div>
|
|
{editingName ? (
|
|
<input
|
|
ref={nameInputRef}
|
|
className="vm-name-input"
|
|
value={nameDraft}
|
|
maxLength={60}
|
|
placeholder={name}
|
|
aria-label={tr('displayNameLabel')}
|
|
autoFocus
|
|
onFocus={(e) => e.currentTarget.select()}
|
|
onChange={(e) => setNameDraft(e.target.value)}
|
|
onBlur={() => void saveName()}
|
|
onKeyDown={(e) => {
|
|
if (e.key === 'Enter') { e.preventDefault(); void saveName() }
|
|
if (e.key === 'Escape') { e.preventDefault(); setEditingName(false) }
|
|
}}
|
|
/>
|
|
) : (
|
|
<h1 className="vm-hero-name" id="vm-name">
|
|
<Tip label={displayName ? tr('displayNameTip', { name }) : tr('displayNameEdit')}>
|
|
<button type="button" className="vm-name-btn" onClick={startRename}>
|
|
<span>{shownName}</span>
|
|
<Pencil size={15} className="vm-name-pencil" aria-hidden="true" />
|
|
</button>
|
|
</Tip>
|
|
</h1>
|
|
)}
|
|
<div className={`vm-hero-pill${pillClass}`} role="status">
|
|
<StatusShape kind={statusKind(state)} />
|
|
<span>{tr(`state_${state}` as I18nKey)}</span>
|
|
{running && stats && stats.uptime_seconds > 0 && <span className="vm-hero-uptime">· {formatUptime(stats.uptime_seconds, locale)}</span>}
|
|
{waitingForGuest && <span className="vm-hero-uptime" title={tr('guestWaitingTip')}>· {tr('guestWaiting')}</span>}
|
|
{(phase === 'installer' || phase === 'recovery') && (
|
|
<span className="badge rg-p-badge badge-warn">{tr(phase === 'installer' ? 'phaseInstaller' : 'phaseRecovery')}</span>
|
|
)}
|
|
</div>
|
|
<span className="rg-slot-anchor" data-rg-slot="vm.header.trailing" />
|
|
<div className="vm-hero-actions rg-p-vm-actions">
|
|
{primary}
|
|
{secondary}
|
|
{isMacOSDriver && (
|
|
<Tip label={suspended ? tr('suspendedSettingsHint') : tr('settings')} shortcut={suspended ? undefined : 'Ctrl+,'}>
|
|
<span>
|
|
<Button icon={<Settings size={14} aria-hidden="true" />} disabled={!detail || suspended || transitioning} onClick={onSettings}>{tr('settingsEllipsis')}</Button>
|
|
</span>
|
|
</Tip>
|
|
)}
|
|
{menu}
|
|
<span className="rg-slot-anchor" data-rg-slot="vm.toolbar" />
|
|
</div>
|
|
</section>
|
|
|
|
<VMSummary locale={locale} running={running} detail={detail} vmInfo={vmInfo} isMacOSDriver={isMacOSDriver} guestFamily={guestFamily} host={host} stats={stats} />
|
|
</div>
|
|
|
|
<VMNotices
|
|
locale={locale} state={state} canSuspend={canSuspend} resumeHintId={resumeHintId} detail={detail} stats={stats}
|
|
host={host} pending={pending} busyAction={busyAction} onAction={onAction}
|
|
/>
|
|
|
|
{detail && installing && (!installGuideEnabled || state === 'stopped') && (
|
|
<InstallCard
|
|
key={name} locale={locale} name={name} detail={detail} running={running} installGuideEnabled={installGuideEnabled}
|
|
busyAction={busyAction} onAction={onAction} onCopy={onCopy} onTypeText={onTypeText}
|
|
/>
|
|
)}
|
|
|
|
{detail && (
|
|
<ConnectionSection
|
|
locale={locale} vmKey={vmKey} state={state} detail={detail} stats={stats} pending={pending} currentAgentVersion={currentAgentVersion}
|
|
installing={installing} guestToolsLocked={guestToolsLocked} canUseHostDNS={canUseHostDNS} ssh={ssh} hostDNS={hostDNS}
|
|
busyAction={busyAction} onAction={onAction} onCopy={onCopy} onTypeText={onTypeText}
|
|
onTogglePreventSleep={onTogglePreventSleep} onDeliverFile={onDeliverFile}
|
|
/>
|
|
)}
|
|
|
|
{!isMacOSDriver && <EndpointSection locale={locale} endpoints={vmInfo?.endpoints} promotedEndpoint={promotedEndpoint} state={endpoints} />}
|
|
|
|
<SnapshotSection
|
|
locale={locale} driverID={driverID} name={name} state={state} shown={showSnapshots}
|
|
locked={running || suspended || transitioning} onToast={onToast} onError={onError}
|
|
/>
|
|
|
|
<TechInfo locale={locale} name={name} driverID={driverID} detail={detail} vmInfo={vmInfo} onCopy={onCopy} />
|
|
|
|
{/* These keys only work inside the VM window, so they show while it runs. */}
|
|
{detail && running && (detail.graphics === 'vmware-svga' ? (
|
|
<p className="vm-footnote">
|
|
<kbd>Ctrl+Alt+F</kbd> {tr('shortcutBarFullscreen')}
|
|
<span className="sep">·</span>
|
|
<kbd>Ctrl+Alt+G</kbd> {tr('shortcutBarRelease')}
|
|
</p>
|
|
) : (!detail.capture_supported || detail.capture) ? (
|
|
<p className="vm-footnote">
|
|
<kbd>Ctrl+Alt+Win</kbd> {tr('shortcutBarRelease')}
|
|
</p>
|
|
) : null)}
|
|
|
|
<SSHUserDialog locale={locale} state={ssh} />
|
|
</div>
|
|
)
|
|
}
|