Skip to content

Commit

Permalink
chore: remove react-router-dom-v5-compat imports (#5372)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndv99 committed Mar 25, 2024
1 parent 41fd7c8 commit 5e2d6fc
Show file tree
Hide file tree
Showing 313 changed files with 325 additions and 369 deletions.
3 changes: 1 addition & 2 deletions src/app/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { lazy } from "react";

import { Redirect } from "react-router-dom";
import { Route, Routes as ReactRouterRoutes } from "react-router-dom-v5-compat";
import { Redirect, Route, Routes as ReactRouterRoutes } from "react-router-dom";

import ErrorBoundary from "@/app/base/components/ErrorBoundary";
import urls from "@/app/base/urls";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { MouseEvent, ReactNode } from "react";

import { Navigation } from "@canonical/maas-react-components";
import classNames from "classnames";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import type { SideNavigationProps } from "../AppSideNavigation";
import type { NavItem } from "../types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { createMemoryHistory } from "history";
import { Provider } from "react-redux";
import { BrowserRouter, Router } from "react-router-dom";
import { CompatRouter, Route, Routes } from "react-router-dom-v5-compat";
import {
BrowserRouter,
Router,
CompatRouter,
Route,
Routes,
} from "react-router-dom";
import configureStore from "redux-mock-store";

import AppSideNavigation from "./AppSideNavigation";
Expand All @@ -21,8 +26,8 @@ import {
} from "@/testing/utils";

const mockUseNavigate = vi.fn();
vi.mock("react-router-dom-v5-compat", async () => {
const actual: object = await vi.importActual("react-router-dom-v5-compat");
vi.mock("react-router-dom", async () => {
const actual: object = await vi.importActual("react-router-dom");
return {
...actual,
useNavigate: () => mockUseNavigate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useMemo } from "react";

import { Navigation, NavigationBar } from "@canonical/maas-react-components";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate, useLocation, useMatch } from "react-router-dom-v5-compat";
import { useNavigate, useLocation, useMatch } from "react-router-dom";
import { useStorageState } from "react-storage-hooks";

import AppSideNavItems from "./AppSideNavItems";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Navigation } from "@canonical/maas-react-components";
import { Link, useLocation } from "react-router-dom-v5-compat";
import { Link, useLocation } from "react-router-dom";

import { isSelected } from "../utils";

Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/AppSideNavigation/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { matchPath } from "react-router-dom-v5-compat";
import { matchPath } from "react-router-dom";

import type { NavItem } from "./types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import ControllerLink, { Labels } from "./ControllerLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/ControllerLink/ControllerLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/base/urls";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/DHCPTable/DHCPTable.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import DHCPTable, { TestIds } from "./DHCPTable";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/DHCPTable/DHCPTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";
import { ExternalLink } from "@canonical/maas-react-components";
import { List, MainTable } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import TitledSection from "../TitledSection";

Expand Down
3 changes: 1 addition & 2 deletions src/app/base/components/DeviceLink/DeviceLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { MemoryRouter, CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import DeviceLink, { Labels } from "./DeviceLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/DeviceLink/DeviceLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/base/urls";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/DhcpForm/DhcpForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import { Labels as FieldLabels } from "../DhcpFormFields";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as reduxToolkit from "@reduxjs/toolkit";
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import { Labels } from "./DhcpFormFields";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/FabricLink/FabricLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import FabricLink, { Labels } from "./FabricLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/FabricLink/FabricLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/base/urls";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/FormikForm/FormikForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import FormikForm from "./FormikForm";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field, Formik } from "formik";
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { MemoryRouter, CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";
import * as Yup from "yup";

Expand All @@ -22,8 +21,8 @@ import {

const mockStore = configureStore<RootState>();
const mockUseNavigate = vi.fn();
vi.mock("react-router-dom-v5-compat", async () => {
const actual: object = await vi.importActual("react-router-dom-v5-compat");
vi.mock("react-router-dom", async () => {
const actual: object = await vi.importActual("react-router-dom");
return {
...actual,
useNavigate: () => mockUseNavigate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { FormikContextType } from "formik";
import { useFormikContext } from "formik";
import { withFormikDevtools } from "formik-devtools-extension";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom-v5-compat";
import { useNavigate } from "react-router-dom";
import type { AnyAction } from "redux";

import type { FormikFormButtonsProps } from "@/app/base/components/FormikFormButtons";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/MachineLink/MachineLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as reduxToolkit from "@reduxjs/toolkit";
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import MachineLink, { Labels } from "./MachineLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/MachineLink/MachineLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Spinner } from "@canonical/react-components";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import urls from "@/app/base/urls";
import type { Machine, MachineMeta } from "@/app/store/machine/types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import ModelNotFound from "./ModelNotFound";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/ModelNotFound/ModelNotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import PageContent from "../PageContent";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Formik } from "formik";
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import NodeConfigurationFields, { Label } from "./NodeConfigurationFields";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Fragment } from "react";

import { Card, Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import NetworkCardTable from "./NetworkCardTable";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Notification } from "@canonical/react-components";
import type { NotificationProps } from "@canonical/react-components";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom-v5-compat";
import { useNavigate } from "react-router-dom";

import settingsURLs from "@/app/settings/urls";
import authSelectors from "@/app/store/auth/selectors";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/PageContent/PageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { HTMLProps, ReactNode } from "react";

import classNames from "classnames";
import { useSelector } from "react-redux";
import { matchPath, useLocation } from "react-router-dom-v5-compat";
import { matchPath, useLocation } from "react-router-dom";

import AppSidePanel from "../AppSidePanel";
import ErrorBoundary from "../ErrorBoundary/ErrorBoundary";
Expand Down
4 changes: 2 additions & 2 deletions src/app/base/components/SSHKeyList/SSHKeyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { ReactNode } from "react";

import { Button, Notification } from "@canonical/react-components";
import { useSelector } from "react-redux";
import type { NavigateFunction } from "react-router-dom-v5-compat";
import { useNavigate } from "react-router-dom-v5-compat";
import type { NavigateFunction } from "react-router-dom";
import { useNavigate } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/preferences/urls";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from "classnames";
import type { Location } from "react-router-dom-v5-compat";
import { Link, matchPath, useLocation } from "react-router-dom-v5-compat";
import type { Location } from "react-router-dom";
import { Link, matchPath, useLocation } from "react-router-dom";

import { useThemeContext } from "@/app/base/theme-context";

Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/SpaceLink/SpaceLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import SpaceLink from "./SpaceLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/SpaceLink/SpaceLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/base/urls";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/SubnetLink/SubnetLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import SubnetLink from "./SubnetLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/SubnetLink/SubnetLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/base/urls";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/TableActions/TableActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Tooltip } from "@canonical/react-components";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import CopyButton from "@/app/base/components/CopyButton";

Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/TagLinks/TagLinks.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";

import TagLinks from "./TagLinks";

Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/TagLinks/TagLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import type { Tag } from "@/app/store/tag/types";

Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/VLANLink/VLANLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import VLANLink from "./VLANLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/VLANLink/VLANLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import { useFetchActions } from "@/app/base/hooks";
import urls from "@/app/base/urls";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Notification } from "@canonical/react-components";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import controllerSelectors from "@/app/store/controller/selectors";
import { vaultEnabled as vaultEnabledSelectors } from "@/app/store/general/selectors";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from "@testing-library/react";
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import MachinesHeader from "./MachinesHeader";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/node/NodeDevices/NodeDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect } from "react";
import classNames from "classnames";
import pluralize from "pluralize";
import { useDispatch, useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import NodeDevicesWarning from "./NodeDevicesWarning";

Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/node/NodeLink/NodeLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux";
import { MemoryRouter } from "react-router-dom";
import { CompatRouter } from "react-router-dom-v5-compat";
import { CompatRouter } from "react-router-dom";
import configureStore from "redux-mock-store";

import NodeLink from "./NodeLink";
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/node/NodeLogs/NodeLogs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tabs } from "@canonical/react-components";
import { Route, useLocation } from "react-router-dom";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import DownloadMenu from "./DownloadMenu";
import EventLogs from "./EventLogs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "react";

import { Col, Row, Spinner, Tooltip } from "@canonical/react-components";
import { useDispatch, useSelector } from "react-redux";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import NodeTestDetailsLogs from "./NodeTestDetailsLogs";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ContextualMenuProps } from "@canonical/react-components";
import type { LinkProps } from "react-router-dom";
import { Link } from "react-router-dom-v5-compat";
import { Link } from "react-router-dom";

import type { SetExpanded } from "../NodeTestsTable";
import { ScriptResultAction } from "../NodeTestsTable";
Expand Down
Loading

0 comments on commit 5e2d6fc

Please sign in to comment.