Gutenberg 12.1.0 has changed the convention for the directory paths from
`block-templates` and `block-template-parts` to `templates` and `parts` respectively.
Allow compatibility with themes which follow both conventions and also make sure that
we remain backwards-compatible.
Fixeswoocommerce/woocommerce-blocks#5450
Some of this fix has a dependency on WooCore
See: WooCommerce/woocommercewoocommerce/woocommerce-blocks#31522
* Fix custom templates with fallback being incorrectly attributed
Category and tags templates can fallback to the generic archive if, e.g., the theme
provides one for the latter but not for the former. However, since Gutenberg is not
aware of this fallback mechanism, it would incorrectly attribute the custom template
to the user instead of the theme.
Here we are explicitly setting the `has_theme_file` to make sure Gutenberg knows
we do, in fact, have a theme fail (if not what it expects).
Also skip the loop if template is duplicate but has no fallback
Fixeswoocommerce/woocommerce-blocks#5441
* Add clear and fill input test util
* Add tests for Filter Products by Price
* Add class name to filter products by price block in editor
* Update wp-env
* Fix formatting
* Update lock
* Revert "Update lock"
This reverts commit f4e809e000430eea3972c94fd2aea0a19ba6961b.
* Create product attributes during setup
* Remove product attributes during teardown
* Add attributes in fixture-data
* Add two new products, for attribute testing
* Load attributes into store and apply them to products
* Add class to Filter by Attribute when editing
This is so it can be targeted in E2E tests more easily.
* Add tests for Filter Product by Attribute
* Fix formatting in attribute-filter.test.js
* Add tests for active filters block
* Add doc block for ensuteCleanAttributes
* Update wording of title test in all filter block E2E
* Update test wording to read better
* Update snapshots
* Use pptr-testing-library selectors to click elements
This makes the tests easier to reason with, and lets us take a step back from the implementation details (classnames etc.)
* Add saveOrPublish test util
* Use pptr-testing-library selectors to click elements in attribute filter
* Use pptr-testing-library selectors to click elements in price filter
* Add `puppeteer-testing-library`
* Use puppeteer-testing-library API to look for H6 button
* Use correct argument in jest-puppeteer.dev.config
* Update package.json & package-lock.json
* remove tests for 5.3
* remove snapshots
* Remove ensureCleanAttributes
* Remove puppeteer-testing-library, install missing expect-puppeteer package and update tests
The puppeteer-testing-library, although added by gutenberg is not actively used.
I have removed it and realised that the added functionality can be easily replaced by expect-puppeteer.
This is a package that we specify in the jest configuration but it was not part of our package.json.
The selectors from puppeteer-testing-library have been replaced with .toClick and the utility clearAndFillInput with .toFill
The Filter by Attribute block has been skiped until tests are fixed.
* Add back setupPageSettings to jest setup
* Fix filter by attribute block test
* Fix linting error
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
* Add isCheckout prop to NoShippingPlaceholder and TotalsShipping
* Pass isCheckout to TotalsShipping in Checkout sidebar
* Show the NoShippingPlaceholder if no rates are found
* Show better error message when no shipping is available in checkout
* Remove Storybook knobs
They are now fully replaced by controls
* Update Storybook to 6.4.9
* Add Storybook documentation and VSCode snippets
* Add VSCode snippets
* Convert stories from checkout packages and include them in Storybook
* Empty commit for release pull request
* Add changelog and version info
* 6.6.0 testing notes
* Remove mini cart from testing instructions
* Clarify testing instructions
* Remove experimental feature from changelog
* fix not found template for the template editor
* update zip
* Remove test instructions for icon
* Testing steps for 5425
* Link order controller to cart routes
* Remove order controller from checkout route
* Fix PHP warnings in abstract schema
* Fix PHP warnings in abstract route
* Update shipping phone handling
* Includes are handled in core now
* Remove maybe_update_order_from_customer
* Add cart_updated routine to all cart routes
* Remove abstract method
* Remove test for woocommerce_blocks_cart_update_order_from_customer_request
* Remove do_order_callback
* Update readme
* Update tests
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Luigi <gigitux@gmail.com>
* Link order controller to cart routes
* Remove order controller from checkout route
* Fix PHP warnings in abstract schema
* Fix PHP warnings in abstract route
* Update shipping phone handling
* Includes are handled in core now
* Remove maybe_update_order_from_customer
* Add cart_updated routine to all cart routes
* Remove abstract method
* Remove test for woocommerce_blocks_cart_update_order_from_customer_request
* Remove do_order_callback
* Add archive-product template into block template hieachy
* Add archive-product condition to product tag block template render method
* Move taxonomy hierarchy filter to WC core
* Undo template amends
* Duplicate the themes archive-product template if it has one for taxonomy block templates
* Review feedback
* Use TextDomain instead of Name
* use correct if/else syntax
* Remove unncessary boolean syntax
* Add full documentation to the component props in Storybook
* Fix `FormattedMonetaryAmount` TypeScript errors
Since this component is passing on props to `NumberFormat`,
it needs to extend all of its original props, except for `onValueChange`
which we wrap in order to accept only `number`s.
* Convert `constrainRangeSliderValues` to TypeScript
* Add docs to `Currency` types
* Convert `PriceSlider` to TypeScript
*Note:* All TypeScript errors were fixed during the conversion,
except for the IE workaround which wasn't clear to me at this time.
Opened an issue: woocommerce/woocommerce-blocks#5276
* Fix Price Slider story (https://github.com/woocommerce/woocommerce-blocks/pull/5253)
* Migrate stories for `ProductName` to latest Storybook
Also add props documentation and add named export.
* Migrate stories for `ProductName` to latest Storybook. Also add props
documentation and add named export.
* Migrate `TotalsFooterItem` to TypeScript and latest Storybook
* Add a `LooselyMustHave` utility type.
* Export `allSettings` so that they can be manipulated in stories and tests
* Implement a way to easily define and reuse Storybook controls
Implement a currency control for a common use-case of selecting currencies.
It currently implements EUR and USD as they have different properties.
* Migrate `TotalsDiscount` to TypeScript and implement stories
* Migrate `TotalsCoupon` to TypeScript and fix stories
* Change Coupon name within Storybook
* Nicer handling of removal of a coupon from Storybook
It now dynamically calculates the discount from the actual coupons.
* Clarify docs for STARTED
* Clarify docs for setActivePaymentMethod
* Remove useActivePaymentMethod hook (this held state for active methods and tokens)
* Update type defs
* Enhance setActivePaymentMethod action to accept method data
* SET_ACTIVE_PAYMENT_METHOD action
* Add setActivePaymentMethod dispatcher and make "started" status only
* Update setActivePaymentMethod usage in express methods
* Set radio control defaults
* Consolodate tokens and methods
* Update assets/js/base/context/providers/cart-checkout/payment-methods/reducer.ts
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Spacing
* Split saved cards tests from regular, since saved cards are checked by default
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* add view switcher for mini cart contents block
* editor view switcher
* update mini cart template file
* render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674
render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674
* update selector
* allow empty mini cart block to add all blocks
* fix tests; improve code style
* install @wordpress/block-editor package
* fix warning on frontend side
* block-editor package is not necessary
* merge attributes object
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Introduce shared trait for draft order handling (DraftOrderTrait)
* Use trait where needed for maybe_release_stock
* Introduce woocommerce_blocks_cart_update_customer_from_request
This hook gets the request data and customer object, and from there, 3rd parties could grab a draft order and manually update it if needed (if the use cases requires this).
* Revert "Introduce woocommerce_blocks_cart_update_customer_from_request"
This reverts commit 6620818eb1e03b87c6eca0d757ec8b78802e3c57.
* Fix link to edit the Mini Cart template part in WP 5.9
* Use wp_is_block_theme() function
* Add protection against overwriting isSiteEditorAvailable setting
* Rename isSiteEditorAvailable to isBlockTheme
* Update icon of legacy template block
* Display legacy block template color in Woo purple
* Display icons in white when block being selected within list view
* ship component stories for storybook
* Refactor RemovableChip for Storybook
* Implement lucio feedback changes
* RemovableChip is part of the Chip story
* Typedefs and cartData for the payment interface
* fix case on noticeContexts
* typeof for enums
* immutable note
* Add cartData to docs table
* Rebase docs
* Update packages to latest Storybook deps
* Migrate `ReadMore` component and its utils to TypeScript
* Add type definitions for `trim-html` package
* Migrate `ReadMore` stories to newest Storybook
Fixeswoocommerce/woocommerce-blocks#5254
* WIP
* Converted block-error-boundary to TS
* Convert CheckboxList to TS
* Converted Chip and Removable Chip components to TS
* Change type to React.FC<T>
* Fix tests
* Implement Lucio feedback
* Mini Cart block: Add label for tax when it should be visible in accordance with WC settings woocommerce/woocommerce-blocks#4849
Mini Cart block: Add label for tax when it should be visible in accordance with WC settings
* improve the tax label handling
* fix code after conflict
* fix tax label handling when it is added the first product
* add another check for avoid PHP error
* rename variables; add test for the function getSettingWithCoercion
* add margin-right for tax-label; add test to check if type guard works correctly
* Convert `ErrorPlaceholder` and `ErrorMessage` to TypeScript
* Add stories for `ErrorPlaceholder` and `ErrorMessage` (https://github.com/woocommerce/woocommerce-blocks/pull/5255)
Stories include:
* Default generic error
* API error
* Unknown error
* Error without possibility to retry
* Base Error atom
Where applicable, the **Retry** button will not only trigger the appropriate
action, but also simulate the loading state of the error component.
* Update references to `ErrorMessage` component to leave the file extension out
Fixwoocommerce/woocommerce-blocks#5255
Refs woocommerce/woocommerce-blocks#5249
* Migrate Storybook to 6.4.0 and enable auto-detection of controls (https://github.com/woocommerce/woocommerce-blocks/pull/5249)
Previously our Babel configuration conflicted with the one provided by
default by Storybook, making us unable to leverage the automatic
detection of properties from both JS and TS components to create
controls (formerly known as knobs).
Upgrading to 6.4.0 fixes a bug that makes it easier to work with
Babel configurations. Also done here:
* Removed a few deprecated addons in favor of the replacement ones
bundled within Storybook Essentials.
* Add auto-detection of certain control types depending on the property names
* Add support for TS stories
More context: https://github.com/storybookjs/storybook/issues/12292
* Use `react-docgen` only in development environments
This should reduce production bundle size dramatically. The only
problem here is that Storybook runs its `build` command with the
`NODE_ENV` set to `production`. For this reason, we change the
script to provide `BABEL_ENV` set to `development` to still make sure
the correct configuration is loaded, while trying to reduce any
side-effects on changing the whole `NODE_ENV`.
* Add global style for product categories list block woocommerce/woocommerce-blocks#4965
Add global style for product categories list block
* add support for link color
* add feature flag
* fix code style and PHP warning
* update doc comment
* remove empty space
* refactor StyleAttributesUtils (https://github.com/woocommerce/woocommerce-blocks/pull/5277)
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Mini Cart Block: add link to edit template part from sidebar woocommerce/woocommerce-blocks#5186
Mini Cart Block: add link to edit template part from sidebar
* fix e2e tests
* Product details metadata now accepts as a default prop, with as an optional alternative
* Updated product details test snapshot
* Don't overwrite key prop
* One of key or value must be entered in ProductItemResponseData type
* Convert ReturnToCartButton component to TS
* Convert FormStep component to TS
* Remoe proptypes from FormStep and AddressFormn components
* Converted order-summary component to TS
* Convert product-price component to TS
* alias path to type-defs
* Fix errors
* Changes from Thomas feedback
* Change minPrice maxPrice logic to be more robust
* Changed types from inline to interface in ReturnToCartButton component
* Check for string type in order-summary-item
* add missing isString check
On the front-end, checkboxes with labels would look squished when the labels wrapped
on a second line. That was due to the flex container taking too much space for the label
as the checkbox minimum dimensions was set in `px` rather than `em`, making it work
differently depending on the relative font size.
* Fix Mini Cart block when Gutenberg is not enabled
* Escape Mini Cart template part
* Avoid creating $part variable
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Within the editor, the checkbox appeared aligned at the bottom of the paragraph, while
on the front-end it would appear aligned at the top. The alignment was actually correct
but a top margin was assigned to checkboxes in the backend.
Instead of removing that globally, this commit resets it for checkboxes within the checkout
block.
* Reference the WooCommerce DEWP instead of WPDEWP
* Apply suggestions from code review
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Format with decimal and thousands, with tests
* Update packages/prices/utils/price.ts
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Fix wrong event prefix in doc comment
* Make className prop in CartLineItemsTableProps optional
* Mini Cart as template part
* Remove BlockTemplatePartsController and instead use BlockTemplatesController
* Remove old code
* Clean up frontend rendering
* Update tests
* Improve if clause
* Fix wrong tests title
* Fix wrong variable name
* Make sure Mini Cart contents block is unmounted whem mini cart closes or unmounts
* Remove unnecessary waitFor
* Fix PaymentMethodDataProvider wrong children type
* TypeScript fixes
* Make comment shorter
* Remove test code
* Fix contant unmounts of Mini Cart contents block
* Fix wrong template_type passed
* Set Template part area to 'uncategorized'
* Set Template part area to the correct value
* Move template dir check outside loop
* Empty commit for release pull request
* Update readme.txt with release changelog
* Add testing instructions for 6.3.0 release
* Update testing instructions as MD tables didn't work
* Update testing instructions
* Update testing instructions
* Update testing instructions
* Update readme.txt
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Update docs/testing/releases/630.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Update readme.txt
* Update release zip in testing note
* Update testing instructions
* Remove feature gate condition for Legacy Template block (https://github.com/woocommerce/woocommerce-blocks/pull/5158)
* Update testing instructions
* Update testing instructions
* Update testing instructions
* Update readme.txt
* Update testing instructions
* Update testing instructions
* Update release zip in testing note
* Update testing instructions for SE templates
* Update testing instructions for SE templates II
* Update testing instructions
* Bumping version strings to new version.
* Empty commit for release pull request
* Fix state validation to compare state codes, and only validate if a country is given (https://github.com/woocommerce/woocommerce-blocks/pull/5132)
* Only get valid states from wc if there is a country
* Shared validation logic which uses keys
* Fix 'Country is required' error on the Cart block when updating shipping address (https://github.com/woocommerce/woocommerce-blocks/pull/5129)
* Fix error on the Cart block
* Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook
* Fix the country is required error on the Cart page using refs
* Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls
* Remove redundant check for customerDataToUpdate
* remove use of refs in initial values
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Make order note block removable (https://github.com/woocommerce/woocommerce-blocks/pull/5139)
* unforce order note
* show block in inserter
* Mini Cart block fatal error caused by append_script_and_deps_src (https://github.com/woocommerce/woocommerce-blocks/pull/5142)
* Remove unused use statements
* Fix types for $script
* `get_script_from_handle` might return null so handle this case to prevent errors
* Missing escaping
* Replace do_action_deprecated with the WC equivalent (https://github.com/woocommerce/woocommerce-blocks/pull/5151)
* Remove feature gate condition for Legacy Template block (https://github.com/woocommerce/woocommerce-blocks/pull/5158)
* Update readme.txt
* Update testing instructions
* Bumping version strings to new version.
* Empty commit for release pull request
* Update readme.txt
* Add testing instructions
* Add testing notes to README.md
* Hide WooCommmerce block templates from Edit Post template dropdown (https://github.com/woocommerce/woocommerce-blocks/pull/5167)
* Hide WooCommmerce block templates from Edit Post template dropdown
* Add empty post_types value to template and update comments.
* Legacy Template Block: Remove the deletion lock (https://github.com/woocommerce/woocommerce-blocks/pull/5166)
Previously, our legacy template block was locked to prevent the users from
removing it. The block could however be removed by erasing the parent, so
this change allows the user to directly remove the block itself.
Also:
Closeswoocommerce/woocommerce-blocks#5163Closeswoocommerce/woocommerce-blocks#5109
* Update release zip
* Update release zip
* Update testing instructions
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Michael P. Pfeiffer <michael@cssconf.eu>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Alex Florisca <alexflorisca@gmail.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
Previously, our legacy template block was locked to prevent the users from
removing it. The block could however be removed by erasing the parent, so
this change allows the user to directly remove the block itself.
Also:
Closeswoocommerce/woocommerce-blocks#5163Closeswoocommerce/woocommerce-blocks#5109