Skip to content
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

fix: datapilot code block ui #1452

Merged
merged 1 commit into from
Oct 7, 2024
Merged

fix: datapilot code block ui #1452

merged 1 commit into from
Oct 7, 2024

Conversation

saravmajestic
Copy link
Collaborator

@saravmajestic saravmajestic commented Oct 7, 2024

Overview

Problem

In datapilot, codeblock UI is broken

Solution

Fix the codeblock with right css and theme

Screenshot/Demo

A picture is worth a thousand words. Please highlight the changes if applicable.

How to test

  • Open a dbt model
  • right click -> datapilot -> change
  • codeblock should be having right UI

Checklist

  • I have run this code and it appears to resolve the stated issue
  • README.md updated and added information about my change

Important

Fixes DataPilot code block UI by adding a classname prop to CodeBlockComponent and updating styles in datapilot.module.scss.

  • UI Fix:
    • Add classname prop to CodeBlockComponent in index.tsx to allow custom styling.
    • Update QueryAnalysis.tsx to pass classname from datapilot.module.scss to CodeBlock.
    • Define .codeblock class in datapilot.module.scss to set --code-bg to transparent.

This description was created by Ellipsis for 49403e9. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Enhanced CodeBlock component with customizable styling through a new classname prop.
    • Introduced theme-based styling for the CodeBlock component.
  • Style

    • Added a new CSS class .codeblock for improved styling options, setting the background to transparent.

These updates improve the visual flexibility and customization options for users interacting with the QueryAnalysis component.

@saravmajestic saravmajestic self-assigned this Oct 7, 2024
Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The pull request introduces changes to enhance the styling and functionality of the CodeBlock component within the QueryAnalysis component. A new CSS class is added to the stylesheet, and the CodeBlockComponent is updated to accept a new classname prop for custom styling. These changes facilitate improved visual customization without altering existing logic or functionality.

Changes

File Change Summary
webview_panels/src/modules/dataPilot/components/queryAnalysis/QueryAnalysis.tsx Added import for CSS module and updated CodeBlock to use classname={classes.codeblock}.
webview_panels/src/modules/dataPilot/datapilot.module.scss Introduced new CSS class .codeblock with --code-bg: transparent.
webview_panels/src/uiCore/components/codeblock/index.tsx Added optional classname prop to CodeBlockComponent and updated props destructuring and theme handling.

Possibly related PRs

Suggested reviewers

  • mdesmet

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 resolve resolve all the CodeRabbit review comments.
  • @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.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 49403e9 in 22 seconds

More details
  • Looked at 73 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 drafted comments based on config settings.
1. webview_panels/src/uiCore/components/codeblock/index.tsx:29
  • Draft comment:
    Consider using the classname prop for the outer div to ensure consistent styling.
    <div className={classname || classes.codeblock}>
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment suggests a change that could improve the flexibility of the component by allowing the outer div's className to be customized. This is a valid suggestion as it enhances the component's styling capabilities. The current implementation does not utilize the 'classname' prop for the outer div, which could be a missed opportunity for customization.
    The suggestion might not align with the intended design of the component. The author might have a specific reason for using 'classes.codeblock' for the outer div.
    The suggestion does not remove the existing class but adds flexibility by allowing an override. This does not conflict with the current design but enhances it.
    The comment is valid as it suggests a meaningful improvement to the code by allowing customization of the outer div's className. It should be kept.
2. webview_panels/src/uiCore/components/codeblock/index.tsx:21
  • Draft comment:
    Rename classname to className to follow camelCase convention.
  className
  • Reason this comment was not posted:
    Marked as duplicate.
3. webview_panels/src/uiCore/components/codeblock/index.tsx:38
  • Draft comment:
    Rename classname to className to follow camelCase convention.
        className={className}
  • Reason this comment was not posted:
    Marked as duplicate.
4. webview_panels/src/modules/dataPilot/components/queryAnalysis/QueryAnalysis.tsx:56
  • Draft comment:
    Rename classname to className to follow camelCase convention.
      className={classes.codeblock}
  • Reason this comment was not posted:
    Marked as duplicate.
5. webview_panels/src/uiCore/components/codeblock/index.tsx:15
  • Draft comment:
    Add a return type to the CodeBlockComponent function signature for better clarity and refactoring ease.
}: Props): JSX.Element => {
  • Reason this comment was not posted:
    Comment was on unchanged code.
6. webview_panels/src/uiCore/components/codeblock/index.tsx:13
  • Draft comment:
    Use 'className' instead of 'classname' for clarity and consistency with React conventions.
  className?: string;
  • Reason this comment was not posted:
    Marked as duplicate.
7. webview_panels/src/modules/dataPilot/components/queryAnalysis/QueryAnalysis.tsx:56
  • Draft comment:
    Use 'className' instead of 'classname' for clarity and consistency with React conventions. This applies to multiple instances in the file.
      <CodeBlock code={chat.query} language="sql" fileName={chat.fileName} className={classes.codeblock}/>
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_7dVK3MZV1TDyzJgx


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -10,27 +10,32 @@ interface Props {
fileName?: string;
showLineNumbers?: boolean;
titleActions?: ReactNode;
classname?: string;
Copy link

Choose a reason for hiding this comment

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

Rename classname to className to follow camelCase convention.

Suggested change
classname?: string;
className?: string;

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
webview_panels/src/uiCore/components/codeblock/index.tsx (3)

13-13: Consider renaming classname to className for consistency with React conventions.

The addition of this property enhances the component's flexibility for styling. However, to maintain consistency with React naming conventions, it would be better to use className instead of classname.

Apply this change:

-  classname?: string;
+  className?: string;

27-27: LGTM. Consider using an object for theme mapping.

The addition of editorTheme enhances visual customization based on the current theme. To improve readability and maintainability, consider using an object for theme mapping:

- const editorTheme = theme === Themes.Dark ? "vsc-dark-plus" : "vs";
+ const editorThemes = {
+   [Themes.Dark]: "vsc-dark-plus",
+   [Themes.Light]: "vs"
+ };
+ const editorTheme = editorThemes[theme];

This approach would make it easier to add more themes in the future if needed.


35-35: LGTM. Remember to update classname to className if renamed.

The addition of editorTheme and className props to the CodeblockLib component successfully implements the intended UI improvements. These changes align well with the PR objectives.

If you implement the earlier suggestion to rename classname to className, remember to update this line as well:

- className={classname}
+ className={className}

Also applies to: 38-38

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 058fed6 and 49403e9.

📒 Files selected for processing (3)
  • webview_panels/src/modules/dataPilot/components/queryAnalysis/QueryAnalysis.tsx (2 hunks)
  • webview_panels/src/modules/dataPilot/datapilot.module.scss (1 hunks)
  • webview_panels/src/uiCore/components/codeblock/index.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • webview_panels/src/modules/dataPilot/datapilot.module.scss
🧰 Additional context used
🔇 Additional comments (5)
webview_panels/src/uiCore/components/codeblock/index.tsx (2)

21-21: LGTM, pending rename to className.

The addition of classname to the destructured props is correct and corresponds to the interface change. Remember to rename this to className if you implement the previous suggestion.


Line range hint 1-45: Summary: Changes successfully address PR objectives with minor improvements suggested.

The implemented changes effectively enhance the CodeBlockComponent by introducing custom styling capabilities and theme-based editor customization. These modifications align well with the PR objective of fixing the code block UI by applying the correct CSS and theme.

To further improve the code:

  1. Rename classname to className for consistency with React conventions.
  2. Consider using an object for theme mapping to improve readability and maintainability.

Overall, the changes successfully resolve the stated issue and improve the component's flexibility.

To verify that these changes resolve the issue as intended, you can run the following commands:

These tests will help ensure that the changes have been implemented correctly and that the component is using the new props as intended.

webview_panels/src/modules/dataPilot/components/queryAnalysis/QueryAnalysis.tsx (3)

13-13: LGTM: Import statement for CSS module

The import statement for the SCSS module is correctly placed and follows best practices for importing CSS modules in React components.


Line range hint 1-114: Overall assessment: Changes look good and align with PR objectives

The modifications to import and apply a custom CSS class to the CodeBlock component are well-implemented and should address the UI issues mentioned in the PR objectives. The use of CSS modules is a good practice for style encapsulation.

To fully validate the changes:

  1. Ensure the styles in the codeblock class in datapilot.module.scss correctly fix the UI issues.
  2. Test the component as described in the PR objectives: open a dbt model, right-click to access the datapilot option, and select "change" to verify that the code block displays the correct UI.

Please confirm that you have tested the changes as described in the PR objectives and that the UI issues have been resolved.


56-56: LGTM: Applied custom CSS class to CodeBlock

The custom CSS class from the imported module is correctly applied to the CodeBlock component. This change should address the UI issues mentioned in the PR objectives.

To ensure the CSS is correctly applied and the UI is fixed as intended, please verify the following:

  1. The codeblock class exists in the datapilot.module.scss file
  2. The styles defined in this class correctly address the UI issues

You can run the following script to check the SCSS file:

If the class is found, please review its contents to ensure it addresses the UI issues described in the PR objectives.

@mdesmet mdesmet merged commit 5336c7a into master Oct 7, 2024
10 checks passed
@mdesmet mdesmet deleted the fix/datapilot-codeblock branch October 7, 2024 05:14
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