This repository was archived by the owner on Feb 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +63
-3
lines changed
Expand file tree Collapse file tree 3 files changed +63
-3
lines changed Original file line number Diff line number Diff line change 22 * External dependencies
33 */
44import { __ } from '@wordpress/i18n' ;
5- import { registerBlockType } from '@wordpress/blocks' ;
5+ import { createBlock , registerBlockType } from '@wordpress/blocks' ;
66import { Icon , list } from '@woocommerce/icons' ;
77
88/**
@@ -83,6 +83,26 @@ registerBlockType( 'woocommerce/product-categories', {
8383 } ,
8484 } ,
8585
86+ transforms : {
87+ from : [
88+ {
89+ type : 'block' ,
90+ blocks : [ 'core/legacy-widget' ] ,
91+ // We can't transform if raw instance isn't shown in the REST API.
92+ isMatch : ( { idBase, instance } ) =>
93+ idBase === 'woocommerce_product_categories' &&
94+ ! ! instance ?. raw ,
95+ transform : ( { instance } ) =>
96+ createBlock ( 'woocommerce/product-categories' , {
97+ hasCount : ! ! instance . raw . count ,
98+ hasEmpty : ! instance . raw . hide_empty ,
99+ isDropdown : ! ! instance . raw . dropdown ,
100+ isHierarchical : ! ! instance . raw . hierarchical ,
101+ } ) ,
102+ } ,
103+ ] ,
104+ } ,
105+
86106 deprecated : [
87107 {
88108 // Deprecate HTML save method in favor of dynamic rendering.
Original file line number Diff line number Diff line change 22 * External dependencies
33 */
44import { __ } from '@wordpress/i18n' ;
5- import { registerBlockType } from '@wordpress/blocks' ;
5+ import { createBlock , registerBlockType } from '@wordpress/blocks' ;
66import { Icon , search } from '@woocommerce/icons' ;
77/**
88 * Internal dependencies
@@ -71,6 +71,25 @@ registerBlockType( 'woocommerce/product-search', {
7171 } ,
7272 } ,
7373
74+ transforms : {
75+ from : [
76+ {
77+ type : 'block' ,
78+ blocks : [ 'core/legacy-widget' ] ,
79+ // We can't transform if raw instance isn't shown in the REST API.
80+ isMatch : ( { idBase, instance } ) =>
81+ idBase === 'woocommerce_product_search' && ! ! instance ?. raw ,
82+ transform : ( { instance } ) =>
83+ createBlock ( 'woocommerce/product-search' , {
84+ label :
85+ instance . raw . title === ''
86+ ? __ ( 'Search' , 'woo-gutenberg-products-block' )
87+ : instance . raw . title ,
88+ } ) ,
89+ } ,
90+ ] ,
91+ } ,
92+
7493 edit,
7594
7695 /**
Original file line number Diff line number Diff line change 22 * External dependencies
33 */
44import { __ } from '@wordpress/i18n' ;
5- import { registerBlockType } from '@wordpress/blocks' ;
5+ import { createBlock , registerBlockType } from '@wordpress/blocks' ;
66import { Icon , discussion } from '@woocommerce/icons' ;
77
88/**
@@ -51,6 +51,27 @@ registerBlockType( 'woocommerce/all-reviews', {
5151 } ,
5252 } ,
5353
54+ transforms : {
55+ from : [
56+ {
57+ type : 'block' ,
58+ blocks : [ 'core/legacy-widget' ] ,
59+ // We can't transform if raw instance isn't shown in the REST API.
60+ isMatch : ( { idBase, instance } ) =>
61+ idBase === 'woocommerce_recent_reviews' && ! ! instance ?. raw ,
62+ transform : ( { instance } ) =>
63+ createBlock ( 'woocommerce/all-reviews' , {
64+ reviewsOnPageLoad : instance . raw . number ,
65+ imageType : 'product' ,
66+ showLoadMore : false ,
67+ showOrderby : false ,
68+ showReviewDate : false ,
69+ showReviewContent : false ,
70+ } ) ,
71+ } ,
72+ ] ,
73+ } ,
74+
5475 /**
5576 * Renders and manages the block.
5677 *
You can’t perform that action at this time.
0 commit comments