* Display Add Review link in the All Products if there's no product rating in All Products and Products
* Apply the font-size mixin to the Add Review link
* Make Add review link NOT clickable in editor
* Improve styles of Rating component so they support alignment in product grids
* Product Query: First attempt at adding patterns
* Product Query: Update patterns and the default block template
* Product Query: And new and update existing patterns
* Product Query: Adjust layout of the Minimal Product Row pattern
* Product Query: Update pattern names
* Product Query: Polish spaces between blocks inside the patterns
* Product Query patterns: Link product titles and improve spacing between product elements
* Product Query patterns: Button font-size update
* Product Query patterns: Center the pagination
* Product Query patterns: Center the pagination for the default pattern
* Product Query patterns: Remove an empty column
* Product Query patterns: Remove an empty column from the product list with 1:1 images pattern
* Product Query: add Feedback Prompt in inspector
The prompt doesn't appear at the very bottom as there isn't
currently any straightforward way to do this in the block variation.
More investigation is required.
* Product Query: Change icon, description and name
* Product Query: switch to Feature plugin flag
* Add all currently available atomic blocks to the default Product Query template
* Update feature flags doc
* Change SKU and Stock Indicator feature flags
* Change feature flags docs
* Add title prop to the `FeedbackPrompt` and add a title to the Product Query one
* Hacky solution to display the feedback block at the bottom
The order of the inspector controls is set in Gutenberg.
We can hack our way down by hooking to the “color” group and
display our feedback there.
Other panels would be displayed below that if added, such as borders
and margin.
* Reduce Product Query default template
* Fix e2e tests after Product Query block name change (https://github.com/woocommerce/woocommerce-blocks/pull/7840)
* Product Query: Add a better default pattern (https://github.com/woocommerce/woocommerce-blocks/pull/7833)
* Product Query: Add a better default pattern
* Product Price: Add bottom margin
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
* Add product query support for Product Summary block
On the client side, when the Product Summary block is used within the product query block, the markup will be rendered on the server side - No javascript related to Product Summary block will be rendered.
* Update variable names for clarity & readability
* Escape all values in output string
* Fix custom style not working
More info: https://github.com/woocommerce/woocommerce-blocks/pull/7774#discussion_r1035909243
* Adds product query support for Category list block
On the client side, when the Category list block is used within the
product query bloc, the markup will be rendered on the server side -
No javascript related to Category list block will be rendered.
* bot: update checkstyle.xml
* Fix extra space after the category link
I used the solution from following link: https://css-tricks.com/fighting-the-space-between-inline-block-elements/#aa-remove-the-spaces
Here is the content from the above link:
The reason you get the spaces is because, well, you have spaces between the elements (a line break and a few tabs counts as a space, just to be clear). Minimized HTML will solve this problem, or one of these tricks:
```CSS
<ul>
<li>
one</li><li>
two</li><li>
three</li>
</ul>
```
or
```CSS
<ul>
<li>one</li
><li>two</li
><li>three</li>
</ul>
```
or with comments…
```CSS
<ul>
<li>one</li><!--
--><li>two</li><!--
--><li>three</li>
</ul>
```
They’re all pretty funky, but it does the trick.
* Fix custom style doesn't work on the frontend side
For more info, check this comment on the PR:
https://github.com/woocommerce/woocommerce-blocks/pull/7675#pullrequestreview-1179267957
In summary, user can set the custom styles like text color, link color, font size, font weight, line height using the editor sidebar.
These styles weren't showing on the frontend side.
* Add support for additional CSS class(es)
* Fix "custom style -> link color" not working
To understand the issue in more details please check following comment:
https://github.com/woocommerce/woocommerce-blocks/pull/7675#issuecomment-1319822535
* Fix classname undefined issue
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add product query support for Sale badge block
On the client side, when the Sale badge block is used within the product query block, the markup will be rendered on the server side - No javascript related to Sale badge block will be rendered.
* Add support for additional CSS class(es)
ADDITIONAL CSS CLASS(ES)(available in advanced toggle in sidebar) should be added to the container div
* Convert preset to css variable for padding
We are getting padding value in preset format like this:
"var:preset|spacing|50"
Therefore I added a function to convert it to CSS variable like this:
"var(--wp--preset--spacing--50)"
i.e. "var:preset|spacing|50" -> "var(--wp--preset--spacing--50)"
* Add reference for preset to css variable conversion logic
* Fix typo in HTML markup of ProductImage block placeholder
Typo caused rendering of incorrect HTML attributes: width and height of Product Image placeholder that were anyway ignored by the browser
* Remove inline styles (width and height) from ImagePlaceholder in ProductElements > Image block
Inline height took precedence over the inherited styles which made the placeholder image skewed (in loading and loaded state). Removal of those styles allows the ImagePlaceholder to adapt the height to the available space keeping the ratio or inherit the styles from the parent
* Remove inline styles (width and height) from placeholder image in ProductImage.php block
Inline styles applied to the placeholder image of ProductImage block were overriden by other styles with higher specificity, which made them redundant. Additionally, corresponding styles were removed from the placeholder image from Editor code as they caused UI glitches. Additional proof that it's safe to remove them is in the first commit in this branch, the purpose of which was to fix those styles as there was a typo which corrupted them and eventually inline width and height were ignored by the browser and not applied to the element
* Add test to check placeholder image renders without width and height inline attributes
This is to prevent adding inline width and height attributes so the sizing of the placeholder image is controlled by the inherited styles or element styles, in the same way as a regular product image
* Fix TypeScript errors in the block test file of Product Image
* Add generic alt text to placeholder image
Alt text added in this commit is a generic text, not description of the actual image. That's because the image itself is set externally through the settings and may change over time
* Revert adding placeholder image alt text and add comments to make the empty alt explicit
After a Github discussion: https://github.com/woocommerce/woocommerce-blocks/pull/7651\#discussion_r1019560494 it was decided the placeholder should NOT have alt text as it serves the purpose of decorative image. According to the guidelines decorative images should not have alt text: https://www.w3.org/WAI/tutorials/images/decorative/. Comments were added also to other places where it happens
* bot: update checkstyle.xml
Co-authored-by: Karol Manijak <karolm@Karols-MacBook-Pro.local>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add attributes, settings, and editor PQ settings.
- Adds isDescendentOfQueryLoop attribute and sets up usage in editor.
- Connects Context (via useContext) in editor.
- Sets up necessary hierarchy in block index file settings.
* Update parent inner blocks config.
Reassign parent array to ancestor array which allows for blocks to be
included with more flexibility - i.e., added within groups that are
children of the ancestor block.
* Add dynamic render function for PQ support.
* Update to use correct classnames on PHP side.
SSR markup was accidentally using rating classname instead of sku so it
was not applying the proper text transform seen in the editor.
* Rename BlockAttributes type to Attributes
This keeps things consistent with the type naming on the other blocks.
* Remove redundant spread of sharedConfig object.
We don't need to spread the `sharedConfig` object into the `blockConfig`
object when defining `blockConfig` since we spread/merge these two
objects when registering the block via `registerExperimentalBlockType`.
* bot: update checkstyle.xml
* bot: update checkstyle.xml
* Empty commit to trigger checks.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Move ValidatedTextInput and ValidationInputError to checkout package
* Include checkout package in tsconfig file
* Remove unnecessary index file
We export these components from packages/checkout/index.js instead
* Import ValidatedTextInput & ValidationInput error from checkout package
* Only add validationError.message when validationError is an object
* Explicitly add undefined to optional props
* Import isObject to test validationError
* Extend the HTML Input element attributes
* Use more performant useDispatch instead of dispatch
* Export component without withInstanceId hoc for testing
* Add tests for ValidatedTextInput
* bot: update checkstyle.xml
* Rename export of unwrapped component to have __
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Remove `parent` from block config.
By removing the `parent` property from the block config, we can have
more flexibility to where we can use the pricing block - i.e., it does
not need to be a direct descendent of a `core/group` block.
* Remove unused save function/file.
* bot: update checkstyle.xml
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
* Convert product-elements/summary to TypeScript
* bot: update checkstyle.xml
* Update assets/js/atomic/blocks/product-elements/summary/index.ts
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Resolve introduced TS error
* bot: update checkstyle.xml
* Remove default subproperties
* Add TODO to refactor this part in the future
* Make attribute type more strict
* Add more context to the todo regarding removing the HOC
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Add type to imports that need it
* Add type to imports that need it
* Fix the sanitize lint error
* Include missing dep
* Remove check from deps
* bot: update checkstyle.xml
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add PQ support for client-side.
Set up the block for PQ support and add necessary adjustments for the
editor. Will address dynamic save functionality in a following commit.
* Add dynamic render function for PQ support.
* Add dynamic render callback for SSR.
* Remove client-side Save function.
* Add PQ Context interface to shared type defs.
* Convert all block JS files to TS.
* Remove commented import from block file.
* Add typecasting to block function params.
As a workaround, added a general Record type but left a TODO to revisit
the proper object, as there is a mismatch in the shape of the default
object property types and the actual types.
* Update inserter behavior.
Allows for the ability to add the rating block from in the inserter
(as long as it's an inner block of the listed parents in the config).
Also disables the placeholder product selector from being rendered
unnecessarily (i.e., when the context ID is present).
* Update parent inner blocks config.
Reassign parent array to ancestor array which allows for blocks to be
included with more flexibility - i.e., added within groups that are
children of the ancestor block.
* Add productID to rating Attributes interface.
* TS type casting and import adustments.
Some adjustments to utilize types that we already have available, along
with some syntax adjustments and more sensible import tweaks.
* Update type-casting to use ProductResponseItem
Instead of using the generic Record, we can utilize the
ProductResponseItem interface and set an omission for the average_rating
property until that is corrected to properly reflect the API response.
* Add alias to blocks dir for imports.
Allows us to use exports from the blocks dir as "external" imports. This
way we do not need to write long, relative import paths (which can be
fragile in the long run).
* fix inconsistent button styling with TT3
* use wc_wp_theme_get_element_class_name
* add check to be sure that wc_wp_theme_get_element_class_name function exists
* Add attributes, settings, and editor PQ settings.
- Adds isDescendentOfQueryLoop attribute and sets up usage in editor.
- Connects Context (via useContext) in editor.
- Sets up necessary hierarchy in block index file settings.
* Add server-side rendered product price.
Adds the SSR output for the atomic Price block for PQ support.
* Remove Save attribute from JS index.
To allow for the block to be SSR, we need to remove the Save
attrubite/function on the JS side and allow for the PHP class to handle
it on the backend.
* Update PHP asset register method for added clarity
* Adjust block attr/context spreading for clarity.
* Convert checkout context to data store - part 1 (https://github.com/woocommerce/woocommerce-blocks/pull/6232)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Delete empty types.ts file
* remove merge conflict from docs
* Correct linting in docs
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Move checkout state code into thunks and rename `CheckoutState` context to `CheckoutEvents` (https://github.com/woocommerce/woocommerce-blocks/pull/6455)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* validate event emitter button
* Added thunks in a separate file
* Call thunks from checkout-state
* Checkout logic tested and working
* Remove dependency injection as much as poss, tidy up and fix some TS errors
* Fix types in thunks.ts
* Fixed some ts errors
* WIP
* Fixed bug
* Shift side effects from checkout-state to checkout-processor
* Revert "Shift side effects from checkout-state to checkout-processor"
This reverts commit 059533da4eb34f9982f66cd4adacc7b2c24f939f.
* Rename CheckoutState to CheckoutEvents
* Move status check outside the thunk
* remove duplicate EVENTS constant
* remove temp buttons
* Remove console logs
* Augment @wordpress/data package with our new store types
* Add correct type for CheckoutAction
* Remove createErrorNotice arg from runCheckoutAfterProcessingWithErrorObservers
* Remove createErrorNotice from emit event types
* Use type keyword when importing types
* Add correct types for dispatch and select in thunks
* Update wordpress/data types
* Replace store creation with new preferred method
* Set correct action type on reducer
* Remove unnecessary async from thunk
* add CHECKOUT_ prefix to checkout events again
* export EVENTS with eveything else in checkout0-events/event-emit
* Remove duplicate SelectFromMap and TailParameters
* Updated type for paymentStatus
* TODO remove wp/data experimental thunks
* Remove `setCustomerId` from events and `processCheckoutResponseHeaders` (https://github.com/woocommerce/woocommerce-blocks/pull/6586)
* Prevent passing dispatch, instead get actions direct from store
* Get setCustomerId from the store instead of passing it to processCheckoutResponseHeaders
* Revert "Prevent passing dispatch, instead get actions direct from store"
This reverts commit 4479a2ef5599d9c8d99c3629616b3d662210fc08.
* Auto stash before revert of "Prevent passing dispatch, instead get actions direct from store"
* Remove duplicate dispatch
* Fix unit tests
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Refactor selectors to not return functions anymore
This is a poor DevEx and naming did not reflect what the selector was returning.
* Update combobox to be more explicit when selecting validation error
* Update useValidation to use the new getValidationError selector
* Include @woocommerce/base-hooks in tsconfig
* Update ValidationInputError to use new selector
* Update ValidatedTextInput to use new selectors
* Prevent reference errors when getting validation errors in ComboBox
* Defend against case where message prop of error object is undefined
* Fix totals/coupon to use new validation selector
* Use validation data store in CheckoutTerms block
* Update AddressForm to use new validation selector
* Update AttributeSelectControl to use new validation selector
* Fix syntax error in ValidatedTextInput
* Fix multiple import error from rebase
* Fix lint issue in useStoreCartItemQantity
* Fix tests to reflect new selector API
* Remove unused validation prop from CheckoutTermsBlock
* Change CheckoutTermsBlock unit tests to use validation data store
* Fix JSDOC syntax
* fix merge conflict in checkout-api.md
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Niels Lange <info@nielslange.de>
* Move paymentMethodDataProvider into a data store (https://github.com/woocommerce/woocommerce-blocks/pull/6208)
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Use correct key in payment method data context
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Fix linting issues
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
* Rebase on the update/checkout-data-store branch & Fix failed payments (https://github.com/woocommerce/woocommerce-blocks/pull/6587)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Fix merge conflict error
* Set & get the provider's state from our data store instead of React's useReducer (https://github.com/woocommerce/woocommerce-blocks/pull/6588)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Get payment method data directly from the data store instead of the usePaymentMethodDataContext hook (https://github.com/woocommerce/woocommerce-blocks/pull/6589)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
* Get payment method state from data store in the checkout submit hook
* Copy types.ts file into the payment data store folder
* Fix isExpressPaymentMethodActive selector
* Move the entire currentStatus into the data store
* Replace the payment context state with the data store
* Fix getActiveSavedToken & clean up the context file
* Use the accutrate name of the "createErrorNotice"
* Update the payment method data store key import
* Diable unused state from the context
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Refactor the payment method data store & context (https://github.com/woocommerce/woocommerce-blocks/pull/6607)
* Add checkout data store
* wip on checkout data store
* CheckoutContext now uses the checkout store
* Investigated and removed setting the redirectUrl on the default state
* update extension and address hooks to use checkout data store
* use checkout data store in checkout-processor and use-checkout-button
* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity
* Remove useCheckoutContext from shipping provider
* Remove isCalculating from state
* Removed useCheckoutContext from lots of places
* Remove useCheckoutContext from checkout-payment-block
* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block
* add isCart selector and action and update the checkoutstate context
* Fixed redirectUrl bug by using thunks
* Remove dispatchActions from checkout-state
* Change SET_HAS_ERROR action to be neater
* Thomas' feedback
* Tidy up
* Oops, deleted things I shouldn't have
* Typescript
* Fix types
* Fix tests
* Remove isCart
* Update docs and remove unecessary getRedirectUrl() selector
* set correct type for preloadedCheckoutData
* Remove duplicate Address type
* Fix missing addresses from type-defs index
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Revert feedback changes
* REvert feedback formatting
* Update docs formatting
* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type
* Add default state for PaymentMethod data store
* Add preliminary action types
* Add preliminary action dispatchers
* Create payment method data store
* Add preliminary reducers for payment method data store
* Add preliminary selectors for payment method data store
* Add reducers/actions for registering payment methods
* Export payment method data store key
* Add test for payment method data reducers
* Add shouldSavePaymentMethod selector
* Add store key as constant
* Add more action types for registering and initializing payment methods
* Get active payment method from data store instead of from context
* Add registered methods to default state of payment method data store
* Dispatch name of registered payment method to payment method data store
* Remove setShouldSavePayment from payment method dispatcher and types
* Get payment methods from registry instead of payment context
* Add available payment methods to store
* Add function to check whether payment methods are allowed to be used
* Add selector to check if payments are initialised
* Remove resolvers and add controls to payment method data store
* Change type of payment requirements to string[]
* Turn addRegistered and addRegisteredExpress into generators
This is so we can check each payment method's validity before adding it to the list of available payment methods
* Add action type for setting express payments as initialized
* Only select from available methods in payment method options
* Remove argument from addRegisteredPaymentMethod in payment method registry
* Rename folder and store name to not contain the word data
* Add selectors for express payment methods and their initialisation
* Delete controls again in favour of thunks
* Rename payment-method-data to payment-methdods
* Create new setDefaultPaymentMethod function
This will set the payment method when the cart loads.
* Add CustomerPaymentMethodConfiguration type
* Make getAvailableExpressPaymentMethods return correct data
* Check express methods and normal methods when cart changes
* Add action for setting active express payment methods
* Handle express methods in checkPaymentMethodCanPay
* Hide express payments area if none are available
* Add selector for paymentMethodData
* Add customer data to default state and add selector for it
* Add setPaymentStatus action and reducer case
* Set the default payment method when one isn't selected
* Correct types on getCustomerPaymentMethods
* Set status in data store alongside context status
* Comment out active gateway selection - remove later
* Set status in express payment methods in data store
* Directly check payment methods from the list in blocks-registry
* Add semicolon to import statement
* Fix payment method data state call
* Get paymentMethodData from store not context
* Add addPaymentMethodData action/reducer case
* Update payment method on payment success
* Add 'getCurrentStatus' selector
* Remove the temporary solution
For getting payment method data into the data store
* Prevent the 'success' context action from being dispatched
* Update the "setPaymentStatus" data store action
Accept status as an object instead of string
* Fix the "currentStatus" reducer state update value
* Get payment data into data store
* Set the correct payment status to data store
* Get the success status of payment from data store
* Use store data in the payment dispatchers
Replace the React useReducers action in the payment dispatchers file with
the payment method data store
* Get payment status from data store
* Use data store for the payment error status
* Use payment data store failed status
* Use payment data store for the isFinished status
* Update the setPaymentStatus argument
* Set up setRegisteredPaymentMethods in data store
* Use the data store version of the registeredPaymentMethods
* Fix the default state type of the registeredPaymentMethods
* Set up setRegisteredExpressPaymentMethod in data store
* Use the data version of the registred express payment methods
* Set the correct action type for removing payment methods
* Fix default state express payment methods type
* Use the store data version of activePaymentMethod
* Use setActivePaymentMethod in the dispatchers file
And refactor code
* Update payment status arguments for express payment methods
* Use paymentMethodData from the data store
* Use payment method's errorMessage from data store
* Update paymentMethods list in data store reducer
* Replace remaining payment context data with data store
* Clean up payment method context file
* Get payment method state from data store in the checkout submit hook
* Copy types.ts file into the payment data store folder
* Fix isExpressPaymentMethodActive selector
* Move the entire currentStatus into the data store
* Replace the payment context state with the data store
* Fix getActiveSavedToken & clean up the context file
* Use the accutrate name of the "createErrorNotice"
* Update the payment method data store key import
* Diable unused state from the context
* Get enabled customer payment methods using data store selector
* Remove remaining useReducer action from the dispatchers file
* Update types and remove unused vars
* Remove the payment method dispatchers hook
* Refactor & clean up (remove unused files)
* Remove commented line from payment methods types
* Move event emitter into thunks
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Remove checkout-state after merge conflicts
* Fix linting errors
* Move types to types.ts
* Move default states into respective store folders
* Fix types and add comment
* Move setExpressPaymentError to payment-methods store
* fix express payment methods not showing up
* Check if payment method is active from the state
* Add comments
* Remove commented out code in payment method data context
* Display an error in the check-payment-methods directly from data store
* Remove use-emit-response hook and move utils in event-emit/utils.ts
* Use correct action property to remove payment methods
* Fix formatting
* Only try to initialize payment methods when cart is done loading
* Add function to order payment methods from server
* Add payment methods in the correct order
* Prevent adding registered payment methods before cart is ready
* Ensure payment methods get removed from state when deregistered
* Reorder setting default payment methods to add customer methods first
* Get customer methods from store not context
* Remove error from payment-method state and associated selectors
* Remove use-payment-method-registration and update the payment method state to remove the duplicated registeredPaymentMethods
* Remove errorMessage from payment-methods store
* Rename customerPaymentMethods -> savedPaymentMethods
* Order payment methods when validating
* Refactor payment-methods.js
* Fix "Payment methods not set in editor" woocommerce/woocommerce-blocks#6655 bug
We never get to load the payment methods object in the editor mode
because there are no cart totals to load.
* Initialize payment methods when available payments are loaded
* Remove duplicate code
* Fix data store state mutation anti-pattern
A Redux rule is to never mutate the state in a reducer to avoid any unexpected results
* Set availablePaymentMethods to the paymentMethods object
Instead of its keys. We can get the keys using "Object.keys".
* Use the available ordered payment methods
The `getPaymentMethods` & `getExpressPaymentMethods` may include unordored
& unavailable payment methods.
* Get the correct value from the emit event response
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Add validation reducers, actions, and action types
* Add selector for getValidationErrors
* Export store key and register store
* Export validation store key
* Move TextInput files to checkout package
* Export ValidatedTextInput from blocks-checkout package
* Update imports of ValidatedTextInput to reflect new location
* Use the validation wp-data store for showing error messages
* Export getValidationError in checkout package
* Move validation store to checkout package
* Move ValidationInputError to blocks-checkout package
* Only export "exposedSelectors" from validation
* Convert validation context to data store
* Fixed linting error
* Fixed linting error
* Change the validation selectors to return a function
* Convert reducer and selectors to TS
* Remove superfluous comments and improve test titles
* Test to ensure visible errors remain visible
* Make test for hasValidationErrors more robust
* Augment the wp-data module to include our selectors and actions
* Removed unused `exposedSelectors` variable
* Remove TS error because of `instanceId` on props
* Remove unnecessary as const
* Use function returned by getValidationError
* Use correct selector/action names now context has been decoupled
* hide validation error when input value changes
* Add correct aria-describedBy now we can get error id from store
* Clear validation error from store when component unmounts
* Clear validation error if input is valid
* convert ValidationInputError to TS and get correct id/error from store
* Ensure checkout block doesn't break when there are no errors
* Get validation data from the store instead of context
* Update country input to remove validation context
* Move validation store out of checkout package
* Move TextInput and ValidationInputError back out of the checkout package
* Remove duplicate internal styles comment
* Remove exports that no longer exist
* Get validation store key from block-data
* Make attribute-select-control use validation data store
* Export FieldValidationStatus type
* Make combobox use validation store not context
* Make Address use validation store not context
* Make Address use validation store not context
* Use hasValidationErrors selector as a function in shipping calculator
* Remove validation context from coupon story
* Import VALIDATION_STORE_KEY from correct location
* Stop coupon story from erroring
* Update useStoreCartCoupons to use validation store not context
* Make TotalsCoupon use validation store instead of context
* Make AddToCartFormContext use validation store not context
* Remove ValidationContext
* Import FieldValidationStatus from correct location
* Import ValidatedTextInput and ValidatedTextInput from correct location
* Remove ValidationContextProvider
* Update components to use validation store not context
* Update useValidation to use the data store
* Replace the validation context in checkout-events file
* Use the re-mapped path for the store key import
* Use "register" instead of the deprecated "registerStore"
* Fix import error of the "FieldValidationStatus" type
* Use TS instead of React's "PropTypes"
* Fix the type of "ValidationInputError" in the "payment-method-interface"
* Fix error not showing on the first place order click bug
We were mutating the state in the reducer, which prevented re-rendering
on state change
* Fix state mutation issue in the Validation reducer
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
* Adds to the Product Image Block the support for the Product Query Block
Adds to the Product Image Block the support for the Product Query Block woocommerce/woocommerce-blocks#6911
* use shared config
* use shared config
* use shared config
* Add to the Product Button Block the support for the Product Query Block
* Add to the Product Image Block the support for the Product Query Block
* fix lint errors
* address feedback
* set grid view and font-size L as default
We noticed that oftentimes our labels and text tend to be overly
technical or unclear. We decided to do a bulk pass to improve
the readability to non-technical users.
* Adds to the Product Image Block the support for the Product Query Block
Adds to the Product Image Block the support for the Product Query Block woocommerce/woocommerce-blocks#6911
* Add to the Product Image Block the support for the Product Query Block
* address feedback
* set grid view and font-size L as default
* Copy style-attributes file to desired directory.
Add a copy of the style-attributes file in blocks/hooks to the desired
base/hooks directory with the other hooks.
* Remove relative imports in favor of global aliases
Utilizes the custom global project aliases in place of using relative
imports.
Note: seeing some linting issues with the aliases. This seems to be the
case elsewhere so it is likely not a blocker for this effort, however,
it may be worth looking into as a follow-up.
* Adjust all imports to use @woocommerce/base-hooks.
Replace all instances of relative file paths to hooks/style-attributes
to use the custom global alias.
* Remove the hooks dir in `assets/js/blocks/`.
Now that everything is using the `@woocommerce/base-hooks` custom global
alias and we have the `style-attributes` hooks file in the base/hooks
directory, we no longer need the `style-attributes` hooks file in the
aforementioned `assets/js/blocks` directory.
* Split style-attributes.ts out into separate files.
Moved the four hooks in style-attributes.ts out into their own, separate
hook file to be consistent with the rest of our custom hooks.
Additionally, moved the helper function (parseStyle) out into a separate
export in base/utils.