Commit Graph

16 Commits

Author SHA1 Message Date
Rua Haszard 5c7447f434 Rename js/components to js/editor-components (https://github.com/woocommerce/woocommerce-blocks/pull/3069)
* mass-rename js/components => js/editor-components & update webpack

* mass-change import '@woocommerce/editor-components' +
+ jsprettier quotes fix

* more mass-rename @woocommerce/editor-components

* fix up references to js/editor-components in various places:
- docs/readmes
- jest config
- typescritp config

* fix story path to match new folder/alias 'editor-components'

* fix jest tests: use new alias for editor-components

* include renamed `editor-components` in editor stylesheet cache group
2020-09-02 10:21:46 +02:00
Mike Jolley 98d240d5e6 Introduce Variation Picker Component (https://github.com/woocommerce/woocommerce-blocks/pull/2497)
* Add attributes to API

* Add component

* API updates to return variation data

* Update to handle updated api responses

* Working picker

* Update tests

* update test

* Use SelectControl

* Add Picker to Form Block

* Code cleanup and splitting

* Inline todos

* Update todos

* Update assets/js/atomic/blocks/product/add-to-cart/product-types/variable/variation-attributes/index.js

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

* change classname and move styles within component

* Correct conditional

* Avoid nesting filters

* Remove exclude from getVariationsMatchingSelectedAttributes

* basic select styles

* remove custom select styles

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-19 15:51:09 +01:00
Mike Jolley 7f85c1bcc0 Migrate REST API usage to the Store API (https://github.com/woocommerce/woocommerce-blocks/pull/2282)
* Remove unused wc/blocks/cart endpoint

* remove unused withProducts hoc

* Remove getProducts util

* Use store API products endpoint in product blocks

* Remove product endpoint tests

* Remove controller

* Switch attributes endpoint to store api

* Refactor withAttributes to use store API

* Migrate tags and cats to store API

* MIgrate variations to store api

* Migrate reviews to store API

* Drop dedicated variation endpoint

* Move tests

* Move cart init

* Fix reviews

* Comment out broken tests

* Remove old class based with-attributes test
2020-04-24 14:36:47 +01:00
Albert Juhé Lluveras 140bdc39d0 Add tests to some cart and checkout hooks (https://github.com/woocommerce/woocommerce-blocks/pull/2013) 2020-03-30 20:32:28 +02:00
Albert Juhé Lluveras ec77f88a72 Reformat files (https://github.com/woocommerce/woocommerce-blocks/pull/1389) 2019-12-16 14:58:19 +01:00
Mike Jolley 5a1bbbefb9 Update NPM dependencies and script dependency handling (https://github.com/woocommerce/woocommerce-blocks/pull/1337)
* Update NPM packages

* Switch JSON dependencies to new PHP files

* include->require

* include->require

* Remove from package and run audit fix

* Update wp-prettier

* Use version from asset file

* Fix eslint issues and test failures

* Update OriginalComponent docblocks

* Props are objects, not arrays

* Array to Object

* fix tests throwing unhandled rejection errors in node.

These tests were all testing Promise.rejects but then not properly catching the reject in the assertions.

* exclude rule for no short array syntax allowed

This is a WordPress core standard that we choose to ignore because it’s silly in our context to follow that rule (and we’re being consistent with WooCommerce Admin).
2019-12-10 12:17:46 -05:00
Seghir Nadir bb0227edb1 Show number of reviews in each category in Reviews per Category block (https://github.com/woocommerce/woocommerce-blocks/pull/1177)
* Add reviews to Category endpoint

* add option to show categories with reviews

* update label text if we're using reviews for counting

* update reviews count to use raw sql

* add flag before querying review count

* add review_count to collection data & schema

* fix PR code review problems

* update tests to it expects the new collection param

* add note about review_count is schema
2019-11-19 16:22:16 +01:00
Albert Juhé Lluveras 01412e6af0 Update ProductControl to use HOCs (https://github.com/woocommerce/woocommerce-blocks/pull/974)
* Update ProductControl to use HOCs

* Only show variations in certain ProductControls

* Cleanup

* Refactor withSingleSelected selected prop logic

* Fix selected values not being respected

* Fix wrong propTypes notation

* Set parent: 0 in getProducts util func

* Use static properties in withProductVariations

* Move messages outside of the functional component

* Check that variations is an array

* Fix debounced search

* Fix broken tests

* Rename withSingleSelected to withTransformSingleSelectToMultipleSelect
2019-09-25 16:22:36 +02:00
Albert Juhé Lluveras 85df274523 Reformat files with new tabwidth (https://github.com/woocommerce/woocommerce-blocks/pull/953)
* Reformat files with new tabwidth

* Review featured product background position so it doesn't break
2019-09-09 12:52:48 +02:00
Albert Juhé Lluveras 6ab7834f59 Install prettier and reformat files (https://github.com/woocommerce/woocommerce-blocks/pull/945)
* Install prettier

* Reformat all files

* Add prettier to precommit hook

* Update prettier settings to match Gutenberg code standards

* Reformat files with new settings

* Improve legibility in some line breaks
2019-09-05 17:09:31 +02:00
Albert Juhé Lluveras dc232e87d6 Add withCategories and withAttributes HOCs (https://github.com/woocommerce/woocommerce-blocks/pull/935)
* Add withCategories HOC and show API errors in Product Category Control

* Create withAttributes HOC and display errors in Product Attribute Control

* Refactor formatError so it handles JS errors and API errors

* Rename 'onSelectAttribute' with 'onExpandAttribute'

* Add and update tests

* Fix error in product attributes endpoint

* Refactor ProductCategoryControl into a functional component

* Refactor ProductAttributeControl into a functional component

* Refactor formatError to use a 'message' and 'type' properties

* Replace enzyme with TestRenderer

* Fix formatErrors doctype format

* Rename 'frontend' error type to 'general'
2019-09-04 18:07:00 +02:00
Mike Jolley ea0ce0e915 Fix wcSettings conflicts with wc-admin (https://github.com/woocommerce/woocommerce-blocks/pull/916)
* Add inline settings script later than init

* Rename to shared-settings for clarity - other extensions filter these

* Implement block settings

* tweak used hooks

* update comment

* Shared settings should be dependency

* Make Webpack output shared and block settings (https://github.com/woocommerce/woocommerce-blocks/pull/918)
2019-08-27 16:25:32 +01:00
Darren Ethier 72f0ed470f Refactor: Introduce `wc-block-settings` bundle serving as `@woocommerce/settings` external. (https://github.com/woocommerce/woocommerce-blocks/pull/903)
* export new @woocommerce/settings external on `wc.blockSettings` global

- This handles reading data from the dom and assigning it to the global used in all packages dependent on `@woocommerce/settings` which is registered as an external pointing to the global.
- ensures that server data is only loaded on a route if needed.

* switch all direct imports of constants to use new `@woocommerce/settings` external

* enqueu new `wc-block-settings` script and attach inline data to it.

* fix test configuration and adjust test to use new external

* fix bad merge resolution after rebase

* switch constants import to `@woocommerce/settings` external after rebase

* reorder imports for convention

* improve method name
2019-08-22 16:56:47 -04:00
Albert Juhé Lluveras a6a131f8fd Move wc_product_block_data variables to constants file (https://github.com/woocommerce/woocommerce-blocks/pull/870) 2019-08-17 11:14:11 +02:00
Darren Ethier 2d5b06f07a Introduce withSearchedProducts higher order component and refactor ProductsControl Component (https://github.com/woocommerce/woocommerce-blocks/pull/791)
* add new withSearchedProducts hoc

includes tests

* convert to functional component and wrap with new hoc

* remove dependency between tests

* Fix typo with PropTypes bool

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* remove unnecessary specific import

* fix bug introduced on refactor for selected prop recalc

* fix tests that were testing the wrong expectation

- also improved mocks a bit so they are a bit more realistic for the purpose of the test coverage.

* remove unnecessary Fragment

* tweak propType definitions and remove defaults

- this keeps argument expectations in sync with wrapped component and reduces chance of unexpected behaviour if `SearchListControl` logic changes.

* remove lodash.find dependency.
2019-08-06 11:34:13 -04:00
Albert Juhé Lluveras 2504bffdfa Create `withProduct` HOC (https://github.com/woocommerce/woocommerce-blocks/pull/779)
* Reset 'loaded' state in Featured Product and Category blocks

* Minor code improvements

* Remove state from ApiErrorPlaceholder

* Move getProduct to a HOC

* Undo changes in Featured Category

* Update proptypes

* Move error messages to <ApiErrorPlaceholder>

* Reorder props

* Move lifecycle methods to HOC

* Make <FeaturedProduct> component presentational

* Move withProduct to js/hocs

* Create NAMESPACE constant in utils

* Create getProduct util function

* Set 'error' and 'product' state to null instead of 'false' when they have no value

* Prevent getImageSrcFromProduct and getImageIdFromProduct returning an error when 'product' is not an object

* Add HOC tests

* Use 'toBe' and 'toBeNull' jest expect methods instead of 'toEqual' when possible

* Export HOCs from index

* Move mock implementation to beforeEach
2019-08-02 13:56:53 +02:00