Commit Graph

1535 Commits

Author SHA1 Message Date
Darren Ethier 12a28556db Switch lint:js command to use wp-scripts and address errors. (https://github.com/woocommerce/woocommerce-blocks/pull/1837)
* switch js lint command to use wp-scripts.

* fix lint warning for improper jsdoc syntax

* fix linting errors
2020-02-28 16:54:07 -05:00
Darren Ethier 6b110d00f2 Fixes some typedef errors (https://github.com/woocommerce/woocommerce-blocks/pull/1832) 2020-02-28 06:51:30 -05:00
Rua Haszard 69ea94378b support removing cart items (https://github.com/woocommerce/woocommerce-blocks/pull/1813)
* first cut - removing an item from cart:
- add actions to cart store for removing an item and keeping track of
pending removal API call
- add reducer logic for storing pending state on an item, and removing
an item
- expose removeCartItem on new useStoreCartItems hook
- hook it up to remove link / trashcan icon in row item

* disable cart quantity picker/remove link while API request in progress:
- expose cart item pending status from store using selector
- use selector to disable quantity related components in line item row

* fix jsdoc - getCartItem returns undefined if not found

* add typedef for cart items store object provided by hook

* fix rebase error - key prop went awol

* orient useStoreCartItem hook to single cart item:
- simplify interface for client component
  - isPending bool (was callback)
  - removeItem callback no need to specify item key
+ reinstate disabled prop on remove link when updating (lost in rebase)

* move cart item pending state out of cartItems, preserve API state shape:
- pending is now stored as array of keys
- fix isItemQuantityPending selector (now much simpler)

* ensure react knows that our useSelect depends on cartItemKey
2020-02-28 15:05:10 +13:00
Rua Haszard bb637bbaa3 support disabled QuantitySelector [in progress] (https://github.com/woocommerce/woocommerce-blocks/pull/1823)
* add basic story for QuantitySelector (so can easily test disabled)

* add disabled prop to QuantitySelector:
- apply to all input controls
- add storybook knob for testing
- use disabled grey for number edit when disabled

* fix indentation of jsdoc comment (linter is coming)

* use self-closing tag in QuantitySelector story

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-02-28 09:52:18 +13:00
Albert Juhé Lluveras 185149f2bd Persist previous shipping rates while loading and show its package name (https://github.com/woocommerce/woocommerce-blocks/pull/1806)
* Persist previous shipping rates while loading

* Refactor ShippingRatesControl LoadingMask

* Show package name

* Simplify CSS to avoid using the adjacent selector

* Add comment to explain why 'selected' is hardcoded in the editor

* Rename package 'index' to 'key'
2020-02-27 19:28:36 +01:00
Mike Jolley 335e0eae41 Add screen reader text to sale badge (https://github.com/woocommerce/woocommerce-blocks/pull/1826) 2020-02-27 14:19:05 +00:00
Mike Jolley 6339e85d64 Add aria labels for counts (https://github.com/woocommerce/woocommerce-blocks/pull/1828) 2020-02-27 14:17:22 +00:00
Mike Jolley d4e843fd65 Update snapshot to fix broken tests 2020-02-27 11:53:12 +00:00
Mike Jolley 6ac5b8288f Add chip component for coupons in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/1807)
* Chip componet and styling

* Tests

* Move coupon code for API requests to body - fixes issues with coupon codes containing special characters

* Implement chip component in cart page

* Revert "Move coupon code for API requests to body - fixes issues with coupon codes containing special characters"

This reverts commit ac5a72f55d51d939bb989f3936e28cf993af19a6.

* Update comment

* prevent overflow

* Add screen reader text for coupon name

* Adjust icon alignment and padding/hit box

* update string
2020-02-26 17:09:18 +00:00
Albert Juhé Lluveras 7603b1391f Checkout block: don't show message of missing shipping options if they are already set (https://github.com/woocommerce/woocommerce-blocks/pull/1804)
* Checkout block: don't show message of missing shipping options if they are already set

* Use 'wc_get_shipping_method_count' to check if shipping methods are created

* Fix frontend error

* Check  exists before calling a method on it

* Fix Configure Shipping Options button mispositioned in last Gutenberg release
2020-02-26 15:50:53 +00:00
Mike Jolley eee2d342ae Add loading placeholder for cart block (inital load) (https://github.com/woocommerce/woocommerce-blocks/pull/1819)
* Tidied up source code for line item row and fixed image placeholder support

* Return null if not rendering

* Add is loading state and className to cart block

* Hide title if there are no items

* Add placeholder rows when there are not items and cart is loading

* Pass though isLoading to cart

* Set defaults for cart item rows

* Style the placeholder elements

* Move placeholderRows

* Remove getPriceNumber

* Move decodeEntities

* Split up utils
2020-02-26 15:49:07 +00:00
Albert Juhé Lluveras 1deb0f853c Fix radio control styles in editor (https://github.com/woocommerce/woocommerce-blocks/pull/1817) 2020-02-26 13:02:48 +00:00
Albert Juhé Lluveras 11f5210297 Wrap Coupon code input/button in a <form> element (https://github.com/woocommerce/woocommerce-blocks/pull/1818)
* Wrap Coupon code input/button in a <form> element

* Add back row class
2020-02-26 13:48:16 +01:00
renovate[bot] d5094047ee Update dependency babel-eslint to v10.1.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1812)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-26 12:46:04 +00:00
renovate[bot] 4281fbf13d Update dependency config to v3.2.6 (https://github.com/woocommerce/woocommerce-blocks/pull/1815)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-26 12:45:29 +00:00
renovate[bot] 8dfa248a1f Update dependency eslint-plugin-jest to v23.8.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1816)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-26 12:45:13 +00:00
renovate[bot] f22ef7f7d5 Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/1811)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-26 12:44:43 +00:00
Mike Jolley 740a636c88 Updated `store/cart` endpoint coupon formatting and handling (https://github.com/woocommerce/woocommerce-blocks/pull/1808)
* Move coupon code for API requests to body - fixes issues with coupon codes containing special characters

* Use wc_format_coupon_code when applying/removing coupons via the cart endpoint

* Add tests
2020-02-26 11:46:58 +00:00
Darren Ethier 25e86fbc56 move jest types to devDependencies 2020-02-25 14:01:23 -05:00
Rua Haszard 0f57b6fdef show discount badge in line items in cart (https://github.com/woocommerce/woocommerce-blocks/pull/1784)
* calculate regular price for line item and return in API `line_subtotal`

* restore `line_subtotal` api field to previous behaviour

* correctly handle discounts on cart line items:
- return product `prices` in cart items endpoint
- calculate full price and discount on client using product
regular_price * quantity in cart

* add product prices to preview cart API data

* show product sale price discount in "save" badge:
- previously we were displaying any effective discount, e.g. from coupons which apply to whole cart
- now this badge will only display discount due to product on sale - much simpler

* rename sale badge class (discount => sale)

* clarify docs for line_subtotal - includes sale prices, not coupons

* clarify line_total docs

* add prices to schema (fix unit test)

* fix schema unit test - return `prices` as object, consistent with `totals`

* Further line total rewording

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-02-25 12:17:13 +00:00
Mike Jolley 6d7fdf50e0 Allow coupons to be applied and removed from the cart (https://github.com/woocommerce/woocommerce-blocks/pull/1790)
* useStoreCartCoupons hook

* Apply coupon w/ basic error handling for the fetch

* Basic store specifically for cart data

* Working on error states

* Show error on coupon fail

* removeCoupon action

* Added extra endpoints for more efficient cart queries

* Apply/remove coupons working

* Track applying/removing state

* StoreCartCoupon typedef

* Use coupon code on index

* Remove custom controls definition

* Adjust storecartcoupons mapper and remove ref

* Move cartData defaults and remove ref

* Call API directly, avoid schema lookup

* Improved selectors

* StoreCart typedef

* Split up cart state data and add more typedefs

* Add API tests for apply/remove coupon

* Jest tests

* Move default cart data to constant

* Comment indentation
2020-02-25 11:36:53 +00:00
Albert Juhé Lluveras d803f6cc64 Add product name and quantity to cart shipping rates endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/1783)
* Add product name and quantity to cart shipping rates endpoint

* Make text accessible

* Add styling

* Create Packages component

* Add preview shipping rates to editor

* Add onChange default value

* Order props

* Use CSS instead of JS to render commas between package elements

* Change quantity type to number instead of integer
2020-02-25 10:32:59 +01:00
Darren Ethier 83d82f3061 Add missing alias for tsconfig and re-order alphabetically (https://github.com/woocommerce/woocommerce-blocks/pull/1800)
* add missing alias and re-order alphabetically

* Fix incorrect alias configuration
2020-02-24 10:50:16 -05:00
Albert Juhé Lluveras 4a5ad79823 Add style to radio control (https://github.com/woocommerce/woocommerce-blocks/pull/1789) 2020-02-24 13:30:09 +00:00
Darren Ethier f8d6735baf Create typedefs and add basic typescript configuration (https://github.com/woocommerce/woocommerce-blocks/pull/1796)
* install typescript and add typedef support

* add typedefs for Cart things

* improve typescript config

- adds more base config
- add our aliases

* fix error caught by typescript!

* Tweak typescript configuration

* Add missing `@woocommerce/settings` alias to ts config

* Add alias for type-defs
2020-02-24 07:52:24 -05:00
Mike Jolley 454bb07eda Add permalink to line items (https://github.com/woocommerce/woocommerce-blocks/pull/1791) 2020-02-24 12:39:43 +00:00
renovate[bot] 2212a74d49 Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/1799)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-24 12:15:37 +00:00
Albert Juhé Lluveras 261966d82c Remove broken links from README.md (https://github.com/woocommerce/woocommerce-blocks/pull/1792)
There were some links in README.md that were broken:
* `Contributing`: I linked it to `docs`, which has a summary of links to the `contributors` folder.
* `About the npm scripts`: I'm not sure where it was linking in the past, so I removed it (but happy to add it back if needed).
* `Publishing a release`: fixed the link to `docs/releases/readme.md`.
2020-02-21 18:22:06 +01:00
Seghir Nadir 2058c64bac redo work after rebase (https://github.com/woocommerce/woocommerce-blocks/pull/1777) 2020-02-21 17:40:25 +01:00
Albert Juhé Lluveras f0239d6378 Make Shipping Calculator Button type="submit" (https://github.com/woocommerce/woocommerce-blocks/pull/1785) 2020-02-21 16:26:27 +00:00
Mike Jolley 3e6f8fe6a6 Add isLoading property (https://github.com/woocommerce/woocommerce-blocks/pull/1788) 2020-02-21 14:08:57 +00:00
renovate[bot] edd3745f4a Update dependency downshift to v4.1.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1771)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-21 10:53:50 +01:00
Albert Juhé Lluveras 9debaf8daf Cart & Checkout: conditionally register country and state settings (https://github.com/woocommerce/woocommerce-blocks/pull/1782)
* Conditionally register wcSettings in the Cart and Checkout blocks

* Add tests
2020-02-20 16:16:32 +01:00
Mike Jolley 806cd76987 Display selected shipping location in cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1767)
* county->state clarity

* Show formatted address
2020-02-19 17:14:41 +00:00
renovate[bot] 05d2815cf5 Update dependency eslint-plugin-jest to v23.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1772)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-19 16:36:56 +00:00
renovate[bot] 8209ecabbd Update dependency puppeteer to v2.1.1 (https://github.com/woocommerce/woocommerce-blocks/pull/1773)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-19 16:36:23 +00:00
renovate[bot] cd7a34a651 Update dependency compare-versions to v3.6.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1770)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-19 16:36:06 +00:00
renovate[bot] d5df819644 Update Node.js to v12.16.1 (https://github.com/woocommerce/woocommerce-blocks/pull/1769)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-19 16:35:04 +00:00
renovate[bot] 961a5274b2 Update dependency rimraf to v3.0.2 (https://github.com/woocommerce/woocommerce-blocks/pull/1774)
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
2020-02-19 16:34:39 +00:00
Seghir Nadir 90a7579461 Add Shipping settings to Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1561)
* add cart settings

* address typos

* update how settings should work

* get settings from woo and pass them to frontend

* reapply condition

* fix issue with attributes not presisting

* abstract shipping control

* rename constants

* update props in frontend

* fix bug with attributes not presisting

* conditionally display prices

* use country to decide to show prices

* disable shipping if shipping is not enabled

* enable coupons by default
2020-02-19 17:33:10 +01:00
Mike Jolley 6c954bdc5b Add support for image for product categories block (https://github.com/woocommerce/woocommerce-blocks/pull/1739)
* Add support for image for product categories block.

* Resolve feedback and style images, w/ thumbnails

* Toggle visibility of option based on list style

* Remove image size variable

* hasImage false by default

* reset styles

Co-authored-by: strarsis <strarsis@gmail.com>
2020-02-19 15:12:28 +00:00
Mike Jolley 2a25cfd0ed Implement browser autocomplete for checkout address fields (https://github.com/woocommerce/woocommerce-blocks/pull/1755)
* Add autocomplete support for textinput

* Add autocomplete fields to forms

* Prefix default ids

* Hack for autocomplete on custom select components

* Restore labels and avoid reset of state

* State field autocomplete

* Fix calculator autocomplete

* Simplify existance of hidden field

* move label on autofill preview in chrome

* Put back state clearance

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-02-19 15:10:26 +00:00
Albert Juhé Lluveras 7b53486be3 Add loading state to shipping rates selector (https://github.com/woocommerce/woocommerce-blocks/pull/1764)
* Add loading state to shipping rates selector

* Add screenReaderLabel specific for ShippingRatesControl

* Rename LoadingComponent to LoadingMask
2020-02-19 11:51:15 +01:00
Albert Juhé Lluveras 8b7fa87b81 Add 2.5.12 and 2.5.13 changelog notes 2020-02-19 10:46:04 +01:00
Rua Haszard c13bd7e641 hook up cart items to API data in front end (https://github.com/woocommerce/woocommerce-blocks/pull/1741)
* hook up cart items to API data in front end (first cut)

* correctly decode entities in product attributes in cart:
+ support unnamed attributes

* correctly render markup in cart line item descriptions:
- description api field is html, so use dangerouslySetInnerHTML

* fix PropTypes - cartItems, not items

* hook up cart totals area to API data +
+ move editor preview totals data to resource-previews (to match API)

* tweak/tidy todo comments for cart front end

* use shorter summary field for cart line item blurb

* render empty cart inner blocks on front end when shopper cart is empty

* ensure empty cart doesn't show while cart contents is loading

* decode entities in attribute names when rendering cart items

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* factor out cart data to a custom hook + exit earlier while loading

* wrap preview/sample cart variation data for translation

* use RawHTML component for rendering cart line item summary +
+ linter whitespace tweak

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-02-19 12:06:37 +13:00
Albert Juhé Lluveras bd6426ae84 Update WooCommerce tested version up to 4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1768) 2020-02-18 14:51:25 +01:00
Mike Jolley 2ef1209ed8 Implement last modified header for the products endpoint to allow for cache busting (https://github.com/woocommerce/woocommerce-blocks/pull/1647)
* Implement last modified header for the products endpoint.

* Invalidation handling

* Freshness

* indenting correction

* Remove freshness and resolve feedback for last modified handling

* Remove getCollectionTimestamp

* Move logic to resolver

* Handle state during INVALIDATE_RESOLUTION_FOR_STORE
2020-02-18 11:37:39 +00:00
Rua Haszard c8c6d4ec7b fix cart api total_price value (previously had '36' appended to front): (https://github.com/woocommerce/woocommerce-blocks/pull/1760)
- explictly request 'edit' context before converting to money response
- default 'view' response returns string with markup, which confuses
prepare_money_response()
2020-02-18 11:31:24 +00:00
Albert Juhé Lluveras 29a763d7de Shipping rates: decode entities (https://github.com/woocommerce/woocommerce-blocks/pull/1762) 2020-02-18 11:50:08 +01:00
Seghir Nadir 23f574911b adjust currency and add docs (https://github.com/woocommerce/woocommerce-blocks/pull/1757) 2020-02-18 09:32:53 +01:00