This commit is contained in:
		@@ -29,11 +29,9 @@ export interface BaseFileVMDisk {
 | 
			
		||||
  deleteType?: "keepfile" | "deletefile";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type DiskAllocType = "Sparse" | "Fixed";
 | 
			
		||||
 | 
			
		||||
interface RawVMDisk {
 | 
			
		||||
  format: "Raw";
 | 
			
		||||
  alloc_type: DiskAllocType;
 | 
			
		||||
  is_sparse: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface QCow2Disk {
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,6 @@ import { ServerApi } from "../api/ServerApi";
 | 
			
		||||
import { VMFileDisk, VMInfo } from "../api/VMApi";
 | 
			
		||||
import { useAlert } from "../hooks/providers/AlertDialogProvider";
 | 
			
		||||
import { useLoadingMessage } from "../hooks/providers/LoadingMessageProvider";
 | 
			
		||||
import { useSnackbar } from "../hooks/providers/SnackbarProvider";
 | 
			
		||||
import { FileDiskImageWidget } from "../widgets/FileDiskImageWidget";
 | 
			
		||||
import { CheckboxInput } from "../widgets/forms/CheckboxInput";
 | 
			
		||||
import { SelectInput } from "../widgets/forms/SelectInput";
 | 
			
		||||
 
 | 
			
		||||
@@ -13,13 +13,14 @@ import {
 | 
			
		||||
  Tooltip,
 | 
			
		||||
} from "@mui/material";
 | 
			
		||||
import { filesize } from "filesize";
 | 
			
		||||
import React from "react";
 | 
			
		||||
import { ServerApi } from "../../api/ServerApi";
 | 
			
		||||
import { VMFileDisk, VMInfo, VMState } from "../../api/VMApi";
 | 
			
		||||
import { ConvertDiskImageDialog } from "../../dialogs/ConvertDiskImageDialog";
 | 
			
		||||
import { useConfirm } from "../../hooks/providers/ConfirmDialogProvider";
 | 
			
		||||
import { CheckboxInput } from "./CheckboxInput";
 | 
			
		||||
import { SelectInput } from "./SelectInput";
 | 
			
		||||
import { TextInput } from "./TextInput";
 | 
			
		||||
import React from "react";
 | 
			
		||||
import { ConvertDiskImageDialog } from "../../dialogs/ConvertDiskImageDialog";
 | 
			
		||||
 | 
			
		||||
export function VMDisksList(p: {
 | 
			
		||||
  vm: VMInfo;
 | 
			
		||||
@@ -166,7 +167,9 @@ function DiskInfo(p: {
 | 
			
		||||
            </>
 | 
			
		||||
          }
 | 
			
		||||
          secondary={`${filesize(p.disk.size)} - ${p.disk.format}${
 | 
			
		||||
            p.disk.format == "Raw" ? " - " + p.disk.alloc_type : ""
 | 
			
		||||
            p.disk.format == "Raw"
 | 
			
		||||
              ? " - " + (p.disk.is_sparse ? "Sparse" : "Fixed")
 | 
			
		||||
              : ""
 | 
			
		||||
          }`}
 | 
			
		||||
        />
 | 
			
		||||
      </ListItem>
 | 
			
		||||
@@ -218,21 +221,20 @@ function DiskInfo(p: {
 | 
			
		||||
        value={p.disk.format}
 | 
			
		||||
        onValueChange={(v) => {
 | 
			
		||||
          p.disk.format = v as any;
 | 
			
		||||
 | 
			
		||||
          if (p.disk.format === "Raw") p.disk.is_sparse = true;
 | 
			
		||||
 | 
			
		||||
          p.onChange?.();
 | 
			
		||||
        }}
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
      {p.disk.format === "Raw" && (
 | 
			
		||||
        <SelectInput
 | 
			
		||||
          editable={true}
 | 
			
		||||
          label="File allocation type"
 | 
			
		||||
          options={[
 | 
			
		||||
            { label: "Sparse allocation", value: "Sparse" },
 | 
			
		||||
            { label: "Fixed allocation", value: "Fixed" },
 | 
			
		||||
          ]}
 | 
			
		||||
          value={p.disk.alloc_type}
 | 
			
		||||
        <CheckboxInput
 | 
			
		||||
          editable
 | 
			
		||||
          label="Sparse file"
 | 
			
		||||
          checked={p.disk.is_sparse}
 | 
			
		||||
          onValueChange={(v) => {
 | 
			
		||||
            if (p.disk.format === "Raw") p.disk.alloc_type = v as any;
 | 
			
		||||
            if (p.disk.format === "Raw") p.disk.is_sparse = v;
 | 
			
		||||
            p.onChange?.();
 | 
			
		||||
          }}
 | 
			
		||||
        />
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user