-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: React router dom from v5 to v6 #2580
base: main
Are you sure you want to change the base?
Update: React router dom from v5 to v6 #2580
Conversation
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
This reverts commit 154c7c0. Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2580 +/- ##
==========================================
- Coverage 96.58% 96.58% -0.01%
==========================================
Files 255 255
Lines 7732 7728 -4
Branches 1944 1996 +52
==========================================
- Hits 7468 7464 -4
Misses 264 264 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
Migration to v6 done! All the unit tests pass TODOs:
Or when two traces are selected: Interestingly, manually going to Problem found: react-router dropped regex path support in v6
|
please do not bundle 6 & 7 migration into one PR, let's get a green CI and merge |
please document in the description how the dependency files were changed (which commands did you run). For example, why are |
Signed-off-by: Kaung Zin Hein <[email protected]>
@@ -29,9 +29,9 @@ describe('<TraceIDSearchInput />', () => { | |||
history = createMemoryHistory(); | |||
render( | |||
<HistoryProvider history={history}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why in packages/jaeger-ui/src/components/App/index.jsx
the history provider is removed but here it's not? What is the motivation for either decision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In packages/jaeger-ui/src/components/App/index.jsx
, HistoryProvider
is removed b/c rrd v6 works without being wrapped with that component.
But in this test and other tests, the history
object from it's namesake package is used for assertions. So, removing HistoryProvider
would mean a rewrite for these tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but what's the story with the history
package, aren't we going to have to remove it altogether as incompatible going forward? It's ok if that clean-up can be done incrementally, we can defer it to other PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
history
is no longer a peer dep in v6 and later. And yes, we should have a separate PR for removing it from this repo.
And we need to consider how to replace the function of that package - currently, it's used to provide the navigation props (e.g., history.push(/)
) in class-based components wrapped with withRouteProps
. Because they're class based, we can't use hooks like useNavigation
). This discussion is better continued in another PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, the migration guide you linked recommends using navigate
instead of history
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the docs say BrowserRouter incorporates the history in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, the migration guide you linked recommends using
navigate
instead ofhistory
.
yep, we should replace history
with navigate
from the useNavigate
hook. But that change can't be made unless the class-based components (like this) are rewritten into functional components.
Signed-off-by: Kaung Zin Hein <[email protected]>
noted. i'm on node v22.12.0 and npm 10.9.0. |
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
<Routes> | ||
<Route path="/" element={<Page />}> | ||
<Route index element={<SearchTracePage />} /> | ||
<Route path={searchPath} element={<SearchTracePage />} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use relative paths in v7 migration: e.g., search
instead of /search
@@ -42,8 +42,7 @@ import '../common/vars.css'; | |||
import '../common/utils.css'; | |||
import 'antd/dist/reset.css'; | |||
import './index.css'; | |||
import { history, store } from '../../utils/configure-store'; | |||
import { HistoryProvider } from '../../utils/useHistory'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this module be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not in this PR, other unrelated tests depend on it. We should remove history on its own PR
packages/jaeger-ui/src/components/SearchTracePage/index.test.js
Outdated
Show resolved
Hide resolved
package-lock.json
Outdated
@@ -20103,7 +19951,7 @@ | |||
"@ant-design/compatible": "^5.1.3", | |||
"@jaegertracing/plexus": "0.2.0", | |||
"@pyroscope/flamegraph": "0.21.4", | |||
"@sentry/browser": "^8.48.0", | |||
"@sentry/browser": "^8.18.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What causes this downgrade? Before you're running install/uninstall commands, are you on the latest set of dependencies (npm ci
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that the current dep version is 8.18.0
?
jaeger-ui/packages/jaeger-ui/package.json
Line 51 in 1ee19c2
"@sentry/browser": "^8.18.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. I hate it when GH glitches like that. It's showing fake diffs, how to even trust its diff...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is 8.48 in the lock file though:
$ grep sentry/browser package-lock.json
"node_modules/@sentry/browser": {
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.48.0.tgz",
"@sentry/browser": "^8.48.0",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the original repo, the current versions in the lock file is 8.48.0
as well.
Line 4121 in 1ee19c2
"version": "8.48.0", |
so i updated the version in package.json
to match that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall lgtm, but please address questions / comments.
Signed-off-by: Kaung Zin Hein <[email protected]>
Signed-off-by: Kaung Zin Hein <[email protected]>
export const ROUTE_PATH = prefixUrl('/trace/:a?\\.\\.\\.:b?'); | ||
|
||
const ROUTE_MATCHER = { path: ROUTE_PATH, strict: true, exact: true }; | ||
export const ROUTE_PATH = prefixUrl('/trace-diff/:a?/:b?'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2208,7 +2204,6 @@ | |||
"resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz", | |||
"integrity": "sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==", | |||
"license": "MIT", | |||
"peer": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need be reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Deep Dependency Graph on the Search page stopped working
Signed-off-by: Kaung Zin Hein <[email protected]>
it might involve converting a few class-based components into functional ones; i'll keep exploring solutions |
If we have to, can we do it in a separate PR and merge it before this one? |
Signed-off-by: Kaung Zin Hein <[email protected]>
the previous commit fixes the error of DDG not being displayed (due to a missing No components were rewritten into function components in this PR, but in this. The rewriting process would block the migration process b/c to use the rrdv6/7 hooks (i.e.g,
But there are a few errors (so a few tests are failing):
|
Signed-off-by: Kaung Zin Hein <[email protected]>
@@ -89,47 +89,21 @@ export default class JaegerUIApp extends Component { | |||
<ConfigProvider theme={jaegerTheme}> | |||
<Provider store={store}> | |||
<HistoryProvider history={history}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: HistoryProvider
is still needed by the router b/c history
is used for navigation:
jaeger-ui/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.tsx
Line 116 in 1ee19c2
history.push(getUrl({ ...urlState, view })); |
useNavigate
can't be used inside a class-based component.
@@ -36,7 +36,9 @@ const svcOp = memoizeOne((service, operation) => ({ service, operation })); | |||
|
|||
// export for tests | |||
export function mapStateToProps(state: ReduxState, ownProps: TOwnProps): TReduxProps { | |||
const urlState = getUrlState(ownProps.location.search); | |||
const locationUrlState = getUrlState(ownProps.location.search); | |||
const urlState = { ...locationUrlState, ...ownProps.urlQueryParams }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging with the passed urlQueryParams
b/c location
and the redux state router are out of sync.
caveat of this approach: we need to do this to every component that are connected to the store and that affect the url in some way
@@ -93,7 +93,7 @@ exports[`DiffSelection renders multiple traces as expected 1`] = ` | |||
className="DiffSelection--message" | |||
> | |||
<Link | |||
to="/trace/trace-id-0...trace-id-1?cohort=trace-id-0&cohort=trace-id-1" | |||
to="/trace-diff/trace-id-0/trace-id-1?cohort=trace-id-0&cohort=trace-id-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: the second cohort
param should be separated by an &
const urlArgs = queryString.parse(location.search); | ||
const { navigateTo } = this.props; | ||
|
||
const urlArgs = queryString.parse(navigateTo.split('/search?')[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO fix:
parsing the manually passed url prop (that contains the correct params) like this is very hacky.
Blocked by #2588 |
more issue of |
Which problem is this PR solving?
Description of the changes
How was this change tested?
npm run test
Commands Ran
npm install @types/history@^4.7.11
, removed in [deps] Remove @types/moment, @types/history and @types/classnames #1637 but added back b/c the pkg became fully typed only in v5.0.0npm uninstall react-router-dom-v5-compat
to uninstall compat pkgnpm install react-router-dom@^v6.28.1
to install v6npm uninstall @types/react-router-dom
b/c the rrd pkg became fully typed in v6.0.0Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test