2019-01-10 18:16:37 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-02-26 05:31:25 +00:00
|
|
|
import { createBlock, registerBlockType } from '@wordpress/blocks';
|
|
|
|
import { without } from 'lodash';
|
2019-01-10 18:16:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import Block from './block';
|
2019-05-16 13:03:11 +00:00
|
|
|
import { deprecatedConvertToShortcode } from '../../utils/deprecations';
|
2019-01-10 18:16:37 +00:00
|
|
|
import { IconNewReleases } from '../../components/icons';
|
2019-05-16 13:03:11 +00:00
|
|
|
import sharedAttributes, {
|
|
|
|
sharedAttributeBlockTypes,
|
|
|
|
} from '../../utils/shared-attributes';
|
2019-01-10 18:16:37 +00:00
|
|
|
|
|
|
|
registerBlockType( 'woocommerce/product-new', {
|
|
|
|
title: __( 'Newest Products', 'woo-gutenberg-products-block' ),
|
2019-05-28 10:18:07 +00:00
|
|
|
icon: {
|
|
|
|
src: <IconNewReleases />,
|
|
|
|
foreground: '#96588a',
|
|
|
|
},
|
2019-01-10 18:16:37 +00:00
|
|
|
category: 'woocommerce',
|
|
|
|
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
|
|
|
description: __(
|
|
|
|
'Display a grid of your newest products.',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
),
|
|
|
|
supports: {
|
|
|
|
align: [ 'wide', 'full' ],
|
2019-05-16 13:03:11 +00:00
|
|
|
html: false,
|
2019-01-10 18:16:37 +00:00
|
|
|
},
|
|
|
|
attributes: {
|
|
|
|
...sharedAttributes,
|
|
|
|
},
|
2019-02-26 05:31:25 +00:00
|
|
|
transforms: {
|
|
|
|
from: [
|
|
|
|
{
|
|
|
|
type: 'block',
|
|
|
|
blocks: without( sharedAttributeBlockTypes, 'woocommerce/product-new' ),
|
2019-05-16 13:03:11 +00:00
|
|
|
transform: ( attributes ) =>
|
|
|
|
createBlock( 'woocommerce/product-new', attributes ),
|
2019-02-26 05:31:25 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-01-10 18:16:37 +00:00
|
|
|
|
2019-05-16 13:03:11 +00:00
|
|
|
deprecated: [
|
|
|
|
{
|
|
|
|
// Deprecate shortcode save method in favor of dynamic rendering.
|
|
|
|
attributes: sharedAttributes,
|
|
|
|
save: deprecatedConvertToShortcode( 'woocommerce/product-new' ),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2019-01-10 18:16:37 +00:00
|
|
|
/**
|
|
|
|
* Renders and manages the block.
|
|
|
|
*/
|
|
|
|
edit( props ) {
|
|
|
|
return <Block { ...props } />;
|
|
|
|
},
|
|
|
|
|
2019-05-16 13:03:11 +00:00
|
|
|
save() {
|
|
|
|
return null;
|
2019-01-10 18:16:37 +00:00
|
|
|
},
|
|
|
|
} );
|