- Runtime: list and fetch runtimes from this repo's GitHub Releases (stable by default, candidate on request), with SHA256 check and resume. CLI gains `runtime available` and `runtime fetch`; the host page gets an online install row and a "receive candidates" switch. - First launch: pick a data folder (non-system drives first, USB never recommended); the choice is recorded in %APPDATA%\reims-go\location.json. Existing installs in the default folder are adopted without asking. - pack-runtime.ps1: also builds the matching source package, records every patch with its SHA256 and the channel, and refuses undeclared changes in the build trees. - patches: declare reims-vgpu-cargo-lock.patch (Cargo.lock source lines). - UI: sidebar and VM page restyle, new design tokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
91 lines
3.1 KiB
TypeScript
91 lines
3.1 KiB
TypeScript
import { Cpu, Monitor, Plus } from 'lucide-react'
|
||
import React, { useRef } from 'react'
|
||
import { I18nKey, t } from '../i18n'
|
||
import { Locale, VMListItem } from '../types'
|
||
import { IconButton, StatusShape, Tip, statusKind } from '../ui/controls'
|
||
|
||
export const HOST_ID = '__host__'
|
||
|
||
interface Props {
|
||
locale: Locale
|
||
vms: VMListItem[]
|
||
transitions: Record<string, string>
|
||
selected: string
|
||
hostReady: boolean
|
||
onSelect: (id: string) => void
|
||
onNew: () => void
|
||
}
|
||
|
||
export const Sidebar: React.FC<Props> = ({ locale, vms, transitions, selected, hostReady, onSelect, onNew }) => {
|
||
const listRef = useRef<HTMLDivElement>(null)
|
||
const ids = [...vms.map((v) => v.name), HOST_ID]
|
||
|
||
// Listbox keyboard model: ↑/↓/Home/End move selection and focus together.
|
||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||
const idx = ids.indexOf(selected)
|
||
let next = -1
|
||
if (e.key === 'ArrowDown') next = Math.min(ids.length - 1, idx + 1)
|
||
else if (e.key === 'ArrowUp') next = Math.max(0, idx - 1)
|
||
else if (e.key === 'Home') next = 0
|
||
else if (e.key === 'End') next = ids.length - 1
|
||
if (next < 0) return
|
||
e.preventDefault()
|
||
onSelect(ids[next])
|
||
listRef.current?.querySelector<HTMLElement>(`[data-id="${CSS.escape(ids[next])}"]`)?.focus()
|
||
}
|
||
|
||
const item = (
|
||
id: string,
|
||
label: string,
|
||
icon: React.ReactNode,
|
||
badgeClass: string,
|
||
stateLabel: string,
|
||
kind: ReturnType<typeof statusKind>,
|
||
) => (
|
||
<button
|
||
key={id}
|
||
type="button"
|
||
role="option"
|
||
data-id={id}
|
||
className="nav-item"
|
||
aria-selected={selected === id}
|
||
aria-label={`${label},${stateLabel}`}
|
||
tabIndex={selected === id ? 0 : -1}
|
||
onClick={() => onSelect(id)}
|
||
>
|
||
<span className={`nav-icon-badge ${badgeClass}`} aria-hidden="true">{icon}</span>
|
||
<span className="nav-label">{label}</span>
|
||
<Tip label={stateLabel} side="right">
|
||
<span className="hstack"><StatusShape kind={kind} /></span>
|
||
</Tip>
|
||
</button>
|
||
)
|
||
|
||
return (
|
||
<div className="sidebar-wrap">
|
||
<aside className="sidebar">
|
||
<div className="sidebar-head">
|
||
<span>{t(locale, 'sidebarVMs')}</span>
|
||
<IconButton small label={t(locale, 'newVM')} shortcut="Ctrl+N" icon={<Plus size={15} />} onClick={onNew} tipSide="right" />
|
||
</div>
|
||
<div className="nav" role="listbox" aria-label={t(locale, 'sidebarVMs')} ref={listRef} onKeyDown={onKeyDown}>
|
||
{vms.length === 0 && <div className="nav-empty">{t(locale, 'emptyVMs')}</div>}
|
||
{vms.map((vm) => {
|
||
const st = transitions[vm.name] ?? vm.state
|
||
return item(vm.name, vm.name, <Monitor size={13} />, 'nav-icon-vm', t(locale, `state_${st}` as I18nKey), statusKind(st))
|
||
})}
|
||
<div className="sidebar-sep" role="presentation" />
|
||
{item(
|
||
HOST_ID,
|
||
t(locale, 'sidebarHost'),
|
||
<Cpu size={13} />,
|
||
'nav-icon-host',
|
||
t(locale, hostReady ? 'hostReady' : 'hostNeedsAction'),
|
||
hostReady ? 'running' : 'warn',
|
||
)}
|
||
</div>
|
||
</aside>
|
||
</div>
|
||
)
|
||
}
|