Single Product Block: avoid to register incompatibility blocks with the Single Product Block on the post/page editor (https://github.com/woocommerce/woocommerce-blocks/pull/10044)

This commit is contained in:
Luigi Teschio 2023-06-30 14:06:12 +02:00 committed by GitHub
parent 6a35063dd1
commit cf8b73d79f
8 changed files with 10 additions and 5 deletions

View File

@ -30,4 +30,5 @@ registerBlockSingleProductTemplate( {
blockName: metadata.name,
blockMetadata: metadata,
blockSettings,
isAvailableOnPostEditor: true,
} );

View File

@ -25,6 +25,6 @@ registerBlockSingleProductTemplate( {
),
},
edit,
ancestor: [ 'woocommerce/single-product' ],
},
isAvailableOnPostEditor: false,
} );

View File

@ -19,6 +19,6 @@ registerBlockSingleProductTemplate( {
icon,
// @ts-expect-error `edit` can be extended to include other attributes
edit,
ancestor: [ 'woocommerce/single-product' ],
},
isAvailableOnPostEditor: false,
} );

View File

@ -29,4 +29,5 @@ registerBlockSingleProductTemplate( {
},
ancestor: [ 'woocommerce/single-product' ],
},
isAvailableOnPostEditor: true,
} );

View File

@ -15,6 +15,6 @@ registerBlockSingleProductTemplate( {
blockMetadata: metadata,
blockSettings: {
edit,
ancestor: [ 'woocommerce/single-product' ],
},
isAvailableOnPostEditor: false,
} );

View File

@ -30,4 +30,5 @@ registerBlockSingleProductTemplate( {
blockName: 'woocommerce/product-rating',
blockMetadata: metadata,
blockSettings: blockConfig,
isAvailableOnPostEditor: true,
} );

View File

@ -19,6 +19,6 @@ registerBlockSingleProductTemplate( {
icon,
edit,
save,
ancestor: [ 'woocommerce/single-product' ],
},
isAvailableOnPostEditor: false,
} );

View File

@ -26,10 +26,12 @@ export const registerBlockSingleProductTemplate = ( {
blockSettings,
isVariationBlock = false,
variationName,
isAvailableOnPostEditor,
}: {
blockName: string;
blockMetadata: Partial< BlockConfiguration >;
blockSettings: Partial< BlockConfiguration >;
isAvailableOnPostEditor: boolean;
isVariationBlock?: boolean;
variationName?: string;
} ) => {
@ -97,7 +99,7 @@ export const registerBlockSingleProductTemplate = ( {
// This subscribe callback could be invoked with the core/blocks store
// which would cause infinite registration loops because of the `registerBlockType` call.
// This local cache helps prevent that.
if ( ! isBlockRegistered ) {
if ( ! isBlockRegistered && isAvailableOnPostEditor ) {
if ( isVariationBlock ) {
blocksRegistered.add( variationName );
registerBlockVariation(