/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
import { BlockControls } from '@wordpress/block-editor';
import { getAdminLink, getSetting } from '@woocommerce/settings';
import {
Notice,
ToggleControl,
ToolbarGroup,
RangeControl,
SelectControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControl as ToggleGroupControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
export const getBlockControls = ( editMode, setAttributes, buttonTitle ) => (
setAttributes( { editMode: ! editMode } ),
isActive: editMode,
},
] }
/>
);
export const getSharedReviewContentControls = ( attributes, setAttributes ) => {
const showAvatars = getSetting( 'showAvatars', true );
const reviewRatingsEnabled = getSetting( 'reviewRatingsEnabled', true );
return (
<>
setAttributes( {
showReviewRating: ! attributes.showReviewRating,
} )
}
/>
{ attributes.showReviewRating && ! reviewRatingsEnabled && (
{ createInterpolateElement(
__(
'Product rating is disabled in your store settings.',
'woocommerce'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
),
}
) }
) }
setAttributes( {
showReviewerName: ! attributes.showReviewerName,
} )
}
/>
setAttributes( {
showReviewImage: ! attributes.showReviewImage,
} )
}
/>
setAttributes( {
showReviewDate: ! attributes.showReviewDate,
} )
}
/>
setAttributes( {
showReviewContent: ! attributes.showReviewContent,
} )
}
/>
{ attributes.showReviewImage && (
<>
setAttributes( { imageType: value } )
}
>
{ attributes.imageType === 'reviewer' && ! showAvatars && (
{ createInterpolateElement(
__(
'Reviewer photo is disabled in your site settings.',
'woocommerce'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
),
}
) }
) }
>
) }
>
);
};
export const getSharedReviewListControls = ( attributes, setAttributes ) => {
const minPerPage = 1;
const maxPerPage = 20;
return (
<>
setAttributes( { showOrderby: ! attributes.showOrderby } )
}
/>
setAttributes( { orderby } ) }
/>
setAttributes( { reviewsOnPageLoad } )
}
max={ maxPerPage }
min={ minPerPage }
/>
setAttributes( { showLoadMore: ! attributes.showLoadMore } )
}
/>
{ attributes.showLoadMore && (
setAttributes( { reviewsOnLoadMore } )
}
max={ maxPerPage }
min={ minPerPage }
/>
) }
>
);
};