* add missing blocks and update old links
* features behind a feature flag
* update filters and JS methods
* Apply suggestions from code review
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Remove i2 from build
* Remove i2 php registration
* Rename old checkout dir
* Rename i2 dir
* Migrate i1 to i2 code
* Register block metadata to fix frontend rendering when migrating to i2
* Register in correct order
* Missing styles
* add register-components to side effectful list
* wrong block class in e2e test
* wp prefix missing on selector
* Fix top level block test
* Reselect labels to work around rerendering
* missing empty cart styles
* Consolodate duplicate styles
* remove init code
* update selectBlockByName
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Type payment method under /block-registry
* Type assertions and add them back to PaymentMethodConfig
* Type ExpressPaymentMethodConfig
* Fix comment on payments types
* Fix CanMakePayment type
* Fix assertion for payment methods and the savedTokenComponent property
Because class properties come from the config object, they will never be null except if somebody explicitly adds them the the object with a value of null.
Which is not the case for savedTokenComponent for example, because it's optional and that's why we check it like this paymentMethods[ activePaymentMethod ]?.savedTokenComponent
* Add the complete CanMakePaymentReturnType and account for null for PaymentMethod.icons
- canMakePayment can also return a Promise and this was not included in the type definition
- in PaymentMethodConfig's constructor we also need to account for extensions passing {icons: null}.
* Revert Fix assertion for payment methods and the savedTokenComponent property
* Fix failing tests because of savedTokenComponent
I've reverted my changes and left the initialization of savedTokenComponent as it was.
* Rename types for more clarity
* Fix ExtensionNamespace and PaymentMethodName types
* Rename Supports and *PaymentMethodOptions type for better clarity
* Add tests for registerPaymentMethodExtensionCallbacks
* Use the console mocks from @wordpress/jest-console
Overriding console.error with my own mock was unnecessary.
* Add tests for canMakePaymentWithExtensions
* Add tests for payment-method-config
* Apply suggestions from code review
Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
* Apply suggestions from code review
* Change file types to .ts and .tsx
* Add test to check namespace is not overwritten
* Move overwriting test to new test case
This assertion feels different enough to warrant its own test case.
Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
* Add back end E2E tests for Filter by Stock
* Add unit/snapshot tests for Filter by stock block
* Refactor Filter by Stock block to load stock statuses in the block body
This is required to make the code easier to test, since the mocked settings were being applied immediately after the block was imported, which didn't give time to let the `allSettings` override take place in the unit tests.
* Add PHP Unit tests for test_custom_stock_counts of ProductQueryFilters
* Remove useMemo from stock filter block
This felt like an overoptimisation, it's very inexpensive to run this every render. The result is less complex code, so it's better this way imo.
* Move initial stock options and the values they are derived from into useState
* Add class name to block in editor
* Add custom close button label to Mini Cart drawer
* Add screen reader notice when removing an item from cart
* Focus next item from cart when an item is removed
* Add back CSS to hide close button label
* Don't focus previous item after the last one is removed
* Remove period from button label
* Don't show the number of items in Cart if Mini Cart is loading
This prevents displaying outdated data. That's specially important
for screen readers, because they were reading the outdated value
before it was replaced by the new one.
* Focus cart items table when last item in list is removed
* Use a ref to focus cart items table
* Use a ref to focus cart item table rows
* Fix empty cart if Mini Cart items have been removed
* Update snapshots
* Add extensionsConfig when registering a payment method
The extension config has its own canMakePayment where extensions can add callback using a payment method's name.
* Make canMakePayment a getter on PaymentMethodConfig
Because extensions can register canMakePayment callbacks for a payment method before it is registered we need to transform
canMakePayment into a getter so that it's always recalculating it's value based on the registered callbacks/
* Rename extension related config and method
* Format comments
* Add an extension namespace to registerPaymentMethodExtensionCallback utility
This commit changes the API for how extensions will register their own callbacks to canMakePayment, so that they can add their namespace and also callbacks for multiple payment methods.
* Format comments
* Update assets/js/blocks-registry/payment-methods/payment-method-config.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update assets/js/blocks-registry/payment-methods/registry.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update assets/js/blocks-registry/payment-methods/payment-method-config-helper.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update assets/js/blocks-registry/payment-methods/payment-method-config-helper.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update assets/js/blocks-registry/payment-methods/registry.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Fix eslint warning
* Handle errors at registerPaymentMethodExtensionCallbacks level
* Update assets/js/blocks-registry/payment-methods/registry.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Fix formatting issues
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Update registry to register components with block JSON metadata
* Use updated registration API in sample block
* remove editorScript
* Rename area and allow forced blocks to do it's thing without defining a template manually
* More naming consistency
* Validate a registered checkout block has at least one valid parent
* Append forced blocks
* Fix child detection
* Improve render logic to remove clone element
* Areas instead of block names
* Revert "Areas instead of block names"
This reverts commit c8d68e6424313ed15ca1eb1f91a3edfc24d06a8d.
* revert area change
* Registration system
* Refactor block registration to handle components + forcing
* Remove need for atomic block registration
* add attributes to namespaced blocks only
* Update area names to new format
* Avoid passing custom props to DOM
* Put back usage of cloneelement for DOM elements
* correct case of innerBlockAreas
* Inline documentation for renderParentBlock
* Play nice with other attributes when registering forced blocks
* Add Drawer component
* Use element dataset instead of a window global
* Rename miniCartOverlay to miniCartDrawerPlaceholder
* Refactor styles so screen overlay covers the entire screen
* Use rem instead of em for the drawer title size to keep it consistent between renders
* Keep focus when replacing the mini cart button
* Match overlay colors from designs
* Use is-loading class like several other blocks
* Add more doc comments
* Don't listen to clicks on Mini Cart button when it's open
* Update Drawer component styles
* Extract function from lazyLoadScript to simplify code
* Prevent TS errors when assigning attributes to script element
* Update assets/js/base/utils/lazy-load-script.ts
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* Update assets/js/base/utils/lazy-load-script.ts
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* force insert blocks
* add force attribute
* delete console.log
* make sure we don't override move
* polish force system in editor
* get sample block to show on frontend
* add force to frontend
* remove force on blocks
* move ref to function
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* remove todo from sample block
* Add newsletter block
* Block registration
* Move provider/processor so separate them from context providers
* customData implementation for setting customData for requests
* Make data and schema callbacks optional in extendrestapi class
* schema_type should be data_type
* Allow checkout endpoint to be extended
* Support validation, sanitization, and defaults on nested REST properties
* Experimental endpoint data for newsletter field
* Add extension data to requests
* SET_EXTENSION_DATA
* Update types
* Add todo
* move check within hook function
* Remove newsletter block
This is because we're testing with the integration being done in a separate extension
* Delete newsletter subscription block
* Pass the result of hooks down to the children blocks
We need to do this to allow extension blocks to modify the extensionData (so they can send custom input to the REST api when submitting the checkout form).
* Remove newsletter signup block
* remove checkoutSubmitData
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Create MiniCart block prototype
* Use window.onload instead of DOMContentLoaded
* Don't load translations for scripts without localized strings
* Don't try to load cart instance in API requests
* Remove PHP pre-rendering
* Fix some typos
* Move Mini Cart block files under 'cart-checkout' directory
* Update selectors to follow guidelines
* Only enable the MiniCart block in experimental builds
* Fix wrong translations element selector
* Improve lazyLoadScript and preloadScript documentation
* Move lazy-load-script and preload-script to base-utils
* Add function to check if script tag is already in the DOM
* Added Stock Status filter
* Pre pull request clean up code
* Reverted package-lock.json ( downgraded node version to 12 )
* Coped package-lock.json from trunk
* Fix label includ path
* Created new component for Filters elements labels
* Removed hideOutOfStock from AllProducts and realized hide out of stock functionality from SQL query
* Linter fix
* Review suggestion changes
* Update index.js
* Fixed preview part for stock and attribute filters
* Update assets/js/blocks/stock-filter/block.js
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Bring back removed css
* Allow custom stock statuses
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Escape statuses for sql query
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: aaron <aaron.yor@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>