-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add delete static IP side panel (#5410)
Co-authored-by: Nick De Villiers <[email protected]>
- Loading branch information
1 parent
ab91890
commit 315f14b
Showing
11 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/app/subnets/views/SubnetDetails/SubnetStaticIPs/DeleteStaticIP/DeleteStaticIP.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import DeleteStaticIPs from "./DeleteStaticIP"; | ||
|
||
import { renderWithBrowserRouter, screen } from "@/testing/utils"; | ||
|
||
it("renders a delete confirmation form", () => { | ||
renderWithBrowserRouter( | ||
<DeleteStaticIPs | ||
macAddress="91:2a:95:aa:2e:50" | ||
setSidePanelContent={vi.fn()} | ||
/> | ||
); | ||
expect( | ||
screen.getByRole("form", { name: "Delete static IP" }) | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByText( | ||
"Are you sure you want to delete this static IP? This action is permanent and can not be undone." | ||
) | ||
).toBeInTheDocument(); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/app/subnets/views/SubnetDetails/SubnetStaticIPs/DeleteStaticIP/DeleteStaticIP.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { SubnetActionProps } from "../../types"; | ||
|
||
import ModelActionForm from "@/app/base/components/ModelActionForm"; | ||
|
||
type Props = Pick<SubnetActionProps, "setSidePanelContent" | "macAddress">; | ||
const DeleteStaticIP = ({ setSidePanelContent, macAddress }: Props) => { | ||
if (!macAddress) return null; | ||
const handleClose = () => setSidePanelContent(null); | ||
// TODO: Implement onSubmit function and passing IDs when API supports it. | ||
// https://warthogs.atlassian.net/browse/MAASENG-2983 | ||
return ( | ||
<ModelActionForm | ||
aria-label="Delete static IP" | ||
initialValues={{}} | ||
modelType="static IP" | ||
onCancel={handleClose} | ||
onSubmit={() => {}} | ||
/> | ||
); | ||
}; | ||
|
||
export default DeleteStaticIP; |
1 change: 1 addition & 0 deletions
1
src/app/subnets/views/SubnetDetails/SubnetStaticIPs/DeleteStaticIP/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./DeleteStaticIP"; |
13 changes: 13 additions & 0 deletions
13
src/app/subnets/views/SubnetDetails/SubnetStaticIPs/SubnetStaticIPs.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import SubnetStaticIPs from "./SubnetStaticIPs"; | ||
|
||
import { renderWithBrowserRouter, screen } from "@/testing/utils"; | ||
|
||
it("renders", () => { | ||
renderWithBrowserRouter(<SubnetStaticIPs />); | ||
expect( | ||
screen.getByRole("heading", { name: "Static IPs" }) | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole("button", { name: "Reserve static IP" }) | ||
).toBeInTheDocument(); | ||
}); |
34 changes: 34 additions & 0 deletions
34
src/app/subnets/views/SubnetDetails/SubnetStaticIPs/SubnetStaticIPs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { MainToolbar } from "@canonical/maas-react-components"; | ||
import { Button } from "@canonical/react-components"; | ||
|
||
import { SubnetActionTypes, SubnetDetailsSidePanelViews } from "../constants"; | ||
|
||
import { useSidePanel } from "@/app/base/side-panel-context"; | ||
|
||
const SubnetStaticIPs = () => { | ||
const { setSidePanelContent } = useSidePanel(); | ||
|
||
return ( | ||
<> | ||
<MainToolbar> | ||
<MainToolbar.Title>Static IPs</MainToolbar.Title> | ||
<MainToolbar.Controls> | ||
<Button | ||
appearance="positive" | ||
onClick={() => | ||
setSidePanelContent({ | ||
view: SubnetDetailsSidePanelViews[ | ||
SubnetActionTypes.ReserveStaticIP | ||
], | ||
}) | ||
} | ||
> | ||
Reserve static IP | ||
</Button> | ||
</MainToolbar.Controls> | ||
</MainToolbar> | ||
</> | ||
); | ||
}; | ||
|
||
export default SubnetStaticIPs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./SubnetStaticIPs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters