diff --git a/src/app/base/components/node/MachinesHeader/MachinesHeader.test.tsx b/src/app/base/components/node/MachinesHeader/MachinesHeader.test.tsx
deleted file mode 100644
index a3f757db98..0000000000
--- a/src/app/base/components/node/MachinesHeader/MachinesHeader.test.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { render, screen } from "@testing-library/react";
-import { Provider } from "react-redux";
-import { MemoryRouter } from "react-router-dom";
-import configureStore from "redux-mock-store";
-
-import MachinesHeader from "./MachinesHeader";
-
-import type { RootState } from "@/app/store/root/types";
-import * as factory from "@/testing/factories";
-
-const mockStore = configureStore();
-
-describe("MachinesHeader", () => {
- let state: RootState;
-
- beforeEach(() => {
- state = factory.rootState({
- machine: factory.machineState({
- loaded: true,
- counts: factory.machineStateCounts({
- "mocked-nanoid": factory.machineStateCount({
- count: 2,
- loaded: true,
- loading: false,
- }),
- }),
- items: [
- factory.machine({ system_id: "abc123" }),
- factory.machine({ system_id: "def456" }),
- ],
- statuses: {
- abc123: factory.machineStatus({}),
- def456: factory.machineStatus({}),
- },
- }),
- });
- });
-
- it("renders", () => {
- state.machine.loaded = true;
- const store = mockStore(state);
- render(
-
-
-
-
-
- );
- expect(screen.getByTestId("section-header-title")).toHaveTextContent(
- "Machines"
- );
- });
-});
diff --git a/src/app/base/components/node/MachinesHeader/MachinesHeader.tsx b/src/app/base/components/node/MachinesHeader/MachinesHeader.tsx
deleted file mode 100644
index 47f9a0fe6c..0000000000
--- a/src/app/base/components/node/MachinesHeader/MachinesHeader.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import type { SectionHeaderProps } from "@/app/base/components/SectionHeader";
-import SectionHeader from "@/app/base/components/SectionHeader";
-import { useFetchActions } from "@/app/base/hooks";
-import { resourcePoolActions } from "@/app/store/resourcepool";
-import { tagActions } from "@/app/store/tag";
-type Props = SectionHeaderProps & { machineCount: number };
-
-export const MachinesHeader = ({
- machineCount,
- ...props
-}: Props): JSX.Element => {
- useFetchActions([resourcePoolActions.fetch, tagActions.fetch]);
-
- return (
-
- );
-};
-
-export default MachinesHeader;
diff --git a/src/app/base/components/node/MachinesHeader/index.ts b/src/app/base/components/node/MachinesHeader/index.ts
deleted file mode 100644
index d6ed311508..0000000000
--- a/src/app/base/components/node/MachinesHeader/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./MachinesHeader";
diff --git a/src/app/controllers/components/ImageStatus/ImageStatus.test.tsx b/src/app/controllers/components/ImageStatus/ImageStatus.test.tsx
deleted file mode 100644
index c02ab04972..0000000000
--- a/src/app/controllers/components/ImageStatus/ImageStatus.test.tsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import configureStore from "redux-mock-store";
-
-import { ImageStatus } from "./ImageStatus";
-
-import { ImageSyncStatus } from "@/app/store/controller/types/enum";
-import type { RootState } from "@/app/store/root/types";
-import * as factory from "@/testing/factories";
-import { screen, renderWithBrowserRouter } from "@/testing/utils";
-
-const mockStore = configureStore();
-
-describe("ImageStatus", () => {
- let state: RootState;
- beforeEach(() => {
- state = factory.rootState({
- controller: factory.controllerState({
- loaded: true,
- items: [
- factory.controller({
- system_id: "abc123",
- }),
- ],
- }),
- });
- });
-
- it("starts polling the image status", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(, {
- route: "/controllers",
- store,
- });
- expect(
- store
- .getActions()
- .some((action) => action.type === "controller/pollCheckImages")
- ).toBe(true);
- });
-
- it("stops polling when unmounting", () => {
- const store = mockStore(state);
- const { unmount } = renderWithBrowserRouter(
- ,
- { route: "/", store }
- );
- unmount();
- expect(
- store
- .getActions()
- .some((action) => action.type === "controller/pollCheckImagesStop")
- ).toBe(true);
- });
-
- it("shows a spinner when polling", () => {
- state.controller.statuses = factory.controllerStatuses({
- abc123: factory.controllerStatus({ checkingImages: true }),
- });
- renderWithBrowserRouter(, {
- route: "/controllers",
- state,
- });
- expect(screen.getByText("Loading")).toBeInTheDocument();
- });
-
- it("shows the synced state", () => {
- state.controller.imageSyncStatuses = factory.controllerImageSyncStatuses({
- abc123: ImageSyncStatus.Synced,
- });
- const store = mockStore(state);
- renderWithBrowserRouter(, {
- route: "/controllers",
- store,
- });
- expect(screen.getByTestId("sync-success-icon")).toHaveClass(
- "p-icon--success-grey"
- );
- expect(screen.getByTestId("status")).toHaveTextContent(
- ImageSyncStatus.Synced
- );
- });
-
- it("shows a state that is not synced", () => {
- state.controller.imageSyncStatuses = factory.controllerImageSyncStatuses({
- abc123: ImageSyncStatus.Syncing,
- });
- const store = mockStore(state);
- renderWithBrowserRouter(, {
- route: "/controllers",
- store,
- });
- expect(screen.queryByTestId("sync-success-icon")).not.toBeInTheDocument();
- expect(screen.getByTestId("status")).toHaveTextContent(
- ImageSyncStatus.Syncing
- );
- });
-});
diff --git a/src/app/controllers/components/ImageStatus/ImageStatus.tsx b/src/app/controllers/components/ImageStatus/ImageStatus.tsx
deleted file mode 100644
index 5ba2384c9d..0000000000
--- a/src/app/controllers/components/ImageStatus/ImageStatus.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { useEffect, useRef } from "react";
-
-import { Icon, Spinner } from "@canonical/react-components";
-import { nanoid } from "@reduxjs/toolkit";
-import { useDispatch, useSelector } from "react-redux";
-
-import { controllerActions } from "@/app/store/controller";
-import controllerSelectors from "@/app/store/controller/selectors";
-import { ControllerMeta, ImageSyncStatus } from "@/app/store/controller/types";
-import type { Controller } from "@/app/store/controller/types";
-import type { RootState } from "@/app/store/root/types";
-
-type Props = {
- systemId: Controller[ControllerMeta.PK];
-};
-
-export const ImageStatus = ({ systemId }: Props): JSX.Element | null => {
- const controller = useSelector((state: RootState) =>
- controllerSelectors.getById(state, systemId)
- );
- const dispatch = useDispatch();
- const pollId = useRef(nanoid());
- const status = useSelector((state: RootState) =>
- controllerSelectors.imageSyncStatusesForController(
- state,
- controller?.system_id
- )
- );
- const checkingImages = useSelector((state: RootState) =>
- controllerSelectors.getStatusForController(
- state,
- controller?.system_id || null,
- "checkingImages"
- )
- );
-
- useEffect(() => {
- const id = pollId.current;
- if (controller) {
- dispatch(
- controllerActions.pollCheckImages([controller[ControllerMeta.PK]], id)
- );
- }
- return () => {
- dispatch(controllerActions.pollCheckImagesStop(id));
- };
- }, [dispatch, controller]);
-
- if (!controller) {
- return null;
- }
- if (checkingImages) {
- return ;
- }
- return (
- <>
- {status === ImageSyncStatus.Synced && (
- <>
- {" "}
- >
- )}
- {status ?? "Asking for status..."}
- >
- );
-};
-
-export default ImageStatus;
diff --git a/src/app/controllers/components/ImageStatus/index.ts b/src/app/controllers/components/ImageStatus/index.ts
deleted file mode 100644
index c52742d5eb..0000000000
--- a/src/app/controllers/components/ImageStatus/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./ImageStatus";
diff --git a/src/app/controllers/views/ControllerDetails/ControllerConfiguration/types.ts b/src/app/controllers/views/ControllerDetails/ControllerConfiguration/types.ts
deleted file mode 100644
index de937765e8..0000000000
--- a/src/app/controllers/views/ControllerDetails/ControllerConfiguration/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Tag, TagMeta } from "@/app/store/tag/types";
-
-export type ControllerConfigurationValues = {
- tags: Tag[TagMeta.PK][];
- zone: string;
- description: string;
-};
diff --git a/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/EditInterfaceTable.test.tsx b/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/EditInterfaceTable.test.tsx
deleted file mode 100644
index 523354ae4a..0000000000
--- a/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/EditInterfaceTable.test.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import configureStore from "redux-mock-store";
-
-import EditInterfaceTable from "./EditInterfaceTable";
-
-import type { DeviceNetworkInterface } from "@/app/store/device/types";
-import type { RootState } from "@/app/store/root/types";
-import { NetworkInterfaceTypes } from "@/app/store/types/enum";
-import * as factory from "@/testing/factories";
-import { screen, renderWithBrowserRouter } from "@/testing/utils";
-
-const mockStore = configureStore();
-
-describe("EditInterfaceTable", () => {
- let state: RootState;
- let nic: DeviceNetworkInterface;
- beforeEach(() => {
- nic = factory.deviceInterface();
- state = factory.rootState({
- fabric: factory.fabricState({
- loaded: true,
- }),
- device: factory.deviceState({
- items: [
- factory.deviceDetails({ interfaces: [nic], system_id: "abc123" }),
- ],
- loaded: true,
- statuses: {
- abc123: factory.deviceStatus(),
- },
- }),
- subnet: factory.subnetState({
- loaded: true,
- }),
- vlan: factory.vlanState({
- loaded: true,
- }),
- });
- });
-
- it("displays a spinner when loading", () => {
- state.device.items = [];
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(screen.getByText("Loading...")).toBeInTheDocument();
- });
-
- it("displays a table when loaded", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(screen.getByRole("grid")).toBeInTheDocument();
- });
-
- it("can display an interface", () => {
- const fabric = factory.fabric({ name: "fabric-name" });
- state.fabric.items = [fabric];
- const vlan = factory.vlan({ fabric: fabric.id, vid: 2, name: "vlan-name" });
- state.vlan.items = [vlan];
- const subnets = [
- factory.subnet({ cidr: "subnet-cidr", name: "subnet-name" }),
- factory.subnet({ cidr: "subnet2-cidr", name: "subnet2-name" }),
- ];
- state.subnet.items = subnets;
- nic = factory.deviceInterface({
- discovered: null,
- links: [],
- type: NetworkInterfaceTypes.PHYSICAL,
- vlan_id: vlan.id,
- });
- state.device.items = [
- factory.deviceDetails({
- interfaces: [nic],
- system_id: "abc123",
- }),
- ];
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(screen.getByTestId("ip-mode")).toHaveTextContent("Unconfigured");
- });
-});
diff --git a/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/EditInterfaceTable.tsx b/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/EditInterfaceTable.tsx
deleted file mode 100644
index 510ae4a753..0000000000
--- a/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/EditInterfaceTable.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-import { MainTable, Spinner } from "@canonical/react-components";
-import { useSelector } from "react-redux";
-
-import TableHeader from "@/app/base/components/TableHeader";
-import DHCPColumn from "@/app/base/components/node/networking/DHCPColumn";
-import FabricColumn from "@/app/base/components/node/networking/FabricColumn";
-import NameColumn from "@/app/base/components/node/networking/NameColumn";
-import SubnetColumn from "@/app/base/components/node/networking/SubnetColumn";
-import { useFetchActions } from "@/app/base/hooks";
-import deviceSelectors from "@/app/store/device/selectors";
-import type {
- Device,
- DeviceMeta,
- DeviceNetworkInterface,
-} from "@/app/store/device/types";
-import { isDeviceDetails } from "@/app/store/device/utils";
-import { fabricActions } from "@/app/store/fabric";
-import fabricSelectors from "@/app/store/fabric/selectors";
-import type { RootState } from "@/app/store/root/types";
-import type { NetworkLink } from "@/app/store/types/node";
-import {
- getInterfaceIPAddress,
- getInterfaceTypeText,
- getLinkFromNic,
- getLinkModeDisplay,
-} from "@/app/store/utils";
-import { vlanActions } from "@/app/store/vlan";
-import vlanSelectors from "@/app/store/vlan/selectors";
-
-type Props = {
- linkId?: NetworkLink["id"] | null;
- nicId?: DeviceNetworkInterface["id"] | null;
- systemId: Device[DeviceMeta.PK];
-};
-
-const EditInterfaceTable = ({
- linkId,
- nicId,
- systemId,
-}: Props): JSX.Element => {
- const device = useSelector((state: RootState) =>
- deviceSelectors.getById(state, systemId)
- );
- const fabrics = useSelector(fabricSelectors.all);
- const vlans = useSelector(vlanSelectors.all);
- const nic = useSelector((state: RootState) =>
- deviceSelectors.getInterfaceById(state, systemId, nicId, linkId)
- );
- const link = getLinkFromNic(nic, linkId);
-
- useFetchActions([fabricActions.fetch, vlanActions.fetch]);
-
- if (!isDeviceDetails(device) || !nic) {
- return ;
- }
- const typeDisplay = getInterfaceTypeText(device, nic, link);
- return (
-
- Name
- Mac
-
- ),
- },
- {
- content: Type,
- },
- {
- content: (
-
- ),
- },
- {
- content: Subnet,
- },
- {
- content: IP address,
- },
- {
- content: IP mode,
- },
- {
- content: (
-
- DHCP
-
- ),
- },
- ]}
- rows={[
- {
- columns: [
- {
- content: ,
- },
- {
- content: typeDisplay,
- },
- {
- content: ,
- },
- {
- content: ,
- },
- {
- content: (
-
- {getInterfaceIPAddress(device, fabrics, vlans, nic, link)}
-
- ),
- },
- {
- content: (
- {getLinkModeDisplay(link)}
- ),
- },
- {
- content: ,
- },
- ],
- key: systemId,
- },
- ]}
- />
- );
-};
-
-export default EditInterfaceTable;
diff --git a/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/index.ts b/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/index.ts
deleted file mode 100644
index 4fe272a3f9..0000000000
--- a/src/app/devices/views/DeviceDetails/DeviceNetwork/EditInterface/EditInterfaceTable/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./EditInterfaceTable";
diff --git a/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/NetworkTableConfirmation.test.tsx b/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/NetworkTableConfirmation.test.tsx
deleted file mode 100644
index 92ccea51ac..0000000000
--- a/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/NetworkTableConfirmation.test.tsx
+++ /dev/null
@@ -1,382 +0,0 @@
-import configureStore from "redux-mock-store";
-
-import NetworkTableConfirmation from "./NetworkTableConfirmation";
-
-import { ExpandedState } from "@/app/base/components/NodeNetworkTab/NodeNetworkTab";
-import type { RootState } from "@/app/store/root/types";
-import { NetworkInterfaceTypes } from "@/app/store/types/enum";
-import type { NetworkInterface } from "@/app/store/types/node";
-import * as factory from "@/testing/factories";
-import {
- getByTextContent,
- renderWithBrowserRouter,
- screen,
- userEvent,
-} from "@/testing/utils";
-
-const mockStore = configureStore();
-
-describe("NetworkTableConfirmation", () => {
- let nic: NetworkInterface;
- let state: RootState;
- beforeEach(() => {
- nic = factory.machineInterface();
- state = factory.rootState({
- machine: factory.machineState({
- items: [
- factory.machineDetails({
- interfaces: [nic],
- system_id: "abc123",
- }),
- ],
- loaded: true,
- statuses: {
- abc123: factory.machineStatus(),
- },
- }),
- });
- });
-
- it("does not display a confirmation if it is not expanded", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(
- screen.queryByText("Are you sure you want to remove this interface?")
- ).not.toBeInTheDocument();
- expect(
- screen.queryByRole("button", { name: "Cancel" })
- ).not.toBeInTheDocument();
- expect(
- screen.queryByRole("button", { name: "Remove" })
- ).not.toBeInTheDocument();
- });
-
- describe("delete confirmation", () => {
- it("can display a delete confirmation for an interface", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(
- screen.getByText("Are you sure you want to remove this interface?")
- ).toBeInTheDocument();
- expect(
- screen.getByRole("button", { name: "Cancel" })
- ).toBeInTheDocument();
- expect(
- screen.getByRole("button", { name: "Remove" })
- ).toBeInTheDocument();
- });
-
- it("can confirm deleting an interface", async () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
-
- await userEvent.click(screen.getByRole("button", { name: "Remove" }));
- expect(
- store
- .getActions()
- .find((action) => action.type === "machine/deleteInterface")
- ).toStrictEqual({
- type: "machine/deleteInterface",
- meta: {
- method: "delete_interface",
- model: "machine",
- },
- payload: {
- params: {
- interface_id: nic.id,
- system_id: "abc123",
- },
- },
- });
- });
-
- it("can display a delete confirmation for an alias", () => {
- const link = factory.networkLink();
- state.machine.items = [
- factory.machineDetails({
- interfaces: [
- factory.machineInterface({
- discovered: null,
- links: [factory.networkLink(), link],
- name: "alias",
- type: NetworkInterfaceTypes.PHYSICAL,
- }),
- ],
- system_id: "abc123",
- }),
- ];
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(
- screen.getByText("Are you sure you want to remove this Alias?")
- ).toBeInTheDocument();
- });
-
- it("can confirm deleting an alias", async () => {
- const link = factory.networkLink();
- state.machine.items = [
- factory.machineDetails({
- interfaces: [
- factory.machineInterface({
- discovered: null,
- links: [factory.networkLink(), link],
- name: "alias",
- type: NetworkInterfaceTypes.PHYSICAL,
- }),
- ],
- system_id: "abc123",
- }),
- ];
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- await userEvent.click(screen.getByRole("button", { name: "Remove" }));
- expect(
- store
- .getActions()
- .find((action) => action.type === "machine/unlinkSubnet")
- ).toStrictEqual({
- type: "machine/unlinkSubnet",
- meta: {
- method: "unlink_subnet",
- model: "machine",
- },
- payload: {
- params: {
- interface_id: nic.id,
- link_id: link.id,
- system_id: "abc123",
- },
- },
- });
- });
- });
-
- describe("connect/disconnect confirmations", () => {
- it("can display a mark connected confirmation", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(
- screen.getByText(/Are you sure you want to mark it as connected\?/i)
- ).toBeInTheDocument();
- expect(
- screen.getByRole("button", { name: "Mark as connected" })
- ).toHaveClass("p-button--positive");
- });
-
- it("can display a mark disconnected confirmation", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
-
- expect(
- screen.getByText(/Are you sure you want to mark it as disconnected\?/i)
- ).toBeInTheDocument();
- expect(
- screen.getByRole("button", { name: "Mark as disconnected" })
- ).toHaveClass("p-button--negative");
- });
-
- it("can display a disconnected warning", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
-
- expect(
- getByTextContent(
- /This interface is disconnected, it cannot be configured unless a cable is connected.If this is no longer true, mark cable as connected./i
- )
- ).toBeInTheDocument();
- expect(
- screen.getByRole("button", { name: "Mark as connected" })
- ).toHaveClass("p-button--positive");
- });
-
- it("can confirm marking connected", async () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- await userEvent.click(
- screen.getByRole("button", { name: "Mark as connected" })
- );
- expect(
- store
- .getActions()
- .find((action) => action.type === "machine/updateInterface")
- ).toStrictEqual({
- type: "machine/updateInterface",
- meta: {
- method: "update_interface",
- model: "machine",
- },
- payload: {
- params: {
- interface_id: nic.id,
- link_connected: true,
- system_id: "abc123",
- },
- },
- });
- });
-
- it("can confirm marking disconnected", async () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- await userEvent.click(
- screen.getByRole("button", { name: "Mark as disconnected" })
- );
- expect(
- store
- .getActions()
- .find((action) => action.type === "machine/updateInterface")
- ).toStrictEqual({
- type: "machine/updateInterface",
- meta: {
- method: "update_interface",
- model: "machine",
- },
- payload: {
- params: {
- interface_id: nic.id,
- link_connected: false,
- system_id: "abc123",
- },
- },
- });
- });
- });
-
- it("can display an add alias form", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(screen.getByRole("textbox", { name: "Type" })).toHaveValue("Alias");
- expect(
- screen.getByRole("button", { name: "Save interface" })
- ).toBeInTheDocument();
- });
-
- it("can display an add VLAN form", () => {
- const store = mockStore(state);
- renderWithBrowserRouter(
- ,
- { store }
- );
- expect(screen.getByRole("textbox", { name: "Type" })).toHaveValue("VLAN");
- expect(
- screen.getByRole("button", { name: "Save interface" })
- ).toBeInTheDocument();
- });
-});
diff --git a/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/NetworkTableConfirmation.tsx b/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/NetworkTableConfirmation.tsx
deleted file mode 100644
index efba6475fb..0000000000
--- a/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/NetworkTableConfirmation.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-import type { ReactNode } from "react";
-
-import { useDispatch, useSelector } from "react-redux";
-
-import AddAliasOrVlan from "../../AddAliasOrVlan";
-
-import type {
- Expanded,
- SetExpanded,
-} from "@/app/base/components/NodeNetworkTab/NodeNetworkTab";
-import { ExpandedState } from "@/app/base/components/NodeNetworkTab/NodeNetworkTab";
-import ActionConfirm from "@/app/base/components/node/ActionConfirm";
-import { machineActions } from "@/app/store/machine";
-import machineSelectors from "@/app/store/machine/selectors";
-import type { Machine } from "@/app/store/machine/types";
-import type { RootState } from "@/app/store/root/types";
-import { NetworkInterfaceTypes } from "@/app/store/types/enum";
-import type { NetworkInterface, NetworkLink } from "@/app/store/types/node";
-import {
- getLinkInterface,
- getRemoveTypeText,
- isAlias,
-} from "@/app/store/utils";
-
-type Props = {
- expanded: Expanded | null;
- link?: NetworkLink | null;
- nic?: NetworkInterface | null;
- setExpanded: SetExpanded;
- systemId: Machine["system_id"];
-};
-
-const NetworkTableConfirmation = ({
- expanded,
- link,
- nic,
- setExpanded,
- systemId,
-}: Props): JSX.Element | null => {
- const dispatch = useDispatch();
- const machine = useSelector((state: RootState) =>
- machineSelectors.getById(state, systemId)
- );
- if (machine && link && !nic) {
- [nic] = getLinkInterface(machine, link);
- }
- if (!machine || !nic || !expanded) {
- return null;
- }
- const removeTypeText = getRemoveTypeText(machine, nic, link);
- const isAnAlias = isAlias(machine, link);
- const close = () => setExpanded(null);
- let content: ReactNode;
- if (expanded?.content === ExpandedState.REMOVE) {
- content = (
- {
- dispatch(machineActions.cleanup());
- if (isAnAlias) {
- if (nic?.id && link?.id) {
- dispatch(
- machineActions.unlinkSubnet({
- interfaceId: nic?.id,
- linkId: link?.id,
- systemId: machine.system_id,
- })
- );
- }
- } else if (nic?.id) {
- dispatch(
- machineActions.deleteInterface({
- interfaceId: nic?.id,
- systemId: machine.system_id,
- })
- );
- }
- }}
- onSaveAnalytics={{
- action: `Remove ${removeTypeText}`,
- category: "Machine network",
- label: "Remove",
- }}
- statusKey={isAnAlias ? "unlinkingSubnet" : "deletingInterface"}
- systemId={machine.system_id}
- />
- );
- } else if (
- [
- ExpandedState.MARK_CONNECTED,
- ExpandedState.MARK_DISCONNECTED,
- ExpandedState.DISCONNECTED_WARNING,
- ].includes(expanded?.content)
- ) {
- const showDisconnectedWarning =
- expanded?.content === ExpandedState.DISCONNECTED_WARNING;
- const markConnected =
- expanded?.content === ExpandedState.MARK_CONNECTED ||
- showDisconnectedWarning;
- const event = markConnected ? "connected" : "disconnected";
- const updateConnection = () => {
- if (nic?.id) {
- dispatch(
- machineActions.updateInterface({
- interface_id: nic?.id,
- link_connected: !!markConnected,
- system_id: machine.system_id,
- })
- );
- }
- };
- let message: ReactNode;
- if (showDisconnectedWarning) {
- message = (
- <>
- This interface is disconnected, it cannot be
- configured unless a cable is connected.
-
- If this is no longer true, mark cable as connected.
- >
- );
- } else {
- message = (
- <>
- This interface was detected as{" "}
- {nic.link_connected ? "connected" : "disconnected"}.
- Are you sure you want to mark it as {event}?
- {markConnected ? null : (
- <>
-
- When the interface is disconnected, it cannot be configured.
- >
- )}
- >
- );
- }
- content = (
-
- );
- } else if (expanded?.content === ExpandedState.ADD_ALIAS) {
- content = (
-
- );
- } else if (expanded?.content === ExpandedState.ADD_VLAN) {
- content = (
-
- );
- }
- return {content}
;
-};
-
-export default NetworkTableConfirmation;
diff --git a/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/index.ts b/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/index.ts
deleted file mode 100644
index 95440504f7..0000000000
--- a/src/app/machines/views/MachineDetails/MachineNetwork/NetworkTable/NetworkTableConfirmation/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./NetworkTableConfirmation";