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:
parent
6a35063dd1
commit
cf8b73d79f
|
@ -30,4 +30,5 @@ registerBlockSingleProductTemplate( {
|
||||||
blockName: metadata.name,
|
blockName: metadata.name,
|
||||||
blockMetadata: metadata,
|
blockMetadata: metadata,
|
||||||
blockSettings,
|
blockSettings,
|
||||||
|
isAvailableOnPostEditor: true,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -25,6 +25,6 @@ registerBlockSingleProductTemplate( {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
edit,
|
edit,
|
||||||
ancestor: [ 'woocommerce/single-product' ],
|
|
||||||
},
|
},
|
||||||
|
isAvailableOnPostEditor: false,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -19,6 +19,6 @@ registerBlockSingleProductTemplate( {
|
||||||
icon,
|
icon,
|
||||||
// @ts-expect-error `edit` can be extended to include other attributes
|
// @ts-expect-error `edit` can be extended to include other attributes
|
||||||
edit,
|
edit,
|
||||||
ancestor: [ 'woocommerce/single-product' ],
|
|
||||||
},
|
},
|
||||||
|
isAvailableOnPostEditor: false,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -29,4 +29,5 @@ registerBlockSingleProductTemplate( {
|
||||||
},
|
},
|
||||||
ancestor: [ 'woocommerce/single-product' ],
|
ancestor: [ 'woocommerce/single-product' ],
|
||||||
},
|
},
|
||||||
|
isAvailableOnPostEditor: true,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -15,6 +15,6 @@ registerBlockSingleProductTemplate( {
|
||||||
blockMetadata: metadata,
|
blockMetadata: metadata,
|
||||||
blockSettings: {
|
blockSettings: {
|
||||||
edit,
|
edit,
|
||||||
ancestor: [ 'woocommerce/single-product' ],
|
|
||||||
},
|
},
|
||||||
|
isAvailableOnPostEditor: false,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -30,4 +30,5 @@ registerBlockSingleProductTemplate( {
|
||||||
blockName: 'woocommerce/product-rating',
|
blockName: 'woocommerce/product-rating',
|
||||||
blockMetadata: metadata,
|
blockMetadata: metadata,
|
||||||
blockSettings: blockConfig,
|
blockSettings: blockConfig,
|
||||||
|
isAvailableOnPostEditor: true,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -19,6 +19,6 @@ registerBlockSingleProductTemplate( {
|
||||||
icon,
|
icon,
|
||||||
edit,
|
edit,
|
||||||
save,
|
save,
|
||||||
ancestor: [ 'woocommerce/single-product' ],
|
|
||||||
},
|
},
|
||||||
|
isAvailableOnPostEditor: false,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -26,10 +26,12 @@ export const registerBlockSingleProductTemplate = ( {
|
||||||
blockSettings,
|
blockSettings,
|
||||||
isVariationBlock = false,
|
isVariationBlock = false,
|
||||||
variationName,
|
variationName,
|
||||||
|
isAvailableOnPostEditor,
|
||||||
}: {
|
}: {
|
||||||
blockName: string;
|
blockName: string;
|
||||||
blockMetadata: Partial< BlockConfiguration >;
|
blockMetadata: Partial< BlockConfiguration >;
|
||||||
blockSettings: Partial< BlockConfiguration >;
|
blockSettings: Partial< BlockConfiguration >;
|
||||||
|
isAvailableOnPostEditor: boolean;
|
||||||
isVariationBlock?: boolean;
|
isVariationBlock?: boolean;
|
||||||
variationName?: string;
|
variationName?: string;
|
||||||
} ) => {
|
} ) => {
|
||||||
|
@ -97,7 +99,7 @@ export const registerBlockSingleProductTemplate = ( {
|
||||||
// This subscribe callback could be invoked with the core/blocks store
|
// This subscribe callback could be invoked with the core/blocks store
|
||||||
// which would cause infinite registration loops because of the `registerBlockType` call.
|
// which would cause infinite registration loops because of the `registerBlockType` call.
|
||||||
// This local cache helps prevent that.
|
// This local cache helps prevent that.
|
||||||
if ( ! isBlockRegistered ) {
|
if ( ! isBlockRegistered && isAvailableOnPostEditor ) {
|
||||||
if ( isVariationBlock ) {
|
if ( isVariationBlock ) {
|
||||||
blocksRegistered.add( variationName );
|
blocksRegistered.add( variationName );
|
||||||
registerBlockVariation(
|
registerBlockVariation(
|
||||||
|
|
Loading…
Reference in New Issue