Add dashboard backup catalog and health tools
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import ActivityPanel from "./ActivityPanel"
|
||||
import SandboxHealthPanel from "./SandboxHealthPanel"
|
||||
import type { SandboxInventoryItem } from "../hooks/useSandboxInventory"
|
||||
|
||||
const helpSections = [
|
||||
{
|
||||
title: "Daily Flow",
|
||||
@@ -30,6 +35,7 @@ const helpSections = [
|
||||
title: "Backup / Restore",
|
||||
items: [
|
||||
"Backup downloads a compressed .tar.gz archive from a sandbox directory, usually /sandbox.",
|
||||
"Save to Catalog stores a backup on the controller host for later cloning or redeploying.",
|
||||
"Restore extracts a .tar.gz archive into the selected sandbox path.",
|
||||
"Replace target contents deletes existing files in the target directory before extraction; merge leaves existing files in place.",
|
||||
],
|
||||
@@ -52,9 +58,81 @@ const helpSections = [
|
||||
},
|
||||
]
|
||||
|
||||
export default function HelpPanel() {
|
||||
function HealthAccordion({ sandboxes }: { sandboxes: SandboxInventoryItem[] }) {
|
||||
const [open, setOpen] = useState(true)
|
||||
const [selectedSandboxId, setSelectedSandboxId] = useState("")
|
||||
const selectedSandbox = useMemo(
|
||||
() => sandboxes.find((sandbox) => sandbox.id === selectedSandboxId) || sandboxes[0] || null,
|
||||
[sandboxes, selectedSandboxId],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedSandboxId && sandboxes[0]) {
|
||||
setSelectedSandboxId(sandboxes[0].id)
|
||||
}
|
||||
}, [sandboxes, selectedSandboxId])
|
||||
|
||||
return (
|
||||
<section className="panel overflow-hidden">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen((current) => !current)}
|
||||
aria-expanded={open}
|
||||
className="flex w-full items-center justify-between gap-4 p-5 text-left"
|
||||
>
|
||||
<div>
|
||||
<p className="text-[10px] font-mono uppercase tracking-wider text-[var(--nvidia-green)]">Operator Checks</p>
|
||||
<h2 className="mt-1 text-sm font-semibold uppercase tracking-wider text-[var(--foreground)]">Sandbox Health</h2>
|
||||
<p className="mt-1 text-xs text-[var(--foreground-dim)]">OpenShell reachability, runtime state, SSH config, and backup coverage.</p>
|
||||
</div>
|
||||
<svg
|
||||
className={`h-4 w-4 shrink-0 text-[var(--foreground-dim)] transition-transform ${open ? "rotate-90" : ""}`}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<div className="space-y-4 border-t border-[var(--border-subtle)] p-5">
|
||||
{sandboxes.length > 1 && (
|
||||
<label className="block max-w-lg space-y-2">
|
||||
<span className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox</span>
|
||||
<select
|
||||
value={selectedSandbox?.id || ""}
|
||||
onChange={(event) => setSelectedSandboxId(event.target.value)}
|
||||
className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground)] focus:border-[var(--nvidia-green)] focus:outline-none"
|
||||
>
|
||||
{sandboxes.map((sandbox) => (
|
||||
<option key={sandbox.id} value={sandbox.id}>
|
||||
{sandbox.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
|
||||
{selectedSandbox ? (
|
||||
<SandboxHealthPanel sandbox={selectedSandbox} />
|
||||
) : (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4 text-sm text-[var(--foreground-dim)]">
|
||||
No sandboxes are available for health checks yet.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default function HelpPanel({ sandboxes }: { sandboxes: SandboxInventoryItem[] }) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<HealthAccordion sandboxes={sandboxes} />
|
||||
|
||||
<section className="panel p-8">
|
||||
<p className="text-[10px] font-mono uppercase tracking-wider text-[var(--nvidia-green)]">Operator Guide</p>
|
||||
<h1 className="mt-2 text-xl font-semibold uppercase tracking-wider text-[var(--foreground)]">Help</h1>
|
||||
@@ -94,6 +172,8 @@ export default function HelpPanel() {
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<ActivityPanel />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user