-
Notifications
You must be signed in to change notification settings - Fork 516
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?
Changes from 11 commits
2af7813
154c7c0
2455d90
8a40827
2743cca
3ee6445
828e985
d5eb985
93c2181
52793ea
aa98700
c1eaadd
188ae81
8aebf4c
375bed2
9e691d6
4228454
b0ac58a
fe98dc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
import React, { Component } from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { Route, Redirect, Switch, Router } from 'react-router-dom'; | ||
import { Route, Routes, Navigate } from 'react-router-dom'; | ||
|
||
import { ConfigProvider } from 'antd'; | ||
import { defaultTheme } from '@ant-design/compatible'; | ||
|
@@ -30,7 +30,7 @@ import SearchTracePage from '../SearchTracePage'; | |
import { ROUTE_PATH as searchPath } from '../SearchTracePage/url'; | ||
import TraceDiff from '../TraceDiff'; | ||
import { ROUTE_PATH as traceDiffPath } from '../TraceDiff/url'; | ||
import TracePage from '../TracePage'; | ||
import TracePage from '../TracePage/index'; | ||
Zen-cronic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { ROUTE_PATH as tracePath } from '../TracePage/url'; | ||
import MonitorATMPage from '../Monitor'; | ||
import { ROUTE_PATH as monitorATMPath } from '../Monitor/url'; | ||
|
@@ -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 commentThe 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 commentThe 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 |
||
import { store } from '../../utils/configure-store'; | ||
|
||
const jaegerTheme = { | ||
token: { | ||
|
@@ -88,49 +87,23 @@ export default class JaegerUIApp extends Component { | |
return ( | ||
<ConfigProvider theme={jaegerTheme}> | ||
<Provider store={store}> | ||
<HistoryProvider history={history}> | ||
<Router history={history}> | ||
<Page> | ||
<Switch> | ||
<Route path={searchPath}> | ||
<SearchTracePage /> | ||
</Route> | ||
<Route path={traceDiffPath}> | ||
<TraceDiff /> | ||
</Route> | ||
<Route path={tracePath}> | ||
<TracePage /> | ||
</Route> | ||
<Route path={dependenciesPath}> | ||
<DependencyGraph /> | ||
</Route> | ||
<Route path={deepDependenciesPath}> | ||
<DeepDependencies /> | ||
</Route> | ||
<Route path={qualityMetricsPath}> | ||
<QualityMetrics /> | ||
</Route> | ||
<Route path={monitorATMPath}> | ||
<MonitorATMPage /> | ||
</Route> | ||
<Page> | ||
<Routes> | ||
<Route path={searchPath} element={<SearchTracePage />} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should use relative paths in v7 migration: e.g., |
||
<Route path={traceDiffPath} element={<TraceDiff />} /> | ||
<Route path={tracePath} element={<TracePage />} /> | ||
<Route path={dependenciesPath} element={<DependencyGraph />} /> | ||
<Route path={deepDependenciesPath} element={<DeepDependencies />} /> | ||
<Route path={qualityMetricsPath} element={<QualityMetrics />} /> | ||
<Route path={monitorATMPath} element={<MonitorATMPage />} /> | ||
|
||
<Route exact path="/"> | ||
<Redirect to={searchPath} /> | ||
</Route> | ||
<Route exact path={prefixUrl()}> | ||
<Redirect to={searchPath} /> | ||
</Route> | ||
<Route exact path={prefixUrl('/')}> | ||
<Redirect to={searchPath} /> | ||
</Route> | ||
<Route path="/" element={<Navigate to={searchPath} />} /> | ||
<Route path={prefixUrl()} element={<Navigate to={searchPath} />} /> | ||
<Route path={prefixUrl('/')} element={<Navigate to={searchPath} />} /> | ||
|
||
<Route> | ||
<NotFound /> | ||
</Route> | ||
</Switch> | ||
</Page> | ||
</Router> | ||
</HistoryProvider> | ||
<Route path="*" element={<NotFound />} /> | ||
</Routes> | ||
</Page> | ||
</Provider> | ||
</ConfigProvider> | ||
); | ||
|
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, removingHistoryProvider
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 withwithRouteProps
. Because they're class based, we can't use hooks likeuseNavigation
). 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 ofhistory
.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.
yep, we should replace
history
withnavigate
from theuseNavigate
hook. But that change can't be made unless the class-based components (like this) are rewritten into functional components.