Switch productType to postType in context augmentation
This commit is contained in:
parent
46140f18b9
commit
b40f9d2035
|
@ -16,14 +16,14 @@ interface BlockRepresentation< T extends Record< string, object > > {
|
||||||
}
|
}
|
||||||
|
|
||||||
function useEvaluationContext( context: Record< string, unknown > ) {
|
function useEvaluationContext( context: Record< string, unknown > ) {
|
||||||
const { productType } = context;
|
const { postType } = context;
|
||||||
|
|
||||||
const productId = useEntityId( 'postType', productType );
|
const productId = useEntityId( 'postType', postType );
|
||||||
|
|
||||||
const getEvaluationContext = ( select: typeof WPSelect ) => {
|
const getEvaluationContext = ( select: typeof WPSelect ) => {
|
||||||
const editedProduct = select( 'core' ).getEditedEntityRecord(
|
const editedProduct = select( 'core' ).getEditedEntityRecord(
|
||||||
'postType',
|
'postType',
|
||||||
productType,
|
postType,
|
||||||
productId
|
productId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ function useEvaluationContext( context: Record< string, unknown > ) {
|
||||||
function augmentUsesContext( usesContext?: string[] ) {
|
function augmentUsesContext( usesContext?: string[] ) {
|
||||||
// Note: If you modify this function, also update the server-side
|
// Note: If you modify this function, also update the server-side
|
||||||
// Automattic\WooCommerce\Admin\Features\ProductBlockEditor\BlockRegistry::augment_uses_context() function.
|
// Automattic\WooCommerce\Admin\Features\ProductBlockEditor\BlockRegistry::augment_uses_context() function.
|
||||||
return [ ...( usesContext || [] ), 'productType' ];
|
return [ ...( usesContext || [] ), 'postType' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerProductEditorBlockType<
|
export function registerProductEditorBlockType<
|
||||||
|
|
|
@ -164,7 +164,7 @@ class BlockRegistry {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
isset( $uses_context ) ? $uses_context : [],
|
isset( $uses_context ) ? $uses_context : [],
|
||||||
[
|
[
|
||||||
'productType',
|
'postType',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue