Skip to content

Commit

Permalink
Show network parent in read and edit mode, when lxd is not clustered (#…
Browse files Browse the repository at this point in the history
…911)

## Done

- Show network parent in read and edit mode, when lxd is not clustered
- In clustered mode we can not read the parent, thus hiding it for now.

## QA

1. Run the LXD-UI:
- On the demo server via the link posted by @webteam-app below. This is
only available for PRs created by collaborators of the repo. Ask
@mas-who or @edlerd for access.
- With a local copy of this branch, [build and run as described in the
docs](../CONTRIBUTING.md#setting-up-for-development).
2. Perform the following QA steps:
- edit a network that is of type physical in a clustered and
non-clustered lxd.
  • Loading branch information
edlerd authored Sep 18, 2024
2 parents f2d9768 + 7fb43e9 commit a8f5c73
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/pages/networks/forms/NetworkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { getHandledNetworkConfigKeys, getNetworkKey } from "util/networks";
import NetworkFormOvn from "pages/networks/forms/NetworkFormOvn";
import YamlNotification from "components/forms/YamlNotification";
import { ensureEditMode } from "util/instanceEdit";
import { useSettings } from "context/useSettings";
import { isClusteredServer } from "util/settings";

export interface NetworkFormValues {
readOnly: boolean;
Expand Down Expand Up @@ -166,6 +168,8 @@ const NetworkForm: FC<Props> = ({
}) => {
const docBaseLink = useDocs();
const notify = useNotify();
const { data: settings } = useSettings();
const isClustered = isClusteredServer(settings);

const updateFormHeight = () => {
updateMaxHeight("form-contents", "p-bottom-controls");
Expand All @@ -187,7 +191,11 @@ const NetworkForm: FC<Props> = ({
<Row className="form-contents" key={section}>
<Col size={12}>
{section === slugify(MAIN_CONFIGURATION) && (
<NetworkFormMain formik={formik} project={project} />
<NetworkFormMain
formik={formik}
project={project}
isClustered={isClustered}
/>
)}
{section === slugify(BRIDGE) && <NetworkFormBridge formik={formik} />}
{section === slugify(DNS) && <NetworkFormDns formik={formik} />}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/networks/forms/NetworkFormMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { ensureEditMode } from "util/instanceEdit";
interface Props {
formik: FormikProps<NetworkFormValues>;
project: string;
isClustered: boolean;
}

const NetworkFormMain: FC<Props> = ({ formik, project }) => {
const NetworkFormMain: FC<Props> = ({ formik, project, isClustered }) => {
const getFormProps = (id: "network" | "name" | "description" | "parent") => {
return {
id: id,
Expand Down Expand Up @@ -59,7 +60,7 @@ const NetworkFormMain: FC<Props> = ({ formik, project }) => {
<UplinkSelector props={getFormProps("network")} project={project} />
)}
{formik.values.networkType === "physical" &&
formik.values.isCreating && (
(formik.values.isCreating || !isClustered) && (
<NetworkParentSelector props={getFormProps("parent")} />
)}
</Col>
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const createNetwork = async (
await page.getByRole("button", { name: "Create network" }).click();
await page.getByRole("heading", { name: "Create a network" }).click();
await page.getByLabel("Type").selectOption(type);
await page.getByLabel("Name").click();
await page.getByLabel("Name").fill(network);
await page.getByLabel("Name", { exact: true }).click();
await page.getByLabel("Name", { exact: true }).fill(network);
if (type === "physical") {
await page.getByLabel("Parent").selectOption({ index: 1 });
}
Expand Down

0 comments on commit a8f5c73

Please sign in to comment.