Commit Graph

246 Commits

Author SHA1 Message Date
Alba Rincón 34c7fa95e1 Add Catalog Sorting filter block (https://github.com/woocommerce/woocommerce-blocks/pull/8122)
* WIP

* Render in editor and add styles

* Simplify select

* Undo change

* Update titles and description

* Wrapped text for translation

* Remove from products inner blocks

* Allow the block in the inserter

* Rename test file and add new tests for catalog-sorting block

* Register on the site editor only

* Fix tests

* Disable block server side

* Override the `enqueue_assets`

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix TS error

* Simplify edit

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Disable background color

* Add custom classes

* Remove alignment

* Inherit color and font properties

* Merge edit and block files

* Use sprintf to improve code readability

* Make fontsize small by default

* Add order placeholders and woocommerce class

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix floating issue

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Add woocommerce class

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 16:20:10 +01:00
kmanijak d00a21fbaf [Blockifying Product Archive Templates] Add Results Count block (https://github.com/woocommerce/woocommerce-blocks/pull/8078)
* Init setup to add a new block Results Count

* Render  template part as a content of ResultsCount block

* Switch to template part rendering

* Rename the block to ProductResultsCount

* Fix typo in BlockTypesController

* Change the ProductResultsCount class name

* Remove Product Results Count block from Product Query template

* Improve the way Product Results Count is rendered in the editor

* Add  prefix to places that missed renaming from ResultsCount to ProductResultsCount

* Remove unnecessary frontend.tsx file for ProductResultsCount

* Make sure global styles are applied and respected by Product Results Count block

* Make sure the Product Results Count is available inly in Product Catalog template

* Add basic tests to Product Results Count

* Remove empty line in style file

* Fix TS issue in Product Results Count

* Fix typo

* Override the enqueue_assets method to prevent unnecessary enqueue and 404 error on the frontend

* Add necessary property to block's metadata

* Address code review feedback

* Update description

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Remove disabled component

* Improve test description

* Merge edit and block files

* Remove align support

* Remove background support

* Simplify edit component

* Improve readability with sprintf and add custom class

* Simplify test case

* Add styles and order placeholders

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix markup to match with the frontend

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 16:19:42 +01:00
Mike Jolley c49426570d React Based Local Pickup Settings Screen (https://github.com/woocommerce/woocommerce-blocks/pull/7581)
* Move payment methods

* Setup entrypoints

* Sortable implementation

* Sortable

* Basic UI in place for settings

* Hydrate real settings

* Form updates values

* Styling and save button placement

* useSettings hook

* Prepare for save

* delete

* Add location button

* Remove className

* Conditional display of taxes

* Save via API

* Update general settings to designs

* Modal styles

* Style table

* Border colors and radius

* Added e2e tests

* use node 16

* Enqueue states in admin

* Use render from wordpress/element

* Missing handle style

* Enable translations

* Remove curried function

* Todo for inline settings

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-01-12 15:40:15 +01:00
kmanijak c0f33efb1c Order blocks alphabetically in webpack-entries and BlockTypesController (https://github.com/woocommerce/woocommerce-blocks/pull/8109)
* Order blocks in webpack-entries alphabetically

* Order blocks in BlockTypesController.php alphabetically
2023-01-12 08:34:45 +01:00
kmanijak 00ac537474 Make each Bundle Analyzer report open in new tab with the proper title (https://github.com/woocommerce/woocommerce-blocks/pull/8045)
* Make each Bundle Analzyer report open in new tab with the proper title
2022-12-29 17:00:30 +01:00
Mike Jolley fdbe4e7c54 Remove legacy handling on the PHP side (https://github.com/woocommerce/woocommerce-blocks/pull/7978) 2022-12-22 17:04:54 +01:00
Alba Rincón a223af0ad5 Add 'Customer Account' block (https://github.com/woocommerce/woocommerce-blocks/pull/7876)
* Add empty 'Customer Account' block

* Add edit to render the block on the editor

* Add Customer Account icon to @woocommerce/icons library

This icon is used in the Customer Account block.

* Use customerAccount icon in the Customer Account block

* Add Block Settings to Customer Account block

Add Typography and Color settings to the Customer Account block that can be used during Edit mode.

* Add Customer Account style icons

This adds the customer account style icons to be used by the customer account block.

* Render the block in the frontend

* Add Display setting to the Customer Account block

This setting allow users to choose if they want to include an icon with the customer account link.

* Add icon style selector to Display settings

This adds an icon style selector in which users can choose the customer account link icon.

* Display on the frontend depending on the icon style

* Rename attributes

* Refactor block rendering

* Improve styling

* Make the account link dynamic

* Add alignment menu

* Get dashboardUrl with getSettings and add fallback

* Add link to account settings

* Add tests

* Fix test

* Change display title

* Split css file

* Switch to SSR

* Add styles to the front end

* Address latest feedback

* Remove experimental flag

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2022-12-22 16:01:01 +01:00
kmanijak 6ea35ccc93 Remove Legacy Webpack Configs along with FallbackModuleDirectoryWebpackPlugin (https://github.com/woocommerce/woocommerce-blocks/pull/7961) 2022-12-16 12:00:06 +01:00
Tarun Vijwani 4f75d12188 Add woocommerce_blocks_loaded hook information to actions doc (https://github.com/woocommerce/woocommerce-blocks/pull/7600)
* Add woocommerce_blocks_loaded hook information to actions doc

* add docs to woocommerce_blocks_loaded hook inline

* fix docs

* Switch to updated wp-hooks/generator package

* Prevent syntax error in doc script from storeapi.php

* Remove footer from internal docs and examples

* Doc footer script should ignore examples and internal developer docs

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-11-10 09:52:04 +01:00
Paulo Arromba f857afae0f Add PHP8 Unit Testing (https://github.com/woocommerce/woocommerce-blocks/pull/7528)
* fixed method sig

* Updated to @wordpress/env@5.5.0 and set default PHP 7.4 for wp-env.

* updated Coding Standards flow to use PHP 8.0

* Added comment to E2E flows explaining what PHP version is used

* Revert "Updated to @wordpress/env@5.5.0 and set default PHP 7.4 for wp-env."

This reverts commit 696cd7f42edc9d9726b777cf4f83a501a6d63936.

* Added comment to Unit test flows explaining what PHP version is used.
Specified PHP version on .wp-env.json

* Fixed composer-lock.json version.

* Updated tests to run on PHP Unit 9.2.6

* Updated tests to run on PHP 8

* Reverted test, mismatched results between local and pipeline

* Removed Todo

* Updated platform overrides

* Update Migrationb tests with Mockery for PHP8 compat

* try at PHP unit flow matrix

* Fix blocks.ini invalid config

* Temp disable E2E

* Downgraded woocommerce/woocommerce-sniffs as it introduced new sniffs we should be handling on a different PR

* re-enable E2E tests

* blocks.ini fix

* revert blocks.ini fix

* Update @wordpress/env

* remove .htaccess mapping

* Fix permissions for tests

* Debug permissions

* Attempt at perm fix

* Attempt at perm fix

* Downgraded @wordpress/env

* Another attempt at upgrade @wordpress/env

* Attempt at cleaning wp-env before run

* Attempt at destroying wp-env before run. Disabled E2E.

* Attempt at destroying wp-env before run.

* debug wp-env data

* attempt at deleting wp-env data (destroy won't work due to prompt)

* re-enable E2E

* Fix deprecation warnings

* Cleaned wp-env data for E2E

* Fix perms for E2E

* Updated RateLimitsTests

* debug

* Force 7.4 for wp-env

* Run sh outside of npm

* Reverted E2E flow

* reverted wp-env-config.sh debug test

* reverted .wp-env.json phpVersion force

* Update tests/php/StoreApi/Utilities/ProductQueryFilters.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartExtensions.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartItems.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Products.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/ProductCollectionData.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Batch.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Checkout.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartCoupons.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/ProductAttributes.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Cart.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* downgraded @wordpress/env to v4

* Reverted back to reflection class for pivate attribs manipulation on tests

* reverted JS unit testing job name

* Update tests/php/StoreApi/Formatters/TestMoneyFormatter.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Typo fix

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-11-09 15:28:08 +00:00
Thomas Roberts 6f85ab593f Use backslashes to fix webpack build on windows (https://github.com/woocommerce/woocommerce-blocks/pull/6798)
* Use backslashes to fix webpack build on windows

* Update regex to use square brackets, and update copywebpack path for Windows

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-11-02 03:24:19 -07:00
Daniel W. Robert fdc07e5a96 Add Product Query Support for Atomic Rating Block (https://github.com/woocommerce/woocommerce-blocks/pull/7352)
* Add PQ support for client-side.

Set up the block for PQ support and add necessary adjustments for the
editor. Will address dynamic save functionality in a following commit.

* Add dynamic render function for PQ support.

* Add dynamic render callback for SSR.

* Remove client-side Save function.

* Add PQ Context interface to shared type defs.

* Convert all block JS files to TS.

* Remove commented import from block file.

* Add typecasting to block function params.

As a workaround, added a general Record type but left a TODO to revisit
the proper object, as there is a mismatch in the shape of the default
object property types and the actual types.

* Update inserter behavior.

Allows for the ability to add the rating block from in the inserter
(as long as it's an inner block of the listed parents in the config).
Also disables the placeholder product selector from being rendered
unnecessarily (i.e., when the context ID is present).

* Update parent inner blocks config.

Reassign parent array to ancestor array which allows for blocks to be
included with more flexibility - i.e., added within groups that are
children of the ancestor block.

* Add productID to rating Attributes interface.

* TS type casting and import adustments.

Some adjustments to utilize types that we already have available, along
with some syntax adjustments and more sensible import tweaks.

* Update type-casting to use ProductResponseItem

Instead of using the generic Record, we can utilize the
ProductResponseItem interface and set an omission for the average_rating
property until that is corrected to properly reflect the API response.

* Add alias to blocks dir for imports.

Allows us to use exports from the blocks dir as "external" imports. This
way we do not need to write long, relative import paths (which can be
fragile in the long run).
2022-10-31 14:56:17 -04:00
Tom Cafferkey 872788e13c Convert filter blocks to inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6978)
* register filter wrapper block

* register block variation

* rename the active filters wrapper

* prevent 404 error

* Revert "prevent 404 error"

This reverts commit 8b6cb7c6658b2a5a99b890b67f1dce8c1c51cdbf.

* render parent wrapper block

* support price filter block

* hide the active filter block from inserter

* swap the title of wrapper and inner filter block for active filters

* hide the legacy heading for the price filter

* update block title and description for active filters and price filter

* remove heading control for price filter

* remove heading control for active filters

* update pattern

* try: upgrade button

* limit the number of inner block to 2

* prevent removing the inner filter block

* Revert "prevent removing the inner filter block"

This reverts commit 83b7feed78a7a7f50fd5799d1706faa9f2fc9050.

* convert stock filter to inner block

* refactor block upgrade button to share between filter blocks

* update default heading

* update pattern

* update icon and title

* Fix stock filter error by importing translations package

* Upgrade Active Filters name to Active Filter Controls

* Add upgrade support to price filter

* Convert attribute filter to inner block (https://github.com/woocommerce/woocommerce-blocks/pull/7101)

* wip: convert attribute filter to inner block

* fix: render inner attribute filter block on the front end

* refactor: inner block wrapper, extract the attribute parsing logic into a utility

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Set correct attribute on the new filter blocks when they are upgraded

* Use the Warning component to display the upgrade message so it is consistent with Gutenberg

* address code review

* better detect legacy block to show the upgrade notice

* rename UpgradeToolbarButton to UpgradeNotice

* add upgrade notice to the stock filter block

* rename InnerBlockWrapper to BlockWrapper

* attribute-filter: control wrapper visibility

* passing block attributes down to inner active filters control block

* fix styling of inner attribute filter control block

* passing attribute to inner price filter control block

* passing down the attribute to inner stock filter control block

* remove unneccessary parsing

* use default scope for variations

* fix default attribute values

* use default block appender

* fix: lock control blocks

* remove dynamic title code from attribute filter block

* register active filters as variation and set it to the default that overrides the base block

* fix isActive for default variation

* fix: isActive logic for the active filters block

* register side effect

* fix ts error

* e2e: fix active filters block backend test

* e2e: fix frontend active filters test

* e2e: fix attribute filter test

* e2e: fix price filter test

* e2e: fix stock filter test

* e2e: update fixture

* e2e: fix attribute filter test

* remove invalid test

* e2e: update heading selector for price filter in backend test

* e2e: fixe backend price filter heading test

* fix: patterns i18n

* fix: heading level when upgrading the block

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-10-07 16:00:19 +01:00
Daniel Dudzic 8ae19b5a42 Add a Products by Rating filter block (https://github.com/woocommerce/woocommerce-blocks/pull/7048)
* Add interactivity to the Product by Rating filter block

* Fix block with the latest repo changes

* Product by Rating: Code tidying up

* Add an experimental build gate and update block title and description

* Remove redundant title and description

* Add support for the CheckboxList component in the Products by Rating block

* Products by Rating: Minor code clean-up

* Active Filters: Fix the Clear All button for Ratings. Closes #woocommerce/woocommerce-blocks#7172

* Products by Rating: Add misc TS fixes
2022-09-28 23:12:14 +02:00
Saad Tarhi 085242bbe9 Clean the top-level of the /build folder (https://github.com/woocommerce/woocommerce-blocks/pull/7047)
* Generate Inner Blocks' JSON files in a common folder

* Get the correct metadata path for the Inner Blocks

The Inner Blocks' metadata lives now in the `/build/inner-blocks`. But,
the function `get_block_metadata_path` was only looking for metadata
inside the top-level of the `build/` folder
2022-09-26 15:02:36 +01:00
Niels Lange 2f52565c75 Correct broken *.md links (https://github.com/woocommerce/woocommerce-blocks/pull/7108) 2022-09-12 11:29:24 +07:00
Luigi Teschio ffbf5823d3 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 10:02:21 +02:00
Thomas Roberts d45ef84219 Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869)
* Add default page notice

* show notice all inner blocks

* support flow when page isnt saved

* switch from where we get the current post id

* update lock

* fix types

* Remove old compatibility notices from Cart and Checkout

* Move useCompatibilityNotice to sidebar-compatibility-notice directory

* Remove old CartCheckoutCompatibilityNotice

* Create sidebar compatibility notice hoc

* Add isCartOrCheckoutOrInnerBlock function

* Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func

* Remove BlockSettings from checkout edit and export from checkout-shared

* Change so component still renders, it is just hidden with display: none

This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time.

* Set the priorities of the hoc filters so compat notice renders first

* Make isCartOrCheckoutInnerBlock a hook

* Remove old compatibility notice related tests

* Remove BlockSettings from Cart

* Remove withDefaultNotice hoc

* Include DefaultNotice in compatibility notice

* Remove DefaultNotice from Checkout

* Rename withSidebarCompatibilityNotice to withSidebarNotices

This is because it includes the sidebar compatibility notice and the default notices

* Remove useIsCartOrCheckoutOrInnerBlock hook

* Remove compatibility notice code from tests

* Revert DefaultNotice back to the old one

* Remove unused components

* Remove withBlockSettings HOC and fix TS types

This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks

* Remove CartCheckoutFeedbackPrompt from BlockSettings

It will be included in sidebar-notices instead

* Fix TS Types in DefaultNotice

* Add BlockSettings to cart and checkout edit

* Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)

* Show "Feedback prompt" for all inner blocks

* Fix the "feedback" notice position for these blocks

The "checkout fields", "checkout billing address" and
"checkout shipping address" have the addressFields option which
gets rerendered and placed at the bottom of the inspector controls.

* Tidy up the address-fields hoc

* Use correct block name to check for billing or shipping address

* Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)"

This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f.

* Add hack to get feedback prompt to render last

* Fix TS errors for context and attributes

* Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols

* Do not include feedback prompt if on an address block or contact info

* Remove unused hoc for address fields

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 15:23:08 +01:00
Saad Tarhi dc97e5af1e Fix missing translations in inspector (https://github.com/woocommerce/woocommerce-blocks/pull/6737)
* Try registering the "cart taxes" inner block

Registering server side. This example isn't working, but I'm pushing to
share it and see what's wrong with this implementation.

* Fix registering the cart taxes inner block issue

* Update translation script loading

* Remove unnecessary JS translation

The translation should work fine by getting the title & description from
the `block.json` file

* Put back the initial code in the 'Cart Taxes' inner block

We didn't provide the correct `block.json` file path server side,
that's why the `metadata` wasn't correctly registered

* Generate `block.json`files for inner blocks

This is the first step on fixing the missing translations of `metadata`
in `block.json` files

* Set the folder name exactly the same as the inner block name

We are doing this first test for the `Cart taxes` inner block.

The `Block` & its containing folder need to have the same name for:
- Consistency
- We use the `Block` name to get the file Path

* Update imports after folder renaming

* Get block name directly from the JSON metadata

Getting the block name from the JSON metadata is less error prone than
extracting it from the file path.

And no need to rename all our `inner-blocks` to get the correct
`block.json` path

* Revert folder naming change of `Cart taxes` inner block

Since we are getting the `block` name directly from the `block.json`
metadata instead of extracting it from the file path, there is no need
to keep their names in sync anymore

* Fix missing translations for the `Cart Subtotal` Block

* Register only the client-side settings on the client

When the block is registered on the server, you only need to register
the client-side settings on the client using the same block’s name.
See [docs](https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#javascript-client-side).

* Add schema validation to `block.json`

Development is improved by using a defined schema definition file.
Supported editors can provide help like tooltips, autocomplete, and
schema validation.

* Use the same `editor_script` as the parent block

This prevents WordPress from generating script tags to inexistant
inner blocks JS files

* Add C&C inner blocks in Cart.php & Checkout.php

This is a refactoring to keep the block types controller file less
overloaded

* Fix all Cart inner blocks missing translations

* Create the "AbstractInnerBlock" class

The "Inner Blocks" will use their parent's script, so no need to create
new scripts for each one of them

And, our "Inner Blocks" should always be registered using the metadata file

* Update the "Inner Blocks" PHP classes

* Fix PHP lint erros & update function description

* Fix missing translations bug for all Checkout Inner Blocks

* Update src/BlockTypes/Checkout.php

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* skip lazy loaded scripts

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-08-01 15:57:33 +01:00
Tung Du 0ee5dbbc18 Fix: Replace DropdownSelector with FormTokenField from Gutenberg (https://github.com/woocommerce/woocommerce-blocks/pull/6647) 2022-08-01 19:00:59 +07:00
Seghir Nadir 2ebb166b41 add new action for customer updates (https://github.com/woocommerce/woocommerce-blocks/pull/6792) 2022-08-01 09:56:28 +01:00
Luigi Teschio dc2765efcb Add dry run and simulate release mode (https://github.com/woocommerce/woocommerce-blocks/pull/5273)
* Add dry run and simulate release mode woocommerce/woocommerce-blocks#3059

Add dry run and simulate release mode

* execute more svn commands in release mode

* fix boolean

* fix command
2022-06-23 17:39:30 +02:00
Michael P. Pfeiffer 521f93619b Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566)
* Remove mixed tabs and spaces in tsconfig.json

* Update formatting in json files

* Upgrade wp-prettier to 2.6.2
2022-06-15 11:56:52 +02:00
Niels Lange 3208da551b Improve the structure of the WooCommerce Blocks Handbook (https://github.com/woocommerce/woocommerce-blocks/pull/6429)
* Improve the structure of the WooCommerce Blocks Handbook

Co-authored-by: Rania Lang <rania.langouretou@automattic.com>
2022-06-09 17:52:19 +02:00
Tung Du 45f48e6b0a Fix: Register Filter Blocks using `block.json` (https://github.com/woocommerce/woocommerce-blocks/pull/6505) 2022-06-09 21:45:24 +07:00
Niels Lange a748f533a8 Format Markdown files using wp-scripts (https://github.com/woocommerce/woocommerce-blocks/pull/6462)
* Format Markdown files using Prettier

* Format Markdown files using wp-scripts

* Adjust MD linting
2022-06-09 14:43:17 +02:00
Seghir Nadir d3c2f638fa Revert changes to webpack build output (https://github.com/woocommerce/woocommerce-blocks/pull/6456)
* revert changes to webpack file

* fix loading of chunks

* revert changes to assets api as well

* include chunks from other blocks

* bail early if there is no build folder
2022-05-25 16:59:51 +01:00
Seghir Nadir 238ab01ab2 Refactor webpack splitting to fix missing translation (https://github.com/woocommerce/woocommerce-blocks/pull/6420)
* don't splitChunk frontend scripts

* simplfy output folders

* reduce minimum chunk size to 10kb

* add all inner blocks for loading

* better splitChunks

* update translation code

* wait for scripts

* try sleeping

* fix loading translation

* fix tests for mini cart

* simplfy po logic

* automate loading chunks

* rename webpack group file

* rename block.json path
2022-05-23 15:58:13 +01:00
Alba Rincón d61c5116ad Start using `block.json` for the `Products by Attribute` block (https://github.com/woocommerce/woocommerce-blocks/pull/6414) 2022-05-23 10:10:06 +02:00
Alba Rincón 6e5ebdff85 Start using the `block.json` metadata file for `Products by Tag` (https://github.com/woocommerce/woocommerce-blocks/pull/6403)
* Start using the block.json metadata file for `Products by Tag`

* Remove comment

* Add version, schema, and text domain

* Add defaults

* Remove wrong keyword

* Add tag icon when registering the block
2022-05-20 14:43:43 +02:00
Lucio Giannotta 7fcc561db1 Refactor Featured Category and Featured Product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6406)
This PR creates a new directory called `featured-items` which includes both blocks.
All the shared code lives at the top level of that directory.

Individual blocks still have their own directories, with their `block.json` and all other relevant configuration.

All the functionalities have been refactored out into their own files, accepting configuration when relevant, but mostly de-duplicating all the code.

Styles have also been refactored using mixins and extends and they mostly live in one place.
2022-05-19 18:16:46 +02:00
Alba Rincón 42166068b6 Start using the `block.json` metadata file for `Handpicked products` (https://github.com/woocommerce/woocommerce-blocks/pull/6392)
* Start using the `block.json` metadata file for `Handpicked products`

* Add the `properties` attribute to properly parse booleans

* Remove comment

* Add schema, delete version
2022-05-13 14:57:34 +02:00
Alex Florisca 2f9b54ae03 Try to fix E2E tests once and for all (https://github.com/woocommerce/woocommerce-blocks/pull/6337)
* Try to fix account.test.js

* Remove language installations for woo core and wp core and take screenshots

* Upload screenshots to artifacts

* npm install instead of npm ci

* Upload artifacts  not matter what

* fsdf

* fsdfsf

* remove screenshoting from account.test.js and only run checkout-terms.test.js

* Print NODE_ENV

* Better handling of overriding wp-env.json

* Run all tests

* Re-enable translations for WP and Woo

* Wait for Cart & Checkout blocks to load before moving on

* Uncomment github actions

* Try to fix shipping test

* fill checkout before placing order, duuuh

* Wait until networkidel0 instead of domcontentloaded for page navigations

* Fix account.test.js

* change visitBlockPage() to  use Promise.all()

* Remove screenshot taking

* I think Promise.all() is being funny and not throwing properly, testing

* wait for checkbox to be visible before clicking

* Remove try catch around Promise.all()

* Fix linting issues

* Remove screenshot dir

* Raluca feedback:

* Timeout back to 30000

* Login to merhcant before changing settings

* merchant.logout()
2022-05-01 12:33:58 +01:00
Alba Rincón bdfd1da4c5 Start using the `block.json` metadata file for the `Featured Category` block (https://github.com/woocommerce/woocommerce-blocks/pull/6300)
* Start using the `block.json` metadata file for the `Featured Category` block

* Get default attributes from the `block.json` file

* Remove unnecessary `get_block_metadata_defaults` function

* Add alt attribute to the block.json file

* Remove unused imports
2022-04-28 17:31:59 +02:00
Alba Rincón 0aac2c59ef Start using the `block.json` metadata file for the `Featured Product` block (https://github.com/woocommerce/woocommerce-blocks/pull/6296)
* Start using the `block.json` metadata file for the `Feature Product` block

* Get default attributes from the block.json file

* Add removed comment

* Remove unnecessary `get_block_metadata_defaults` function

* Add alt default to block.json
2022-04-28 17:04:56 +02:00
Luigi Teschio 881c202717 Make Filter Products by Stock block compatible with PHP rendered Classic Template block (https://github.com/woocommerce/woocommerce-blocks/pull/6261)
* Enable Attribute Filter block to work with the PHP rendered Classic Template block

* Check for presence of option before rendering it

* improve filter product by attribute

* fix pagination problem

* fix check when two filter block with same attribute are used

* fix filter by stock for PHP templates

* fix naming and comment

* Update filter key in ClassicTemplate

* Update stock filter block for PHP templates when the filter button is enabled

* Remove unused useEffect and fix ESLint error

* Set active stock filter and track using local state

* ESLint fix

* Remove unncessary dependencies from useEffect

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2022-04-21 08:28:41 +01:00
Tung Du e8d922142c E2E: Explain the reason for the addition language update command (https://github.com/woocommerce/woocommerce-blocks/pull/6280) 2022-04-20 11:48:13 +07:00
Alex Florisca 59b4da800b Cart & Checkout translations test use nl_NL (https://github.com/woocommerce/woocommerce-blocks/pull/6267)
* Cart & Checkout translations test use the already installed language nl_NL

* Extra timeout when checking for shipping and billing addresses

* wait for selector instead of increase timeout

* Change waitForSelector selector:

* Clean up

* Increase idleTime for waitForNetworkRequest

* Fix random timeouts and increase timeout of verifying shipping option

* feedack
2022-04-19 08:56:52 +01:00
Tung Du ad85348151 Shopper → Mini Cart → Can view translated mini cart contents block (https://github.com/woocommerce/woocommerce-blocks/pull/6214) 2022-04-13 18:51:13 +07:00
Tung Du 5415c22251 Prepare the Mini Cart block for WC Core release (https://github.com/woocommerce/woocommerce-blocks/pull/6209) 2022-04-08 15:51:21 +07:00
Alex Florisca e37b787e50 Move mini cart outside cart-checkout folder (https://github.com/woocommerce/woocommerce-blocks/pull/6192)
* Move shared folder to /blocks

* Moved mini-cart block in blocks dir:

* Rename shared folder to cart-checkout-shared

* Remove customDir from mini-cart webpack entry

* Update assets/js/base/context/tsconfig.json

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Feedback changes

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-04-07 14:47:58 +01:00
AndrewJDawes fc20c8363e Fix Actions and Filters documentation with broken links woocommerce/woocommerce-blocks#5808 (https://github.com/woocommerce/woocommerce-blocks/pull/6128)
* Fix docs paths for actions and filters source links woocommerce/woocommerce-blocks#5824

* Build docs after fixes for woocommerce/woocommerce-blocks#5824 - see 0c79cb7f4e75fc5c48c9b054cbac6f0344b4048a
2022-04-05 16:22:56 +02:00
Alex Florisca e15d516163 Revert "Move cart and mini-cart blocks into their own folders (https://github.com/woocommerce/woocommerce-blocks/pull/6126)" (https://github.com/woocommerce/woocommerce-blocks/pull/6190)
This reverts commit d005dbd2cf.
2022-04-05 11:14:32 +01:00
Alex Florisca d005dbd2cf Move cart and mini-cart blocks into their own folders (https://github.com/woocommerce/woocommerce-blocks/pull/6126)
* Move cart and mini-cart into their own folders

* Update other references of cart-checkout
2022-04-04 12:34:29 +01:00
Mike Jolley eb196226d8 WIP: Add Inner blocks to order summary (https://github.com/woocommerce/woocommerce-blocks/pull/6065)
* Sub/Total/Fee inner blocks

* Row blocks within the inner block

* Update icons

* Resolve stying issues

* Remove old block

* Pin totals row

* Locking logic update

* Heading inner block

* Refactor where inner blocks are defined

* Add todos

* Todo for Consider deprecating OrderMetaSlotFill and DiscountSlotFill in favour of inner block areas.

* Improve frontend registration of components using new entrypoint

* Experiment- external block context

* Revert "Experiment- external block context"

This reverts commit 4b75668ec7eb62f065c6a488cd942a666e26204f.

* Duplicate inner blocks to avoid conflicts with context

* Remove todo

* Rename block dir

* Some test fixes

* Fix import

* fix import

* linting

* Remove unused attributes

* Optional classname

* fix coupons import

* fix shipping mocks

* Styling

* Fix selectors in e2e tests

* Add back the wc-block-components-totals-wrapper class that was used for each segment in the totals Order summary

Because, removing them was:
-  a breaking change for the old structure
- was making it harder to target the inner blocks. Before the class was used to target each segment
- it was making the wc-block-components-totals-item behave as a child or parent depending on the inner block, inconsitency

* Reuse the TotalsWrapper component for C& C blocks inner blocks

This component was removed in this PR, but  we wrap components in the Cart and Checkout sidebar in a TotalsWrapper. This will ensure consistent spacing and borders are applied to items in the sidebar.

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2022-04-01 15:45:18 +02:00
Tomasz Tunik f7f1b89dc5 Upgrade @wordpress/scripts and /env packages (https://github.com/woocommerce/woocommerce-blocks/pull/6114)
* upgrade wordpress/scripts to 22.3

* update jest config/setup

* add explicit-exports-references plugin

to handle payment-method-config.tsx spying on external methods
the way code is output now changed and tests like this would not
work anymore as transpilet files were no longer using exports but
local references to methods.

* missing snapshot

* make cart-products E2E test more stable

* surppress eslint error in test file

* fix css stylelint issues

* update eslint-plugin-woocommerce eslint package

* remove temp test:e2e:start script

* re-run

* add stylelint as recommended extension

* remove redundant types (provided by packages now)

* patch update @testing-library/jest-dom
2022-03-28 15:00:20 +02:00
Alba Rincón 13311e7bee Rename Legacy Template block to Classic Template block (https://github.com/woocommerce/woocommerce-blocks/pull/6021)
The internal ID has been kept after a comment by @tjcafferkey. This causes a
bit of inconsistency in the internal code, but it was deemed that it would have
been better as users who have customized templates using this
blocks ID will have saved this in their database, and it would result
in a corrupt block when loaded, and we didn't want to support both IDs at the
moment.

Otherwise, most other references to the legacy template, are now using the word
“classic”.

Co-authored-by: Alba Rincón <alba@albasauatticmbp.home>
2022-03-22 23:34:43 +01:00
Niels Lange d9dd7a0df6 Shopper can choose shipping option (https://github.com/woocommerce/woocommerce-blocks/pull/5844) 2022-03-09 13:23:52 +01:00
Mike Jolley eae1d75c86 Store API: Consistent error code and hook naming (https://github.com/woocommerce/woocommerce-blocks/pull/5992)
* Update error codes with `woocommerce_rest_` prefixes.

* Update action and filter hooks with woocommerce_store_api_ prefix

* Update hook docs

* Update error code mismatches

* Update hook name in tests

* update hook name in tests

* phpcs
2022-03-07 13:51:07 +00:00
Mike Jolley fd03b79995 StoreAPI: Rename namespace to remove `\Blocks` (https://github.com/woocommerce/woocommerce-blocks/pull/5982)
* Composer config

* Update namespace in deprecated.php

* Bulk update namespace

* Revert rename in deprecated class

* bw compat

* Store API: Add dedicated container and make Store API code self-contained (https://github.com/woocommerce/woocommerce-blocks/pull/5986)

* Move ArrayUtils to StoreApi

* Move PaymentContext/PaymentResult

* Move create account functionality to checkout endpoint. Update tests.

* Move get_routes_from_namespace to blocks

* Move RestApi logic within StoreApi namespace/directory

* StoreAPI Container

* Update functions

* Update extend docs

* Run Doc build script

* Missing container calls for 3rd party extensions

* Fix doc toc
2022-03-04 13:28:37 +00:00