* Rename productLink to showProductLink

* Add explicit prop value
This commit is contained in:
Niels Lange 2021-08-25 14:45:10 +02:00 committed by GitHub
parent e3b88d501e
commit ea55000792
7 changed files with 20 additions and 20 deletions

View File

@ -1,5 +1,5 @@
export const blockAttributes = {
productLink: {
showProductLink: {
type: 'boolean',
default: true,
},

View File

@ -25,7 +25,7 @@ import './style.scss';
* @param {Object} props Incoming props.
* @param {string} [props.className] CSS Class name for the component.
* @param {string} [props.imageSizing] Size of image to use.
* @param {boolean} [props.productLink] Whether or not to display a link to the product page.
* @param {boolean} [props.showProductLink] Whether or not to display a link to the product page.
* @param {boolean} [props.showSaleBadge] Whether or not to display the on sale badge.
* @param {string} [props.saleBadgeAlign] How should the sale badge be aligned if displayed.
* @return {*} The component.
@ -33,7 +33,7 @@ import './style.scss';
export const Block = ( {
className,
imageSizing = 'full-size',
productLink: showProductLink = true,
showProductLink = true,
showSaleBadge,
saleBadgeAlign = 'right',
} ) => {
@ -136,7 +136,7 @@ const Image = ( { image, onLoad, loaded, showFullSize, fallbackAlt } ) => {
Block.propTypes = {
className: PropTypes.string,
fallbackAlt: PropTypes.string,
productLink: PropTypes.bool,
showProductLink: PropTypes.bool,
showSaleBadge: PropTypes.bool,
saleBadgeAlign: PropTypes.string,
};

View File

@ -17,7 +17,7 @@ import { BLOCK_TITLE, BLOCK_ICON } from './constants';
const Edit = ( { attributes, setAttributes } ) => {
const {
productLink,
showProductLink,
imageSizing,
showSaleBadge,
saleBadgeAlign,
@ -38,10 +38,10 @@ const Edit = ( { attributes, setAttributes } ) => {
'Links the image to the single product listing.',
'woo-gutenberg-products-block'
) }
checked={ productLink }
checked={ showProductLink }
onChange={ () =>
setAttributes( {
productLink: ! productLink,
showProductLink: ! showProductLink,
} )
}
/>

View File

@ -56,7 +56,7 @@ describe( 'Product Image Block', () => {
test( 'should render an anchor with the product image', () => {
const component = render(
<ProductDataContextProvider product={ productWithImages }>
<Block productLink />
<Block showProductLink={ true } />
</ProductDataContextProvider>
);
@ -80,7 +80,7 @@ describe( 'Product Image Block', () => {
test( 'should render an anchor with the placeholder image', () => {
const component = render(
<ProductDataContextProvider product={ productWithoutImages }>
<Block productLink />
<Block showProductLink={ true } />
</ProductDataContextProvider>
);
@ -103,7 +103,7 @@ describe( 'Product Image Block', () => {
test( 'should render the product image without an anchor wrapper', () => {
const component = render(
<ProductDataContextProvider product={ productWithImages }>
<Block productLink={ false } />
<Block showProductLink={ false } />
</ProductDataContextProvider>
);
const image = component.getByTestId( 'product-image' );
@ -123,7 +123,7 @@ describe( 'Product Image Block', () => {
test( 'should render the placeholder image without an anchor wrapper', () => {
const component = render(
<ProductDataContextProvider product={ productWithoutImages }>
<Block productLink={ false } />
<Block showProductLink={ false } />
</ProductDataContextProvider>
);

View File

@ -8,7 +8,7 @@ let blockAttributes = {
type: 'number',
default: 2,
},
productLink: {
showProductLink: {
type: 'boolean',
default: true,
},

View File

@ -25,7 +25,7 @@ import './style.scss';
* @param {Object} props Incoming props.
* @param {string} [props.className] CSS Class name for the component.
* @param {number} [props.headingLevel] Heading level (h1, h2 etc)
* @param {boolean} [props.productLink] Whether or not to display a link to the product page.
* @param {boolean} [props.showProductLink] Whether or not to display a link to the product page.
* @param {string} [props.align] Title alignment.
* @param {string} [props.color] Title color name.
* @param {string} [props.customColor] Custom title color value.
@ -37,7 +37,7 @@ import './style.scss';
export const Block = ( {
className,
headingLevel = 2,
productLink = true,
showProductLink = true,
align,
color,
customColor,
@ -98,10 +98,10 @@ export const Block = ( {
className={ classnames( {
[ titleClasses ]: isFeaturePluginBuild(),
} ) }
disabled={ ! productLink }
disabled={ ! showProductLink }
name={ product.name }
permalink={ product.permalink }
rel={ productLink ? 'nofollow' : null }
rel={ showProductLink ? 'nofollow' : null }
style={ gatedStyledText( {
color: customColor,
fontSize: customFontSize,
@ -119,7 +119,7 @@ export const Block = ( {
Block.propTypes = {
className: PropTypes.string,
headingLevel: PropTypes.number,
productLink: PropTypes.bool,
showProductLink: PropTypes.bool,
align: PropTypes.string,
color: PropTypes.string,
customColor: PropTypes.string,

View File

@ -31,7 +31,7 @@ const TitleEdit = ( {
attributes,
setAttributes,
} ) => {
const { headingLevel, productLink, align } = attributes;
const { headingLevel, showProductLink, align } = attributes;
return (
<>
<BlockControls>
@ -66,10 +66,10 @@ const TitleEdit = ( {
'Links the image to the single product listing.',
'woo-gutenberg-products-block'
) }
checked={ productLink }
checked={ showProductLink }
onChange={ () =>
setAttributes( {
productLink: ! productLink,
showProductLink: ! showProductLink,
} )
}
/>