Skip to content

Commit da86580

Browse files
authored
web: migrate to React Router v7 (#2861)
## Problem React Router v7 was released almost a year now (see https://reactrouter.com/changelog#v700), but it has not been updated in Agama yet. In addition to the obvious benefit of keeping dependencies up-to-date, updating it might help to address some limitations we have found with the v6 version, like 06d858c ## Solution Migrate React Router dependency to its latest version. ## Testing - Adapted existing tests. ## Notes This migration has been straightforward, and as of now, Agama is using Data Mode (see https://reactrouter.com/start/modes). However, this could change in the future if we find advantages in switching to Declarative or Framework Mode. Before making any decisions, we’ll need to work on `src/App.tsx` along with the changes planned for the api-v2 branch that this PR is based on. ## Documentation * https://reactrouter.com/upgrading/v6 * remix-run/react-router#12363 (comment) * remix-run/react-router#13530 (`generatePath` now encodes URL params by default, related to #2576) * https://www.typescriptlang.org/tsconfig/#moduleResolution
2 parents 0b9ab30 + 2dcde83 commit da86580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+114
-190
lines changed

web/package-lock.json

Lines changed: 25 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"radashi": "^12.6.2",
102102
"react": "^18.3.1",
103103
"react-dom": "^18.3.1",
104-
"react-router-dom": "^6.30.1",
104+
"react-router": "^7.9.5",
105105
"sprintf-js": "^1.1.3",
106106
"xbytes": "^1.9.1"
107107
},

web/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
import React, { useEffect } from "react";
24-
import { Navigate, Outlet, useLocation } from "react-router-dom";
24+
import { Navigate, Outlet, useLocation } from "react-router";
2525
import { Loading } from "~/components/layout";
2626
import { useProduct, useProductChanges } from "~/queries/software";
2727
import { useProposalChanges } from "~/queries/proposal";

web/src/Protected.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
import React from "react";
24-
import { Navigate, Outlet } from "react-router-dom";
24+
import { Navigate, Outlet } from "react-router";
2525
import { useAuth } from "./context/auth";
2626
import { AppProviders } from "./context/app";
2727

web/src/components/core/ChangeProductOption.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import React from "react";
2424
import { DropdownItem, DropdownItemProps } from "@patternfly/react-core";
25-
import { useHref, useLocation } from "react-router-dom";
25+
import { useHref, useLocation } from "react-router";
2626
import { useProduct, useRegistration } from "~/queries/software";
2727
import { PRODUCT as PATHS, SIDE_PATHS } from "~/routes/paths";
2828
import { _ } from "~/i18n";

web/src/components/core/InstallButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Popup } from "~/components/core";
2626
import { startInstallation } from "~/api/manager";
2727
import { useAllIssues } from "~/queries/issues";
2828
import { IssueSeverity } from "~/types/issues";
29-
import { useLocation } from "react-router-dom";
29+
import { useLocation } from "react-router";
3030
import { SIDE_PATHS } from "~/routes/paths";
3131
import { _ } from "~/i18n";
3232
import { Icon } from "../layout";

web/src/components/core/InstallationFinished.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
GridItem,
3838
Stack,
3939
} from "@patternfly/react-core";
40-
import { Navigate, useNavigate } from "react-router-dom";
40+
import { Navigate, useNavigate } from "react-router";
4141
import { Icon } from "~/components/layout";
4242
import alignmentStyles from "@patternfly/react-styles/css/utilities/Alignment/alignment";
4343
import { useInstallerStatus } from "~/queries/status";

web/src/components/core/InstallationProgress.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { _ } from "~/i18n";
2525
import ProgressReport from "./ProgressReport";
2626
import { InstallationPhase } from "~/types/status";
2727
import { ROOT as PATHS } from "~/routes/paths";
28-
import { Navigate } from "react-router-dom";
28+
import { Navigate } from "react-router";
2929
import { useInstallerStatus, useInstallerStatusChanges } from "~/queries/status";
3030

3131
function InstallationProgress() {

web/src/components/core/InstallerOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333

3434
import React, { useReducer } from "react";
35-
import { useHref, useLocation } from "react-router-dom";
35+
import { useHref, useLocation } from "react-router";
3636
import {
3737
Button,
3838
ButtonProps,

web/src/components/core/Link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import React from "react";
2424
import { Button, ButtonProps } from "@patternfly/react-core";
25-
import { To, useHref, useLinkClickHandler } from "react-router-dom";
25+
import { To, useHref, useLinkClickHandler } from "react-router";
2626

2727
export type LinkProps = Omit<ButtonProps, "component"> & {
2828
/** The target route */

0 commit comments

Comments
 (0)