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

Define parent in registerCheckoutBlock #4591

Merged
merged 1 commit into from
Aug 18, 2021

Conversation

mikejolley
Copy link
Member

Update registerCheckoutBlock to include an empty parent property. This ensures a block registered via registerCheckoutBlock is only available in defined areas, not globally.

Fixes #4492

How to test the changes in this Pull Request:

  1. Dev build only (npm start).
  2. "sample block" should not be available in the block inspector at top level.
  3. Insert checkout i2.
  4. "sample block" should be available in the contact information section as an inner block.

@mikejolley mikejolley added status: needs review skip-changelog PRs that you don't want to appear in the changelog. block: checkout Issues related to the checkout block. labels Aug 17, 2021
@mikejolley mikejolley self-assigned this Aug 17, 2021
@mikejolley mikejolley requested a review from a team as a code owner August 17, 2021 15:40
@mikejolley mikejolley requested review from Aljullu and removed request for a team August 17, 2021 15:40
@github-actions
Copy link
Contributor

github-actions bot commented Aug 17, 2021

Size Change: +7 B (0%)

Total Size: 1.13 MB

Filename Size Change
build/blocks-checkout.js 21.2 kB +7 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 8.25 kB
build/active-filters.js 7.89 kB
build/all-products-frontend.js 23.1 kB
build/all-products.js 37.1 kB
build/all-reviews.js 9.6 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.66 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 1.81 kB
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 334 B
build/atomic-block-components/add-to-cart-frontend.js 8.39 kB
build/atomic-block-components/add-to-cart.js 7.74 kB
build/atomic-block-components/button-frontend.js 1.74 kB
build/atomic-block-components/button.js 875 B
build/atomic-block-components/category-list-frontend.js 468 B
build/atomic-block-components/category-list.js 476 B
build/atomic-block-components/image-frontend.js 1.88 kB
build/atomic-block-components/image.js 1.34 kB
build/atomic-block-components/price-frontend.js 2.1 kB
build/atomic-block-components/price.js 2.11 kB
build/atomic-block-components/rating-frontend.js 561 B
build/atomic-block-components/rating.js 566 B
build/atomic-block-components/sale-badge-frontend.js 859 B
build/atomic-block-components/sale-badge.js 867 B
build/atomic-block-components/sku-frontend.js 388 B
build/atomic-block-components/sku.js 394 B
build/atomic-block-components/stock-indicator-frontend.js 610 B
build/atomic-block-components/stock-indicator.js 611 B
build/atomic-block-components/summary-frontend.js 905 B
build/atomic-block-components/summary.js 912 B
build/atomic-block-components/tag-list-frontend.js 466 B
build/atomic-block-components/tag-list.js 471 B
build/atomic-block-components/title-frontend.js 1.43 kB
build/atomic-block-components/title.js 1.28 kB
build/attribute-filter-frontend.js 18.1 kB
build/attribute-filter.js 12 kB
build/cart-frontend.js 90.7 kB
build/cart.js 45.8 kB
build/checkout-blocks/sample.js 173 B
build/checkout-frontend.js 94.8 kB
build/checkout-i2-frontend.js 51.6 kB
build/checkout-i2.js 48.7 kB
build/checkout.js 48.8 kB
build/featured-category.js 7.81 kB
build/featured-product.js 9.51 kB
build/handpicked-products.js 6.35 kB
build/price-filter-frontend.js 14.4 kB
build/price-filter.js 9.62 kB
build/price-format.js 1.37 kB
build/product-best-sellers.js 6.69 kB
build/product-categories.js 3.38 kB
build/product-category.js 7.56 kB
build/product-new.js 6.85 kB
build/product-on-sale.js 7.21 kB
build/product-search.js 2.66 kB
build/product-tag.js 6.67 kB
build/product-top-rated.js 6.82 kB
build/products-by-attribute.js 7.79 kB
build/reviews-by-category.js 11.6 kB
build/reviews-by-product.js 13.1 kB
build/reviews-frontend.js 9.01 kB
build/single-product-frontend.js 26 kB
build/single-product.js 9.8 kB
build/vendors--atomic-block-components/add-to-cart-frontend.js 20.2 kB
build/vendors--atomic-block-components/price-frontend.js 5.71 kB
build/wc-blocks-data.js 11 kB
build/wc-blocks-editor-style-rtl.css 15.3 kB
build/wc-blocks-editor-style.css 15.4 kB
build/wc-blocks-google-analytics.js 1.98 kB
build/wc-blocks-middleware.js 1.47 kB
build/wc-blocks-registry.js 2.74 kB
build/wc-blocks-shared-context.js 1.54 kB
build/wc-blocks-shared-hocs.js 1.75 kB
build/wc-blocks-style-rtl.css 20 kB
build/wc-blocks-style.css 20 kB
build/wc-blocks-vendors-style-rtl.css 1.37 kB
build/wc-blocks-vendors-style.css 1.37 kB
build/wc-blocks-vendors.js 253 kB
build/wc-blocks.js 3.5 kB
build/wc-payment-method-bacs.js 806 B
build/wc-payment-method-cheque.js 806 B
build/wc-payment-method-cod.js 898 B
build/wc-payment-method-paypal.js 839 B
build/wc-payment-method-stripe.js 12.2 kB
build/wc-settings.js 2.91 kB

compressed-size-action

@mikejolley mikejolley force-pushed the fix/register-checkout-block-parent branch from f461fd5 to a3ec41c Compare August 17, 2021 16:09
@senadir senadir requested review from senadir and removed request for Aljullu August 18, 2021 06:43
if ( options?.configuration ) {
assertOption( options, 'configuration', 'object' );
registerExperimentalBlockType( blockName, {
...options.configuration,
category: 'woocommerce',
parent: [],
Copy link
Member

Choose a reason for hiding this comment

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

Can't we extrapolate this from options.areas?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't seem like we need to. Those areas still work.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand?
I mean that instead of waiting for 3PD to pass the parent value, we implicitly provide it from what's in options.areas

Copy link
Member Author

Choose a reason for hiding this comment

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

Parent should be empty. We're not accepting this prop from 3PD, it's being overwritten as [].

3PD use the area prop to define where they want blocks to appear. Not parent.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, sorry. My understanding is that having [] would disable the block from all inserters.
I don't understand yet how can we show sample block only on our innerBlocks, is it because allowedBlocks override parent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup it certainly looks that way. My testing instructions cover this—sample block can be inserted into the contact information section.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I can see that. Approved.

@github-actions github-actions bot added this to the 5.8.0 milestone Aug 18, 2021
@mikejolley mikejolley merged commit 38d0601 into trunk Aug 18, 2021
@mikejolley mikejolley deleted the fix/register-checkout-block-parent branch August 18, 2021 10:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: checkout Issues related to the checkout block. skip-changelog PRs that you don't want to appear in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sample block should only be visible in correct areas, not...
2 participants