69ba8161b6
* convert eslint config to use @woocommerce/eslint-plugin - removes unnecessary dependencies - adds e2e-tests/specs to eslint ignore (they are automatically generated) - turns off rules that will be handled in subsequent pulls (to avoid a mammoth changeset for review). - NOTE: prettier config needs left in because of a bug with the existing version of `@wordpress/eslint-plugin` pulled in (fixed in https://github.com/WordPress/gutenberg/pull/25068) so I left the file for now. * prettier fixes. * remove obsolete plugin and fixes for eslint update This branch brings an update to eslint which also changes some syntax with plugins. So this commit: - fixes featuer-flag plugin syntax. - removed obsolete dependency-group plugin (which is now in the `@woocommerce/eslint-plugin` configuration. * add to-do comment * fixes for test runs - this also converts our e2e test scripts to use `wp-script test:e2e`, an advantage of this is it will load CHROMIUM on demand for the e2e test run. * fixes for test runs - this also converts our e2e test scripts to use `wp-script test:e2e`, an advantage of this is it will load CHROMIUM on demand for the e2e test run. * include prettier alias as a dependency This has to be done because prettier is installed with storybook and thus the alias setup in `@wordpress/scripts` is over-ridden by the storybook import. * another attempt at e2e-test-fix * add some debugging and temporarily just add one e2e config test for travis * more debugging * try installing full puppeteer and see if fixes * fix package-lock? * setupSettings separately from other fixture loading * add debugging of files * add another console.log (hopefully trigger travis) * split out blockPage creation to it’s own as well * fixed! remove debugging and re-enable travis configs for entire test suite * fix config and rename e2e-tests to e2e - fixes the failing product-search test - tests/e2e-tests was redundant, I changed to `tests/e2e` (this follows a file pattern change made in woocommerce core as well). * add todo for some eslint properties * remove unnecessary early function execution * revert earlier commit and remove duplicate call to createBlockPages |
||
---|---|---|
.. | ||
test | ||
README.md | ||
action-types.js | ||
actions.js | ||
constants.js | ||
index.js | ||
reducers.js | ||
resolvers.js | ||
selectors.js |
README.md
Collections Store.
To utilize this store you will import the COLLECTIONS_STORE_KEY in any module referencing it. Assuming @woocommerce/block-data
is registered as an external pointing to wc.wcBlocksData
you can import the key via:
import { COLLECTIONS_STORE_KEY } from '@woocommerce/block-data';
Actions
receiveCollection( namespace, resourceName, queryString, ids = [], items = [], replace = false )
This will return an action object for the given arguments used in dispatching the collection results to the store.
Note: You should rarely have to dispatch this action directly as it is used by the resolver for the
getCollection
selector.
argument | type | description |
---|---|---|
namespace |
string | The route namespace for the collection (eg. /wc/blocks ) |
resourceName |
string | The resource name for the collection (eg. products/attributes ) |
queryString |
string | An additional query string to add to the request for the collection. Note, collections are cached by the query string. (eg. '?order=ASC') |
ids |
array | If the collection route has placeholders for ids, you provide them via this argument in the order of how the placeholders appear in the route |
response |
Object | An object containing a items property with the collection items from the response (array), and a headers property that is matches the window.Headers interface containing the headers from the response. |
replace |
boolean | Whether or not to replace any existing items in the store for the given indexes (namespace, resourceName, queryString) if there are already values in the store |
Selectors
getCollection( namespace, resourceName, query = null, ids=[] )
This selector will return the collection for the given arguments. It has a sibling resolver, so if the selector has never been resolved, the resolver will make a request to the server for the collection and dispatch results to the store.
argument | type | description |
---|---|---|
namespace |
string | The route namespace for the collection (eg. /wc/blocks ) |
resourceName |
string | The resource name for the collection (eg. products/attributes ) |
query |
Object | The query arguments for the collection. Eg. { order: 'ASC', sortBy: Price } |
ids |
Array | If the collection route has placeholders for ids you provide the values for those placeholders in this array (in order). |
getCollectionHeader( namespace, resourceName, header, query = null, ids = [])
This selector will return a header from the collection response using the given arguments. It has a sibling resolver that will resolve getCollection
using the arguments if that has never been resolved.
If the collection has headers but not a matching header for the given header
argument, then undefined
will be returned.
If the collection does not have any matching headers for the given arguments, then null
is returned.
argument | type | description |
---|---|---|
namespace |
string | The route namespace for the collection (eg. /wc/blocks ) |
resourceName |
string | The resource name for the collection (eg. products/attributes ) |
header |
string | The header key for the header. |
query |
Object | The query arguments for the collection. Eg. { order: 'ASC', sortBy: Price } |
ids |
Array | If the collection route has placeholders for ids you provide the values for those placeholders in this array (in order). |