Product Price Block: remove ProductSelector (https://github.com/woocommerce/woocommerce-blocks/pull/8980)
This commit is contained in:
parent
6c86d45951
commit
4d1604bdd0
|
@ -9,14 +9,11 @@ import {
|
||||||
import { useEffect } from '@wordpress/element';
|
import { useEffect } from '@wordpress/element';
|
||||||
import type { BlockAlignment } from '@wordpress/blocks';
|
import type { BlockAlignment } from '@wordpress/blocks';
|
||||||
import { useSelect } from '@wordpress/data';
|
import { useSelect } from '@wordpress/data';
|
||||||
import { __ } from '@wordpress/i18n';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import Block from './block';
|
import Block from './block';
|
||||||
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
|
|
||||||
import { ProductSelector } from '../shared/product-selector';
|
|
||||||
|
|
||||||
type UnsupportedAligments = 'wide' | 'full';
|
type UnsupportedAligments = 'wide' | 'full';
|
||||||
type AllowedAlignments = Exclude< BlockAlignment, UnsupportedAligments >;
|
type AllowedAlignments = Exclude< BlockAlignment, UnsupportedAligments >;
|
||||||
|
@ -82,52 +79,20 @@ const PriceEdit = ( {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const showProductSelector =
|
|
||||||
! isDescendentOfQueryLoop &&
|
|
||||||
! isDescendentOfSingleProductTemplate &&
|
|
||||||
! attributes.isDescendentOfSingleProductBlock;
|
|
||||||
|
|
||||||
if ( ! showProductSelector ) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<BlockControls>
|
|
||||||
<AlignmentToolbar
|
|
||||||
value={ attributes.textAlign }
|
|
||||||
onChange={ ( textAlign: AllowedAlignments ) => {
|
|
||||||
setAttributes( { textAlign } );
|
|
||||||
} }
|
|
||||||
/>
|
|
||||||
</BlockControls>
|
|
||||||
<div { ...blockProps }>
|
|
||||||
<Block { ...blockAttrs } />
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div { ...blockProps }>
|
<>
|
||||||
<ProductSelector
|
<BlockControls>
|
||||||
productId={ attributes.productId }
|
<AlignmentToolbar
|
||||||
setAttributes={ setAttributes }
|
value={ attributes.textAlign }
|
||||||
icon={ BLOCK_ICON }
|
onChange={ ( textAlign: AllowedAlignments ) => {
|
||||||
label={ BLOCK_TITLE }
|
setAttributes( { textAlign } );
|
||||||
description={ __(
|
} }
|
||||||
'Choose a product to display its price.',
|
/>
|
||||||
'woo-gutenberg-products-block'
|
</BlockControls>
|
||||||
) }
|
<div { ...blockProps }>
|
||||||
>
|
|
||||||
<BlockControls>
|
|
||||||
<AlignmentToolbar
|
|
||||||
value={ attributes.textAlign }
|
|
||||||
onChange={ ( textAlign: AllowedAlignments ) => {
|
|
||||||
setAttributes( { textAlign } );
|
|
||||||
} }
|
|
||||||
/>
|
|
||||||
</BlockControls>
|
|
||||||
<Block { ...blockAttrs } />
|
<Block { ...blockAttrs } />
|
||||||
</ProductSelector>
|
</div>
|
||||||
</div>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue