/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { createInterpolateElement } from '@wordpress/element'; import { Notice, ToggleControl, ToolbarGroup, RangeControl, SelectControl, } from '@wordpress/components'; import { BlockControls } from '@wordpress/block-editor'; import { getAdminLink, getSetting } from '@woocommerce/settings'; import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control'; export const getBlockControls = ( editMode, setAttributes ) => ( 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.', 'woo-gutenberg-products-block' ), { 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.', 'woo-gutenberg-products-block' ), { 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 } /> ) } ); };