Commit Graph

2323 Commits

Author SHA1 Message Date
dependabot[bot] 0706ebac63 Bump use-debounce from 7.0.1 to 9.0.4 (https://github.com/woocommerce/woocommerce-blocks/pull/9306)
* Bump use-debounce from 7.0.1 to 9.0.4

Bumps [use-debounce](https://github.com/xnimorz/use-debounce) from 7.0.1 to 9.0.4.
- [Release notes](https://github.com/xnimorz/use-debounce/releases)
- [Changelog](https://github.com/xnimorz/use-debounce/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xnimorz/use-debounce/commits/9.0.4)

---
updated-dependencies:
- dependency-name: use-debounce
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix mocked function

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-07-27 16:10:43 +01:00
Alex Florisca 1e2e0fbe9c Update express checkout title, description, icon (https://github.com/woocommerce/woocommerce-blocks/pull/10237)
* Change icon, title and description of the Express Checkout Block

* Fix icon style

* Update icon and add styles

* change icon for express payments in cart
2023-07-27 09:08:29 +01:00
Tung Du b5100e9d99 Fix: incorrect default number of products in editor when inheriting query (https://github.com/woocommerce/woocommerce-blocks/pull/10303) 2023-07-27 10:06:16 +07:00
Roy Ho a57642318a Change custom toolbar item to use toolbar button (https://github.com/woocommerce/woocommerce-blocks/pull/10246) 2023-07-26 06:19:41 -07:00
Karol Manijak e09962d65a Optimise imports of Product Query variation (https://github.com/woocommerce/woocommerce-blocks/pull/10340)
* Optimise imports of Product Query variation

* Lint: add whitespace
2023-07-26 11:08:01 +02:00
Albert Juhé Lluveras ce16b98893 Fix SearchListControl styles (II) (https://github.com/woocommerce/woocommerce-blocks/pull/10308) 2023-07-24 11:30:54 +02:00
Alba Rincón b8f798b017 Use the `Single Product` block for the `Product Details Product Listing` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9978)
* Show alignment toolbar also when the block is in the single product block

* Start using `Single Product` for the `Product Details Product Listing` pattern

* Use counter and stars blocks in the pattern

* Undo button change

* Make the new rating blocks not experimental

* Add Beta to the average rating block

* Add blocks to block types controller
2023-07-24 11:02:24 +02:00
Roy Ho ef7b811e4b Remove border control (https://github.com/woocommerce/woocommerce-blocks/pull/10277) 2023-07-21 05:46:55 -07:00
Roy Ho 37e197c149 Move sale badge to top right of product image (https://github.com/woocommerce/woocommerce-blocks/pull/10297) 2023-07-21 05:45:09 -07:00
Darren Ethier f708593adb Add Color Panel (https://github.com/woocommerce/woocommerce-blocks/pull/10062)
* Add new ColorPanel component

* Implement new ColorPanel component for the Mini-Cart

* Move ColorPanel types into their own types.ts file alongside the ColorPanel component

* Add useColorPanelStyles hook

* Rename classes to className

* Disable @wordpress/no-unsafe-wp-apis

* Fix tests: Move defaultColorItem object to utils file

* Remove unnecssary types from QuantityBadge

* Fix conflicts

* Remove context

* Fix color picker JS error

* Migrate attribute data to be compatible with ColorPanel component

* Fix incompatible attributes

* Remove useColorPanelStyles hook

* migrateAttributesToColorPanel JS unit tests

* PHP MiniCartUtils tests

* Remove unncessary code for classNames in MiniCart edit

---------

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2023-07-21 10:35:32 +01:00
Karol Manijak 7018ff47b6 Add manual path to upgrade Products block (https://github.com/woocommerce/woocommerce-blocks/pull/10268)
* Add option to manually update Products block to Product Collection

* Disable manual upgrade of Products yet

* Manual update flag doesn't have to be dependant on auto update

* Removed commented out console info logs

* Disable option to upgrade Products block

* Change the way to bold text in Upgrade Notices so it's translatable

* Change the way UpgradeNotice is rendered conditionally
2023-07-21 08:22:49 +02:00
Alexandre Lara f6b84e02e2 Add to Cart Form: Fix broken styles for the block when using inside the Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/10282)
* Fix broken styles for Add to Cart Form block

* Fix PHP CS error
2023-07-20 09:28:15 -03:00
Brian d46997a84f fix woocommerce/woocommerce-blocks#10027 (https://github.com/woocommerce/woocommerce-blocks/pull/10150) 2023-07-20 04:40:40 -07:00
Mike Jolley bd537e1008 Get latest cart when triggering events (https://github.com/woocommerce/woocommerce-blocks/pull/10254) 2023-07-19 10:42:25 +01:00
Alba Rincón 5eef9bff65 Add new `Product Average Rating` block (https://github.com/woocommerce/woocommerce-blocks/pull/10207)
* Add new Product Average Rating block

* Add new blocks to the feature flag docs

* Translate 'No ratings'

* Fix condition

* Small improvements after review

* Avoid duplication of styles

* Update supports in php class
2023-07-19 11:21:30 +02:00
Karol Manijak 67dbd22dfe Fix incorrect filter application in Product Collection (https://github.com/woocommerce/woocommerce-blocks/pull/10263)
* Fix the incorrectly applied filter in Product Collection

* Get the block name from metadata
2023-07-19 11:15:37 +02:00
Manish Menaria 1ea6355a04 Enable auto-expand for product selection in HandPickedProductsControl (https://github.com/woocommerce/woocommerce-blocks/pull/10250)
This commit adds a new `__experimentalExpandOnFocus` attribute to the component within the `HandPickedProductsControl`. The value is set to `true`, enabling automatic expansion of the list when the user focuses on the product selection field.

This change aims to improve the user experience by making it easier for the user to see all available options when they focus on the selection list.
2023-07-19 12:07:24 +05:30
Albert Juhé Lluveras 4e68edff91 Remove work-around code in EditableButton component to fix typing Space (https://github.com/woocommerce/woocommerce-blocks/pull/10248) 2023-07-18 18:04:50 +02:00
Roy Ho cd666ee081 Add class specificity to fix indent (https://github.com/woocommerce/woocommerce-blocks/pull/10245) 2023-07-18 06:21:13 -07:00
Albert Juhé Lluveras bf20e670dd Create Mini-Cart template part area (https://github.com/woocommerce/woocommerce-blocks/pull/10203)
* Create Mini-Cart template part area

* Update Mini-Cart template part name to exclude it

* Update src/BlockTemplatesController.php

Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>

* Update src/BlockTemplatesController.php

Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>

* Keep both variations of the template part name when excluding them

* Revert "Keep both variations of the template part name when excluding them"

This reverts commit c3f293511536d1ebbac0f50caaf74cded28d0025.

---------

Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
2023-07-18 09:12:43 +02:00
Karol Manijak 333c850567 Newest Products: fix Stock Status filter (https://github.com/woocommerce/woocommerce-blocks/pull/10201)
* Newest Products: fix Stock Status filter

* Change the default of Product Stock Control to ALL available stock statuses
2023-07-18 08:39:09 +02:00
Albert Juhé Lluveras 55a6e38598 Prevent Mini-Cart template part preview in Site Editor being too high (https://github.com/woocommerce/woocommerce-blocks/pull/10204)
* Prevent Mini-Cart template part preview in Site Editor being too high

* Remove Mini-Cart Contents styles related to Style Book
2023-07-14 16:12:40 +02:00
Albert Juhé Lluveras a3ac0e2c62 Fix SearchListControl styles (https://github.com/woocommerce/woocommerce-blocks/pull/10192)
* Fix SearchListControl checkbox styles

* Encode SearchListControl labels

* Fix SearchListControl styling

* Update snapshots
2023-07-14 13:50:23 +02:00
Daniel Dudzic 2240504d51 Mini Cart: Fix styling of the Start Shopping button in the drawer. Fixes woocommerce/woocommerce-blocks#10035 (https://github.com/woocommerce/woocommerce-blocks/pull/10169) 2023-07-14 11:47:23 +00:00
Karol Manijak 041d4ad4b1 Stop reading Product IDs from asset store in filter blocks (https://github.com/woocommerce/woocommerce-blocks/pull/10195)
* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.

* Remove the code that's supposed to read product ids for filter context and logic around that in useCollectionData

* Fix incorrect merge

---------

Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-07-14 11:18:10 +02:00
Alba Rincón 3d8331363c `Rating Stars` block improvements (https://github.com/woocommerce/woocommerce-blocks/pull/10148)
* Rating start block improvements

Fix classes, register in single product, remove unused code

* Allow to use block on product & product collection

* Fix star missalignment

* Restrict the block to be insertable only in single product
2023-07-14 09:41:58 +02:00
Alba Rincón d82a4b671f Add new `Ratings counter` block (https://github.com/woocommerce/woocommerce-blocks/pull/10114)
* Add new rating counter block

* Fix colors and register globally

* Add missing import

* Remove unused file

* Reorder blocks alphabetically

* Remove unnecessary html

* Change registration, fix classes

* Fix margin

* Remove icon from block.json, add ancestors

* Move icon and remove unused constants

* Fix classes

* Remove condition

* Allow to use block on product & product collection

* Enable block only on single product

* Move ancestors to block.json
2023-07-14 08:57:19 +02:00
Manish Menaria bd892c4781 Add E2E tests for 'Inherit query from template' control in Product Collection block (https://github.com/woocommerce/woocommerce-blocks/pull/10174)
Key updates:

1. Additional CSS class to Inherit Query Control: A CSS class named `wc-block-product-collection__inherit-query-control` has been added to the ToggleControl component. This provides a precise target for E2E tests and potential custom styles.

2. E2E tests for 'Inherit query from template' control: Numerous scenarios have been covered to ensure the control's correct behavior. These scenarios include verifying visibility under different circumstances and checking its functionality in a Product Catalog template.

3. E2E test code enhancements: The E2E test code now exports the `SELECTORS` object to assist in locating different elements during the tests. This includes the new 'Inherit query from template' control. The `setShowOnlyProductsOnSale()` function has been refactored to improve readability and provide more granular control over its operations.

4. Test scenario for 'Show only products on sale': The existing E2E test for this functionality has been extended to check that it retains its state when the 'Inherit query from template' control is toggled.

These changes increase the robustness of our E2E tests, providing better coverage for the 'Inherit query from template' control in the Product Collection block.
2023-07-14 10:52:19 +05:30
Karol Manijak de0cc88147 Automatic migration path from Products to Product Collection - step 3 - allow reverting migration (https://github.com/woocommerce/woocommerce-blocks/pull/10144)
* Add logic to revert migration from Product to Product Collection
2023-07-12 17:01:49 +02:00
Alex Florisca 52506cbe81 Fix margin issue with the Proceed to checkout button on the site editor (https://github.com/woocommerce/woocommerce-blocks/pull/10182)
* Fix margin issue with the Proceed to checkout button on the site editor

* Remove unecessary selector
2023-07-12 15:28:37 +01:00
Patricia Hillebrandt 64405c7a43 Mini Cart block > Update block registration to rely on a metadata file. (https://github.com/woocommerce/woocommerce-blocks/pull/10168)
* Introduce the block.json file for the mini-cart block.

* Update the index.tsx file to use the new metadata file for registering the mini cart.
2023-07-12 16:20:19 +02:00
Karol Manijak dbfa57bd67 Automatic migration path from Products to Product Collection - step 2 - display notice (https://github.com/woocommerce/woocommerce-blocks/pull/10139)
* Display upgrade notice after successful replacement
2023-07-12 11:19:35 +02:00
Karol Manijak 9b0c610ced Automatic migration path from Products to Product Collection - step 1 - automatic migration (https://github.com/woocommerce/woocommerce-blocks/pull/10115)
* Foundation of the Products block replacement with Product Collection

* Provide logic to replace Products with Product Collection

* Make sure the blocks can be replaced

* Add types and refactor replacement a bit

* Fix the query attributes transform

* Add upgrade Notice to the Product Collection block

* Force upgrade notice to be displayed at the top of the Inspector Controls

* Externalise migration code so it can be reused in both ways

* Add util to get block IDs byt its name

* Add a way to revert the Product Collection blocks to Products

* Move the subscription to another place where it's triggered only once

* Add default values

* Remove attributes from Products block if they're not used to avoid incorrect query

* WIP logic of unseen/seen/reverted notice

* Change the state reading

* Revert changes regarding notice displaying logic

* Change the logc of firing replacement and bail early if there's no core/query blocks

* Add todos

* Implement inner blocks migration

* Implement the revert transformation of inner blocks

* Refactor types

* Add layout transformation from Products to Product Collection

* Add layout migration from Product Collection to Products

* Disable migration by default

* Simplify some parts of code

* Remove additional keyword from Product Collection to move it to another PR

* Adjust the logic to introduce the first step: conversion from Products to Product Collection

* Disable automatic migration
2023-07-12 10:01:36 +02:00
Luigi Teschio 98a61d3a4d Enable declaration-block-no-duplicate-properties stylelint rule (https://github.com/woocommerce/woocommerce-blocks/pull/10163) 2023-07-11 13:03:05 +00:00
Luigi Teschio 45d994d47f Revert "Fix image over content (https://github.com/woocommerce/woocommerce-blocks/pull/10092)" (https://github.com/woocommerce/woocommerce-blocks/pull/10160)
This reverts commit b82c0de69d.
2023-07-11 12:16:12 +00:00
Karol Manijak c55343b736 Product Collection - refactor inspector controls props (https://github.com/woocommerce/woocommerce-blocks/pull/10154)
* Refactor Columns Control inspector controls in Product Collection

* Refactor Order By inspector controls in Product Collection

* Reorder imports in Product Collection Inspector Controls

* Refactor On Sale inspector controls in Product Collection

* Refactor Stock Status inspector controls in Product Collection

* Refactor Keyword inspector controls in Product Collection

* Unify interface of query controlling Inspector Controls

* Unify interfaces of Inspector Controls that modify Query in Product Collection

* Unify other Query modifying Controls

* Simplify types
2023-07-11 13:05:49 +02:00
Karol Manijak fd378be6eb Add "grid" and "list" view switch for Product Collection (https://github.com/woocommerce/woocommerce-blocks/pull/10145)
* Add Display Layout controls to Product Collection

* Adjust the layout type name

* Add explicit display layout types

* Change the function name to setDisplayLayout so it's more explicit

* Pass only the necessary props to nested inspector controls

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-07-10 13:39:09 +02:00
Manish Menaria 708ed47a85 Enhance: Bring back user to 1st page when filters are changed (https://github.com/woocommerce/woocommerce-blocks/pull/9952)
* Add support for filter blocks

This commit updates the `ProductCollection` block implementation to add support for filter blocks, including the Price filter, Attributes filter, Rating filter, and In stock filter.

The changes include:

1. Adding a new property `$attributes_filter_query_args` to store the query arguments related to the filter by attributes block.

2. Adding a new method `add_support_for_filter_blocks()` to enable support for filter blocks. This method sets the necessary asset data to enable filtering and refreshes the page when a filter is applied.

3. Adding new methods to handle specific filter queries, including `get_filter_by_price_query()`, `get_filter_by_attributes_query()`, `get_filter_by_stock_status_query()`, and `get_filter_by_rating_query()`. These methods generate the respective queries based on the applied filters.

4. Refactoring the `get_final_query_args()` method to include the newly added filter queries using the `get_queries_by_applied_filters()` method.

These changes enhance the functionality of the `ProductCollection` block by allowing users to filter products based on price, attributes, rating, and stock status.

* Go to first page when filters are updated

* Enhance ProductCollection block to support filter blocks

This commit enhances the ProductCollection block to support various filter blocks such as Price filter block, Attributes filter block, Rating filter block, and In stock filter block.

The `build_query` method has been refactored into two separate methods: `build_frontend_query` and `get_final_frontend_query` to make the code more modular and readable. The `add_support_for_filter_blocks` method has been modified to support the generation of product IDs for filter blocks.

The method `update_rest_query` has been renamed to `update_rest_query_in_editor` for better clarity and understanding of its function. Similarly, `get_final_query_args` has been refactored to include the `$is_exclude_applied_filters` parameter which helps in generating product IDs for the filter blocks.

Moreover, the filter hook `pre_render_block` has been added to support the filtering of blocks before they are rendered.

This update will enhance the user experience by providing more filtering options in the ProductCollection block.

* Remove changes related to redirect to 1st page

* Go to first page when filters are updated

This commit refactors the changeUrl function in the `filters.ts` file. The purpose of this refactor is to remove the page number from the URL whenever filters are changed. This ensures that the user is always taken to the first page of results.

The commit includes the following changes:
- Added comments explaining the different page number formats in the URL.
- Updated the `newUrl` parameter by removing the page number using regular expressions.
- The page is then reloaded with the updated URL using `window.location.href`.

These changes improve the URL handling in the `changeUrl` function and enhance the user experience when interacting with filters.

* Optimize URL updates to prevent unnecessary page reloads

This commit optimizes the `changeUrl` utility function to prevent unnecessary page reloads.

Changes:
1. It checks if there are no query parameters in the URL and the URL ends with a '?'.
2. If these conditions are met, it removes the trailing '?' from the URL.

The reason for this change is that a '?' in the URL typically indicates that query parameters will follow. If there are no query parameters, the '?' is unnecessary and can cause the page to reload, which can negatively affect performance. Therefore, by removing the '?', we prevent this unnecessary page reload.

* Simplify trailing '?' removal in URL handling

This commit simplifies the removal of trailing '?' characters from URLs.
The previous implementation checked if there were any query parameters
before removing a trailing '?'.

However, upon review, it was determined that this check was unnecessary,
as a trailing '?' could be removed safely even if query parameters were
present, without any negative impact.

This change simplifies the code and prevents unnecessary computation
checking for the existence of query parameters.
2023-07-10 11:34:11 +05:30
Karol Manijak bf157c5996 Add additional Products (Beta) keyword to Product Collection so it appear next to Products in the inserter (https://github.com/woocommerce/woocommerce-blocks/pull/10112) 2023-07-07 15:50:29 +02:00
Daniel Dudzic f6a4b3c143 Product Gallery: Add Large Image inner block (https://github.com/woocommerce/woocommerce-blocks/pull/10045)
* Product Gallery: Add an new block base code

* Product Gallery: Add experimental flag

* Product Gallery: Add Large Image block code

* Product Gallery Large Image: Remove unsed types

* Product Gallery: Move the block from registerBlockType to registerBlockSingleProductTemplate

* Product Gallery: Update icon

* Product Gallery: Add missing icon import

* Product Gallery Large Image: Add experimental mode check

* Product Gallery Large Image: Deregister unnecessary block settings

* Product Gallery Large Image: Add experimental flag to the Product Gallery Large Image and remove the icon override

* Product Gallery Large Image: Add zoom and correct styling

* Product Gallery Large Image: Remove commented out unnecessary code

* Product Gallery Large Image: Re-add the removed action after capturing the large image html

* Product Gallery Large Image: Update Large Image icon and description. Move metadata to the block.json file.
2023-07-06 15:08:39 +00:00
Alba Rincón 3ccfec1eee Fix `Product Rating` styles & alignment (https://github.com/woocommerce/woocommerce-blocks/pull/10097)
* Fix alignment not working on the editor

* Fix style regression on rating
2023-07-06 09:25:29 +02:00
Mike Jolley 599274e3d6 Fix cart and checkout conditionals when using a block based theme and templates (https://github.com/woocommerce/woocommerce-blocks/pull/10098)
* Update conditionals to deal with templates instead of cart/checkout page objects

* Include notice style in main entrypoint
2023-07-05 04:02:27 -07:00
Karol Manijak 283dfc652f Add feedback form to the Product Collection block (https://github.com/woocommerce/woocommerce-blocks/pull/10079)
* Add feedback form to the Product Collection block

* Change the airtable link to the new one related to Product Collection
2023-07-05 10:34:25 +02:00
Alba Rincón b82c0de69d Fix image over content (https://github.com/woocommerce/woocommerce-blocks/pull/10092) 2023-07-05 10:30:20 +02:00
Luigi Teschio 7ca65db5b0 Fix filter count display toggle (https://github.com/woocommerce/woocommerce-blocks/pull/10096)
* fix save method

* improve check

* Only display counts if showCounts is true

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-07-05 08:51:02 +02:00
Tarun Vijwani 6b8e4c38e0 Fix notice banner links for Legacy notices (https://github.com/woocommerce/woocommerce-blocks/pull/9996) 2023-07-04 04:16:26 -07:00
Albert Juhé Lluveras df3ff6793e Per block stylesheets (https://github.com/woocommerce/woocommerce-blocks/pull/9831)
* Clean up blank lines

* Update Webpack config

* Update PHP logic to load block styles

* Style fixes

* Style fixes (II)

* Style fixes (III)

* Style fixes (IV)

* Fix missing stylesheets in the Site Editor

* Fix wrong return values in some PHP method docs

* Fix missing ProductPrice stylesheet causing 404 in tests

* Fix missing ProductGallery stylesheet causing 404 in tests
2023-07-04 13:06:48 +02:00
Alba Rincón 25a5737ec7 Fix image not rendering on the editor and empty styles (https://github.com/woocommerce/woocommerce-blocks/pull/10089) 2023-07-04 11:02:35 +02:00
Daniel Dudzic 3700c1c42d Product Gallery: Add an new block base code (https://github.com/woocommerce/woocommerce-blocks/pull/9937)
* Product Gallery: Add an new block base code

* Product Gallery: Add experimental flag

* Product Gallery: Move the block from registerBlockType to registerBlockSingleProductTemplate

* Product Gallery: Update icon
2023-07-03 14:21:31 +00:00
Roy Ho 48f7a9fdda Remove attributes data from save function for active filters (https://github.com/woocommerce/woocommerce-blocks/pull/10047) 2023-07-03 06:52:31 -07:00