-
Notifications
You must be signed in to change notification settings - Fork 578
Update: React router dom from v5 to v6 #2580
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
base: main
Are you sure you want to change the base?
Changes from all 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 |
---|---|---|
|
@@ -18,7 +18,7 @@ import React from 'react'; | |
import { createMemoryHistory } from 'history'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { Router } from 'react-router-dom'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import TraceIDSearchInput from './TraceIDSearchInput'; | ||
import { HistoryProvider } from '../../utils/useHistory'; | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. why in 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. In But in this test and other tests, the 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. but what's the story with the 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.
And we need to consider how to replace the function of that package - currently, it's used to provide the navigation props (e.g., 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. Specifically, the migration guide you linked recommends using 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. And the docs say BrowserRouter incorporates the history in it. 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.
yep, we should replace |
||
<Router history={history}> | ||
<BrowserRouter> | ||
<TraceIDSearchInput /> | ||
</Router> | ||
</BrowserRouter> | ||
</HistoryProvider> | ||
); | ||
}); | ||
|
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'; | ||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. update: jaeger-ui/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.tsx Line 116 in 1ee19c2
|
||||
<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> | ||||
<Routes> | ||||
<Route path="/" element={<Page />}> | ||||
<Route index element={<SearchTracePage />} /> | ||||
<Route path={searchPath} element={<SearchTracePage />} /> | ||||
<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> | ||||
<NotFound /> | ||||
</Route> | ||||
</Switch> | ||||
</Page> | ||||
</Router> | ||||
<Route path={prefixUrl()} element={<Navigate to={searchPath} />} /> | ||||
<Route path="*" element={<NotFound />} /> | ||||
</Route> | ||||
</Routes> | ||||
</HistoryProvider> | ||||
</Provider> | ||||
</ConfigProvider> | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. merging with the passed 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 |
||
|
||
const { density, operation, service, showOp: urlStateShowOp } = urlState; | ||
const showOp = urlStateShowOp !== undefined ? urlStateShowOp : operation !== undefined; | ||
let graphState: TDdgStateEntry | undefined; | ||
|
@@ -63,15 +65,19 @@ export function mapStateToProps(state: ReduxState, ownProps: TOwnProps): TReduxP | |
type TOwnProps = { | ||
history: RouterHistory; | ||
location: Location; | ||
urlQueryParams: Record<string, string | null>; | ||
navigateTo: string; | ||
}; | ||
|
||
// export for tests | ||
export class TracesDdgImpl extends React.PureComponent<TOwnProps & TReduxProps> { | ||
render(): React.ReactNode { | ||
const { location } = this.props; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. TODO fix: |
||
const { end, start, limit, lookback, maxDuration, minDuration, view } = urlArgs; | ||
const extraArgs = { end, start, limit, lookback, maxDuration, minDuration, view }; | ||
|
||
return ( | ||
<DeepDependencyGraphPageImpl | ||
baseUrl={ROUTE_PATH} | ||
|
Uh oh!
There was an error while loading. Please reload this page.