* Add file and folder structure documentation
* Update docs/contributors/folder-structure.md
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Update docs/contributors/folder-structure.md
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Update docs/contributors/folder-structure.md
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Update description for atomic blocks in folder documentation
* Update description for base blocks in folder documentation
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Add test environment to catch errors
* Add jest-circus and jest-html-reporters
This is so we can log the screenshots and errors that happen during E2E tests.
* Use the jest reporters and jest-circus to run the E2E tests
* Force cart test to break
Revert this!
* Upload jest report artifact when tests fail
* Run artifact upload on failure
* Upload entire report directory to artifact
* Revert "Force cart test to break"
This reverts commit c57f2c5ab1d7b60d8824d854c1cb9a8281a71c4b.
* Update .gitignore and jest.config
* Force cart test to break
* Force cart test to break
* Remove <rootDir> from jest-html-reporter path
This was causing the artefact not to upload.
* Revert "Force cart test to break"
Co-authored-by: Niels Lange <info@nielslange.de>
* Add documentation guidelines
* Link to Automattic Writing Style Guide
* Adjust section for heading usage
* Update docs/contributors/documentation-guidelines.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Convert product elements shared config to TypeScript
* Limit import to type
* Convert deprecated empty save function
* Add comment explaining omitted attributes and title properties
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
This is a better representation of the node and npm version support for Woo Blocks (more notably the NPM 7 exclusion) which can help new contributors coming into the repository.
* Document DOM events used in WC Blocks
* Update docs/extensibility/dom-events.md
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Calculate human readable price values for the purpose of screen readers and set them as the aria values
* Calculate human readable price values for the purpose of screen readers and set them as the aria values
* Update API to add default boolean to attribute values and use this within the component to set the default attributes.
* Modify and add unit tests for isObject and getDefaultAttributes
* Sanitize attribute name to accommodate for custom attributes being default values.
* Comments for sanitized_attribute_name variable
* Remove second argument from getAttributes
* Replace context with __experimentalShareWithChildBlocks
* Switch to parent block when changing views
* Swap order of views
* Drop default, use first view
* Improve block selection after changing views
* WIP getting to work on frontend
* restore frontend.tsx
* fix layout
* support emtpy cart in frontend
* add cart tital to correct place and move useEffect
* Improve the type for callbacks registered by extensions
The previous type was CanMakePaymentCallback, used for the payment methods's own canMakePayment callbacks, which could also return Promises. In order to eliminate the confusion, a new type has been created that defines callbacks that only return true or false.
* Document registerPaymentMethodExtensionCallbacks
* Update docs/extensibility/filtering-payment-methods.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Add information about payment method name in documentation
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* WIP getting to work on frontend
* restore frontend.tsx
* fix layout
* remove unit tests living where they shouldn't be living
* remove skeleton
* support emtpy cart in frontend
* remove extra todo
* use fragment instead of div
* Add empty cart event
* Remove extra fragment
* Add cartCoupons to canMakePayment argument
* Add cart to the paymentMethodArgument and improve the dependencies for the effect calling refreshCanMakePayments
* Debounce refreshCanMakePayments
The initial approach was to debounce billingData and use this value as a dependency for the useEffect that runs refreshCanMakePayments.
But because the depencies array can always change we decided to debounce the callback instead, ensuring this way that callback is not called multiple times: for example when typing a field in the billing address. Debounced was chosen instead of throttle because we want to call refreshCanMakePayments once the change event has stopped, with the final value.
* Update types and docs related to canMakePaymentArgument
* Mock the /cart call when testing payment methods
* Remove unused cartCoupons key in canMakePaymentArguments' interface
* woocommerce/woocommerce-blocks#3906 screen reader fix for order summary block
* removing tabIndex and extra accesibility text
* adding aria-hidden to total price and translation comments change order
* Support express payment methods filtering by extensions
* Add tests for getCanMakePayment and fix payment tests' TS errors
* Add comments for payment-method-config-helper test
* Throw an exception if there is no selected shipping method on an item that needs shipping
* Update src/StoreApi/Utilities/OrderController.php for ensure error message ends with a period.
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* 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
* Empty commit for release pull request
* Update changelog in readme
* Update testing instructions for 5.9.0
* Update testing instructions for 5.9.0 to include screenshots and smoke test
* Remove 4545 from testing notes and changelog
* Update testing instructions for 5.9.0 to include new test plugin zip
* Update testing instructions from postcode to city
* Rename usages of className to class in ProductSearch.php (https://github.com/woocommerce/woocommerce-blocks/pull/4740)
* Update zip file
* Update changelog in readme.txt
* Update testing instructions
* Update testing instructions
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* 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 InboxNotifications class
This will be used to handle displaying the inbox notification to select merchants
* Show inbox notifications on load
* Update copy in inbox notification
* Update URL and percent chance for a user to be chosen
* Add apostrophe to notification content
* Only register notifications when woocommerce_init is done
* Wait for admin to load before adding note
* Add further disallowed plugins
* Allow notification to be shown when using WC Points and Rewards
* Remove timestamp and content data from the note
This isn't necessary and was only added for testing.
* Check for existence of note based on name instead of content_data
* Create delete note function
We'll be deleting notes in the case that an ineligible plugin becomes active.
* Reorder the eligible plugin and % targeting check
This will let us target a truer % of users, and also will let us delete the note if a user activates an ineligible plugin.
* Remove code which was added for testing purposes
The code to return if the feature plugin was active was enabled, woocommerce-gutenberg-products-block was added as an ineligible plugin.
- updated release pull request description template to be more condensed and require no editing.
- moved some elements of release pull request items into pull request template (handled at the PR level instead of the release level).
- updated the release pull request checklist templates to include mobile and desktop test coverage for ui changes.
* 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>
* Empty commit for release pull request
* Add changelog to readme.
* Update metadata for release
* Testing notes for release
* Apply suggestions from code review
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Apply suggestions from code review
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Thomas Roberts <5656702+opr@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
* Add documentation for `cart/extensions`
* Add documentation for ExperimentalDiscountsMeta slot
* Add clearer information to `cart/extensions` documentation
* Change checkout screenshot
* Change checkout screenshot
* Update documentation into new template and amend based on suggestions
* Fix typo
* Fix punctuation and remove passive-aggressive voice!
* Update docs/extensibility/extend-rest-api-update-cart.md
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Remove account creation gating
* Unneccessary use statements
* Tidy up with null coalescing operators
* Add __experimental_woocommerce_blocks_checkout_update_order_from_request action
* Default to 200 status
* add docs in feature flag file
* align docs with hook
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* 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>