SRVKP-10306: Upgrade react-router from v5 to v7 to align with console#1024
Conversation
|
@anwesha-palit-redhat: This pull request references SRVKP-10306 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@anwesha-palit-redhat: This pull request references SRVKP-10306 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@anwesha-palit-redhat: This pull request references SRVKP-10306 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@anwesha-palit-redhat: This pull request references SRVKP-10306 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
| SecondaryButtonAction, | ||
| } from './multi-tab-list-page-types'; | ||
| import { useNavigate } from 'react-router-dom-v5-compat'; | ||
| import { useNavigate } from 'react-router'; |
6d20f7b to
2d29cae
Compare
2d29cae to
281b929
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anwesha-palit-redhat, arvindk-softwaredev The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
b48ed50
into
openshift-pipelines:master
Summary
react-router 5.3.x,react-router-dom 5.3.x, andreact-router-dom-v5-compat ^6.11.2withreact-router ~7.13.1to match the console's version.@openshift-console/dynamic-plugin-sdk{,-internal,-webpack}from4.22.0-prerelease.1to4.22.0-prerelease.2(required — the older SDK validates shared modules against v5 and rejects v7).react-i18next(~15.1.4→~16.5.8),react-redux(8.1.3→~9.2.0), and@types/react-redux(6.0.2→^7.1.34) to satisfy the new SDK's peer dependencies.react-router-dom-v5-compat/react-router-domimports toreact-router.historypackage dependency fromrouter.tsutilities, replacing it with nativewindow.historyAPIs.Why add
__mocks__/textEncoderDecoder.tssetup fileReact Router v7 internally uses
TextEncoder/TextDecoder(for cookie and URL handling). The jsdom test environment doesn't provide these globals, so importingreact-routerin any test causesReferenceError: TextEncoder is not defined. The fix adds a__mocks__/textEncoderDecoder.tssetup file — matching the exact same approach used by the console project — that polyfills these globals from Node'sutilmodule before tests run. It also addsreact-router,cookie, andset-cookie-parsertotransformIgnorePatternsexceptions sobabel-jestcan transform their ESM source.Why the change in
src/components/utils/router.tsThe old version of this file imported
createBrowserHistory,createMemoryHistory, and theHistorytype from the history npm package (v4). That package was a standalone dependency ofreact-router v5— it provided the browser history abstraction that react-router v5 was built on.With
react-router v7, the history package no longer exists as a separate dependency. Its functionality was absorbed into react-router's internals.What the old code did:
Created a History instance via createBrowserHistory() (or createMemoryHistory() in tests), configured with the console's base path.
What the new code does:
It replaces the history package with the native browser window.history API:
The base-path stripping monkey-patch was also removed. It's no longer needed because callers of history.push (like
handlePipelineRunSubmitin pipelines-actions.tsx) pass fully-qualified paths fromresourcePathFromModel(), and the query parameter helpers only modify the query string of the current URL (they read window.location.href directly), so base path handling is irrelevant to them.Test plan
yarn buildpassesyarn testpasses (47/47 suites, 1 skipped — unchanged from before)Screen Recording for verification in OCP 4.22
react-router-testing-1.mov
react-router-testing-2.mov
react-router-testing-3.mov