Skip to content

Commit

Permalink
chore: update static IP wording to DHCP lease (#5416)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Topher authored Apr 24, 2024
1 parent 1e80597 commit 8dfbb11
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/app/subnets/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const urls = {
subnet: {
summary: withSubnetId("/subnet/:id/summary"),
staticRoutes: withSubnetId("/subnet/:id/static-routes"),
reservedIpAddresses: withSubnetId("/subnet/:id/reserved-ip-addresses"),
addressReservation: withSubnetId("/subnet/:id/address-reservation"),
dhcpSnippets: withSubnetId("/subnet/:id/dhcp-snippets"),
usedIpAddresses: withSubnetId("/subnet/:id/used-ip-addresses"),
index: argPath<{ id: Subnet[SubnetMeta.PK] }>("/subnet/:id"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import DeleteStaticIPs from "./DeleteStaticIP";
import DeleteDHCPLease from "./DeleteDHCPLease";

import { renderWithBrowserRouter, screen } from "@/testing/utils";

it("renders a delete confirmation form", () => {
renderWithBrowserRouter(
<DeleteStaticIPs
<DeleteDHCPLease
macAddress="91:2a:95:aa:2e:50"
setSidePanelContent={vi.fn()}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SubnetActionProps } from "../../types";
import ModelActionForm from "@/app/base/components/ModelActionForm";

type Props = Pick<SubnetActionProps, "setSidePanelContent" | "macAddress">;
const DeleteStaticIP = ({ setSidePanelContent, macAddress }: Props) => {
const DeleteDHCPLease = ({ setSidePanelContent, macAddress }: Props) => {
if (!macAddress) return null;
const handleClose = () => setSidePanelContent(null);
// TODO: Implement onSubmit function and passing IDs when API supports it.
Expand All @@ -19,4 +19,4 @@ const DeleteStaticIP = ({ setSidePanelContent, macAddress }: Props) => {
);
};

export default DeleteStaticIP;
export default DeleteDHCPLease;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./DeleteDHCPLease";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import StaticDHCPLease from "./StaticDHCPLease";

import { renderWithBrowserRouter, screen } from "@/testing/utils";

it("renders", () => {
renderWithBrowserRouter(<StaticDHCPLease />);
expect(
screen.getByRole("heading", { name: "Static DHCP leases" })
).toBeInTheDocument();
expect(
screen.getByRole("button", { name: "Reserve static DHCP lease" })
).toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ import { SubnetActionTypes, SubnetDetailsSidePanelViews } from "../constants";

import { useSidePanel } from "@/app/base/side-panel-context";

const SubnetStaticIPs = () => {
const StaticDHCPLease = () => {
const { setSidePanelContent } = useSidePanel();

return (
<>
<MainToolbar>
<MainToolbar.Title>Static IPs</MainToolbar.Title>
<MainToolbar.Title>Static DHCP leases</MainToolbar.Title>
<MainToolbar.Controls>
<Button
appearance="positive"
onClick={() =>
setSidePanelContent({
view: SubnetDetailsSidePanelViews[
SubnetActionTypes.ReserveStaticIP
SubnetActionTypes.ReserveStaticDHCPLease
],
})
}
>
Reserve static IP
Reserve static DHCP lease
</Button>
</MainToolbar.Controls>
</MainToolbar>
</>
);
};

export default SubnetStaticIPs;
export default StaticDHCPLease;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./StaticDHCPLease";
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import AddStaticRouteForm from "../StaticRoutes/AddStaticRouteForm";
import DeleteStaticRouteForm from "../StaticRoutes/DeleteStaticRouteform";
import EditStaticRouteForm from "../StaticRoutes/EditStaticRouteForm";
import DeleteStaticIP from "../SubnetStaticIPs/DeleteStaticIP";

import DeleteSubnet from "./components/DeleteSubnet";
import EditBootArchitectures from "./components/EditBootArchitectures";
import MapSubnet from "./components/MapSubnet";

import ReservedRangeDeleteForm from "@/app/subnets/components/ReservedRangeDeleteForm";
import ReservedRangeForm from "@/app/subnets/components/ReservedRangeForm";
import DeleteDHCPLease from "@/app/subnets/views/SubnetDetails/StaticDHCPLease/DeleteDHCPLease";
import AddStaticRouteForm from "@/app/subnets/views/SubnetDetails/StaticRoutes/AddStaticRouteForm";
import DeleteStaticRouteForm from "@/app/subnets/views/SubnetDetails/StaticRoutes/DeleteStaticRouteform";
import EditStaticRouteForm from "@/app/subnets/views/SubnetDetails/StaticRoutes/EditStaticRouteForm";
import { SubnetActionTypes } from "@/app/subnets/views/SubnetDetails/constants";
import type {
SubnetAction,
Expand All @@ -27,9 +26,9 @@ const FormComponents: Record<
[SubnetActionTypes.DeleteStaticRoute]: DeleteStaticRouteForm,
[SubnetActionTypes.ReserveRange]: ReservedRangeForm,
[SubnetActionTypes.DeleteReservedRange]: ReservedRangeDeleteForm,
[SubnetActionTypes.ReserveStaticIP]: () => null,
[SubnetActionTypes.EditStaticIP]: () => null,
[SubnetActionTypes.DeleteStaticIP]: DeleteStaticIP,
[SubnetActionTypes.ReserveStaticDHCPLease]: () => null,
[SubnetActionTypes.EditStaticDHCPLease]: () => null,
[SubnetActionTypes.DeleteDHCPLease]: DeleteDHCPLease,
};

const SubnetActionForms = ({
Expand Down
2 changes: 1 addition & 1 deletion src/app/subnets/views/SubnetDetails/SubnetDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ beforeEach(() => {
},
{
component: "ReservedRanges",
path: urls.subnets.subnet.reservedIpAddresses({ id: 1 }),
path: urls.subnets.subnet.addressReservation({ id: 1 }),
title: "Reserved ranges",
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/subnets/views/SubnetDetails/SubnetDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Navigate, Route, Routes } from "react-router-dom";

import StaticDHCPLease from "./StaticDHCPLease";
import StaticRoutes from "./StaticRoutes";
import SubnetDetailsHeader from "./SubnetDetailsHeader";
import SubnetStaticIPs from "./SubnetStaticIPs";
import SubnetSummary from "./SubnetSummary";
import SubnetUsedIPs from "./SubnetUsedIPs";
import Utilisation from "./Utilisation";
Expand Down Expand Up @@ -124,13 +124,13 @@ const SubnetDetails = (): JSX.Element => {
element={
<>
{import.meta.env.VITE_APP_STATIC_IPS_ENABLED === "true" && (
<SubnetStaticIPs />
<StaticDHCPLease />
)}
<ReservedRanges subnetId={id} />
</>
}
path={getRelativeRoute(
urls.subnets.subnet.reservedIpAddresses(null),
urls.subnets.subnet.addressReservation(null),
base
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const SubnetDetailsHeader = ({ subnet }: Props): JSX.Element => {
{
active: pathname.startsWith(`${urlBase}/summary`),
component: Link,
label: "Summary",
label: "Subnet summary",
to: `${urlBase}/summary`,
},
{
Expand All @@ -54,10 +54,10 @@ const SubnetDetailsHeader = ({ subnet }: Props): JSX.Element => {
to: `${urlBase}/static-routes`,
},
{
active: pathname.startsWith(`${urlBase}/reserved-ip-addresses`),
active: pathname.startsWith(`${urlBase}/address-reservation`),
component: Link,
label: "Reserved IPs",
to: `${urlBase}/reserved-ip-addresses`,
label: "Address reservation",
to: `${urlBase}/address-reservation`,
},
{
active: pathname.startsWith(`${urlBase}/dhcp-snippets`),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 15 additions & 9 deletions src/app/subnets/views/SubnetDetails/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const SubnetActionTypes = {
DeleteStaticRoute: "DeleteStaticRoute",
ReserveRange: "ReserveRange",
DeleteReservedRange: "DeleteReservedRange",
ReserveStaticIP: "ReserveStaticIP",
EditStaticIP: "EditStaticIP",
DeleteStaticIP: "DeleteStaticIP",
ReserveStaticDHCPLease: "ReserveStaticDHCPLease",
EditStaticDHCPLease: "EditStaticDHCPLease",
DeleteDHCPLease: "DeleteDHCPLease",
} as const;
export type SubnetActionType = ValueOf<typeof SubnetActionTypes>;

Expand All @@ -27,9 +27,9 @@ export const subnetActionLabels = {
[SubnetActionTypes.DeleteStaticRoute]: "Delete static route",
[SubnetActionTypes.ReserveRange]: "Reserve range",
[SubnetActionTypes.DeleteReservedRange]: "Delete Reserved Range",
[SubnetActionTypes.ReserveStaticIP]: "Reserve static IP",
[SubnetActionTypes.EditStaticIP]: "Edit static IP",
[SubnetActionTypes.DeleteStaticIP]: "Delete static IP",
[SubnetActionTypes.ReserveStaticDHCPLease]: "Reserve static DHCP lease",
[SubnetActionTypes.EditStaticDHCPLease]: "Edit static DHCP lease",
[SubnetActionTypes.DeleteDHCPLease]: "Delete static DHCP lease",
} as const;

export const SubnetDetailsSidePanelViews = {
Expand All @@ -50,9 +50,15 @@ export const SubnetDetailsSidePanelViews = {
"",
SubnetActionTypes.DeleteReservedRange,
],
[SubnetActionTypes.ReserveStaticIP]: ["", SubnetActionTypes.ReserveStaticIP],
[SubnetActionTypes.EditStaticIP]: ["", SubnetActionTypes.EditStaticIP],
[SubnetActionTypes.DeleteStaticIP]: ["", SubnetActionTypes.DeleteStaticIP],
[SubnetActionTypes.ReserveStaticDHCPLease]: [
"",
SubnetActionTypes.ReserveStaticDHCPLease,
],
[SubnetActionTypes.EditStaticDHCPLease]: [
"",
SubnetActionTypes.EditStaticDHCPLease,
],
[SubnetActionTypes.DeleteDHCPLease]: ["", SubnetActionTypes.DeleteDHCPLease],
} as const;

export type SubnetDetailsSidePanelContent = SidePanelContent<
Expand Down

0 comments on commit 8dfbb11

Please sign in to comment.