Skip to content

Conversation

@acicovic
Copy link
Collaborator

@acicovic acicovic commented Jul 30, 2024

This PR merges the trunk branch into the develop branch after the release of wp-parsely 3.16.2.

Summary by CodeRabbit

  • New Features

    • Enhanced PCH Smart Linking to prevent unwanted link suggestions and resolve previous error issues.
    • Improved PCH Related Posts to eliminate indefinite loading.
    • Added a new property for allowed blocks in smart linking, enhancing content linking flexibility.
    • Introduced a filter for dynamic user permissions related to PCH features.
  • Bug Fixes

    • Resolved a bug causing 'No smart links' error despite valid API response.
  • Documentation

    • Updated versioning information to reflect the new release version 3.16.2.
  • Chores

    • Incremented plugin and package version numbers to 3.16.2.

vaurdan and others added 12 commits July 23, 2024 11:01
Co-authored-by: Alex Cicovic <23142906+acicovic@users.noreply.github.com>
…-links

PCH Smart Linking: Fix bug causing ‘No smart links’ error despite valid API response
…n-check

Permissions: Add filter to override default permissions for PCH features
* Add timeout to `usePostData` hook

* Improve documentation

* Remove timeout and check if data has been resolved instead.

* Fix spacing in JSDoc
* Filter out suggestions that are on headings or captions.

* Fix minor CSS issue

* Fix Editor Sidebar duplicated initialization

* Prevent non allowed blocks from being selected in the UI

* Prevent Smart Linking if the block is not in the ALLOWED_BLOCKS array.

* Minor reorganization of the Smart_Linking class

* Remove unneeded freeform block check.

* Add block name to the Hint
* Update wp-parsely version number to 3.16.2

* Update CHANGELOG.md for version 3.16.2

* Remove empty line

* Update wrong version number.
This reverts commit 71f4ea1, reversing
changes made to c2d8cbd.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 30, 2024

Walkthrough

Walkthrough

This update introduces version 3.16.2 of the Parsely WordPress plugin, featuring enhancements to smart linking and related posts functionality. Key improvements include better error handling, permission overrides, and optimizations to the content management experience. The changes enhance the user interaction and overall performance of the plugin while maintaining backward compatibility.

Changes

File(s) Change Summary
CHANGELOG.md, README.md, package.json, wp-parsely.php Version updated from 3.16.1 to 3.16.2.
src/@types/assets/window.d.ts Added wpParselySmartLinkingAllowedBlocks property to the global window declaration.
src/class-permissions.php Introduced filter in current_user_can_use_pch_feature for dynamic permission control.
src/content-helper/editor-sidebar/related-posts/hooks.ts Enhanced usePostData function with new loading states for better data-fetching management.
src/content-helper/editor-sidebar/smart-linking/class-smart-linking.php Added constant for allowed blocks and method to enqueue inline scripts for smart linking.
src/content-helper/editor-sidebar/smart-linking/component-settings.tsx Refined selectedBlock type and improved state management for block selections.
src/content-helper/editor-sidebar/smart-linking/component.tsx Defined return type for processSmartLinks and simplified error handling logic.
src/content-helper/editor-sidebar/smart-linking/smart-linking.scss Added CSS for .components-toggle-group-control-option-base to enhance UI.
src/content-helper/editor-sidebar/smart-linking/smart-linking.tsx Introduced ALLOWED_BLOCKS constant for flexible block rendering in smart linking.
src/content-helper/editor-sidebar/smart-linking/utils.ts Added isInsideHeadingOrCaption function to refine linking context checks.
tests/e2e/utils.ts Updated PLUGIN_VERSION from 3.16.1 to 3.16.2.
tests/e2e/specs/blocks/recommendations/settings.spec.ts Minor formatting change in test specifications.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Backend
    participant Frontend

    User->>Frontend: Interacts with smart linking feature
    Frontend->>Backend: Request allowed blocks
    Backend-->>Frontend: Returns allowed blocks
    Frontend->>Frontend: Update UI based on allowed blocks
    User->>Frontend: Selects a block
    Frontend->>Backend: Process smart links for the selected block
    Backend-->>Frontend: Returns processed smart links
    Frontend-->>User: Display smart links
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@acicovic acicovic self-assigned this Jul 30, 2024
@acicovic acicovic added this to the 3.16.2 milestone Jul 30, 2024
@acicovic
Copy link
Collaborator Author

acicovic commented Jul 30, 2024

My latest commit message contains a typo in the version number. However, the code is correct.

@acicovic acicovic marked this pull request as ready for review July 30, 2024 13:07
@acicovic acicovic requested a review from a team as a code owner July 30, 2024 13:07
@acicovic
Copy link
Collaborator Author

Due to some issues, we used an intermediate branch to merge trunk into develop this time.

@acicovic
Copy link
Collaborator Author

@vaurdan, this looks good to me, but just in case I'll let you review, approve and merge this. No urgency to merge this today, but let's have it merged before any new work is started against develop.

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

Outside diff range, codebase verification and nitpick comments (3)
src/@types/assets/window.d.ts (1)

34-34: Add documentation for the new property.

The new property wpParselySmartLinkingAllowedBlocks should have a JSDoc comment to explain its purpose and usage.

/**
 * The allowed blocks for Smart Linking.
 *
 * @since 3.16.2
 */
wpParselySmartLinkingAllowedBlocks: string[];
src/class-permissions.php (1)

86-98: Ensure the filter documentation is complete and accurate.

The filter documentation is well-written, but ensure it includes all necessary details, such as the purpose and usage examples.

CHANGELOG.md (1)

8-8: Add missing punctuation to the version date.

The date should be followed by a period for consistency.

- ## [3.16.2](https://github.com/Parsely/wp-parsely/compare/3.16.1...3.16.2) - 2024-07-30
+ ## [3.16.2](https://github.com/Parsely/wp-parsely/compare/3.16.1...3.16.2) - 2024-07-30.
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 668e171 and ca76e3f.

Files ignored due to path filters (5)
  • build/content-helper/editor-sidebar-rtl.css is excluded by !build/**
  • build/content-helper/editor-sidebar.asset.php is excluded by !build/**
  • build/content-helper/editor-sidebar.css is excluded by !build/**
  • build/content-helper/editor-sidebar.js is excluded by !build/**
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (16)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • src/@types/assets/window.d.ts (1 hunks)
  • src/class-permissions.php (1 hunks)
  • src/content-helper/editor-sidebar/related-posts/hooks.ts (3 hunks)
  • src/content-helper/editor-sidebar/smart-linking/class-smart-linking.php (3 hunks)
  • src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx (1 hunks)
  • src/content-helper/editor-sidebar/smart-linking/component-settings.tsx (8 hunks)
  • src/content-helper/editor-sidebar/smart-linking/component.tsx (5 hunks)
  • src/content-helper/editor-sidebar/smart-linking/smart-linking.scss (1 hunks)
  • src/content-helper/editor-sidebar/smart-linking/smart-linking.tsx (3 hunks)
  • src/content-helper/editor-sidebar/smart-linking/utils.ts (3 hunks)
  • tests/e2e/specs/blocks/recommendations/settings.spec.ts (1 hunks)
  • tests/e2e/utils.ts (1 hunks)
  • wp-parsely.php (3 hunks)
Files skipped from review due to trivial changes (6)
  • README.md
  • package.json
  • src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx
  • src/content-helper/editor-sidebar/smart-linking/smart-linking.scss
  • tests/e2e/specs/blocks/recommendations/settings.spec.ts
  • tests/e2e/utils.ts
Additional context used
Path-based instructions (9)
src/@types/assets/window.d.ts (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/smart-linking.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/related-posts/hooks.ts (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/class-permissions.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/smart-linking/class-smart-linking.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/smart-linking/component-settings.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."
wp-parsely.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code 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."
src/content-helper/editor-sidebar/smart-linking/utils.ts (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 (29)
src/content-helper/editor-sidebar/smart-linking/smart-linking.tsx (3)

38-38: LGTM!

The new constant ALLOWED_BLOCKS is correctly defined and documented.


50-52: LGTM!

The updated logic for rendering the BlockEdit component is correctly implemented and enhances the functionality.


72-74: LGTM!

The updated logic for rendering the SmartLinkingInspectorControlPanel component is correctly implemented and enhances the functionality.

src/content-helper/editor-sidebar/related-posts/hooks.ts (4)

40-41: LGTM!

The new state variables isLoading and hasResolved are correctly defined and documented.


104-110: LGTM!

The updated logic for checking the loading state is correctly implemented and follows best practices.


111-119: LGTM!

The updated logic for checking the resolution of data is correctly implemented and follows best practices.


131-150: LGTM!

The updated logic for setting the post data is correctly implemented and follows best practices.

src/class-permissions.php (2)

99-105: Verify the default value for the filter.

The default value for the filter is set to false. Ensure this is the intended behavior and document any implications.


107-109: Check the conditional logic for the filter result.

The conditional logic prioritizes the filtered result over the default logic. Ensure this does not introduce any unintended behavior.

src/content-helper/editor-sidebar/smart-linking/class-smart-linking.php (2)

47-47: Ensure the script is enqueued correctly.

The method add_inline_script is hooked to admin_enqueue_scripts. Verify this is the correct hook for the intended functionality.


186-205: Ensure the inline script is secure.

The inline script sets a global variable. Ensure the data is sanitized and secure.

src/content-helper/editor-sidebar/smart-linking/component-settings.tsx (9)

4-5: Ensure all imports are necessary and correct.

The imports include BlockInstance and getBlockType. Verify these are necessary and used correctly.


30-30: Ensure the type definition is accurate.

The type definition for selectedBlock has been updated. Verify this change is accurate and necessary.


53-54: Ensure the new state variable selectedBlockId is used correctly.

The new state variable selectedBlockId is introduced. Verify it is used correctly throughout the component.


92-93: Ensure the initial state of applyToValue is correct.

The initial state of applyToValue is set based on applyTo and selectedBlockId. Verify this logic is correct.


101-107: Ensure the useEffect hook handles the selected block correctly.

The useEffect hook updates applyToValue based on the selected block. Verify this logic is correct and handles all edge cases.


144-169: Ensure the moveButtonAndShowHint function is implemented correctly.

The moveButtonAndShowHint function is updated to be asynchronous and accept a hintText parameter. Verify this implementation is correct and handles all edge cases.


178-186: Ensure the useEffect hook handles block selection correctly.

The useEffect hook handles scenarios where no block is selected or the selected block is not allowed. Verify this logic is correct and handles all edge cases.


207-215: Ensure the workaround for ToggleGroupControl is necessary and correct.

The useEffect hook includes a workaround for setting the value of ToggleGroupControl. Verify this workaround is necessary and implemented correctly.


225-225: Ensure the hint reset logic is correct.

The useEffect hook resets the hint when the selected block changes. Verify this logic is correct.

wp-parsely.php (3)

14-14: Version update approved.

The version number has been correctly updated to 3.16.2 in the plugin header.


73-73: Version update approved.

The version number has been correctly updated to 3.16.2 in the constant declaration.


298-307: Conditional check for $GLOBALS['parsely_editor_sidebar'] approved.

The conditional check ensures that the Editor_Sidebar is only instantiated if it is not already set, preventing unnecessary re-initialization.

src/content-helper/editor-sidebar/smart-linking/component.tsx (3)

354-355: Return type for processSmartLinks approved.

The return type Promise<SmartLink[]> enhances type safety and clarity.


Line range hint 357-433: Return statement in processSmartLinks approved.

The return statement ensures that the processed smart links are returned, which is essential for the calling context.


472-482: Updated error handling in generateSmartLinks approved.

The error handling has been updated to reflect the new processing logic, ensuring consistency.

src/content-helper/editor-sidebar/smart-linking/utils.ts (2)

109-130: New function isInsideHeadingOrCaption approved.

This function enhances the logic for determining the context of nodes during smart linking operations.


380-394: Updated calculateSmartLinkingMatches function approved.

The updates ensure that links are only created in appropriate contexts, improving the overall robustness of the feature.

CHANGELOG.md (1)

10-15: Ensure consistency in the changelog format.

The changelog entries are clear and consistent with the previous sections.

@acicovic acicovic merged commit e13c847 into develop Jul 30, 2024
@acicovic acicovic deleted the merge/trunk-into-develop-after-1.16.2 branch July 30, 2024 14:56
@vaurdan vaurdan mentioned this pull request Jul 31, 2024
28 tasks
@vaurdan vaurdan removed this from the 3.17.0 milestone Aug 8, 2024
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