Skip to content

Refactor layout controls to use ToolsPanel instead of PanelBody #59632

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

Conversation

lysyjan
Copy link
Contributor

@lysyjan lysyjan commented Jul 14, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes WOOPLUG-4919

  • This PR replaces usage of the PanelBody component with the ToolsPanel component.

Screenshots or screen recordings:

Before After
Screenshot 2025-07-14 at 12 20 32 Screenshot 2025-07-14 at 12 15 55

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Enable the email editor feature in WooCommerce > Settings > Advanced> Features
  2. Go to WooCommerce > Settings > Emails and open an email in the editor
  3. Verify the functionality of the core/buttons block and its configuration

Testing that has already taken place:

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@lysyjan lysyjan self-assigned this Jul 14, 2025
@lysyjan lysyjan marked this pull request as ready for review July 14, 2025 10:25
Copy link
Contributor

github-actions bot commented Jul 14, 2025

Size Change: +163 B (0%)

Total Size: 5.85 MB

compressed-size-action

Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

📝 Walkthrough

Walkthrough

The changes update the email editor's layout controls by replacing the PanelBody UI component with the ToolsPanel and ToolsPanelItem components. A new resetAll function is added to handle resetting the justifyContent property. No changes are made to exported or public entities.

Changes

File(s) Change Summary
.../changelog/wooplug-4919-migrate-panelbody-to-toolspanel-in-the-email-editor Added changelog entry describing the migration from PanelBody to ToolsPanel.
.../src/layouts/flex-email.tsx Replaced PanelBody with ToolsPanel and ToolsPanelItem; added resetAll function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LayoutControls
    participant ToolsPanel
    participant ToolsPanelItem

    User->>LayoutControls: Interact with layout controls
    LayoutControls->>ToolsPanel: Render ToolsPanel with resetAll prop
    ToolsPanel->>ToolsPanelItem: Render ToolsPanelItem with hasValue and onDeselect
    ToolsPanelItem->>LayoutControls: Trigger resetAll on deselect
    LayoutControls->>LayoutControls: Remove justifyContent from layout attribute
Loading

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a55347 and ac958a7.

📒 Files selected for processing (2)
  • packages/js/email-editor/changelog/wooplug-4919-migrate-panelbody-to-toolspanel-in-the-email-editor (1 hunks)
  • packages/js/email-editor/src/layouts/flex-email.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
  • GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: JavaScript - @woocommerce/admin-library [unit]
  • GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: build
  • GitHub Check: Check Asset Sizes
✨ 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.

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

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4702ce2 and 3a55347.

📒 Files selected for processing (2)
  • packages/js/email-editor/changelog/wooplug-4919-migrate-panelbody-to-toolspanel-in-the-email-editor (1 hunks)
  • packages/js/email-editor/src/layouts/flex-email.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{php,js,ts,jsx,tsx}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-06-30T09:26:55.361Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
Learnt from: triple0t
PR: woocommerce/woocommerce#59186
File: packages/js/email-editor/src/store/initial-state.ts:9-10
Timestamp: 2025-06-26T12:13:32.062Z
Learning: In WooCommerce email editor store initialization (packages/js/email-editor/src/store/initial-state.ts), the current_post_id and current_post_type from window.WooCommerceEmailEditor are required parameters that should cause explicit errors if missing, rather than using fallback values or optional chaining. The design preference is to fail fast when critical initialization data is unavailable.
packages/js/email-editor/changelog/wooplug-4919-migrate-panelbody-to-toolspanel-in-the-email-editor (1)
Learnt from: triple0t
PR: woocommerce/woocommerce#59186
File: packages/js/email-editor/src/store/initial-state.ts:9-10
Timestamp: 2025-06-26T12:13:32.062Z
Learning: In WooCommerce email editor store initialization (packages/js/email-editor/src/store/initial-state.ts), the current_post_id and current_post_type from window.WooCommerceEmailEditor are required parameters that should cause explicit errors if missing, rather than using fallback values or optional chaining. The design preference is to fail fast when critical initialization data is unavailable.
packages/js/email-editor/src/layouts/flex-email.tsx (1)
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Check Asset Sizes
  • GitHub Check: build
🔇 Additional comments (3)
packages/js/email-editor/src/layouts/flex-email.tsx (2)

14-15: LGTM! Proper import of experimental components.

The imports correctly use the experimental ToolsPanel components from @wordpress/components. The naming convention with __experimental prefix is appropriate for these components.


127-148: Well-structured ToolsPanel implementation.

The refactoring from PanelBody to ToolsPanel is well-implemented:

  • Proper use of resetAll function for both ToolsPanel and ToolsPanelItem
  • Correct isShownByDefault prop for core layout controls
  • Appropriate nesting of controls within Flex layout
  • Maintains the same functionality with improved UI structure
packages/js/email-editor/changelog/wooplug-4919-migrate-panelbody-to-toolspanel-in-the-email-editor (1)

1-5: LGTM! Accurate changelog entry.

The changelog entry correctly documents this as a patch-level tweak that replaces PanelBody with ToolsPanel component. The description is concise and accurate.

Copy link
Contributor

github-actions bot commented Jul 14, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@lysyjan lysyjan force-pushed the wooplug-4919-migrate-panelbody-to-toolspanel-in-the-email-editor branch from 3a55347 to ac958a7 Compare July 14, 2025 10:34
@lysyjan lysyjan requested a review from triple0t July 14, 2025 10:54
@lysyjan lysyjan assigned triple0t and unassigned lysyjan Jul 14, 2025
Copy link
Contributor

Testing Guidelines

Hi @triple0t ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copy link
Contributor

@triple0t triple0t left a comment

Choose a reason for hiding this comment

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

Looks good and no error in the console.

Before After
Screenshot 2025-07-14 at 2 18 39 PM Screenshot 2025-07-14 at 2 17 49 PM

This was referenced Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ballade Issues related to block-based email editor package: @woocommerce/email-editor issues related to the @woocommerce/email-editor package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants