Skip to content

Conversation

@acicovic
Copy link
Collaborator

@acicovic acicovic commented Jun 6, 2024

Description

Attempting to update @wordpress/data, @wordpress/core-data and @wordpress/editor to their latest versions has brought a handful of problems to our automated testing and builds. I consider these to be package typing issues, but it's unknown to us when these will be resolved.

This PR updates the above dependencies through an npm update and implements workarounds for allowing tests to pass and builds to succeed.

Motivation and context

How has this been tested?

Tests pass, builds succeed, and a quick manual test was conducted for affected PCH features.

Summary by CodeRabbit

  • New Features

    • Enhanced post editing capabilities with new functions like editPost, lockPostSaving, removeEditorPanel, selectBlock, unlockPostSaving, and updateBlockAttributes.
  • Improvements

    • Updated the RelatedPostsPanel to conditionally set post content for testing environments.
    • Refined the usePostData function to directly use core/editor for accessing post attributes.
    • Improved the SmartLinkingPanel and TitleSuggestionsPanel components with more specific dispatch calls and restructured imports.
  • Bug Fixes

    • Corrected dispatch calls and imports across multiple components to ensure compatibility with updated @wordpress packages.
  • Chores

    • Updated versions of @wordpress/core-data, @wordpress/data, and @wordpress/editor packages for better performance and security.

@acicovic acicovic added Component: Dependencies Deps: JavaScript Reserved to dependency/dependabot PRs labels Jun 6, 2024
@acicovic acicovic added this to the 3.16.0 milestone Jun 6, 2024
@acicovic acicovic self-assigned this Jun 6, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

Walkthrough

The updates primarily involve upgrading the versions of several @wordpress packages and modifying the GutenbergFunction interface to include new functions and aliases. These changes impact various components and hooks within the project, particularly those related to the editor and block functionalities. The updates ensure compatibility with the new versions and streamline the dispatch calls for core editor functionalities.

Changes

File Path Change Summary
package.json Updated versions of @wordpress/core-data, @wordpress/data, and @wordpress/editor packages.
src/@types/gutenberg/types.ts Added new functions and aliases to the GutenbergFunction interface.
src/content-helper/editor-sidebar/related-posts/component.tsx Updated logic for setting postContent based on the presence of jest.
src/content-helper/editor-sidebar/related-posts/hooks.ts Updated usePostData function to use core/editor directly for post attributes.
src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx Removed import of dispatch from @wordpress/data and added dispatchCoreBlockEditor from ../../../@types/gutenberg/types.
src/content-helper/editor-sidebar/smart-linking/component.tsx Reordered imports, updated dispatch calls, and adjusted function calls related to block attributes and post saving.
src/content-helper/editor-sidebar/title-suggestions/component-title-suggestion.tsx Modified imports and function calls, including adjustments to editPost function.
src/content-helper/editor-sidebar/title-suggestions/component.tsx Updated import statement for dispatchCoreEditor and replaced dispatch('core/editor') with dispatchCoreEditor.
src/content-helper/excerpt-generator/excerpt-generator.tsx Updated import and method call from dispatch('core/edit-post') to dispatchCoreEditPost.
src/js/telemetry/block-change.tsx Added type annotations and specified types for parameters in certain functions.

Assessment against linked issues

Objective Addressed Explanation
Bump @wordpress/data from 9.28.0 to 10.0.0 (#2524)
Ensure compatibility with new versions of @wordpress packages (#2524)
Update dispatch calls to use specific modules (#2524)
Modify function calls related to block attributes and post saving (#2524)

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 Configration 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 marked this pull request as ready for review June 6, 2024 06:04
@acicovic acicovic requested a review from a team as a code owner June 6, 2024 06:04
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: 2

Outside diff range and nitpick comments (1)
src/js/telemetry/block-change.tsx (1)

Line range hint 63-88: The addition of type annotations enhances type safety. Consider using an optional chain for the removedBlock check to further improve code robustness.

- if (removedBlock && removedBlock.name.startsWith(parselyBlockPrefix)) {
+ if (removedBlock?.name.startsWith(parselyBlockPrefix)) {
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0ec7b22 and e0e65be.

Files ignored due to path filters (5)
  • 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/**
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (10)
  • package.json (1 hunks)
  • src/@types/gutenberg/types.ts (2 hunks)
  • src/content-helper/editor-sidebar/related-posts/component.tsx (1 hunks)
  • src/content-helper/editor-sidebar/related-posts/hooks.ts (2 hunks)
  • src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx (3 hunks)
  • src/content-helper/editor-sidebar/smart-linking/component.tsx (5 hunks)
  • src/content-helper/editor-sidebar/title-suggestions/component-title-suggestion.tsx (3 hunks)
  • src/content-helper/editor-sidebar/title-suggestions/component.tsx (3 hunks)
  • src/content-helper/excerpt-generator/excerpt-generator.tsx (2 hunks)
  • src/js/telemetry/block-change.tsx (3 hunks)
Files skipped from review due to trivial changes (1)
  • package.json
Additional context used
Path-based instructions (9)
src/@types/gutenberg/types.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/excerpt-generator/excerpt-generator.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/js/telemetry/block-change.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-title-suggestion.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-block-overlay.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/related-posts/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."
Biome
src/js/telemetry/block-change.tsx

[error] 89-89: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

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

[error] 435-435: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (16)
src/@types/gutenberg/types.ts (4)

14-26: The additions to the GutenbergFunction interface align well with the PR's objectives to enhance TypeScript support.


35-36: The alias dispatchCoreBlockEditor is well-defined and will help prevent intellisense errors.


42-42: The alias dispatchCoreEditor is correctly implemented to simplify dispatch calls.


50-50: The alias dispatchCoreEditPost is appropriately defined and will aid in preventing intellisense errors.

src/content-helper/excerpt-generator/excerpt-generator.tsx (1)

53-53: The replacement of dispatch('core/editor') with dispatchCoreEditPost is a good application of the new TypeScript aliases introduced in the PR.

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

51-54: The use of GutenbergFunction for the editor variable and its method calls correctly utilize the enhanced TypeScript definitions.

src/content-helper/editor-sidebar/title-suggestions/component-title-suggestion.tsx (2)

25-25: Updated import to use dispatchCoreEditor for better type safety and clarity.


167-167: Usage of dispatchCoreEditor.editPost aligns with enhanced dispatch specificity and type safety.

src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx (2)

15-15: Updated import to use dispatchCoreBlockEditor for better type safety and clarity.


75-75: Usage of dispatchCoreBlockEditor.selectBlock aligns with enhanced dispatch specificity and type safety.

src/content-helper/editor-sidebar/title-suggestions/component.tsx (2)

13-13: Updated import to use dispatchCoreEditor for better type safety and clarity.


153-153: Usage of dispatchCoreEditor.editPost aligns with enhanced dispatch specificity and type safety.

Also applies to: 180-180

src/content-helper/editor-sidebar/related-posts/component.tsx (1)

138-145: Conditional logic for setting postContent handles test environments effectively by using a mock value.

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

16-16: Update imports to use specific dispatch functions.

This change aligns with the PR's objective to refine dispatch usage by utilizing specific module dispatch functions, enhancing clarity and maintainability.


604-604: Ensure proper locking mechanism for post saving.

This change correctly implements the locking of post saving, which is crucial for preventing data loss or corruption during the editing process.


626-626: Ensure proper unlocking mechanism for post saving.

This change correctly implements the unlocking of post saving, which is essential for resuming normal operations after edits are completed.

@acicovic
Copy link
Collaborator Author

acicovic commented Jun 6, 2024

@coderabbitai resolve

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Actions performed

Comments resolved and changes approved.

Copy link
Contributor

@vaurdan vaurdan left a comment

Choose a reason for hiding this comment

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

Thank you so much for working on this!

@acicovic acicovic merged commit 0bff30a into develop Jun 6, 2024
@acicovic acicovic deleted the update/data-core-data-and-editor-wordpress-packages branch June 6, 2024 07:53
@acicovic acicovic added Deps Reserved to dependency/dependabot PRs and removed Component: Dependencies labels Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deps: JavaScript Reserved to dependency/dependabot PRs Deps Reserved to dependency/dependabot PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants