-
Notifications
You must be signed in to change notification settings - Fork 32
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
PCH: Don't show Snackbar Notices for error messages with links #2601
PCH: Don't show Snackbar Notices for error messages with links #2601
Conversation
WalkthroughWalkthroughThe recent changes primarily focus on enhancing error handling mechanisms in the content helper components by forwarding main UI errors to Snackbar Notices. This update introduces a new method Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as User Interface
participant ErrorComp as ContentHelperError
participant Snackbar as Snackbar Notices
User ->> UI: Triggers an action
UI ->> ErrorComp: Error occurs, createErrorSnackbar()
ErrorComp ->> Snackbar: Displays error message
Snackbar ->> User: Shows error notification
Assessment against linked issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (6)
build/content-helper/dashboard-widget.asset.php
is excluded by!build/**
build/content-helper/dashboard-widget.js
is excluded by!build/**
build/content-helper/editor-sidebar.asset.php
is excluded by!build/**
build/content-helper/editor-sidebar.js
is excluded by!build/**
build/content-helper/excerpt-generator.asset.php
is excluded by!build/**
build/content-helper/excerpt-generator.js
is excluded by!build/**
Files selected for processing (4)
- .eslintrc (1 hunks)
- src/content-helper/common/content-helper-error.tsx (2 hunks)
- src/content-helper/editor-sidebar/smart-linking/component.tsx (1 hunks)
- src/content-helper/editor-sidebar/title-suggestions/component.tsx (1 hunks)
Files not summarized due to errors (1)
- src/content-helper/editor-sidebar/title-suggestions/component.tsx: Error: Server error. Please try again later.
Additional context used
Path-based instructions (3)
src/content-helper/common/content-helper-error.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/title-suggestions/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/smart-linking/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
Additional comments not posted (6)
.eslintrc (1)
50-52
: Addition of a new ESLint rule to allowlink
tag in JSDoc comments.The new rule addition is appropriate and helps in maintaining consistency in JSDoc comments.
src/content-helper/common/content-helper-error.tsx (2)
9-9
: Import ofdispatch
from@wordpress/data
.The import of
dispatch
is necessary for the new methodcreateErrorSnackbar
to create a Snackbar Notice.
186-207
: Addition ofcreateErrorSnackbar
method.The new method
createErrorSnackbar
is well-implemented. It checks if the error message contains links and conditionally creates a Snackbar Notice. The use of a regular expression to check for links is appropriate.src/content-helper/editor-sidebar/title-suggestions/component.tsx (1)
199-199
: Call tocreateErrorSnackbar
method on error.The call to
createErrorSnackbar
method centralizes the error handling logic and ensures that Snackbar Notices are not shown for error messages containing links.src/content-helper/editor-sidebar/smart-linking/component.tsx (2)
480-480
: Call tocreateErrorSnackbar
method on error.The call to
createErrorSnackbar
method centralizes the error handling logic and ensures that Snackbar Notices are not shown for error messages containing links.
488-489
: Call tocreateErrorSnackbar
method on error.The call to
createErrorSnackbar
method centralizes the error handling logic and ensures that Snackbar Notices are not shown for error messages containing links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (6)
build/content-helper/dashboard-widget.asset.php
is excluded by!build/**
build/content-helper/dashboard-widget.js
is excluded by!build/**
build/content-helper/editor-sidebar.asset.php
is excluded by!build/**
build/content-helper/editor-sidebar.js
is excluded by!build/**
build/content-helper/excerpt-generator.asset.php
is excluded by!build/**
build/content-helper/excerpt-generator.js
is excluded by!build/**
Files selected for processing (4)
- .eslintrc (1 hunks)
- src/content-helper/common/content-helper-error.tsx (2 hunks)
- src/content-helper/editor-sidebar/smart-linking/component.tsx (1 hunks)
- src/content-helper/editor-sidebar/title-suggestions/component.tsx (1 hunks)
Files not summarized due to errors (4)
- src/content-helper/editor-sidebar/smart-linking/component.tsx: Error: Server error. Please try again later.
- src/content-helper/editor-sidebar/title-suggestions/component.tsx: Error: Server error. Please try again later.
- src/content-helper/common/content-helper-error.tsx: Error: Server error. Please try again later.
- .eslintrc: Error: Server error. Please try again later.
Additional context used
Path-based instructions (3)
src/content-helper/editor-sidebar/title-suggestions/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/common/content-helper-error.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/smart-linking/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
Additional comments not posted (5)
.eslintrc (2)
50-50
: Allowing unsafe WP APIs might introduce security risks.Disabling
@wordpress/no-unsafe-wp-apis
can introduce security risks. Ensure that this rule is disabled only when necessary and that all usages of unsafe WP APIs are thoroughly reviewed and justified.
52-52
: Ensure link tag usage in JSDocs is properly documented.Allowing the
link
tag in JSDocs is useful for documentation. Ensure that the usage of this tag is consistent and properly documented across the codebase.src/content-helper/common/content-helper-error.tsx (1)
194-207
: LGTM! Ensure proper testing of the new method.The
createErrorSnackbar
method correctly checks for links in the error message and suppresses the Snackbar notification if a link is found. Ensure this new functionality is properly tested.src/content-helper/editor-sidebar/smart-linking/component.tsx (2)
480-480
: Ensure error message is properly formatted.The error message for the
ParselyAborted
error code is correctly formatted usingsprintf
. Ensure that the%d
and%s
placeholders are properly replaced with the number of retry attempts and the pluralized attempt string.
488-489
: Ensure proper testing of the new error handling.The new error handling for the
ParselyAborted
error code correctly sets the error message and creates an error Snackbar. Ensure this new functionality is properly tested.
…messages-with-links
There was a problem hiding this 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
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (6)
build/content-helper/dashboard-widget.asset.php
is excluded by!build/**
build/content-helper/dashboard-widget.js
is excluded by!build/**
build/content-helper/editor-sidebar.asset.php
is excluded by!build/**
build/content-helper/editor-sidebar.js
is excluded by!build/**
build/content-helper/excerpt-generator.asset.php
is excluded by!build/**
build/content-helper/excerpt-generator.js
is excluded by!build/**
Files selected for processing (3)
- src/content-helper/common/content-helper-error.tsx (2 hunks)
- src/content-helper/editor-sidebar/smart-linking/component.tsx (1 hunks)
- src/content-helper/editor-sidebar/title-suggestions/component.tsx (1 hunks)
Additional context used
Path-based instructions (3)
src/content-helper/common/content-helper-error.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/title-suggestions/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/smart-linking/component.tsx (1)
Pattern
**/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
Additional comments not posted (5)
src/content-helper/common/content-helper-error.tsx (2)
203-210
: Ensure JSDoc comments include @SInCE tag.The JSDoc comment for
createErrorSnackbar
is missing the@since
tag. Ensure all JSDoc comments include the@since
tag to indicate the version of the plugin that includes the code.* @since 3.16.0
211-224
: LGTM!The method
createErrorSnackbar
correctly avoids displaying Snackbar Notices for error messages that contain links.src/content-helper/editor-sidebar/title-suggestions/component.tsx (1)
199-199
: LGTM!The method now correctly uses
error.createErrorSnackbar
to handle error notifications, aligning with the new error handling approach.src/content-helper/editor-sidebar/smart-linking/component.tsx (2)
503-504
: LGTM!The method now correctly uses
contentHelperError.createErrorSnackbar
to handle error notifications, aligning with the new error handling approach.
494-494
: LGTM!The method now correctly uses
error.createErrorSnackbar
to handle error notifications, aligning with the new error handling approach.
Description
During our work with #2424 and #2579, we noticed that displaying links in Snackbar Notifications is problematic. With this PR, we're not displaying Snackbar errors when the error message contains an HTML link.
Motivation and context
How has this been tested?
Manually tested that the Snackbar doesn't appear when the error message contains an HTML link.
Summary by CodeRabbit
createErrorSnackbar()
method for more consistent display of error messages.