2019-08-23 14:48:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-05-12 20:31:49 +00:00
|
|
|
import { InspectorControls } from '@wordpress/block-editor';
|
2019-08-23 14:48:48 +00:00
|
|
|
import { PanelBody, ToggleControl } from '@wordpress/components';
|
2022-02-01 16:54:38 +00:00
|
|
|
import { Icon, postComments } from '@wordpress/icons';
|
2019-08-23 14:48:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-11-27 11:08:17 +00:00
|
|
|
import EditorContainerBlock from '../editor-container-block';
|
2023-06-06 12:46:49 +00:00
|
|
|
import NoReviewsPlaceholder from './no-reviews-placeholder';
|
2019-09-05 15:09:31 +00:00
|
|
|
import {
|
|
|
|
getSharedReviewContentControls,
|
|
|
|
getSharedReviewListControls,
|
|
|
|
} from '../edit-utils.js';
|
2023-06-06 12:46:49 +00:00
|
|
|
import type { AllReviewsEditorProps } from './types';
|
2019-08-23 14:48:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component to handle edit mode of "All Reviews".
|
2020-09-20 23:54:08 +00:00
|
|
|
*
|
2022-04-08 13:47:19 +00:00
|
|
|
* @param {Object} props Incoming props for the component.
|
|
|
|
* @param {Object} props.attributes Incoming block attributes.
|
2020-09-20 23:54:08 +00:00
|
|
|
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
2019-08-23 14:48:48 +00:00
|
|
|
*/
|
2023-06-06 12:46:49 +00:00
|
|
|
const AllReviewsEditor = ( {
|
|
|
|
attributes,
|
|
|
|
setAttributes,
|
|
|
|
}: AllReviewsEditorProps ) => {
|
2019-08-23 14:48:48 +00:00
|
|
|
const getInspectorControls = () => {
|
|
|
|
return (
|
|
|
|
<InspectorControls key="inspector">
|
2019-09-09 10:52:48 +00:00
|
|
|
<PanelBody
|
2023-12-12 22:12:36 +00:00
|
|
|
title={ __( 'Content', 'woocommerce' ) }
|
2019-09-09 10:52:48 +00:00
|
|
|
>
|
2019-08-23 14:48:48 +00:00
|
|
|
<ToggleControl
|
2019-09-09 10:52:48 +00:00
|
|
|
label={ __(
|
|
|
|
'Product name',
|
2023-12-12 22:12:36 +00:00
|
|
|
'woocommerce'
|
2019-09-09 10:52:48 +00:00
|
|
|
) }
|
2019-08-23 14:48:48 +00:00
|
|
|
checked={ attributes.showProductName }
|
2019-09-05 15:09:31 +00:00
|
|
|
onChange={ () =>
|
|
|
|
setAttributes( {
|
|
|
|
showProductName: ! attributes.showProductName,
|
|
|
|
} )
|
|
|
|
}
|
2019-08-23 14:48:48 +00:00
|
|
|
/>
|
2019-09-09 10:52:48 +00:00
|
|
|
{ getSharedReviewContentControls(
|
|
|
|
attributes,
|
|
|
|
setAttributes
|
|
|
|
) }
|
2019-08-23 14:48:48 +00:00
|
|
|
</PanelBody>
|
2019-09-05 15:09:31 +00:00
|
|
|
<PanelBody
|
2019-09-09 10:52:48 +00:00
|
|
|
title={ __(
|
|
|
|
'List Settings',
|
2023-12-12 22:12:36 +00:00
|
|
|
'woocommerce'
|
2019-09-09 10:52:48 +00:00
|
|
|
) }
|
2019-09-05 15:09:31 +00:00
|
|
|
>
|
2019-08-23 14:48:48 +00:00
|
|
|
{ getSharedReviewListControls( attributes, setAttributes ) }
|
|
|
|
</PanelBody>
|
|
|
|
</InspectorControls>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2020-12-14 11:54:34 +00:00
|
|
|
<>
|
2019-08-23 14:48:48 +00:00
|
|
|
{ getInspectorControls() }
|
|
|
|
<EditorContainerBlock
|
|
|
|
attributes={ attributes }
|
2020-01-31 18:20:33 +00:00
|
|
|
icon={
|
|
|
|
<Icon
|
2022-02-01 16:54:38 +00:00
|
|
|
icon={ postComments }
|
2020-01-31 18:20:33 +00:00
|
|
|
className="block-editor-block-icon"
|
|
|
|
/>
|
|
|
|
}
|
2023-12-12 22:12:36 +00:00
|
|
|
name={ __( 'All Reviews', 'woocommerce' ) }
|
2023-06-19 10:09:54 +00:00
|
|
|
noReviewsPlaceholder={ NoReviewsPlaceholder }
|
2019-08-23 14:48:48 +00:00
|
|
|
/>
|
2020-12-14 11:54:34 +00:00
|
|
|
</>
|
2019-08-23 14:48:48 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AllReviewsEditor;
|