Make network configuration editable
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import Editor from "@monaco-editor/react";
|
||||
import BookIcon from "@mui/icons-material/Book";
|
||||
import RefreshIcon from "@mui/icons-material/Refresh";
|
||||
import { Grid, IconButton, InputAdornment, Tooltip } from "@mui/material";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { VMInfo } from "../../api/VMApi";
|
||||
import { RouterLink } from "../RouterLink";
|
||||
import { CheckboxInput } from "./CheckboxInput";
|
||||
import { EditSection } from "./EditSection";
|
||||
import { SelectInput } from "./SelectInput";
|
||||
@ -38,6 +40,10 @@ export function CloudInitEditor(p: CloudInitProps): React.ReactElement {
|
||||
{...p}
|
||||
editable={p.editable && p.vm.cloud_init.attach_config}
|
||||
/>
|
||||
<CloudInitNetworkConfig
|
||||
{...p}
|
||||
editable={p.editable && p.vm.cloud_init.attach_config}
|
||||
/>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
@ -108,7 +114,21 @@ function CloudInitMetadata(p: CloudInitProps): React.ReactElement {
|
||||
|
||||
function CloudInitRawUserData(p: CloudInitProps): React.ReactElement {
|
||||
return (
|
||||
<EditSection title="User data">
|
||||
<EditSection
|
||||
title="User data"
|
||||
actions={
|
||||
<RouterLink
|
||||
target="_blank"
|
||||
to="https://cloudinit.readthedocs.io/en/latest/reference/index.html"
|
||||
>
|
||||
<Tooltip title="Official reference">
|
||||
<IconButton size="small">
|
||||
<BookIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</RouterLink>
|
||||
}
|
||||
>
|
||||
<Editor
|
||||
theme="vs-dark"
|
||||
options={{
|
||||
@ -126,3 +146,40 @@ function CloudInitRawUserData(p: CloudInitProps): React.ReactElement {
|
||||
</EditSection>
|
||||
);
|
||||
}
|
||||
|
||||
function CloudInitNetworkConfig(p: CloudInitProps): React.ReactElement {
|
||||
if (!p.editable && !p.vm.cloud_init.network_configuration) return <></>;
|
||||
return (
|
||||
<EditSection
|
||||
title="Network configuration"
|
||||
actions={
|
||||
<RouterLink
|
||||
target="_blank"
|
||||
to="https://cloudinit.readthedocs.io/en/latest/reference/network-config-format-v2.html"
|
||||
>
|
||||
<Tooltip title="Official network configuration reference">
|
||||
<IconButton size="small">
|
||||
<BookIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</RouterLink>
|
||||
}
|
||||
>
|
||||
<Editor
|
||||
theme="vs-dark"
|
||||
options={{
|
||||
readOnly: !p.editable,
|
||||
quickSuggestions: { other: true, comments: true, strings: true },
|
||||
}}
|
||||
language="yaml"
|
||||
height={"30vh"}
|
||||
value={p.vm.cloud_init.network_configuration ?? ""}
|
||||
onChange={(v) => {
|
||||
if (v && v !== "") p.vm.cloud_init.network_configuration = v;
|
||||
else p.vm.cloud_init.network_configuration = undefined;
|
||||
p.onChange?.();
|
||||
}}
|
||||
/>
|
||||
</EditSection>
|
||||
);
|
||||
}
|
||||
|
@ -19,13 +19,10 @@ export function EditSection(
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
marginBottom: "15px",
|
||||
}}
|
||||
>
|
||||
{p.title && (
|
||||
<Typography variant="h5" style={{ marginBottom: "15px" }}>
|
||||
{p.title}
|
||||
</Typography>
|
||||
)}
|
||||
{p.title && <Typography variant="h5">{p.title}</Typography>}
|
||||
{p.actions}
|
||||
</span>
|
||||
)}
|
||||
|
Reference in New Issue
Block a user