import { __, sprintf } from '@wordpress/i18n'; import { Fragment, RawHTML } from '@wordpress/element'; import { escapeHTML } from '@wordpress/escape-html'; import { Notice, ToggleControl, Toolbar, RangeControl, SelectControl, } from '@wordpress/components'; import { BlockControls } from '@wordpress/editor'; import { getAdminLink } from '@woocommerce/navigation'; import { ENABLE_REVIEW_RATING, SHOW_AVATARS, } from '@woocommerce/block-settings'; /** * Internal dependencies */ import ToggleButtonControl from '@woocommerce/block-components/toggle-button-control'; export const getBlockControls = ( editMode, setAttributes ) => ( setAttributes( { editMode: ! editMode } ), isActive: editMode, }, ] } /> ); export const getSharedReviewContentControls = ( attributes, setAttributes ) => { return ( setAttributes( { showReviewRating: ! attributes.showReviewRating, } ) } /> { attributes.showReviewRating && ! ENABLE_REVIEW_RATING && ( { sprintf( escapeHTML( /* translators: A notice that links to WooCommerce settings. */ __( 'Product rating is disabled in your %sstore settings%s.', 'woo-gutenberg-products-block' ) ), ``, '' ) } ) } setAttributes( { showReviewerName: ! attributes.showReviewerName, } ) } /> setAttributes( { showReviewImage: ! attributes.showReviewImage, } ) } /> setAttributes( { showReviewDate: ! attributes.showReviewDate, } ) } /> setAttributes( { showReviewContent: ! attributes.showReviewContent, } ) } /> { attributes.showReviewImage && ( setAttributes( { imageType: value } ) } /> { attributes.imageType === 'reviewer' && ! SHOW_AVATARS && ( { sprintf( escapeHTML( /* translators: A notice that links to WordPress settings. */ __( 'Reviewer photo is disabled in your %ssite settings%s.', 'woo-gutenberg-products-block' ) ), ``, '' ) } ) } ) } ); }; 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 } /> ) } ); };