Skip to content

Commit 1bc598c

Browse files
committed
ui: migrate routed pages to react-router v6
1 parent 8d1a564 commit 1bc598c

6 files changed

Lines changed: 16 additions & 53 deletions

File tree

ui/src/components/advanced/ConditionalRoute/ConditionalRoute.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

ui/src/components/basic/PageLayout/Header/UserMenu/UserMenu.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import styles from './UserMenu.module.scss';
33
import withPopup, { PopupContext } from 'contexts/withPopup/withPopup';
4-
import { withRouter, RouteComponentProps } from 'react-router-dom';
54
import ErrorBoundary from 'components/basic/ErrorBoundary/ErrorBoundary';
65
import Tooltip from 'components/basic/Tooltip/Tooltip';
76
import GitHubButton from 'components/basic/GitHubButton/GitHubButton';
@@ -11,7 +10,7 @@ interface State {
1110
menuOpen: boolean;
1211
}
1312

14-
class UserMenu extends React.PureComponent<Props & RouteComponentProps, State> {
13+
class UserMenu extends React.PureComponent<Props, State> {
1514
state: State = {
1615
menuOpen: false,
1716
};
@@ -30,4 +29,4 @@ class UserMenu extends React.PureComponent<Props & RouteComponentProps, State> {
3029
}
3130
}
3231

33-
export default withRouter(withPopup(UserMenu));
32+
export default withPopup(UserMenu);

ui/src/pages/commands/commands.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { withRouter, RouteComponentProps } from 'react-router';
32
import styles from './commands.module.scss';
43
import PageLayout from 'components/basic/PageLayout/PageLayout';
54
import withPopup, { PopupContext } from 'contexts/withPopup/withPopup';
@@ -12,7 +11,7 @@ import InteractiveTerminal, { InteractiveTerminalProps } from 'components/advanc
1211
import AdvancedCodeLine from 'components/basic/CodeSnippet/AdvancedCodeLine/AdvancedCodeLine';
1312
import Button from '../../components/basic/Button/Button';
1413

15-
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext, RouteComponentProps {}
14+
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext {}
1615

1716
interface State {
1817
podList?: V1PodList;
@@ -139,4 +138,4 @@ class Commands extends React.PureComponent<Props, State> {
139138
}
140139
}
141140

142-
export default withRouter(withPopup(withDevSpaceConfig(withWarning(Commands))));
141+
export default withPopup(withDevSpaceConfig(withWarning(Commands)));

ui/src/pages/logs/containers.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { withRouter, RouteComponentProps } from 'react-router';
32
import styles from './containers.module.scss';
43
import PageLayout from 'components/basic/PageLayout/PageLayout';
54
import withPopup, { PopupContext } from 'contexts/withPopup/withPopup';
@@ -13,7 +12,7 @@ import withWarning, { WarningContext } from 'contexts/withWarning/withWarning';
1312
import ChangeNamespace from 'components/views/Logs/ChangeNamespace/ChangeKubeContext';
1413
import authFetch from "../../lib/fetch";
1514

16-
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext, RouteComponentProps {}
15+
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext {}
1716

1817
interface State {
1918
podList?: V1PodList;
@@ -190,4 +189,4 @@ class LogsContainers extends React.PureComponent<Props, State> {
190189
}
191190
}
192191

193-
export default withRouter(withPopup(withDevSpaceConfig(withWarning(LogsContainers))));
192+
export default withPopup(withDevSpaceConfig(withWarning(LogsContainers)));

ui/src/pages/stack/configuration.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { withRouter, RouteComponentProps } from 'react-router';
32
import styles from './configuration.module.scss';
43
import PageLayout from 'components/basic/PageLayout/PageLayout';
54
import withPopup, { PopupContext } from 'contexts/withPopup/withPopup';
@@ -13,7 +12,7 @@ import ProfilePortlet from 'components/views/Stack/Configuration/ProfilePortlet/
1312
import ConfigVariablesPortlet from 'components/views/Stack/Configuration/ConfigVariablesPortlet/ConfigVariablesPortlet';
1413
import { configToYAML } from 'lib/utils';
1514

16-
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext, RouteComponentProps {}
15+
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext {}
1716

1817
interface State {
1918
podList?: V1PodList;
@@ -58,4 +57,4 @@ class StackConfiguration extends React.PureComponent<Props, State> {
5857
}
5958
}
6059

61-
export default withRouter(withPopup(withDevSpaceConfig(withWarning(StackConfiguration))));
60+
export default withPopup(withDevSpaceConfig(withWarning(StackConfiguration)));

ui/src/routes/Routes.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// prettier-ignore
22
import React from 'react';
3-
import { Route, Switch, BrowserRouter } from 'react-router-dom';
3+
import { BrowserRouter, Navigate, Route, Routes as RouterRoutes } from 'react-router-dom';
44
import LogsContainers from 'pages/logs/containers';
5-
import ConditionalRoute from 'components/advanced/ConditionalRoute/ConditionalRoute';
65
import StackConfiguration from 'pages/stack/configuration';
76
import Commands from 'pages/commands/commands';
87

@@ -11,13 +10,13 @@ interface Props {}
1110
const Routes = (_: Props) => {
1211
return (
1312
<BrowserRouter>
14-
<Switch>
15-
<Route exact path="/logs/containers" component={LogsContainers} />
16-
<Route exact path="/stack/configuration" component={StackConfiguration} />
17-
<Route exact path="/commands/commands" component={Commands} />
18-
<ConditionalRoute exact path="/" redirectTo="/logs/containers" when={true} component={LogsContainers} />
19-
<Route render={() => <h1>Page not found</h1>} />
20-
</Switch>
13+
<RouterRoutes>
14+
<Route path="/logs/containers" element={<LogsContainers />} />
15+
<Route path="/stack/configuration" element={<StackConfiguration />} />
16+
<Route path="/commands/commands" element={<Commands />} />
17+
<Route path="/" element={<Navigate replace to="/logs/containers" />} />
18+
<Route path="*" element={<h1>Page not found</h1>} />
19+
</RouterRoutes>
2120
</BrowserRouter>
2221
);
2322
};

0 commit comments

Comments
 (0)