Repository navigation
feat(new-webui): Add support for page switching using react-router. #797
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
Changes from 16 commits
e7dce76
df9c602
3c475f6
e554796
976c889
1587060
2f3582c
2837d59
e4a4be6
25ce98a
712af39
f433ee7
d84bcf9
02bbfc7
c36902c
6acc4f9
240e4b8
4049669
2a9c75e
f8f176c
4d40764
748b3c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
Member
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.
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| import {createBrowserRouter} from "react-router"; | ||||||
|
|
||||||
| import IngestView from "./ui/IngestView"; | ||||||
| import MainLayout from "./ui/MainLayout"; | ||||||
| import SearchView from "./ui/SearchView"; | ||||||
|
|
||||||
|
|
||||||
| const router = createBrowserRouter([ | ||||||
|
Member
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.
Suggested change
Contributor
Author
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. I took this syntax from their docs. Unless u have strong opinions i would leave it to match
Member
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. we've been using SNAKE_CASE for global constants but i do get variables are mostly
Contributor
Author
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.
Member
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. I discussed this offline with @kirkrodrigues and here're some consolidated thoughts (a copy of section https://www.notion.so/yscope/WIP-Coding-Guidelines-9a308b847a5343958ba3cb97a850be66?pvs=4#1cf04e4d9e6b80c7ac4fe69b846f5791) Naming convention for constants in JavaScript / TypeScriptJavaScript doesn't enforce deep immutability for
Additional Notes
Member
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. That said, let's make this object deeply frozen since the routes are not expected to be modified elsewhere. We will then rename the object and the filename to
Contributor
Author
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.
Member
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. sure. i just thought of another reason that we don't want to make it deeply frozen: if we are to support any plugins like an optional page. this is fine to leave then |
||||||
| { | ||||||
| path: "/", | ||||||
| Component: MainLayout, | ||||||
| children: [ | ||||||
| {path: "ingest", Component: IngestView}, | ||||||
| {path: "search", Component: SearchView}, | ||||||
| ], | ||||||
| }, | ||||||
| ]); | ||||||
|
|
||||||
|
davemarco marked this conversation as resolved.
Resolved
|
||||||
|
|
||||||
| export default router; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| /** | ||
| * Presents compression statistics. | ||
| * | ||
| * @return | ||
| */ | ||
|
davemarco marked this conversation as resolved.
Resolved
|
||
| const IngestView = () => { | ||
| return ( | ||
| <div> | ||
| <h1>Ingest View</h1> | ||
| <p>This is the Ingest view.</p> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
|
davemarco marked this conversation as resolved.
Resolved
|
||
|
|
||
| export default IngestView; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| import React, {useState} from "react"; | ||
| import { | ||
| Link, | ||
| Outlet, | ||
| } from "react-router"; | ||
|
|
||
| import { | ||
| SearchOutlined, | ||
|
|
@@ -10,16 +14,16 @@ import { | |
| MenuProps, | ||
| } from "antd"; | ||
|
|
||
| import "./MainLayout.css"; | ||
| import styles from "./MainLayout.module.css"; | ||
|
|
||
|
|
||
| const {Sider} = Layout; | ||
|
|
||
| type MenuItem = Required<MenuProps>["items"][number]; | ||
|
|
||
| const items: MenuItem[] = [ | ||
|
Member
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. How about SIDEBAR_MENU_ITEMS?
Member
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. Let's make this deeply frozen with
Contributor
Author
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. |
||
| {label: "Ingest", key: "/ingest", icon: <UploadOutlined/>}, | ||
| {label: "Search", key: "/search", icon: <SearchOutlined/>}, | ||
| {label: <Link to={"/ingest"}>Ingest</Link>, key: "/ingest", icon: <UploadOutlined/>}, | ||
| {label: <Link to={"/search"}>Search</Link>, key: "/search", icon: <SearchOutlined/>}, | ||
| ]; | ||
|
|
||
| /** | ||
|
|
@@ -31,7 +35,7 @@ const MainLayout = () => { | |
| const [collapsed, setCollapsed] = useState(false); | ||
|
|
||
| return ( | ||
| <Layout className={"main-layout"}> | ||
| <Layout className={styles["main-layout"]}> | ||
|
Member
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. Let's use camelCasing for class names in CSS modules, following the recommendation at https://github.com/css-modules/css-modules/blob/master/docs/naming.md Then we can use the dot-notation here
Contributor
Author
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. directly accesing them dosen't work with typescript. the linter complains CSS modules dosent have native typescript support I tried this plugin but i can't really seem to get it working - https://github.com/mrmckeb/typescript-plugin-css-modules Let me know if I should just go back to regular css.
Member
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. Let me quickly check the linter on my end.
Member
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.
this plugin is only a Language Service Plugin, which means it only have effects in IDEs (than How about this:
{
files: [
"**/*.ts",
"**/*.tsx",
],
rules: {
"dot-notation": "off",
"@typescript-eslint/dot-notation": "error",
},
},I will also be adding the above to Let me know what you think.
Contributor
Author
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. It's neat that you found a fix for this. Turning this off
Contributor
Author
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. @kirkrodrigues - no longer needed. I resolved with junhao
Contributor
Author
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. @junhaoliao - i got some error adding "@typescript-eslint/dot-notation": "error",, but it worked just fine with only "dot-notation": "off". If this is an issue let me know.
Contributor
Author
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.
Contributor
Author
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. For now i just added "dot-notation": "off"
Member
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.
I created an issue to track this: react-component/select#1143 If time permits, i'll submit a fix to them. Let me know if there're other components giving you issues. |
||
| <Sider | ||
| collapsed={collapsed} | ||
| collapsible={true} | ||
|
|
@@ -41,16 +45,19 @@ const MainLayout = () => { | |
| setCollapsed(value); | ||
| }} | ||
| > | ||
| <div className={"sider-logo-container"}> | ||
| <div className={styles["sider-logo-container"]}> | ||
| <img | ||
| alt={"CLP Logo"} | ||
| className={"sider-logo"} | ||
| className={styles["sider-logo"]} | ||
| src={"/clp-logo.png"}/> | ||
| </div> | ||
| <Menu | ||
| items={items} | ||
| mode={"inline"}/> | ||
| </Sider> | ||
| <Layout> | ||
| <Outlet/> | ||
| </Layout> | ||
| </Layout> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| /** | ||
| * Provides a search interface that allows users to query archives and visualize search results. | ||
| * | ||
| * @return | ||
| */ | ||
| const SearchView = () => { | ||
| return ( | ||
| <div> | ||
| <h1>Search View</h1> | ||
| <p>This is the Search view.</p> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
|
davemarco marked this conversation as resolved.
Resolved
|
||
|
|
||
| export default SearchView; | ||



Uh oh!
There was an error while loading. Please reload this page.