Commit Graph

3143 Commits

Author SHA1 Message Date
Alex Florisca e61eb3b0a4 Fix extra network request on cart (https://github.com/woocommerce/woocommerce-blocks/pull/5394) 2021-12-16 10:30:23 +00:00
M. L. Giannotta 1db7ede31e Migrate storybook entries of ProductPrice component (https://github.com/woocommerce/woocommerce-blocks/pull/5371)
Closes woocommerce/woocommerce-blocks#5368
2021-12-15 19:07:49 +01:00
M. L. Giannotta 5524c0aa91 Storybook and TS migration of `PriceSlider` component (https://github.com/woocommerce/woocommerce-blocks/pull/5253) (https://github.com/woocommerce/woocommerce-blocks/pull/5293)
* Add full documentation to the component props in Storybook
* Fix `FormattedMonetaryAmount` TypeScript errors

Since this component is passing on props to `NumberFormat`,
it needs to extend all of its original props, except for `onValueChange`
which we wrap in order to accept only `number`s.

* Convert `constrainRangeSliderValues` to TypeScript
* Add docs to `Currency` types
* Convert `PriceSlider` to TypeScript

*Note:* All TypeScript errors were fixed during the conversion,
except for the IE workaround which wasn't clear to me at this time.
Opened an issue: woocommerce/woocommerce-blocks#5276

* Fix Price Slider story (https://github.com/woocommerce/woocommerce-blocks/pull/5253)
* Migrate stories for `ProductName` to latest Storybook

Also add props documentation and add named export.
2021-12-15 17:54:49 +01:00
M. L. Giannotta 703051b1bc Storybook and TS migration of some cart checkout components (https://github.com/woocommerce/woocommerce-blocks/pull/5324)
* Migrate stories for `ProductName` to latest Storybook. Also add props
documentation and add named export.
* Migrate `TotalsFooterItem` to TypeScript and latest Storybook
* Add a `LooselyMustHave` utility type.
* Export `allSettings` so that they can be manipulated in stories and tests

* Implement a way to easily define and reuse Storybook controls

Implement a currency control for a common use-case of selecting currencies.
It currently implements EUR and USD as they have different properties.

* Migrate `TotalsDiscount` to TypeScript and implement stories
* Migrate `TotalsCoupon` to TypeScript and fix stories
* Change Coupon name within Storybook
* Nicer handling of removal of a coupon from Storybook

It now dynamically calculates the discount from the actual coupons.
2021-12-15 17:30:17 +01:00
M. L. Giannotta 91c2ca2143 Migrate storybook entries of QuantitySelector component (https://github.com/woocommerce/woocommerce-blocks/pull/5370)
* Add experimental Emotion11 compatibility

Revert the changes introduced in woocommerce/woocommerce-blocks#5354. The team over at Storybook
has recently implemented a workaround to enable Emotion11 compatibility
in 6.x releases.

See: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#emotion11-quasi-compatibility

* Add `QuantitySelector` property docs and migrate stories

*Note:* Because of a Storybook bug, the number input on the control panel of the
story, is not going to get updated by the component.

See: https://github.com/storybookjs/storybook/issues/15924
2021-12-15 17:03:02 +01:00
Albert Juhé Lluveras 8030e278db Set the origin of custom templates to 'plugin' and fix plugin name on REST requests (https://github.com/woocommerce/woocommerce-blocks/pull/5375)
* Set the origin of custom WC templates to 'plugin'

* Fix plugin name
2021-12-15 11:56:41 +01:00
renovate[bot] 0b6686910f Update dependency eslint-import-resolver-typescript to v2.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/5383)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-15 05:04:26 +00:00
renovate[bot] 6d487fd242 Update wordpress monorepo (https://github.com/woocommerce/woocommerce-blocks/pull/5382)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-15 03:18:45 +00:00
Mike Jolley c5e07b8dd2 Move class removal to render callback (https://github.com/woocommerce/woocommerce-blocks/pull/5364) 2021-12-14 10:39:14 +00:00
Tung Du b0623a8b52 Mini Cart: only display the editing link to users with site editing permission (https://github.com/woocommerce/woocommerce-blocks/pull/5372) 2021-12-14 07:54:23 +07:00
Tung Du 0350268b82 Switch to correct view if inner block is selected (https://github.com/woocommerce/woocommerce-blocks/pull/5358) 2021-12-14 07:46:10 +07:00
Mike Jolley 3fc597775c Trigger validation on change (https://github.com/woocommerce/woocommerce-blocks/pull/5373) 2021-12-13 16:44:28 +00:00
Mike Jolley 226780107a Add error message for fetch errors on checkout (https://github.com/woocommerce/woocommerce-blocks/pull/5341)
* Add error message for fetch errors on checkout

* Update message text

* revert gitignore change

* Remove errorNotice variable
2021-12-13 15:31:49 +00:00
Mike Jolley 661896ce9e Loading animation (https://github.com/woocommerce/woocommerce-blocks/pull/5362) 2021-12-13 13:57:59 +00:00
Mike Jolley 59c8c88438 Introduce 2 new hooks in Customer Update Route (https://github.com/woocommerce/woocommerce-blocks/pull/5345)
* Introduce woocommerce_blocks_cart_update_customer_from_request hook

* Introduce woocommerce_blocks_cart_update_order_from_customer_request

* Test actions fire

* Update hook docs
2021-12-13 13:57:45 +00:00
Albert Juhé Lluveras 6e2b5ebb8a Downgrade @wordpress/scripts to 17.1.0 to fix dependency mistmach issue (https://github.com/woocommerce/woocommerce-blocks/pull/5349)
* Downgrade @wordpress/scripts to 17.1.0 to fix dependency mistmach issue

* Update package-lock.json
2021-12-10 17:44:03 +01:00
M. L. Giannotta 1c837c0de7 Fix conflict between Storybook and `@emotion/styled@11.x` (https://github.com/woocommerce/woocommerce-blocks/pull/5354)
Resolve the alias for `@emotion/styled` to the root of the module in Storybook
WebPack config.

Fixes woocommerce/woocommerce-blocks#5353
2021-12-10 17:08:23 +01:00
Seghir Nadir 772ee23faa Update item quantity if server result is different from client (https://github.com/woocommerce/woocommerce-blocks/pull/5352)
* respect when quantity changes from up

* add test
2021-12-10 16:26:57 +01:00
Mike Jolley 70106d45d3 Revise checkout payment statuses to avoid data loss on error (https://github.com/woocommerce/woocommerce-blocks/pull/5350)
* Clarify docs for STARTED

* Clarify docs for setActivePaymentMethod

* Remove useActivePaymentMethod hook (this held state for active methods and tokens)

* Update type defs

* Enhance setActivePaymentMethod action to accept method data

* SET_ACTIVE_PAYMENT_METHOD action

* Add setActivePaymentMethod dispatcher and make "started" status only

* Update setActivePaymentMethod usage in express methods

* Set radio control defaults

* Consolodate tokens and methods

* Update assets/js/base/context/providers/cart-checkout/payment-methods/reducer.ts

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

* Spacing

* Split saved cards tests from regular, since saved cards are checked by default

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2021-12-10 16:26:16 +01:00
Niels Lange 6a74887464 Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363)
* Limit CSS styles to WooCommerce Block icons only

* Update assets/css/editor.scss

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

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-12-10 21:32:44 +07:00
Luigi Teschio 13deb1b09e Mini Cart Block: render the empty state set on template parts (https://github.com/woocommerce/woocommerce-blocks/pull/5338)
* add view switcher for mini cart contents block

* editor view switcher

* update mini cart template file

* render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

* update selector

* allow empty mini cart block to add all blocks

* fix tests; improve code style

* install @wordpress/block-editor package

* fix warning on frontend side

* block-editor package is not necessary

* merge attributes object

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2021-12-10 12:11:59 +01:00
Tom Cafferkey 34ba6ab937 Load required scripts in LegacyTemplate.php render method (https://github.com/woocommerce/woocommerce-blocks/pull/5346) 2021-12-10 10:51:35 +00:00
Mike Jolley b0f9e524a3 Move Draft Order Handling to Shared Trait (DraftOrderTrait) (https://github.com/woocommerce/woocommerce-blocks/pull/5323)
* Introduce shared trait for draft order handling (DraftOrderTrait)

* Use trait where needed for maybe_release_stock

* Introduce woocommerce_blocks_cart_update_customer_from_request

This hook gets the request data and customer object, and from there, 3rd parties could grab a draft order and manually update it if needed (if the use cases requires this).

* Revert "Introduce woocommerce_blocks_cart_update_customer_from_request"

This reverts commit 6620818eb1e03b87c6eca0d757ec8b78802e3c57.
2021-12-10 10:49:04 +00:00
Albert Juhé Lluveras 29fa0a61e6 Fix Mini Cart template part link on WP 5.9 (https://github.com/woocommerce/woocommerce-blocks/pull/5348)
* Fix link to edit the Mini Cart template part in WP 5.9

* Use wp_is_block_theme() function

* Add protection against overwriting isSiteEditorAvailable setting

* Rename isSiteEditorAvailable to isBlockTheme
2021-12-10 11:23:16 +01:00
Niels Lange 865a0a5ffa Update icon of legacy template block (https://github.com/woocommerce/woocommerce-blocks/pull/5317)
* Update icon of legacy template block

* Display legacy block template color in Woo purple

* Display icons in white when block being selected within list view
2021-12-10 17:07:10 +07:00
Tung Du b3ba90e7e9 Fix: Mini Cart block: Edit template part link doesn't work for themes don't have mini cart template part. (https://github.com/woocommerce/woocommerce-blocks/pull/5347) 2021-12-09 20:58:03 +07:00
Albert Juhé Lluveras 6cbff66977 Fix reverting WC templates (https://github.com/woocommerce/woocommerce-blocks/pull/5342) 2021-12-09 10:35:32 +01:00
Mike Jolley f1b85c6bcb Removes legacy shipping_phone handling (https://github.com/woocommerce/woocommerce-blocks/pull/5326) 2021-12-08 15:05:00 +00:00
Seghir Nadir 8e62dea95d Wait until carts load before calling `canMakePayment` (https://github.com/woocommerce/woocommerce-blocks/pull/5337)
* wait till cart loads before calling canMakePayment

* fix tests
2021-12-08 13:41:31 +00:00
Alex Florisca 311a531826 Chip component stories for storybook (https://github.com/woocommerce/woocommerce-blocks/pull/5322)
* ship component stories for storybook

* Refactor RemovableChip for Storybook

* Implement lucio feedback changes

* RemovableChip is part of the Chip story
2021-12-08 12:17:49 +00:00
Tom Cafferkey 30abe6f3bc Update block theme conditionals in BlockTemplateController (https://github.com/woocommerce/woocommerce-blocks/pull/5335) 2021-12-08 11:21:57 +00:00
renovate[bot] 7822affe2e Update dependency @types/wordpress__compose to v4.0.1 (https://github.com/woocommerce/woocommerce-blocks/pull/5334)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-08 05:51:31 +00:00
renovate[bot] 5e3528a05c Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/5333)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-08 03:25:48 +00:00
Mike Jolley cfeb5558b7 Update WordPress Monorepo packages with React 17x support (https://github.com/woocommerce/woocommerce-blocks/pull/5223)
* Use npm 14

* Update WP packages

* Update non-dev wordpress dependencies

* Remove usage of @automattic/data-stores

* Moves tag, search-list-control components back into private `editor-components` to mitigate dependency conflicts with`@woocommerce/components`

* Fix tests with act()

* package-lock

* fix broken maps

* Patch 14x package

* update locks

* Revert nvmrc change

* Fix tests due to debounce

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2021-12-07 15:47:50 +00:00
M. L. Giannotta 77c237d6a2 Storybook migration of `CountryInput` component (https://github.com/woocommerce/woocommerce-blocks/pull/5312)
* Enable `exactOptionalPropertyTypes` in TS config

This option will create more strict types out of optional properties.
Read more: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-beta/#exact-optional-property-types

* Extract `ComboBoxProps` as own interface

This way we can export it to use it somewhere else. In this specific case,
I'll need to use it as a base to extend the `CountryInputProps`.

Also fixed some types to be optional, as the component requires.

* Fix stories and props for `CountryInput` (https://github.com/woocommerce/woocommerce-blocks/pull/5252)
2021-12-07 16:07:21 +01:00
Mike Jolley de068d2fc3 Rest API - Namespace error handling (https://github.com/woocommerce/woocommerce-blocks/pull/5319)
* get_routes_from_namespace needs to handle WP_Error responses

* is_request_to_store_api is not static
2021-12-07 15:03:58 +00:00
Tung Du 185f1d5bd9 Fix: Mini Cart block button should be disabled in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/5308) 2021-12-07 21:29:56 +07:00
Tung Du 90a54b6cf0 Mini Cart Contents block: implement view switcher in editor (https://github.com/woocommerce/woocommerce-blocks/pull/5304) 2021-12-07 21:07:53 +07:00
Mike Jolley 587e3b98d4 Add missing Exception use statement in RoutesController (https://github.com/woocommerce/woocommerce-blocks/pull/5330) 2021-12-07 13:13:48 +00:00
Mike Jolley 7fd25d4b37 Typedefs and cartData for `usePaymentMethodInterface` (https://github.com/woocommerce/woocommerce-blocks/pull/5177)
* Typedefs and cartData for the payment interface

* fix case on noticeContexts

* typeof for enums

* immutable note

* Add cartData to docs table

* Rebase docs
2021-12-07 13:02:57 +00:00
Tom Cafferkey 44aaf67caa Updated version numbers for the next release 2021-12-07 11:51:42 +00:00
github-actions[bot] 212085bbd8 Release: 6.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/5321)
* Empty commit for release pull request

* Update readme.txt and add 6.5.0 testing notes

* Update build link

* Update CSV link

* Testing instruction titles.

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
2021-12-07 11:47:28 +00:00
Albert Juhé Lluveras b927ca6a9f Convert renderFrontend to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/5238)
* Rename render-frontend file to tsx

* Add types to renderFrontend

* Reorder code

* Use PascalCase for types

* add generics

* fix TS error

* restore interface

Co-authored-by: Luigi <gigitux@gmail.com>
2021-12-07 11:07:32 +01:00
Tung Du 66a3ac1d33 Refactor: use StyleAttributesUtils to generate classes and styles (https://github.com/woocommerce/woocommerce-blocks/pull/5307) 2021-12-07 12:21:40 +07:00
Tung Du e3620307df Fix: Mini Cart: don't allow users to create extra template parts in the Mini Cart template part area (https://github.com/woocommerce/woocommerce-blocks/pull/5306) 2021-12-07 12:20:37 +07:00
renovate[bot] 5565b3030a Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/5313)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-07 01:23:20 +01:00
M. L. Giannotta 4651f64341 Storybook and TS migration of ReadMore component (https://github.com/woocommerce/woocommerce-blocks/pull/5300)
* Update packages to latest Storybook deps

* Migrate `ReadMore` component and its utils to TypeScript

* Add type definitions for `trim-html` package

* Migrate `ReadMore` stories to newest Storybook

Fixes woocommerce/woocommerce-blocks#5254
2021-12-06 18:00:33 +01:00
Luigi Teschio 4a134c7fb5 Set WooCommerce like source of WC templates woocommerce/woocommerce-blocks#5271 (https://github.com/woocommerce/woocommerce-blocks/pull/5320)
Set WooCommerce like source of WC templates woocommerce/woocommerce-blocks#5271
2021-12-06 15:41:00 +01:00
Albert Juhé Lluveras b7051c8cd0 Fix JS error in Filter Products by Attribute block (https://github.com/woocommerce/woocommerce-blocks/pull/5301) 2021-12-06 11:03:18 +01:00
Alex Florisca 0a8415e3a6 More ts conversions (https://github.com/woocommerce/woocommerce-blocks/pull/5263)
* WIP

* Converted block-error-boundary to TS

* Convert CheckboxList to TS

* Converted Chip and Removable Chip components to TS

* Change type to React.FC<T>

* Fix tests

* Implement Lucio feedback
2021-12-03 17:23:25 +00:00