Skip to content

Conversation

@acicovic
Copy link
Collaborator

@acicovic acicovic commented May 20, 2025

Description

This PR improves some Content Helper messages, and escapes an unescaped message.

@alecgeatches, I'll be merging this now with the release being today, but I'd welcome a post-merge review.

Motivation and context

Related to #3341 and #3337.

Summary by CodeRabbit

  • Bug Fixes
    • Updated error messages to use more secure and accessible links, including improved link attributes and clearer destinations in authorization-related error notifications.
  • Refactor
    • Improved how error messages are constructed and displayed, enhancing security and localization without changing visible content or functionality.

@acicovic acicovic added this to the 3.19.0 milestone May 20, 2025
@acicovic acicovic self-assigned this May 20, 2025
@acicovic acicovic added the Maintenance & Fixes Ticket/PR related to codebase maintenance tasks label May 20, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 20, 2025

📝 Walkthrough

Walkthrough

The changes update error message links and their attributes in three components related to Content Helper authorization errors. URLs and rel attributes are modified for improved security and accuracy. In one component, error message construction is refactored to separate link generation from translation, using template strings and escaping for safer rendering.

Changes

File(s) Change Summary
src/content-helper/common/content-helper-error.tsx Updated the URL and rel attribute in the error message for the ParselySuggestionsApiNoAuthorization error code. The link now points to a new documentation URL and uses rel="noopener".
src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/tabs-content.tsx Refactored error message rendering for the ParselySuggestionsApiNoAuthorization error. Now constructs the message using sprintf and escapeHTML, with links created as localized anchor tags and injected into the message.
src/js/admin-settings.ts Modified the anchor tag in an error message to include target="_blank" and rel="noopener" for enhanced security. The URL and link text remain unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Component
    participant ContentHelperError

    User->>UI_Component: Triggers action requiring authorization
    UI_Component->>ContentHelperError: Checks for authorization error
    ContentHelperError-->>UI_Component: Returns ParselySuggestionsApiNoAuthorization error
    UI_Component->>UI_Component: Constructs error message with updated links and attributes
    UI_Component-->>User: Displays error message with secure, updated links
Loading

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.

npm warn config production Use --omit=dev instead.
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-20T12_03_11_760Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@acicovic acicovic marked this pull request as ready for review May 20, 2025 12:01
@acicovic acicovic requested a review from a team as a code owner May 20, 2025 12:01
@acicovic acicovic added the Feature: PCI Ticket/PR related to Content Intelligence label May 20, 2025
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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f244a0a and a447c9d.

⛔ Files ignored due to path filters (8)
  • build/admin-settings.asset.php is excluded by !build/**
  • build/admin-settings.js is excluded by !build/**
  • build/content-helper/dashboard-page.asset.php is excluded by !build/**
  • build/content-helper/dashboard-page.js is excluded by !build/**
  • 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/**
📒 Files selected for processing (3)
  • src/content-helper/common/content-helper-error.tsx (1 hunks)
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/tabs-content.tsx (2 hunks)
  • src/js/admin-settings.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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 ...

**/*.{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/js/admin-settings.ts
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/tabs-content.tsx
  • src/content-helper/common/content-helper-error.tsx
🪛 Biome (1.9.4)
src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/tabs-content.tsx

[error] 105-105: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: E2E against WordPress latest
🔇 Additional comments (3)
src/js/admin-settings.ts (1)

279-279: Improved link security and user experience.

The link to request access to Content Helper AI functionality now opens in a new tab (target="_blank") and includes rel="noopener" for security. This ensures the new page cannot access the opener window via JavaScript, which is a security best practice for external links.

src/content-helper/common/content-helper-error.tsx (1)

111-111: Enhanced link security and updated destination URL.

The link has been updated to point to a more specific destination (https://wpvip.com/content-helper/#content-helper-form) and now includes proper security attributes (target="_blank" and rel="noopener"). This change improves both user experience and security.

src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/tabs-content.tsx (1)

6-7: Added necessary imports for safer message handling.

Added escapeHTML and sprintf imports to properly escape HTML and construct messages with variable substitution, which is essential for the improved error message handling.

@acicovic acicovic merged commit 81472bd into add/traffic-boost May 20, 2025
39 checks passed
@acicovic acicovic deleted the update/improve-some-content-helper-messages branch May 20, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: PCI Ticket/PR related to Content Intelligence Maintenance & Fixes Ticket/PR related to codebase maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants