Skip to content

Commit

Permalink
Replace react-router-dom@6 with react-router@7
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Dec 1, 2024
1 parent ed76db0 commit 2bcb24c
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 52 deletions.
69 changes: 41 additions & 28 deletions jsx/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "identity-obj-proxy"
},
"setupFiles": [
"./testing/setup.jest.js"
],
"testEnvironment": "jsdom"
},
"dependencies": {
Expand All @@ -42,7 +45,7 @@
"react-icons": "^5.3.0",
"react-multi-select-component": "^4.3.4",
"react-redux": "^9.1.2",
"react-router-dom": "^6.27.0",
"react-router": "^7.0.1",
"recompose": "npm:react-recompose@^0.33.0",
"redux": "^5.0.1",
"regenerator-runtime": "^0.14.1"
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createStore } from "redux";
import { compose } from "recompose";
import { initialState, reducers } from "./Store";
import withAPI from "./util/withAPI";
import { HashRouter, Routes, Route } from "react-router-dom";
import { HashRouter, Routes, Route } from "react-router";

import ServerDashboard from "./components/ServerDashboard/ServerDashboard";
import Groups from "./components/Groups/Groups";
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/AddUser/AddUser.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Link, useNavigate } from "react-router-dom";
import { Link, useNavigate } from "react-router";
import { Button, Col } from "react-bootstrap";
import PropTypes from "prop-types";
import ErrorAlert from "../../util/error";
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/AddUser/AddUser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen, fireEvent } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { Provider, useDispatch, useSelector } from "react-redux";
import { createStore } from "redux";
import { HashRouter } from "react-router-dom";
import { HashRouter } from "react-router";
// eslint-disable-next-line
import regeneratorRuntime from "regenerator-runtime";

Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/CreateGroup/CreateGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Link, useNavigate } from "react-router-dom";
import { Link, useNavigate } from "react-router";
import { Button, Card } from "react-bootstrap";
import PropTypes from "prop-types";
import { MainContainer } from "../../util/layout";
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/CreateGroup/CreateGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen, fireEvent } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { Provider, useDispatch, useSelector } from "react-redux";
import { createStore } from "redux";
import { HashRouter } from "react-router-dom";
import { HashRouter } from "react-router";
// eslint-disable-next-line
import regeneratorRuntime from "regenerator-runtime";
import CreateGroup from "./CreateGroup";
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/EditUser/EditUser.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import PropTypes from "prop-types";
import { Link, useLocation, useNavigate } from "react-router-dom";
import { Link, useLocation, useNavigate } from "react-router";
import { Button, Card } from "react-bootstrap";
import { MainContainer } from "../../util/layout";

Expand Down
6 changes: 3 additions & 3 deletions jsx/src/components/EditUser/EditUser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "@testing-library/jest-dom";
import { render, screen, fireEvent } from "@testing-library/react";
import { Provider, useDispatch, useSelector } from "react-redux";
import { createStore } from "redux";
import { HashRouter } from "react-router-dom";
import { HashRouter } from "react-router";
// eslint-disable-next-line
import regeneratorRuntime from "regenerator-runtime";

Expand All @@ -15,8 +15,8 @@ jest.mock("react-redux", () => ({
useSelector: jest.fn(),
}));

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
jest.mock("react-router", () => ({
...jest.requireActual("react-router"),
useLocation: jest.fn().mockImplementation(() => {
return { state: { username: "foo", has_admin: false } };
}),
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/GroupEdit/GroupEdit.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { Link, useNavigate, useLocation } from "react-router-dom";
import { Link, useNavigate, useLocation } from "react-router";
import PropTypes from "prop-types";
import { Button, Card } from "react-bootstrap";
import GroupSelect from "../GroupSelect/GroupSelect";
Expand Down
6 changes: 3 additions & 3 deletions jsx/src/components/GroupEdit/GroupEdit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen, fireEvent } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { Provider, useSelector } from "react-redux";
import { createStore } from "redux";
import { HashRouter } from "react-router-dom";
import { HashRouter } from "react-router";
// eslint-disable-next-line
import regeneratorRuntime from "regenerator-runtime";

Expand All @@ -15,8 +15,8 @@ jest.mock("react-redux", () => ({
useSelector: jest.fn(),
}));

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
jest.mock("react-router", () => ({
...jest.requireActual("react-router"),
useLocation: jest.fn().mockImplementation(() => {
return { state: { group_data: { users: ["foo"], name: "group" } } };
}),
Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/Groups/Groups.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useSelector, useDispatch } from "react-redux";
import PropTypes from "prop-types";

import { Button, Card } from "react-bootstrap";
import { Link, useNavigate } from "react-router-dom";
import { Link, useNavigate } from "react-router";
import { usePaginationParams } from "../../util/paginationParams";
import PaginationFooter from "../PaginationFooter/PaginationFooter";
import { MainContainer } from "../../util/layout";
Expand Down
6 changes: 3 additions & 3 deletions jsx/src/components/Groups/Groups.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "@testing-library/jest-dom";
import { render, screen, fireEvent } from "@testing-library/react";
import { Provider, useSelector } from "react-redux";
import { createStore } from "redux";
import { HashRouter, useSearchParams } from "react-router-dom";
import { HashRouter, useSearchParams } from "react-router";
// eslint-disable-next-line
import regeneratorRuntime from "regenerator-runtime";

Expand All @@ -15,8 +15,8 @@ jest.mock("react-redux", () => ({
useSelector: jest.fn(),
}));

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
jest.mock("react-router", () => ({
...jest.requireActual("react-router"),
useSearchParams: jest.fn(),
}));

Expand Down
2 changes: 1 addition & 1 deletion jsx/src/components/ServerDashboard/ServerDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "react-bootstrap";
import ReactObjectTableViewer from "../ReactObjectTableViewer/ReactObjectTableViewer";

import { Link, useSearchParams, useNavigate } from "react-router-dom";
import { Link, useSearchParams, useNavigate } from "react-router";
import { FaSort, FaSortUp, FaSortDown } from "react-icons/fa";

import "./server-dashboard.css";
Expand Down
7 changes: 3 additions & 4 deletions jsx/src/components/ServerDashboard/ServerDashboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
getByText,
getAllByRole,
} from "@testing-library/react";
import { HashRouter, Routes, Route, useSearchParams } from "react-router-dom";
// import { CompatRouter, } from "react-router-dom-v5-compat";
import { HashRouter, Routes, Route, useSearchParams } from "react-router";
import { Provider, useSelector } from "react-redux";
import { createStore } from "redux";
// eslint-disable-next-line
Expand All @@ -23,8 +22,8 @@ jest.mock("react-redux", () => ({
...jest.requireActual("react-redux"),
useSelector: jest.fn(),
}));
jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
jest.mock("react-router", () => ({
...jest.requireActual("react-router"),
useSearchParams: jest.fn(),
}));

Expand Down
2 changes: 1 addition & 1 deletion jsx/src/util/paginationParams.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { debounce } from "lodash";
import { useSearchParams } from "react-router-dom";
import { useSearchParams } from "react-router";

export const usePaginationParams = () => {
// get offset, limit, name filter from URL
Expand Down
5 changes: 5 additions & 0 deletions jsx/testing/setup.jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Workaround "ReferenceError: TextEncoder is not defined"
// https://stackoverflow.com/questions/68468203/why-am-i-getting-textencoder-is-not-defined-in-jest/68468204#68468204
// https://jestjs.io/docs/configuration#setupfiles-array
import { TextEncoder, TextDecoder } from 'util';
Object.assign(global, { TextDecoder, TextEncoder });

0 comments on commit 2bcb24c

Please sign in to comment.