Skip to content

feat(webui): Adds a switch to enable new Ant Design webui and a basic menu.#791

Merged
davemarco merged 10 commits into
mainfrom
nUI
Apr 4, 2025
Merged

feat(webui): Adds a switch to enable new Ant Design webui and a basic menu.#791
davemarco merged 10 commits into
mainfrom
nUI

Conversation

@davemarco

@davemarco davemarco commented Mar 30, 2025

Copy link
Copy Markdown
Contributor

Description

First PR for the front-end of new antd webui.

Design is temporary, for now i am just setting up a shell.

PR adds

  1. Adds a switch to enable new webui front-end. The default is off, so old component is not broken
    until new webui is complete.
  2. Basic menu bar with antd.

Screenshot 2025-03-30 at 5 56 49 PM

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Nothing to validate.

Summary by CodeRabbit

  • New Features

    • Introduced a modern, Ant Design-powered user interface option with an updated layout.
    • Enabled conditional switching between the legacy interface and the new design featuring streamlined navigation.
    • Added a new component for the main layout with a collapsible sidebar and navigation menu.
  • Style

    • Applied fresh styling enhancements ensuring a full-height layout with a responsive, collapsible sidebar for improved visual structure.
    • Introduced new CSS classes for layout styling.
  • Documentation

    • Added a README file with instructions for starting the development server for both standard and Ant Design interfaces.

These updates offer users a more contemporary and flexible interface experience while maintaining a seamless transition from previous versions.

@davemarco davemarco requested a review from a team as a code owner March 30, 2025 22:04
@coderabbitai

coderabbitai Bot commented Mar 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request integrates the Ant Design library into the log viewer web UI client by adding the "antd" dependency. A new functional component, AntApp, has been created to serve as an alternative entry point that renders the MainLayout component. Additionally, the main entry file now includes conditional rendering controlled by the VITE_USE_ANTD_APP environment variable, switching between the existing App component and AntApp. A new CSS file with layout styles and a MainLayout component utilizing Ant Design elements have also been added to support the updated UI structure.

Changes

File(s) Change Summary
components/log-viewer-webui/client/package.json Added new dependency "antd": "^5.24.5" and new script entry "antd": "VITE_USE_ANTD_APP=true npm run start".
components/log-viewer-webui/client/src/AntdApp.tsx Introduced new React component AntApp that imports and renders MainLayout.
components/log-viewer-webui/client/src/main.tsx Modified to conditionally render either AntdApp (when VITE_USE_ANTD_APP is true) or the existing App component, with an added import for AntApp.
components/log-viewer-webui/client/src/ui/MainLayout.tsx
components/log-viewer-webui/client/src/ui/MainLayout.css
Added new layout component MainLayout using Ant Design components along with associated CSS styling for layout and sidebar elements.
components/log-viewer-webui/client/README.md Created new README.md file providing instructions for starting the development server for both standard and Ant Design UI.

Sequence Diagram(s)

sequenceDiagram
    participant Browser as User's Browser
    participant Main as main.tsx
    participant Ant as AntdApp
    participant App as App
    participant Layout as MainLayout

    Browser->>Main: Load application
    Main->>Main: Check VITE_USE_ANTD_APP value
    alt VITE_USE_ANTD_APP is true
        Main->>Ant: Render AntdApp component
        Ant->>Layout: Render MainLayout within AntdApp
    else VITE_USE_ANTD_APP is false
        Main->>App: Render App component
    end
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4a4be6 and 25ce98a.

📒 Files selected for processing (1)
  • components/log-viewer-webui/client/src/main.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/log-viewer-webui/client/src/main.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint-check (macos-latest)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@davemarco davemarco changed the title feat(webui): Adds a switch to enable to new Ant Design webui and a basic menu. feat(webui): Adds a switch to enable new Ant Design webui and a basic menu. Mar 30, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
components/log-viewer-webui/client/src/AntdApp.tsx (1)

1-17: Naming inconsistency and incomplete documentation

There's a naming inconsistency between the file name "AntdApp.tsx" and the component name "AntApp". Also, the JSDoc comment has "@return" but doesn't specify what the component returns.

Consider these improvements:

-const AntApp = () => {
+const AntdApp = () => {
     return (
         <MainLayout/>
     );
 };

-export default AntApp;
+export default AntdApp;

And enhance the JSDoc:

 /**
  * Renders Web UI app.
  *
- * @return
+ * @return {JSX.Element} The main layout of the application
  */
components/log-viewer-webui/client/src/ui/MainLayout.tsx (3)

25-29: Improve JSDoc documentation

The JSDoc comment has "@return" but doesn't specify what the component returns.

 /**
  * The main layout of web ui.
  *
- * @return
+ * @return {JSX.Element} The main layout component with sidebar navigation
  */

39-40: Pass width as a number instead of a string

The "width" prop should be a number rather than a string for consistency with Ant Design's API.

-                width={"150"}
+                width={150}

33-56: Consider adding content area to the layout

The current layout only includes a Sider component, but no content area where the actual application content would be displayed. This might be intentional for this initial PR, but you'll likely need to add this soon.

You could enhance the layout by adding Content and Header components:

<Layout className={"main-layout"}>
    <Sider /* current Sider props */ >
        {/* current Sider content */}
    </Sider>
    <Layout>
        <Layout.Header style={{ padding: 0, background: "#fff" }}>
            {/* Header content */}
        </Layout.Header>
        <Layout.Content style={{ margin: '24px 16px', padding: 24, background: '#fff' }}>
            {/* Main content will go here */}
        </Layout.Content>
    </Layout>
</Layout>
components/log-viewer-webui/client/src/main.tsx (3)

21-33: Follow coding guidelines for condition check

According to the coding guidelines, conditions should use the form false == <expression> rather than !<expression> or <expression>.

-if (antdFlag) {
+if (true == antdFlag) {

20-20: Consider explanation for ESLint disable comment

While the ESLint disable comment addresses the "unnecessary condition" warning (since antdFlag is a constant), it would be helpful to add a brief explanation of why this rule is being disabled.

-/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */
+/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - Required for future configuration options */

12-12: Consider making the flag configurable

Since this is a feature flag for toggling between UI versions, consider making it configurable through environment variables or user settings rather than hardcoded. This would facilitate testing and gradual rollout of the new UI.

-const antdFlag = false;
+const antdFlag = process.env.REACT_APP_USE_ANTD === "true" || false;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2dd008 and 1587060.

⛔ Files ignored due to path filters (2)
  • components/log-viewer-webui/client/package-lock.json is excluded by !**/package-lock.json
  • components/log-viewer-webui/client/public/clp-logo.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • components/log-viewer-webui/client/package.json (1 hunks)
  • components/log-viewer-webui/client/src/AntdApp.tsx (1 hunks)
  • components/log-viewer-webui/client/src/main.tsx (1 hunks)
  • components/log-viewer-webui/client/src/ui/MainLayout.css (1 hunks)
  • components/log-viewer-webui/client/src/ui/MainLayout.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • components/log-viewer-webui/client/src/ui/MainLayout.tsx
  • components/log-viewer-webui/client/src/AntdApp.tsx
  • components/log-viewer-webui/client/src/main.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: lint-check (ubuntu-latest)
🔇 Additional comments (5)
components/log-viewer-webui/client/package.json (1)

20-20: LGTM: Added Ant Design dependency

The addition of the Ant Design library (antd) as a dependency is appropriate for implementing the new UI components described in the PR objectives.

components/log-viewer-webui/client/src/ui/MainLayout.css (1)

1-16: LGTM: Clean layout styling

The CSS styles for the layout are well-structured and follow good practices. Using min-height: 100vh ensures the layout takes up the full viewport height, and the flexbox centering for the logo container is appropriate.

components/log-viewer-webui/client/src/ui/MainLayout.tsx (1)

46-48: Verify logo path existence

Ensure that the logo file exists at the specified path "/clp-logo.png". If using Vite or another bundler, you might need to import the image or place it in the public directory.

Please confirm that the logo file exists at the correct location and is accessible by the application.

components/log-viewer-webui/client/src/main.tsx (2)

10-12: Clear and informative TODO comment

The TODO comment clearly explains that this is temporary logic that should be removed once the new UI is fully implemented. This aligns well with the PR objectives of setting up a foundational structure for the new Ant Design webui.


4-4: New UI integration looks good

The import and conditional rendering of the new Ant Design UI component (AntdApp) is well-implemented. The default setting of antdFlag = false ensures that existing functionality remains unchanged until the new UI is ready, which aligns with the PR objectives.

Also applies to: 21-26

Comment thread components/log-viewer-webui/client/src/ui/MainLayout.tsx
@davemarco davemarco requested a review from junhaoliao March 30, 2025 22:07

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits

import "./MainLayout.css";


const {Sider} = Layout;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Antd intentionally nested the component inside Layout. Would it be fine to use <Layout.Sider/> directly?

@davemarco davemarco Apr 1, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they will both work.
However, the way it is done in the code matches their doc examples for the component

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to post this before the approval -

i did some research and it seems that the destructing way is preferred because it makes the code more concise


/* eslint-disable-next-line no-warning-comments */
// TODO: Remove flag and related logic when the new UI is fully implemented.
const antdFlag = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about writing it as const {USE_ANTD_APP} = import.meta.env; and adding an npm script "dev:antd": "USE_ANTD_APP=true npm run dev"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And document the purpose script somewhere in a Markdown doc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this slightly - requires VITE_ prefix. Also got rid of dev:antd, since the start script is technically also dev.

Comment thread components/log-viewer-webui/client/src/main.tsx Outdated
Comment thread components/log-viewer-webui/client/src/ui/MainLayout.tsx Outdated

@davemarco davemarco left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I made changes

import "./MainLayout.css";


const {Sider} = Layout;

@davemarco davemarco Apr 1, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they will both work.
However, the way it is done in the code matches their doc examples for the component

@davemarco davemarco requested a review from junhaoliao April 1, 2025 16:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
components/log-viewer-webui/client/README.md (2)

3-3: Heading Level Increment Issue at Line 3

The "Start a Dev Server" heading is marked as an H3. Given the main title is H1, consider using H2 to maintain the recommended incremental heading hierarchy.

-### Start a Dev Server
+## Start a Dev Server
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


9-9: Heading Level Increment Issue at Line 9

Similar to the previous comment, the "Start a Dev Server for the New WebUI (Under Development)" heading is set as H3. To maintain a consistent structure following the H1 title, please change it to H2.

-### Start a Dev Server for the New WebUI (Under Development)
+## Start a Dev Server for the New WebUI (Under Development)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3582c and e4a4be6.

📒 Files selected for processing (4)
  • components/log-viewer-webui/client/README.md (1 hunks)
  • components/log-viewer-webui/client/package.json (2 hunks)
  • components/log-viewer-webui/client/src/main.tsx (2 hunks)
  • components/log-viewer-webui/client/src/ui/MainLayout.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/log-viewer-webui/client/src/ui/MainLayout.tsx
  • components/log-viewer-webui/client/package.json
  • components/log-viewer-webui/client/src/main.tsx
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
components/log-viewer-webui/client/README.md

3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes and title lgtm

@junhaoliao junhaoliao Apr 3, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we start using CSS modules instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you thinks its better we can, i think the project is small now so not a big deal now, but maybe later it could be helpful

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, let's start using CSS Modules in this rewrite. One immediate benefit i see is reducing the risk of typos in class names within our JS / TS code. it also enables smarter refactoring and better support from IDEs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I will make this change in the next PR. for now I will just merge this

junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants