Skip to content

Commit 5d0fd06

Browse files
authored
feat(new-webui): Add support for page switching using react-router. (#797)
1 parent 9176001 commit 5d0fd06

File tree

9 files changed

+142
-17
lines changed

9 files changed

+142
-17
lines changed

components/log-viewer-webui/client/eslint.config.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ const EslintConfig = [
4444
],
4545
},
4646
},
47+
{
48+
// eslint-disable-next-line no-warning-comments
49+
// TODO: Remove dot notation rule once part of eslint-config-yscope
50+
files: [
51+
"**/*.ts",
52+
"**/*.tsx",
53+
],
54+
rules: {
55+
"dot-notation": "off",
56+
"@typescript-eslint/dot-notation": "error",
57+
},
58+
},
4759
];
4860

4961

components/log-viewer-webui/client/package-lock.json

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/log-viewer-webui/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"antd": "^5.24.5",
2222
"axios": "^1.7.9",
2323
"react": "^19.0.0",
24-
"react-dom": "^19.0.0"
24+
"react-dom": "^19.0.0",
25+
"react-router": "^7.4.1"
2526
},
2627
"devDependencies": {
2728
"@types/react": "^19.0.10",
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import MainLayout from "./ui/MainLayout";
1+
import {RouterProvider} from "react-router";
2+
3+
import router from "./router";
24

35

46
/**
@@ -7,9 +9,7 @@ import MainLayout from "./ui/MainLayout";
79
* @return
810
*/
911
const AntApp = () => {
10-
return (
11-
<MainLayout/>
12-
);
12+
return <RouterProvider router={router}/>;
1313
};
1414

1515
export default AntApp;

components/log-viewer-webui/client/src/ui/MainLayout.css renamed to components/log-viewer-webui/client/src/components/Layout/MainLayout.module.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
.main-layout {
1+
.mainLayout {
22
min-height: 100vh;
33
}
44

5-
.sider-logo-container {
5+
.siderLogoContainer {
66
display: flex;
77
justify-content: center;
88
align-items: center;
99
height: 64px;
1010
}
1111

12-
.sider-logo {
12+
.siderLogo {
1313
max-width: 100%;
1414
max-height: 100%;
1515
height: 32px;

components/log-viewer-webui/client/src/ui/MainLayout.tsx renamed to components/log-viewer-webui/client/src/components/Layout/MainLayout.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import {useState} from "react";
2+
import {
3+
Link,
4+
Outlet,
5+
} from "react-router";
26

37
import {
48
SearchOutlined,
@@ -10,16 +14,16 @@ import {
1014
MenuProps,
1115
} from "antd";
1216

13-
import "./MainLayout.css";
17+
import styles from "./MainLayout.module.css";
1418

1519

1620
const {Sider} = Layout;
1721

1822
type MenuItem = Required<MenuProps>["items"][number];
1923

20-
const items: MenuItem[] = [
21-
{label: "Ingest", key: "/ingest", icon: <UploadOutlined/>},
22-
{label: "Search", key: "/search", icon: <SearchOutlined/>},
24+
const SIDEBAR_MENU_ITEMS: MenuItem[] = [
25+
{label: <Link to={"/ingest"}>Ingest</Link>, key: "/ingest", icon: <UploadOutlined/>},
26+
{label: <Link to={"/search"}>Search</Link>, key: "/search", icon: <SearchOutlined/>},
2327
];
2428

2529
/**
@@ -31,7 +35,7 @@ const MainLayout = () => {
3135
const [collapsed, setCollapsed] = useState(false);
3236

3337
return (
34-
<Layout className={"main-layout"}>
38+
<Layout className={styles["mainLayout"]}>
3539
<Sider
3640
collapsed={collapsed}
3741
collapsible={true}
@@ -41,18 +45,22 @@ const MainLayout = () => {
4145
setCollapsed(value);
4246
}}
4347
>
44-
<div className={"sider-logo-container"}>
48+
<div className={styles["siderLogoContainer"]}>
4549
<img
4650
alt={"CLP Logo"}
47-
className={"sider-logo"}
51+
className={styles["siderLogo"]}
4852
src={"/clp-logo.png"}/>
4953
</div>
5054
<Menu
51-
items={items}
55+
items={SIDEBAR_MENU_ITEMS}
5256
mode={"inline"}/>
5357
</Sider>
58+
<Layout>
59+
<Outlet/>
60+
</Layout>
5461
</Layout>
5562
);
5663
};
5764

65+
5866
export default MainLayout;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Presents compression statistics.
3+
*
4+
* @return
5+
*/
6+
const IngestPage = () => {
7+
return (
8+
<div>
9+
<h1>Ingest Page</h1>
10+
<p>This is the Ingest Page.</p>
11+
</div>
12+
);
13+
};
14+
15+
16+
export default IngestPage;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Provides a search interface that allows users to query archives and visualize search results.
3+
*
4+
* @return
5+
*/
6+
const SearchPage = () => {
7+
return (
8+
<div>
9+
<h1>Search Page</h1>
10+
<p>This is the Search Page.</p>
11+
</div>
12+
);
13+
};
14+
15+
16+
export default SearchPage;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {createBrowserRouter} from "react-router";
2+
3+
import MainLayout from "./components/Layout/MainLayout";
4+
import IngestPage from "./pages/IngestPage";
5+
import SearchPage from "./pages/SearchPage";
6+
7+
8+
const router = createBrowserRouter([
9+
{
10+
path: "/",
11+
Component: MainLayout,
12+
children: [
13+
{path: "ingest", Component: IngestPage},
14+
{path: "search", Component: SearchPage},
15+
],
16+
},
17+
]);
18+
19+
20+
export default router;

0 commit comments

Comments
 (0)