Set control label per context

This commit is contained in:
Bart Kalisz 2024-09-09 16:28:47 +02:00
parent 6e09d7b480
commit cd537befbe
3 changed files with 4 additions and 1 deletions

View File

@ -81,6 +81,7 @@ function useProducts(
} }
export const HandPickedProductsControlField = ( { export const HandPickedProductsControlField = ( {
label,
query, query,
trackInteraction, trackInteraction,
setQueryAttribute, setQueryAttribute,
@ -151,7 +152,7 @@ export const HandPickedProductsControlField = ( {
return ( return (
<FormTokenField <FormTokenField
displayTransform={ transformTokenIntoProductName } displayTransform={ transformTokenIntoProductName }
label={ __( 'Select Products', 'woocommerce' ) } label={ label || __( 'Hand-Picked Products', 'woocommerce' ) }
onChange={ onTokenChange } onChange={ onTokenChange }
onInputChange={ isLargeCatalog ? handleSearch : undefined } onInputChange={ isLargeCatalog ? handleSearch : undefined }
suggestions={ suggestions } suggestions={ suggestions }

View File

@ -289,6 +289,7 @@ const CollectionSpecificControls = (
'woocommerce/product-collection/hand-picked' && ( 'woocommerce/product-collection/hand-picked' && (
<HandPickedProductsControlField <HandPickedProductsControlField
{ ...queryControlProps } { ...queryControlProps }
label={ __( 'Select Products', 'woocommerce' ) }
/> />
) )
} }

View File

@ -142,6 +142,7 @@ export type DisplayLayoutControlProps = {
setAttributes: ProductCollectionSetAttributes; setAttributes: ProductCollectionSetAttributes;
}; };
export type QueryControlProps = { export type QueryControlProps = {
label?: string;
query: ProductCollectionQuery; query: ProductCollectionQuery;
trackInteraction: TrackInteraction; trackInteraction: TrackInteraction;
setQueryAttribute: ( attrs: Partial< ProductCollectionQuery > ) => void; setQueryAttribute: ( attrs: Partial< ProductCollectionQuery > ) => void;