import { Grid, Paper, Typography } from "@mui/material";
import { PropsWithChildren } from "react";
import { validate as validateUUID } from "uuid";
import { ServerApi } from "../../api/ServerApi";
import { VMInfo } from "../../api/VMApi";
import { CheckboxInput } from "../forms/CheckboxInput";
import { SelectInput } from "../forms/SelectInput";
import { TextInput } from "../forms/TextInput";
export function VMDetails(p: {
vm: VMInfo;
editable: boolean;
onChange?: () => void;
}): React.ReactElement {
return (
{/* Metadata section */}
{
p.vm.name = v ?? "";
p.onChange?.();
}}
size={ServerApi.Config.constraints.name_size}
/>
{
p.vm.genid = v;
p.onChange?.();
}}
checkValue={(v) => validateUUID(v)}
/>
{
p.vm.title = v;
p.onChange?.();
}}
size={ServerApi.Config.constraints.title_size}
/>
{
p.vm.description = v;
p.onChange?.();
}}
multiline={true}
/>
{/* General section */}
{
p.vm.architecture = v! as any;
p.onChange?.();
}}
value={p.vm.architecture}
options={[
{ label: "i686", value: "i686" },
{ label: "x86_64", value: "x86_64" },
]}
/>
{
p.vm.boot_type = v! as any;
p.onChange?.();
}}
value={p.vm.boot_type}
options={[
{ label: "UEFI with Secure Boot", value: "UEFISecureBoot" },
{ label: "UEFI", value: "UEFI" },
]}
/>
{
p.vm.memory = Number(v ?? "0");
p.onChange?.();
}}
checkValue={(v) =>
Number(v) > ServerApi.Config.constraints.memory_size.min &&
Number(v) < ServerApi.Config.constraints.memory_size.max
}
/>
{
p.vm.vnc_access = v;
p.onChange?.();
}}
/>
);
}
function EditSection(
p: { title: string } & PropsWithChildren
): React.ReactElement {
return (
{p.title}
{p.children}
);
}