Refacto storage tab

This commit is contained in:
Pierre HUBERT 2024-01-02 19:58:36 +01:00
parent 767d2015df
commit a8046ebff8
2 changed files with 43 additions and 34 deletions

View File

@ -23,27 +23,6 @@ export function VMSelectIsoInput(p: {
return ( return (
<> <>
<SelectInput
label="Attach an ISO file"
editable={p.editable}
value={undefined}
onValueChange={(v) => {
if (v) {
p.attachedISOs.push(v);
p.onChange(p.attachedISOs);
}
}}
options={[
{ label: "None", value: undefined },
...p.isoList.map((i) => {
return {
label: `${i.filename} ${filesize(i.size)}`,
value: i.filename,
};
}),
]}
/>
{p.attachedISOs.map((isoName, num) => { {p.attachedISOs.map((isoName, num) => {
const iso = p.isoList.find((d) => d.filename === isoName); const iso = p.isoList.find((d) => d.filename === isoName);
return ( return (
@ -78,6 +57,27 @@ export function VMSelectIsoInput(p: {
</ListItem> </ListItem>
); );
})} })}
<SelectInput
label="Attach an ISO file"
editable={p.editable}
value={undefined}
onValueChange={(v) => {
if (v) {
p.attachedISOs.push(v);
p.onChange(p.attachedISOs);
}
}}
options={[
{ label: "None", value: undefined },
...p.isoList.map((i) => {
return {
label: `${i.filename} ${filesize(i.size)}`,
value: i.filename,
};
}),
]}
/>
</> </>
); );
} }

View File

@ -258,11 +258,20 @@ function VMDetailsTabGeneral(p: DetailsInnerProps): React.ReactElement {
); );
} }
/**
* Storage section
*/
function VMDetailsTabStorage(p: DetailsInnerProps): React.ReactElement { function VMDetailsTabStorage(p: DetailsInnerProps): React.ReactElement {
return ( return (
<Grid container spacing={2}> <Grid container spacing={2}>
{/* Storage section */} {p.editable && p.vm.disks.length > 0 && (
<EditSection title="Storage"> <EditSection title="Disks storage">
<VMDisksList {...p} />
</EditSection>
)}
{(p.editable || p.vm.iso_files.length > 0) && (
<EditSection title="ISO storage">
<VMSelectIsoInput <VMSelectIsoInput
editable={p.editable} editable={p.editable}
isoList={p.isoList} isoList={p.isoList}
@ -272,8 +281,8 @@ function VMDetailsTabStorage(p: DetailsInnerProps): React.ReactElement {
p.onChange?.(); p.onChange?.();
}} }}
/> />
<VMDisksList {...p} />
</EditSection> </EditSection>
)}
</Grid> </Grid>
); );
} }