2019-08-23 14:48:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { registerBlockType } from '@wordpress/blocks';
|
2019-11-08 16:30:11 +00:00
|
|
|
import { IconAllReviews } from '@woocommerce/block-components/icons';
|
2019-08-23 14:48:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import '../editor.scss';
|
|
|
|
import Editor from './edit';
|
|
|
|
import sharedAttributes from '../attributes';
|
|
|
|
import save from '../save.js';
|
2019-10-22 14:13:14 +00:00
|
|
|
import { example } from '../example';
|
2019-08-23 14:48:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register and run the "All Reviews" block.
|
2019-12-11 14:58:49 +00:00
|
|
|
* This block lists all product reviews.
|
2019-08-23 14:48:48 +00:00
|
|
|
*/
|
|
|
|
registerBlockType( 'woocommerce/all-reviews', {
|
|
|
|
title: __( 'All Reviews', 'woo-gutenberg-products-block' ),
|
|
|
|
icon: {
|
2019-09-06 16:03:41 +00:00
|
|
|
src: <IconAllReviews />,
|
2019-08-23 14:48:48 +00:00
|
|
|
foreground: '#96588a',
|
|
|
|
},
|
|
|
|
category: 'woocommerce',
|
|
|
|
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
|
|
|
description: __(
|
|
|
|
'Shows a list of all product reviews.',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
),
|
2019-12-17 08:38:31 +00:00
|
|
|
supports: {
|
|
|
|
html: false,
|
|
|
|
},
|
2019-10-22 14:13:14 +00:00
|
|
|
example: {
|
|
|
|
...example,
|
|
|
|
attributes: {
|
|
|
|
...example.attributes,
|
|
|
|
showProductName: true,
|
|
|
|
},
|
|
|
|
},
|
2019-08-23 14:48:48 +00:00
|
|
|
attributes: {
|
|
|
|
...sharedAttributes,
|
|
|
|
/**
|
2019-09-05 15:09:31 +00:00
|
|
|
* Show the product name.
|
|
|
|
*/
|
2019-08-23 14:48:48 +00:00
|
|
|
showProductName: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders and manages the block.
|
2019-12-10 17:17:46 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props Props to pass to block.
|
2019-08-23 14:48:48 +00:00
|
|
|
*/
|
|
|
|
edit( props ) {
|
|
|
|
return <Editor { ...props } />;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the props to post content.
|
|
|
|
*/
|
|
|
|
save,
|
|
|
|
} );
|