Skip to content

Commit

Permalink
feat(network) resolve design review comments from network overhaul
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd committed Jan 9, 2025
1 parent 55cbe9f commit ee27b49
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 36 deletions.
11 changes: 9 additions & 2 deletions src/components/UsedByItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ interface Props {
activeProject: string;
type: ResourceIconType;
to: string;
projectLinkDetailPage?: string;
}

const UsedByItem: FC<Props> = ({ item, activeProject, type, to }) => {
const UsedByItem: FC<Props> = ({
item,
activeProject,
type,
to,
projectLinkDetailPage = "instances",
}) => {
const { data: images = [] } = useQuery({
queryKey: [queryKeys.images],
queryFn: () => fetchImageList(activeProject),
Expand All @@ -30,7 +37,7 @@ const UsedByItem: FC<Props> = ({ item, activeProject, type, to }) => {
<ResourceLink
type="project"
value={item.project}
to={`/ui/project/${item.project}/instances`}
to={`/ui/project/${item.project}/${projectLinkDetailPage}`}
/>{" "}
/{" "}
</>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/networks/CreateNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const CreateNetwork: FC = () => {
name: "",
networkType: hasOvn ? "ovn" : "bridge",
entityType: "network",
ipv4_address: "auto",
ipv6_address: "auto",
},
validationSchema: NetworkSchema,
onSubmit: (values) => {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/networks/EditNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { slugify } from "util/slugify";
import { useLocation, useNavigate } from "react-router-dom";
import {
GENERAL,
TOPOLOGY,
CONNECTIONS,
YAML_CONFIGURATION,
} from "pages/networks/forms/NetworkFormMenu";
import FormFooterLayout from "components/forms/FormFooterLayout";
Expand All @@ -38,7 +38,7 @@ const EditNetwork: FC<Props> = ({ network, project }) => {
const notify = useNotify();
const toastNotify = useToastNotification();
const { hash } = useLocation();
const initialSection = hash ? hash.substring(1) : slugify(TOPOLOGY);
const initialSection = hash ? hash.substring(1) : slugify(CONNECTIONS);
const [section, updateSection] = useState(initialSection);

const queryClient = useQueryClient();
Expand Down Expand Up @@ -121,7 +121,7 @@ const EditNetwork: FC<Props> = ({ network, project }) => {
if (source === "click") {
const baseUrl = `/ui/project/${project}/network/${network.name}`;
if (newSection === GENERAL) {
voidnavigate(baseUrl);
void navigate(baseUrl);
} else {
void navigate(`${baseUrl}/#${slugify(newSection)}`);
}
Expand Down
21 changes: 11 additions & 10 deletions src/pages/networks/NetworkTopology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC, useState } from "react";
import { FormikProps } from "formik/dist/types";
import { NetworkFormValues } from "pages/networks/forms/NetworkForm";
import { slugify } from "util/slugify";
import { TOPOLOGY } from "pages/networks/forms/NetworkFormMenu";
import { CONNECTIONS } from "pages/networks/forms/NetworkFormMenu";
import ResourceLink from "components/ResourceLink";
import { filterUsedByType } from "util/usedBy";
import { Button, Icon } from "@canonical/react-components";
Expand All @@ -18,7 +18,8 @@ interface Props {
}

const NetworkTopology: FC<Props> = ({ formik, project }) => {
const [isCollapsed, setCollapsed] = useState(true);
const [isNetworksCollapsed, setNetworksCollapsed] = useState(true);
const [isInstancesCollapsed, setInstancesCollapsed] = useState(true);
const network = formik.values.bareNetwork;

if (!network) {
Expand All @@ -41,8 +42,8 @@ const NetworkTopology: FC<Props> = ({ formik, project }) => {

return (
<>
<h2 className="p-heading--4" id={slugify(TOPOLOGY)}>
Topology
<h2 className="p-heading--4" id={slugify(CONNECTIONS)}>
Connections
</h2>
<div className="u-sv3 network-topology">
{uplink && (
Expand Down Expand Up @@ -73,7 +74,7 @@ const NetworkTopology: FC<Props> = ({ formik, project }) => {
</div>
<div className="downstream">
{downstreamNetworks
.slice(0, isCollapsed ? 5 : downstreamNetworks.length)
.slice(0, isNetworksCollapsed ? 5 : downstreamNetworks.length)
.map((item) => {
const networkUrl = `/ui/project/default/network/${item.name}`;
return (
Expand All @@ -91,19 +92,19 @@ const NetworkTopology: FC<Props> = ({ formik, project }) => {
</div>
);
})}
{downstreamNetworks.length > 5 && isCollapsed && (
{downstreamNetworks.length > 5 && isNetworksCollapsed && (
<div className="downstream-item">
<Button
appearance="link"
onClick={() => setCollapsed(false)}
onClick={() => setNetworksCollapsed(false)}
small
>
Show all
</Button>
</div>
)}
{instances
.slice(0, isCollapsed ? 5 : instances.length)
.slice(0, isInstancesCollapsed ? 5 : instances.length)
.map((item) => {
const instanceUrl = `/ui/project/${item.project}/instance/${item.name}`;
return (
Expand All @@ -116,11 +117,11 @@ const NetworkTopology: FC<Props> = ({ formik, project }) => {
</div>
);
})}
{instances.length > 5 && isCollapsed && (
{instances.length > 5 && isInstancesCollapsed && (
<div className="downstream-item">
<Button
appearance="link"
onClick={() => setCollapsed(false)}
onClick={() => setInstancesCollapsed(false)}
small
>
Show all
Expand Down
4 changes: 2 additions & 2 deletions src/pages/networks/forms/IpAddressSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const IpAddressSelector: FC<Props> = ({ id, address, setAddress, family }) => {
<>
<div className="ip-address-selector">
<RadioInput
label="auto"
label="Auto"
checked={address === "auto"}
onChange={() => setAddress("auto")}
/>
<RadioInput
label="none"
label="None"
checked={address === "none"}
onChange={() => setAddress("none")}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/networks/forms/NetworkFormBridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const NetworkFormBridge: FC<Props> = ({ formik, filterRows }) => {
getConfigurationRow({
formik,
name: "bridge_driver",
label: "Bridge driver",
label: "Driver",
defaultValue: "",
children: (
<Select
Expand Down
2 changes: 1 addition & 1 deletion src/pages/networks/forms/NetworkFormMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MenuItem from "components/forms/FormMenuItem";
import { FormikProps } from "formik/dist/types";
import { NetworkFormValues } from "pages/networks/forms/NetworkForm";

export const TOPOLOGY = "Topology";
export const CONNECTIONS = "Connections";
export const GENERAL = "General";
export const BRIDGE = "Bridge";
export const DNS = "DNS";
Expand Down
1 change: 1 addition & 0 deletions src/pages/networks/forms/NetworkProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const NetworkProfiles: FC<Props> = ({ formik, project }) => {
activeProject={project}
type="profile"
to={`/ui/project/${item.project}/profile/${item.name}`}
projectLinkDetailPage="profiles"
/>
))}
/>
Expand Down
4 changes: 0 additions & 4 deletions src/sass/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@

.ip-address-custom {
align-items: flex-start;

> :nth-child(2) {
margin-top: -5px;
}
}

.snapshot-schedule {
Expand Down
12 changes: 12 additions & 0 deletions src/sass/_network_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
.create-network > .row,
.edit-network > .row {
padding-right: 0;

.content-details,
.p-bottom-controls {
display: block;
overflow: auto;
padding-right: $sph--x-large;
scrollbar-gutter: stable;

.bottom-btns {
max-width: 54rem;
}
}
}

.edit-network .p-notification--negative {
Expand Down
28 changes: 16 additions & 12 deletions src/sass/_network_topology.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,39 @@
}
}

.resource-link .p-chip__value {
max-width: 13vw !important;
}

.uplink::after,
.has-parent::before,
.has-descendents::after,
.downstream-item::before {
background-color: #6e7681;
content: "";
display: inline-block;
height: 30px;
height: 2rem;
position: relative;
transform: translate(0, 0);
width: 30px;
width: 2rem;
}

.uplink::after,
.has-parent::before,
.has-descendents::after {
clip-path: polygon(100% 80%, 0 80%, 0 85%, 100% 85%);
clip-path: polygon(100% 80%, 0 80%, 0 83%, 100% 83%);
}

.downstream-item::before {
clip-path: polygon(
100% 80%,
5% 80%,
5% 0,
4% 80%,
4% 0,
0 0,
0 100%,
5% 100%,
5% 85%,
100% 85%
4% 100%,
4% 83%,
100% 83%
);
}

Expand All @@ -51,23 +55,23 @@
}

.downstream-item:first-child::before {
clip-path: polygon(100% 80%, 0 80%, 0 100%, 5% 100%, 5% 85%, 100% 85%);
clip-path: polygon(100% 80%, 0 80%, 0 100%, 4% 100%, 4% 83%, 100% 83%);
}

.downstream-item:last-child::before {
clip-path: polygon(100% 80%, 5% 80%, 5% 0, 0 0, 0 85%, 100% 85%);
clip-path: polygon(100% 80%, 4% 80%, 4% 0, 0 0, 0 83%, 100% 83%);
}

.downstream-item:only-child::before {
clip-path: polygon(100% 80%, 0 80%, 0 85%, 100% 85%);
clip-path: polygon(100% 80%, 0 80%, 0 83%, 100% 83%);
}

.downstream {
display: flex;
flex-direction: column;

.downstream-item {
height: 30px;
height: 2rem;
}
}
}
2 changes: 1 addition & 1 deletion tests/networks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test.describe("bridge type", () => {
await setTextarea(page, "Hardware address", HARDWARE_ADDRESS);

const options = ["openvswitch", "native"];
await checkAllOptions(page, "Bridge driver", options);
await checkAllOptions(page, "Driver", options);
});

test("configure bridge DNS settings", async ({ page }) => {
Expand Down

0 comments on commit ee27b49

Please sign in to comment.