Product Collection: Revert rename of "Sync with current query" option (#49907)

* Revert renaming Sync with current query option

* Add changelog
This commit is contained in:
Karol Manijak 2024-07-24 14:17:37 +02:00 committed by GitHub
parent d40b2ced59
commit 0824b7e65d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 3 deletions

View File

@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { usePrevious } from '@woocommerce/base-hooks';
import { select } from '@wordpress/data';
import { useMemo } from '@wordpress/element';
import {
ToggleControl,
@ -25,19 +26,61 @@ import {
getDefaultValueOfFilterable,
} from '../../utils';
const label = __( 'Use page context', 'woocommerce' );
const label = __( 'Sync with current query', 'woocommerce' );
const helpText = __(
const productArchiveHelpText = __(
'Enable to adjust the displayed products based on the current template and any applied filters.',
'woocommerce'
);
const productsByCategoryHelpText = __(
'Enable to adjust the displayed products based on the current category and any applied filters.',
'woocommerce'
);
const productsByTagHelpText = __(
'Enable to adjust the displayed products based on the current tag and any applied filters.',
'woocommerce'
);
const productsByAttributeHelpText = __(
'Enable to adjust the displayed products based on the current attribute and any applied filters.',
'woocommerce'
);
const searchResultsHelpText = __(
'Enable to adjust the displayed products based on the current search and any applied filters.',
'woocommerce'
);
const filterableHelpText = __(
'Adjust the displayed products depending on the current template and any applied query filters.',
'woocommerce'
);
const getHelpTextForTemplate = ( templateId: string ): string => {
if ( templateId.includes( '//taxonomy-product_cat' ) ) {
return productsByCategoryHelpText;
}
if ( templateId.includes( '//taxonomy-product_tag' ) ) {
return productsByTagHelpText;
}
if ( templateId.includes( '//taxonomy-product_attribute' ) ) {
return productsByAttributeHelpText;
}
if ( templateId.includes( '//product-search-results' ) ) {
return searchResultsHelpText;
}
return productArchiveHelpText;
};
const InheritQueryControl = ( {
setQueryAttribute,
trackInteraction,
query,
}: QueryControlProps ) => {
const inherit = query?.inherit;
const editSiteStore = select( 'core/edit-site' );
const queryObjectBeforeInheritEnabled = usePrevious(
query,
@ -48,6 +91,9 @@ const InheritQueryControl = ( {
const defaultValue = useMemo( () => getDefaultValueOfInherit(), [] );
const currentTemplateId = editSiteStore.getEditedPostId() as string;
const helpText = getHelpTextForTemplate( currentTemplateId );
return (
<ToolsPanelItem
label={ label }
@ -111,7 +157,7 @@ const FilterableControl = ( {
<ToggleControl
className="wc-block-product-collection__inherit-query-control"
label={ label }
help={ helpText }
help={ filterableHelpText }
checked={ !! filterable }
onChange={ ( value ) => {
setQueryAttribute( {

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Product Collection: revert renaming "Sync with current query" option