Fix All Products Block Tests due to incorrect Stock Filter addition (https://github.com/woocommerce/woocommerce-blocks/pull/5541)

* Remove stock filter from all products block

* Add missing stock filter to product-category block
This commit is contained in:
Mike Jolley 2022-01-11 11:25:05 +00:00 committed by GitHub
parent a1695861f2
commit a5bd8f0564
3 changed files with 58 additions and 71 deletions

View File

@ -18,6 +18,7 @@ import GridContentControl from '@woocommerce/editor-components/grid-content-cont
import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control';
import ProductCategoryControl from '@woocommerce/editor-components/product-category-control';
import ProductOrderbyControl from '@woocommerce/editor-components/product-orderby-control';
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
import { gridBlockPreview } from '@woocommerce/resource-previews';
import { Icon, folder } from '@woocommerce/icons';
import { getSetting } from '@woocommerce/settings';
@ -119,6 +120,7 @@ class ProductByCategoryBlock extends Component {
orderby,
rows,
alignButtons,
stockStatus,
} = attributes;
return (
@ -186,6 +188,18 @@ class ProductByCategoryBlock extends Component {
value={ orderby }
/>
</PanelBody>
<PanelBody
title={ __(
'Stock level',
'woo-gutenberg-products-block'
) }
initialOpen={ false }
>
<ProductStockControl
setAttributes={ setAttributes }
value={ stockStatus }
/>
</PanelBody>
</InspectorControls>
);
}

View File

@ -18,7 +18,6 @@ export const defaults = {
orderby: 'date',
layoutConfig: DEFAULT_PRODUCT_LIST_LAYOUT,
isPreview: false,
stockStatus: 'any',
};
export const attributes = {
@ -65,12 +64,4 @@ export const attributes = {
type: 'boolean',
default: false,
},
/**
* Whether to display in stock, out of stock or backorder products.
*/
stockStatus: {
type: 'string',
default: 'any',
},
};

View File

@ -2,8 +2,7 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { PanelBody, ToggleControl, SelectControl } from '@wordpress/components';
import ProductStockControl from '@woocommerce/editor-components/product-stock-control';
import { ToggleControl, SelectControl } from '@wordpress/components';
export const getSharedContentControls = ( attributes, setAttributes ) => {
const { contentVisibility } = attributes;
@ -28,65 +27,48 @@ export const getSharedContentControls = ( attributes, setAttributes ) => {
export const getSharedListControls = ( attributes, setAttributes ) => {
return (
<div>
<SelectControl
label={ __(
'Order Products By',
'woo-gutenberg-products-block'
) }
value={ attributes.orderby }
options={ [
{
label: __(
'Default sorting (menu order)',
'woo-gutenberg-products-block'
),
value: 'menu_order',
},
{
label: __(
'Popularity',
'woo-gutenberg-products-block'
),
value: 'popularity',
},
{
label: __(
'Average rating',
'woo-gutenberg-products-block'
),
value: 'rating',
},
{
label: __( 'Latest', 'woo-gutenberg-products-block' ),
value: 'date',
},
{
label: __(
'Price: low to high',
'woo-gutenberg-products-block'
),
value: 'price',
},
{
label: __(
'Price: high to low',
'woo-gutenberg-products-block'
),
value: 'price-desc',
},
] }
onChange={ ( orderby ) => setAttributes( { orderby } ) }
/>
<PanelBody
title={ __( 'Stock level', 'woo-gutenberg-products-block' ) }
initialOpen={ false }
>
<ProductStockControl
setAttributes={ setAttributes }
value={ attributes.stockStatus }
/>
</PanelBody>
</div>
<SelectControl
label={ __( 'Order Products By', 'woo-gutenberg-products-block' ) }
value={ attributes.orderby }
options={ [
{
label: __(
'Default sorting (menu order)',
'woo-gutenberg-products-block'
),
value: 'menu_order',
},
{
label: __( 'Popularity', 'woo-gutenberg-products-block' ),
value: 'popularity',
},
{
label: __(
'Average rating',
'woo-gutenberg-products-block'
),
value: 'rating',
},
{
label: __( 'Latest', 'woo-gutenberg-products-block' ),
value: 'date',
},
{
label: __(
'Price: low to high',
'woo-gutenberg-products-block'
),
value: 'price',
},
{
label: __(
'Price: high to low',
'woo-gutenberg-products-block'
),
value: 'price-desc',
},
] }
onChange={ ( orderby ) => setAttributes( { orderby } ) }
/>
);
};