woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-query/constants.ts

114 lines
2.2 KiB
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { getSetting } from '@woocommerce/settings';
import type { InnerBlockTemplate } from '@wordpress/blocks';
Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812) * Move `EditorBlock` to general `type-defs` `EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references. * Define types for the Product Query block Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern. * Add Product Query utils Add two utility functions: 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type. 2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute. * Refactor and cleanup the JS demo code Specifically: 1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes. 2. Move the variations to their own directory. One file per variation. 3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings. * Update webpack config * Add ProductQuery class * Fix `QueryVariation` enum We had changed the Products on Sale variation slug to something else, but we had forgotten to update the proper enum. * Remove unused params from `update_query` The filter we added to Gutenberg will pass the block and the page, as we might need them in the future and we want to minimize the amount of changes we'll have to do upstream. However, we currently do not use those, so I removed them from our own inner function. Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 08:02:21 +00:00
/**
* Internal dependencies
*/
import { QueryBlockAttributes } from './types';
import { VARIATION_NAME as PRODUCT_TITLE_ID } from './variations/elements/product-title';
Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812) * Move `EditorBlock` to general `type-defs` `EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references. * Define types for the Product Query block Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern. * Add Product Query utils Add two utility functions: 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type. 2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute. * Refactor and cleanup the JS demo code Specifically: 1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes. 2. Move the variations to their own directory. One file per variation. 3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings. * Update webpack config * Add ProductQuery class * Fix `QueryVariation` enum We had changed the Products on Sale variation slug to something else, but we had forgotten to update the proper enum. * Remove unused params from `update_query` The filter we added to Gutenberg will pass the block and the page, as we might need them in the future and we want to minimize the amount of changes we'll have to do upstream. However, we currently do not use those, so I removed them from our own inner function. Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 08:02:21 +00:00
/**
* Returns an object without a key.
*/
function objectOmit< T, K extends keyof T >( obj: T, key: K ) {
const { [ key ]: omit, ...rest } = obj;
return rest;
}
export const QUERY_LOOP_ID = 'core/query';
export const DEFAULT_CORE_ALLOWED_CONTROLS = [ 'taxQuery', 'search' ];
export const ALL_PRODUCT_QUERY_CONTROLS = [
'attributes',
'presets',
'onSale',
'stockStatus',
Release: 9.1.1 (https://github.com/woocommerce/woocommerce-blocks/pull/7948) * Empty commit for release pull request * Update the readme file with 9.1.1 release changes * Product Query: Add `Sorted by title` preset. (https://github.com/woocommerce/woocommerce-blocks/pull/7949) * Add `Sort by title` preset. * sorted, thanks @nerrad * Update the readme file with woocommerce/woocommerce-blocks#7949 changes * 9.1.1 Release: Add testing docs * Atomic Block: fix ancestor definition (https://github.com/woocommerce/woocommerce-blocks/pull/7947) * Fix the incorrect layout of Rating and Price in Classic Template and Products block (https://github.com/woocommerce/woocommerce-blocks/pull/7932) * Fix the incorrect layout of Rating and Price in Classic Template There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block * Add dropdown version of Filter by Stock Status (https://github.com/woocommerce/woocommerce-blocks/pull/7831) * Extend Filter by Stock Editor options with dropdown and single/multiple choice * Add dropdown implementation for Filter by Stock Status * Adjust font-sizes to the rest of the filters * Add tests to Filter by Stock: dropdown and list variants * Change test file extension from .js to .tsx, so it handles types as well * Add E2E test to Filter by Stock checking if display style can be toggled * When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions * Change the name of the filter blocks in the test files * Remove unnecessary waiting step in E2E test for Filter by Stock toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed * Improve the STOCK_STATUS_OPTIONS type handling * Extract onDropdownChange function instead of inline arrow function * Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single * Product Query: Add patterns (https://github.com/woocommerce/woocommerce-blocks/pull/7857) * Product Query: First attempt at adding patterns * Product Query: Update patterns and the default block template * Product Query: And new and update existing patterns * Product Query: Adjust layout of the Minimal Product Row pattern * Product Query: Update pattern names * Product Query: Polish spaces between blocks inside the patterns * Product Query patterns: Link product titles and improve spacing between product elements * Product Query patterns: Button font-size update * Product Query patterns: Center the pagination * Product Query patterns: Center the pagination for the default pattern * Product Query patterns: Remove an empty column * Product Query patterns: Remove an empty column from the product list with 1:1 images pattern * Add dropdown version of Filter by Rating (https://github.com/woocommerce/woocommerce-blocks/pull/7771) * Rename the setting section to match Filter by Attribute * Add Display Style toggle to the block settings * Set list as a default value of displayStyle for Filter by Rating * Add dropdown variant of Filter by Rating * Extend the Editor settings with selectType: single or multiple * Adjust the styles of a FormTokenField to other dropdown * Align Editor settings order and wording between Filter by Attribute and Rating * Fix the issue with cut off corners of dropdown borders * Provide translated screen reader messages and placeholder * Revert the label property, which is necessary to display checkbox list * Make classname for Rating component optional and remove styling in Filter by Rating * Cover the case when filter with zero products needs string methods for comparison * Handle Typescript errors and add ts-ignore annotations when necessary * Remove explicit key prop assignment in Rating component * Remove leftover property in type definition * Refactor JSX element extension with custom properties to more robust way with object copy * Filter by rating tests (https://github.com/woocommerce/woocommerce-blocks/pull/7845) * Filter by Rating tests: - List single - List multiple - Dropdown single - Dropdown multiple * Adjust the font-size of Filter by Rating dropdown to the rest of the filters * Fix E2E tests after the Editor settings label has been changed * Improve sorting in Filter by Rating dropdown With this change the order of options is always descending: in the chips, suggestions, active filters and URL * Change the name of the filter blocks in the test files * Prevent single dropdown input to overflow the wrapper The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css * Remove the unused styles of active options in Filter by Rating Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then * Change the approach of shared styles to fix the dropdown issue in filters Instead of using direct classes, rewrite it to mixin and include in the filters * Fix the Filter by Rating with Products block The problem was with the Products block, that there was incorrect initial value of product ratings query * Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Product Query - Enable "Inherit Query from template" option (https://github.com/woocommerce/woocommerce-blocks/pull/7641) * Add Inherit Query from template option * Update label * Product Elements: Fix block settings (https://github.com/woocommerce/woocommerce-blocks/pull/7914) * Product Elements: Fix block settings * Rating: Fix inactive star color * Product Rating: Fix color inheritance * StyleAttributesUtils: Fix PHP notices and invalid CSS output (https://github.com/woocommerce/woocommerce-blocks/pull/7909) * StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes woocommerce/woocommerce-blocks#7899. * StyleAttributesUtils: Fix border radius and width support * StyleAttributesUtils: Fix border radius and border color support * StyleAttributesUtils: Include additional checks to deal with PHP warnings * StyleAttributesUtils: Improve the custom border array check * Update MiniCart.php to fix price total amount on page load prices are including tax (https://github.com/woocommerce/woocommerce-blocks/pull/7832) * Update MiniCart.php Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is active. Currently displaying wrong amount total on page load if items are already in the basket. * Update MiniCart.php Removed white spaces? * Update MiniCart.php Fixed IF statement * Remove whitespace at end of line Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Product Query: implement compatibility with Filter by Rating block (https://github.com/woocommerce/woocommerce-blocks/pull/7792) * Product Query: implement compatibility with Filter by Rating block woocommerce/woocommerce-blocks#7631 Product Query: implement compatibility with Filter by Rating block * address feedback * address feedback * add comment * add new zip file link * add missing class * add testing instructions about woocommerce/woocommerce-blocks#7947 * add new zip file link * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: kmanijak <karol.manijak@automattic.com> Co-authored-by: Luke O'Regan <oregan.luke@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-12-15 09:02:35 +00:00
'wooInherit',
];
export const DEFAULT_ALLOWED_CONTROLS = [
...DEFAULT_CORE_ALLOWED_CONTROLS,
...ALL_PRODUCT_QUERY_CONTROLS,
];
export const STOCK_STATUS_OPTIONS = getSetting< Record< string, string > >(
'stockStatusOptions',
[]
);
const GLOBAL_HIDE_OUT_OF_STOCK = getSetting< boolean >(
'hideOutOfStockItems',
false
);
export const QUERY_DEFAULT_ATTRIBUTES: QueryBlockAttributes = {
allowedControls: DEFAULT_ALLOWED_CONTROLS,
displayLayout: {
type: 'flex',
columns: 3,
},
Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812) * Move `EditorBlock` to general `type-defs` `EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references. * Define types for the Product Query block Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern. * Add Product Query utils Add two utility functions: 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type. 2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute. * Refactor and cleanup the JS demo code Specifically: 1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes. 2. Move the variations to their own directory. One file per variation. 3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings. * Update webpack config * Add ProductQuery class * Fix `QueryVariation` enum We had changed the Products on Sale variation slug to something else, but we had forgotten to update the proper enum. * Remove unused params from `update_query` The filter we added to Gutenberg will pass the block and the page, as we might need them in the future and we want to minimize the amount of changes we'll have to do upstream. However, we currently do not use those, so I removed them from our own inner function. Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 08:02:21 +00:00
query: {
perPage: 9,
Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812) * Move `EditorBlock` to general `type-defs` `EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references. * Define types for the Product Query block Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern. * Add Product Query utils Add two utility functions: 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type. 2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute. * Refactor and cleanup the JS demo code Specifically: 1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes. 2. Move the variations to their own directory. One file per variation. 3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings. * Update webpack config * Add ProductQuery class * Fix `QueryVariation` enum We had changed the Products on Sale variation slug to something else, but we had forgotten to update the proper enum. * Remove unused params from `update_query` The filter we added to Gutenberg will pass the block and the page, as we might need them in the future and we want to minimize the amount of changes we'll have to do upstream. However, we currently do not use those, so I removed them from our own inner function. Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 08:02:21 +00:00
pages: 0,
offset: 0,
postType: 'product',
Release: 9.1.1 (https://github.com/woocommerce/woocommerce-blocks/pull/7948) * Empty commit for release pull request * Update the readme file with 9.1.1 release changes * Product Query: Add `Sorted by title` preset. (https://github.com/woocommerce/woocommerce-blocks/pull/7949) * Add `Sort by title` preset. * sorted, thanks @nerrad * Update the readme file with woocommerce/woocommerce-blocks#7949 changes * 9.1.1 Release: Add testing docs * Atomic Block: fix ancestor definition (https://github.com/woocommerce/woocommerce-blocks/pull/7947) * Fix the incorrect layout of Rating and Price in Classic Template and Products block (https://github.com/woocommerce/woocommerce-blocks/pull/7932) * Fix the incorrect layout of Rating and Price in Classic Template There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block * Add dropdown version of Filter by Stock Status (https://github.com/woocommerce/woocommerce-blocks/pull/7831) * Extend Filter by Stock Editor options with dropdown and single/multiple choice * Add dropdown implementation for Filter by Stock Status * Adjust font-sizes to the rest of the filters * Add tests to Filter by Stock: dropdown and list variants * Change test file extension from .js to .tsx, so it handles types as well * Add E2E test to Filter by Stock checking if display style can be toggled * When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions * Change the name of the filter blocks in the test files * Remove unnecessary waiting step in E2E test for Filter by Stock toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed * Improve the STOCK_STATUS_OPTIONS type handling * Extract onDropdownChange function instead of inline arrow function * Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single * Product Query: Add patterns (https://github.com/woocommerce/woocommerce-blocks/pull/7857) * Product Query: First attempt at adding patterns * Product Query: Update patterns and the default block template * Product Query: And new and update existing patterns * Product Query: Adjust layout of the Minimal Product Row pattern * Product Query: Update pattern names * Product Query: Polish spaces between blocks inside the patterns * Product Query patterns: Link product titles and improve spacing between product elements * Product Query patterns: Button font-size update * Product Query patterns: Center the pagination * Product Query patterns: Center the pagination for the default pattern * Product Query patterns: Remove an empty column * Product Query patterns: Remove an empty column from the product list with 1:1 images pattern * Add dropdown version of Filter by Rating (https://github.com/woocommerce/woocommerce-blocks/pull/7771) * Rename the setting section to match Filter by Attribute * Add Display Style toggle to the block settings * Set list as a default value of displayStyle for Filter by Rating * Add dropdown variant of Filter by Rating * Extend the Editor settings with selectType: single or multiple * Adjust the styles of a FormTokenField to other dropdown * Align Editor settings order and wording between Filter by Attribute and Rating * Fix the issue with cut off corners of dropdown borders * Provide translated screen reader messages and placeholder * Revert the label property, which is necessary to display checkbox list * Make classname for Rating component optional and remove styling in Filter by Rating * Cover the case when filter with zero products needs string methods for comparison * Handle Typescript errors and add ts-ignore annotations when necessary * Remove explicit key prop assignment in Rating component * Remove leftover property in type definition * Refactor JSX element extension with custom properties to more robust way with object copy * Filter by rating tests (https://github.com/woocommerce/woocommerce-blocks/pull/7845) * Filter by Rating tests: - List single - List multiple - Dropdown single - Dropdown multiple * Adjust the font-size of Filter by Rating dropdown to the rest of the filters * Fix E2E tests after the Editor settings label has been changed * Improve sorting in Filter by Rating dropdown With this change the order of options is always descending: in the chips, suggestions, active filters and URL * Change the name of the filter blocks in the test files * Prevent single dropdown input to overflow the wrapper The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css * Remove the unused styles of active options in Filter by Rating Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then * Change the approach of shared styles to fix the dropdown issue in filters Instead of using direct classes, rewrite it to mixin and include in the filters * Fix the Filter by Rating with Products block The problem was with the Products block, that there was incorrect initial value of product ratings query * Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Product Query - Enable "Inherit Query from template" option (https://github.com/woocommerce/woocommerce-blocks/pull/7641) * Add Inherit Query from template option * Update label * Product Elements: Fix block settings (https://github.com/woocommerce/woocommerce-blocks/pull/7914) * Product Elements: Fix block settings * Rating: Fix inactive star color * Product Rating: Fix color inheritance * StyleAttributesUtils: Fix PHP notices and invalid CSS output (https://github.com/woocommerce/woocommerce-blocks/pull/7909) * StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes woocommerce/woocommerce-blocks#7899. * StyleAttributesUtils: Fix border radius and width support * StyleAttributesUtils: Fix border radius and border color support * StyleAttributesUtils: Include additional checks to deal with PHP warnings * StyleAttributesUtils: Improve the custom border array check * Update MiniCart.php to fix price total amount on page load prices are including tax (https://github.com/woocommerce/woocommerce-blocks/pull/7832) * Update MiniCart.php Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is active. Currently displaying wrong amount total on page load if items are already in the basket. * Update MiniCart.php Removed white spaces? * Update MiniCart.php Fixed IF statement * Remove whitespace at end of line Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Product Query: implement compatibility with Filter by Rating block (https://github.com/woocommerce/woocommerce-blocks/pull/7792) * Product Query: implement compatibility with Filter by Rating block woocommerce/woocommerce-blocks#7631 Product Query: implement compatibility with Filter by Rating block * address feedback * address feedback * add comment * add new zip file link * add missing class * add testing instructions about woocommerce/woocommerce-blocks#7947 * add new zip file link * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: kmanijak <karol.manijak@automattic.com> Co-authored-by: Luke O'Regan <oregan.luke@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-12-15 09:02:35 +00:00
order: 'asc',
orderBy: 'title',
Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812) * Move `EditorBlock` to general `type-defs` `EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references. * Define types for the Product Query block Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern. * Add Product Query utils Add two utility functions: 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type. 2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute. * Refactor and cleanup the JS demo code Specifically: 1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes. 2. Move the variations to their own directory. One file per variation. 3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings. * Update webpack config * Add ProductQuery class * Fix `QueryVariation` enum We had changed the Products on Sale variation slug to something else, but we had forgotten to update the proper enum. * Remove unused params from `update_query` The filter we added to Gutenberg will pass the block and the page, as we might need them in the future and we want to minimize the amount of changes we'll have to do upstream. However, we currently do not use those, so I removed them from our own inner function. Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 08:02:21 +00:00
author: '',
search: '',
exclude: [],
sticky: '',
inherit: false,
__woocommerceAttributes: [],
__woocommerceStockStatus: GLOBAL_HIDE_OUT_OF_STOCK
? Object.keys( objectOmit( STOCK_STATUS_OPTIONS, 'outofstock' ) )
: Object.keys( STOCK_STATUS_OPTIONS ),
Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812) * Move `EditorBlock` to general `type-defs` `EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references. * Define types for the Product Query block Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern. * Add Product Query utils Add two utility functions: 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type. 2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute. * Refactor and cleanup the JS demo code Specifically: 1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes. 2. Move the variations to their own directory. One file per variation. 3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings. * Update webpack config * Add ProductQuery class * Fix `QueryVariation` enum We had changed the Products on Sale variation slug to something else, but we had forgotten to update the proper enum. * Remove unused params from `update_query` The filter we added to Gutenberg will pass the block and the page, as we might need them in the future and we want to minimize the amount of changes we'll have to do upstream. However, we currently do not use those, so I removed them from our own inner function. Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 08:02:21 +00:00
},
};
export const INNER_BLOCKS_TEMPLATE: InnerBlockTemplate[] = [
[
'core/post-template',
{},
[
[ 'woocommerce/product-image' ],
[
'core/post-title',
{
textAlign: 'center',
level: 3,
fontSize: 'medium',
__woocommerceNamespace: PRODUCT_TITLE_ID,
},
[],
],
[
'woocommerce/product-price',
{ textAlign: 'center', fontSize: 'small' },
[],
],
[
'woocommerce/product-button',
{ textAlign: 'center', fontSize: 'small' },
[],
],
],
],
Release: 9.1.1 (https://github.com/woocommerce/woocommerce-blocks/pull/7948) * Empty commit for release pull request * Update the readme file with 9.1.1 release changes * Product Query: Add `Sorted by title` preset. (https://github.com/woocommerce/woocommerce-blocks/pull/7949) * Add `Sort by title` preset. * sorted, thanks @nerrad * Update the readme file with woocommerce/woocommerce-blocks#7949 changes * 9.1.1 Release: Add testing docs * Atomic Block: fix ancestor definition (https://github.com/woocommerce/woocommerce-blocks/pull/7947) * Fix the incorrect layout of Rating and Price in Classic Template and Products block (https://github.com/woocommerce/woocommerce-blocks/pull/7932) * Fix the incorrect layout of Rating and Price in Classic Template There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block * Add dropdown version of Filter by Stock Status (https://github.com/woocommerce/woocommerce-blocks/pull/7831) * Extend Filter by Stock Editor options with dropdown and single/multiple choice * Add dropdown implementation for Filter by Stock Status * Adjust font-sizes to the rest of the filters * Add tests to Filter by Stock: dropdown and list variants * Change test file extension from .js to .tsx, so it handles types as well * Add E2E test to Filter by Stock checking if display style can be toggled * When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions * Change the name of the filter blocks in the test files * Remove unnecessary waiting step in E2E test for Filter by Stock toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed * Improve the STOCK_STATUS_OPTIONS type handling * Extract onDropdownChange function instead of inline arrow function * Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single * Product Query: Add patterns (https://github.com/woocommerce/woocommerce-blocks/pull/7857) * Product Query: First attempt at adding patterns * Product Query: Update patterns and the default block template * Product Query: And new and update existing patterns * Product Query: Adjust layout of the Minimal Product Row pattern * Product Query: Update pattern names * Product Query: Polish spaces between blocks inside the patterns * Product Query patterns: Link product titles and improve spacing between product elements * Product Query patterns: Button font-size update * Product Query patterns: Center the pagination * Product Query patterns: Center the pagination for the default pattern * Product Query patterns: Remove an empty column * Product Query patterns: Remove an empty column from the product list with 1:1 images pattern * Add dropdown version of Filter by Rating (https://github.com/woocommerce/woocommerce-blocks/pull/7771) * Rename the setting section to match Filter by Attribute * Add Display Style toggle to the block settings * Set list as a default value of displayStyle for Filter by Rating * Add dropdown variant of Filter by Rating * Extend the Editor settings with selectType: single or multiple * Adjust the styles of a FormTokenField to other dropdown * Align Editor settings order and wording between Filter by Attribute and Rating * Fix the issue with cut off corners of dropdown borders * Provide translated screen reader messages and placeholder * Revert the label property, which is necessary to display checkbox list * Make classname for Rating component optional and remove styling in Filter by Rating * Cover the case when filter with zero products needs string methods for comparison * Handle Typescript errors and add ts-ignore annotations when necessary * Remove explicit key prop assignment in Rating component * Remove leftover property in type definition * Refactor JSX element extension with custom properties to more robust way with object copy * Filter by rating tests (https://github.com/woocommerce/woocommerce-blocks/pull/7845) * Filter by Rating tests: - List single - List multiple - Dropdown single - Dropdown multiple * Adjust the font-size of Filter by Rating dropdown to the rest of the filters * Fix E2E tests after the Editor settings label has been changed * Improve sorting in Filter by Rating dropdown With this change the order of options is always descending: in the chips, suggestions, active filters and URL * Change the name of the filter blocks in the test files * Prevent single dropdown input to overflow the wrapper The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css * Remove the unused styles of active options in Filter by Rating Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then * Change the approach of shared styles to fix the dropdown issue in filters Instead of using direct classes, rewrite it to mixin and include in the filters * Fix the Filter by Rating with Products block The problem was with the Products block, that there was incorrect initial value of product ratings query * Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Product Query - Enable "Inherit Query from template" option (https://github.com/woocommerce/woocommerce-blocks/pull/7641) * Add Inherit Query from template option * Update label * Product Elements: Fix block settings (https://github.com/woocommerce/woocommerce-blocks/pull/7914) * Product Elements: Fix block settings * Rating: Fix inactive star color * Product Rating: Fix color inheritance * StyleAttributesUtils: Fix PHP notices and invalid CSS output (https://github.com/woocommerce/woocommerce-blocks/pull/7909) * StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes woocommerce/woocommerce-blocks#7899. * StyleAttributesUtils: Fix border radius and width support * StyleAttributesUtils: Fix border radius and border color support * StyleAttributesUtils: Include additional checks to deal with PHP warnings * StyleAttributesUtils: Improve the custom border array check * Update MiniCart.php to fix price total amount on page load prices are including tax (https://github.com/woocommerce/woocommerce-blocks/pull/7832) * Update MiniCart.php Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is active. Currently displaying wrong amount total on page load if items are already in the basket. * Update MiniCart.php Removed white spaces? * Update MiniCart.php Fixed IF statement * Remove whitespace at end of line Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Product Query: implement compatibility with Filter by Rating block (https://github.com/woocommerce/woocommerce-blocks/pull/7792) * Product Query: implement compatibility with Filter by Rating block woocommerce/woocommerce-blocks#7631 Product Query: implement compatibility with Filter by Rating block * address feedback * address feedback * add comment * add new zip file link * add missing class * add testing instructions about woocommerce/woocommerce-blocks#7947 * add new zip file link * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: kmanijak <karol.manijak@automattic.com> Co-authored-by: Luke O'Regan <oregan.luke@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-12-15 09:02:35 +00:00
[
'core/query-pagination',
{
layout: {
type: 'flex',
justifyContent: 'center',
},
},
[],
],
[ 'core/query-no-results' ],
];