Skip to content
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

Product Block Editor: Convert Label component and custom block registration to use the newly added APIs in Woo 8.5 #2193

Conversation

eason9487
Copy link
Member

Changes proposed in this Pull Request:

To be compatible with Product Block Editor and to use Woo core APIs as much as possible, this PR converts a few codes to rely on Woo 8.5:

  • Use Woo's product block template API to register custom blocks. (Ref: woocommerce#41937)
  • Replace the copied Label component with the one imported from @woocommerce/product-editor. (Ref: woocommerce#42959)

Screenshots:

📷 Label of the Product select with text field block

image

📷 Label of the Product select field block

image

Detailed test instructions:

📌 Prepare test environment

  1. Please refer to the test preparation in PR 2151 with Woo 8.5.0.
  2. npm install
  3. npm start

📌 Test the changes

  1. Install WooCommerce Brands and activate it.
  2. Go to edit a variable product, e.g. the Hoodie imported from WC's sample products.
  3. Switch to the Google Listings & Ads tab.
  4. Check if there are only two attributes in the Product attributes sections and if the attributes can access their product data.
    • There are features specific to the product block template and they require specific block attributes such as _templateBlockHideConditions and usesContext to make them work.
    • The _templateBlockHideConditions is for conditional hiding a block.
    • The use of usesContext is explained here.
    • After removing _templateBlockHideConditions from block.json files, attributes that are not applicable for variable product should still be hidden, e.g. Color.
    • After removing the usesContext from block.json files, the accessing of attributes should still work well.
  5. Hover on the question icon of Brand (Product select with text field block) to see if the label content shows up.
  6. Hover on the question icon of Adult content (Product select field block) to see if the label content shows up.

Changelog entry

@eason9487 eason9487 requested a review from a team January 3, 2024 11:07
@eason9487 eason9487 self-assigned this Jan 3, 2024
@github-actions github-actions bot added the changelog: tweak Small change, that isn't actually very important. label Jan 3, 2024
@eason9487 eason9487 changed the title Tweak/product block editor use wc 8 5 Product Block Editor: Convert Label component and custom block registration to use the newly added APIs in Woo 8.5 Jan 3, 2024
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (34ca9e8) 60.9% compared to head (2d84378) 61.6%.
Report is 30 commits behind head on feature/support-product-block-editor.

Additional details and impacted files

Impacted file tree graph

@@                           Coverage Diff                            @@
##             feature/support-product-block-editor   #2193     +/-   ##
========================================================================
+ Coverage                                    60.9%   61.6%   +0.7%     
- Complexity                                   4151    4152      +1     
========================================================================
  Files                                         453     453             
  Lines                                       17847   16602   -1245     
========================================================================
- Hits                                        10870   10223    -647     
+ Misses                                       6977    6379    -598     
Flag Coverage Δ
php-unit-tests 61.6% <0.0%> (+0.7%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/Menu/MenuFixesTrait.php 0.0% <ø> (ø)
google-listings-and-ads.php 7.7% <0.0%> (+1.4%) ⬆️
src/Google/GlobalSiteTag.php 0.0% <0.0%> (ø)
src/Admin/ProductBlocksService.php 0.0% <0.0%> (-95.3%) ⬇️

... and 107 files with indirect coverage changes

Copy link
Member

@tomalec tomalec left a comment

Choose a reason for hiding this comment

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

Thanks for the changes and updated explanations :)
I tested it locally with WC 8.5.0-rc.1, reviewed the code, LGTM!

@eason9487 eason9487 merged commit b2eee28 into feature/support-product-block-editor Jan 10, 2024
15 of 16 checks passed
@eason9487 eason9487 deleted the tweak/product-block-editor-use-wc-8-5 branch January 10, 2024 02:28
@eason9487 eason9487 mentioned this pull request Feb 27, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: tweak Small change, that isn't actually very important.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants