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: doc prop issues #1513

Merged
merged 5 commits into from
Dec 10, 2024
Merged

fix: doc prop issues #1513

merged 5 commits into from
Dec 10, 2024

Conversation

AdiGajbhiye
Copy link
Collaborator

@AdiGajbhiye AdiGajbhiye commented Nov 27, 2024

Overview

  • showing doc prop button when column description is present
  • fix styling
  • added text when no column lineage present
  • added "saved successfully" message when saving documentation

Problem

Describe the problem you are solving. Mention the ticket/issue if applicable.

Solution

Describe the implemented solution. Add external references if needed.

Screenshot/Demo

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

How to test

  • Steps to be followed to verify the solution or code changes
  • Mention if there is any settings configuration added/changed/deleted

Checklist

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

Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

Walkthrough

The pull request introduces enhancements to the DocumentationPropagationButton component in DocumentationPropagation.tsx, adding a new state variable isSaved to track save status. Modifications to the useEffect hook ensure isSaved resets appropriately, while the propagateDocumentation function updates isSaved upon successful saves. The rendering logic now includes feedback for successful saves and adjusts the display when no downstream lineage is detected. Additionally, styling changes in styles.module.scss improve the visual presentation of certain elements.

Changes

File Change Summary
webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx Added isSaved state variable, updated useEffect to reset isSaved, modified propagateDocumentation to set isSaved on success, and adjusted rendering logic for success messages and conditional displays.
webview_panels/src/modules/documentationEditor/components/documentationPropagation/styles.module.scss Increased font weight for first child of .itemRow and .colDesc, added line break and color for second child of .itemRow, and set font weight for the first child of .colDesc.

Possibly related PRs

Suggested reviewers

  • mdesmet

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "/webview_panels".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in "webview_panels/.eslintrc.cjs".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


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
Contributor

@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 d8ce150 in 54 seconds

More details
  • Looked at 221 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. webview_panels/src/modules/documentationEditor/components/documentationPropagation/styles.module.scss:11
  • Draft comment:
    The use of :nth-child here is incorrect. It targets the first and second child of the parent element, not the intended elements within the class. Consider using a more specific selector or restructuring the HTML to apply styles correctly.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx:79
  • Draft comment:
    Please specify a return type for the loadMoreDownstreamModels function to improve code readability and maintainability.
  • Reason this comment was not posted:
    Comment was on unchanged code.
3. webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx:173
  • Draft comment:
    Please specify a return type for the setAllColumnsValue function to improve code readability and maintainability.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_rrlOcOIiZfPR6Oks


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.

>
Propagate documentation to selected models
</Button>
{isSaved && <div>Saved documentation successfully</div>}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider resetting isSaved to false after displaying the success message to ensure correct UI behavior if the component is reused.

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 (7)
webview_panels/src/modules/documentationEditor/components/documentationPropagation/styles.module.scss (1)

21-23: Consider reducing style duplication between .itemRow and .colDesc.

Both classes share identical styling for their children. Consider extracting these common styles into a shared mixin or class.

Here's a suggested refactor:

+@mixin itemChildren {
+  :nth-child(1) {
+    font-weight: 600;
+  }
+
+  :nth-child(2) {
+    line-break: anywhere;
+    color: var(--text-grey2-color);
+  }
+}

.itemRow {
  display: grid;
  grid-template-columns: 1fr 3fr;
-  :nth-child(1) {
-    font-weight: 600;
-  }
-
-  :nth-child(2) {
-    line-break: anywhere;
-    color: var(--text-grey2-color);
-  }
+  @include itemChildren;
}

.colDesc {
-  :nth-child(1) {
-    font-weight: 600;
-  }
-
-  :nth-child(2) {
-    line-break: anywhere;
-    color: var(--text-grey2-color);
-  }
+  @include itemChildren;
}
webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx (6)

Line range hint 71-77: Consider splitting the useEffect for better separation of concerns

The current useEffect handles multiple state resets. Consider separating the isSaved reset into its own effect for better maintainability and clearer intent.

 useEffect(() => {
   setAllColumns([]);
   setCurrColumns(startColumn);
   setTableMetadata([]);
-  setIsSaved(false);
 }, [currentDocsData?.uniqueId, name]);
+
+useEffect(() => {
+  setIsSaved(false);
+}, [currentDocsData?.uniqueId, name]);

189-191: Consider adding user feedback for missing description

While the null check prevents propagation of empty descriptions, consider providing feedback to help users understand why the propagation button isn't visible.

 if (!currColumnDescription) {
-  return null;
+  return (
+    <div className="text-muted">
+      Add a description to enable documentation propagation
+    </div>
+  );
 }

217-222: Consider improving the empty state UI

The "no downstream lineage" message could be enhanced with visual elements and actionable guidance.

-<div className="mt-4">
-  No downstream column level lineage detected to propagate the
-  documentation
-</div>
+<Stack direction="column" className="mt-4 text-center">
+  <div className="mb-2">
+    <EmptyStateIcon size="lg" />
+  </div>
+  <div className="font-medium">
+    No Downstream Lineage Detected
+  </div>
+  <div className="text-muted">
+    This column has no downstream dependencies to propagate documentation to.
+  </div>
+</Stack>

284-284: Enhance the success message feedback

The success message could be improved with styling and potentially an auto-dismiss timer.

-{isSaved && <div>Saved documentation successfully</div>}
+{isSaved && (
+  <div className={styles.successMessage}>
+    <CheckIcon className="mr-2" />
+    Documentation propagated successfully
+  </div>
+)}

Consider adding this CSS to your styles module:

.successMessage {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--success-bg);
  color: var(--success-text);
  border-radius: 4px;
  margin-top: 8px;
}

265-273: Improve loading state handling

The "Load 3 more downstream levels" button's disabled state could be enhanced with a loading indicator.

 <Button
   color="primary"
   outline
   onClick={loadMoreDownstreamModels}
   disabled={isLoading}
 >
-  Load 3 more downstream levels
+  {isLoading ? (
+    <>
+      <Spinner size="sm" className="mr-2" />
+      Loading...
+    </>
+  ) : (
+    'Load 3 more downstream levels'
+  )}
 </Button>

Line range hint 144-169: Consider adding input validation for documentation propagation

The propagateDocumentation function should validate the documentation content before propagation to prevent potential XSS or injection attacks.

 const propagateDocumentation = async () => {
+  // Validate documentation content
+  const sanitizedDescription = sanitizeHtml(currColumnDescription, {
+    allowedTags: ['b', 'i', 'em', 'strong', 'a'],
+    allowedAttributes: {
+      'a': ['href']
+    }
+  });
+
   const defaultPackageName = tableMetadata.filter((t) => t.packageName)[0]
     ?.packageName;
   const defaultPatchPath = defaultPackageName
     ? defaultPackageName + "://models/schema.yml"
     : "";

   const req = [];
   // ... rest of the function
   columns: [{ 
     name: item.column, 
-    description: currColumnDescription 
+    description: sanitizedDescription
   }],
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 035a27e and d8ce150.

📒 Files selected for processing (2)
  • webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx (5 hunks)
  • webview_panels/src/modules/documentationEditor/components/documentationPropagation/styles.module.scss (1 hunks)
🔇 Additional comments (2)
webview_panels/src/modules/documentationEditor/components/documentationPropagation/styles.module.scss (1)

12-19: LGTM! Enhanced visual hierarchy with stronger font weights.

The increased font weight and text styling improvements help distinguish between different levels of content.

webview_panels/src/modules/documentationEditor/components/documentationPropagation/DocumentationPropagation.tsx (1)

63-63: LGTM: Good addition of save status tracking

The addition of the isSaved state variable improves user feedback by tracking successful documentation propagation.

@anandgupta42 anandgupta42 merged commit f9042e7 into master Dec 10, 2024
9 checks passed
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.

3 participants