Skip to content

Commit

Permalink
Cleanup (#1001)
Browse files Browse the repository at this point in the history
## Done

- remove unused component for instance devices
- remove unused functions for instance and profile devices
- Clean up proxy device code
  • Loading branch information
edlerd authored Nov 25, 2024
2 parents 46ee650 + af6fd99 commit 4f5b822
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 134 deletions.
90 changes: 0 additions & 90 deletions src/pages/instances/InstanceOverviewDevices.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/util/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { LxdNetwork } from "types/network";
import { LxdStorageVolume } from "types/storage";
import { Dispatch, SetStateAction } from "react";
import crypto from "crypto";
import { LxdDeviceValue } from "types/device";
import { isDiskDevice } from "./devices";
import { isRootDisk } from "./instanceValidation";
import { FormDevice } from "./formDevices";
Expand Down Expand Up @@ -322,18 +321,6 @@ export const getUniqueResourceName = (
return name;
};

export const getInstanceDevices = (
instance: LxdInstance,
): [string, LxdDeviceValue][] => {
return Object.entries(instance.expanded_devices ?? {});
};

export const getProfileDevices = (
profile: LxdProfile,
): [string, LxdDeviceValue][] => {
return Object.entries(profile.devices ?? {});
};

export const getRootPool = (instance: LxdInstance): string => {
const rootStorage = Object.values(instance.expanded_devices ?? {})
.filter(isDiskDevice)
Expand Down
62 changes: 31 additions & 31 deletions src/util/proxyDevices.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Input, Label, Select } from "@canonical/react-components";
import { MainTableRow } from "@canonical/react-components/dist/components/MainTable/MainTable";
import { getConfigurationRowBase } from "components/ConfigurationRow";
import { LxdProxyDevice } from "types/device";
import { ensureEditMode } from "./instanceEdit";
import { proxyAddressTypeOptions } from "./instanceOptions";
import { InstanceAndProfileFormikProps } from "components/forms/instanceAndProfileFormValues";
import { MainTableRow } from "@canonical/react-components/dist/components/MainTable/MainTable";

type ConnectionType = "listen" | "connect";

Expand Down Expand Up @@ -129,35 +129,35 @@ export const getProxyAddress = (
}),
);

deviceType === "unix"
? null
: customRows.push(
getConfigurationRowBase({
className: "no-border-top inherited-with-form",
configuration: (
<Label forId={`devices.${index}.${connectionType}.port`} required>
Port
</Label>
),
if (deviceType !== "unix") {
customRows.push(
getConfigurationRowBase({
className: "no-border-top inherited-with-form",
configuration: (
<Label forId={`devices.${index}.${connectionType}.port`} required>
Port
</Label>
),

inherited: (
<Input
id={`devices.${index}.${connectionType}.port`}
onChange={(e) => {
ensureEditMode(formik);
const newPort = e.target.value;
void formik.setFieldValue(
`devices.${index}.${connectionType}`,
`${deviceType}:${deviceAddress}:${newPort}`,
);
}}
value={devicePort}
placeholder="00[-00]"
type="text"
className="u-no-margin--bottom"
/>
),
override: "",
}),
);
inherited: (
<Input
id={`devices.${index}.${connectionType}.port`}
onChange={(e) => {
ensureEditMode(formik);
const newPort = e.target.value;
void formik.setFieldValue(
`devices.${index}.${connectionType}`,
`${deviceType}:${deviceAddress}:${newPort}`,
);
}}
value={devicePort}
placeholder="00[-00]"
type="text"
className="u-no-margin--bottom"
/>
),
override: "",
}),
);
}
};

0 comments on commit 4f5b822

Please sign in to comment.