Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Block Widgets: add block transforms for legacy widgets with a block equivalent #4292

Merged
merged 3 commits into from Jun 4, 2021

Conversation

frontdevde
Copy link
Contributor

@frontdevde frontdevde commented May 31, 2021

Fixes #4220

This PR aims to provide block transforms for legacy widgets that have a block equivalent.

As per the product decision outlined in #4220, the widgets we want to provide transforms for are:
Product Search, Product Categories, and Recent Product Reviews

Before After
Screenshot 2021-05-31 at 12 11 27 Screenshot 2021-05-31 at 12 10 37

How to test the changes in this Pull Request:

Widgets to test: Product Search, Product Categories, Recent Product Reviews

Prerequisites:

  1. Install the latest nightly version of WordPress 5.8 (for example using WordPress beta tester).
  2. Install the latest version of Gutenberg.
  3. In order for the block transforms to work, we also need the raw widget instance to be exposed in the REST API. This change is done over in WooCommerce core in a separate PR. To be able to test this, you'll need to use WooCommerce with changes in said PR applied: Widgets: show instance in Rest API woocommerce#30012.
  4. In order to test this, you'll need to add the above-mentioned legacy widgets in the Widgets screen. We're already hiding these as options for the user as we want them to use the blocks instead. The easiest way for you to make them show up for testing again is probably to just remove the following line in woocommerce-gutenberg-products-block:

Screenshot 2021-05-31 at 11 47 30

What to test:

  1. Go to the Widgets editor in Appearance > Widgets.
  2. Add the Product Search, Product Categories, Recent Product Reviews widgets.
  3. Transform each of the widgets using the provided block transform option.
  4. Confirm the default transformation to the Product Search block, the Product Categories List block and the All Reviews block work as expected.
  5. Test each of the widgets again, this time changing options on the widgets. For example for Recent Product Reviews change the "Number of reviews to show" to a small number. In the Product Search widget add a "Title". In the Product Categories List change various combinations of options.
  6. Transform each of the widgets using the provided block transform option.
  7. Confirm the transformations work as expected and retain the changed options that have an equivalent in the blocks.

Changelog

Provide block transforms for legacy widgets with a feature-complete block equivalent.

@frontdevde frontdevde added type: enhancement The issue is a request for an enhancement. focus: FSE Work related to prepare WooCommerce for FSE. labels May 31, 2021
@frontdevde frontdevde requested a review from a team as a code owner May 31, 2021 10:13
@frontdevde frontdevde self-assigned this May 31, 2021
@frontdevde frontdevde requested review from mikejolley and removed request for a team May 31, 2021 10:13
@github-actions
Copy link
Contributor

github-actions bot commented May 31, 2021

Size Change: +391 B (0%)

Total Size: 986 kB

Filename Size Change
build/active-filters.js 7.53 kB +1 B (0%)
build/all-reviews.js 9.28 kB +132 B (+1%)
build/attribute-filter.js 11.4 kB +2 B (0%)
build/featured-category.js 7.23 kB +1 B (0%)
build/featured-product.js 9.4 kB -2 B (0%)
build/price-filter.js 9.3 kB -1 B (0%)
build/product-best-sellers.js 6.12 kB +1 B (0%)
build/product-categories.js 3.38 kB +140 B (+4%)
build/product-category.js 6.99 kB +1 B (0%)
build/product-on-sale.js 6.62 kB +1 B (0%)
build/product-search.js 2.68 kB +118 B (+5%) 🔍
build/product-tag.js 6.11 kB +2 B (0%)
build/products-by-attribute.js 7.22 kB +2 B (0%)
build/reviews-by-category.js 11.2 kB +1 B (0%)
build/reviews-by-product.js 12.7 kB -2 B (0%)
build/vendors.js 242 kB -6 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 7.98 kB 0 B
build/all-products-frontend.js 34.7 kB 0 B
build/all-products.js 36.5 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.39 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 1.95 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 334 B 0 B
build/atomic-block-components/add-to-cart-frontend.js 8.75 kB 0 B
build/atomic-block-components/add-to-cart.js 7.8 kB 0 B
build/atomic-block-components/button-frontend.js 1.73 kB 0 B
build/atomic-block-components/button.js 844 B 0 B
build/atomic-block-components/category-list-frontend.js 469 B 0 B
build/atomic-block-components/category-list.js 478 B 0 B
build/atomic-block-components/image-frontend.js 1.66 kB 0 B
build/atomic-block-components/image.js 1.3 kB 0 B
build/atomic-block-components/price-frontend.js 1.98 kB 0 B
build/atomic-block-components/price.js 2.01 kB 0 B
build/atomic-block-components/rating-frontend.js 521 B 0 B
build/atomic-block-components/rating.js 525 B 0 B
build/atomic-block-components/sale-badge-frontend.js 470 B 0 B
build/atomic-block-components/sale-badge.js 474 B 0 B
build/atomic-block-components/sku-frontend.js 389 B 0 B
build/atomic-block-components/sku.js 393 B 0 B
build/atomic-block-components/stock-indicator-frontend.js 569 B 0 B
build/atomic-block-components/stock-indicator.js 572 B 0 B
build/atomic-block-components/summary-frontend.js 906 B 0 B
build/atomic-block-components/summary.js 910 B 0 B
build/atomic-block-components/tag-list-frontend.js 464 B 0 B
build/atomic-block-components/tag-list.js 472 B 0 B
build/atomic-block-components/title-frontend.js 1.41 kB 0 B
build/atomic-block-components/title.js 1.26 kB 0 B
build/attribute-filter-frontend.js 17.7 kB 0 B
build/blocks-checkout-editor.js 10.4 kB 0 B
build/blocks-checkout.js 19.6 kB 0 B
build/blocks.js 3.51 kB 0 B
build/cart-frontend.js 77.7 kB 0 B
build/cart.js 44.2 kB 0 B
build/checkout-frontend.js 81.8 kB 0 B
build/checkout.js 46.5 kB 0 B
build/editor-rtl.css 14.9 kB 0 B
build/editor.css 14.9 kB 0 B
build/handpicked-products.js 5.89 kB 0 B
build/price-filter-frontend.js 14.2 kB 0 B
build/price-format.js 1.37 kB 0 B
build/product-new.js 6.28 kB 0 B
build/product-top-rated.js 6.26 kB 0 B
build/reviews-frontend.js 8.94 kB 0 B
build/single-product-frontend.js 38.1 kB 0 B
build/single-product.js 9.65 kB 0 B
build/style-rtl.css 18.8 kB 0 B
build/style.css 18.8 kB 0 B
build/vendors--atomic-block-components/price-frontend.js 6.54 kB 0 B
build/vendors-style-rtl.css 1.05 kB 0 B
build/vendors-style.css 1.05 kB 0 B
build/wc-blocks-data.js 10.6 kB 0 B
build/wc-blocks-google-analytics.js 1.99 kB 0 B
build/wc-blocks-middleware.js 1.48 kB 0 B
build/wc-blocks-registry.js 2.74 kB 0 B
build/wc-payment-method-bacs.js 812 B 0 B
build/wc-payment-method-cheque.js 807 B 0 B
build/wc-payment-method-cod.js 903 B 0 B
build/wc-payment-method-paypal.js 844 B 0 B
build/wc-payment-method-stripe.js 12.4 kB 0 B
build/wc-settings.js 2.93 kB 0 B
build/wc-shared-context.js 1.54 kB 0 B
build/wc-shared-hocs.js 1.73 kB 0 B

compressed-size-action

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

Really exciting to see the changes in this PR! One step forward to a day when all WooCommerce frontend can be powered by blocks. 🥳

I will leave the final review to @mikejolley, but I left a suggestion below:

assets/js/blocks/reviews/all-reviews/index.js Show resolved Hide resolved
Copy link
Member

@mikejolley mikejolley left a comment

Choose a reason for hiding this comment

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

This worked once I sorted out my environment :) Just one small item of feedback otherwise :shipit:

assets/js/blocks/product-categories/index.js Outdated Show resolved Hide resolved
@frontdevde frontdevde force-pushed the update/add-block-widget-transforms branch from 833707e to 5261ba2 Compare June 3, 2021 12:14
@Aljullu Aljullu added this to the 5.3.0 milestone Jun 4, 2021
@frontdevde frontdevde merged commit 9257076 into trunk Jun 4, 2021
@frontdevde frontdevde deleted the update/add-block-widget-transforms branch June 4, 2021 14:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: FSE Work related to prepare WooCommerce for FSE. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block widgets: where applicable allow migration to a block for legacy widgets
3 participants