From 352100308db0ac9b08a1efd59672c9de4c75be11 Mon Sep 17 00:00:00 2001 From: Zebulan Stanphill Date: Fri, 2 Nov 2018 09:42:45 -0500 Subject: [PATCH] Latest Comments block: use align supports flag + code cleanup --- .../block-library/src/latest-comments/edit.js | 22 +++---------------- .../src/latest-comments/index.js | 13 ++--------- .../src/latest-comments/index.php | 8 +++---- .../e2e-tests/fixtures/blocks/core__rss.html | 2 +- .../fixtures/blocks/core__rss.serialized.html | 2 +- .../blocks/core__search__custom-text.html | 2 +- .../core__search__custom-text.serialized.html | 2 +- .../core__tag-cloud__showTagCounts.html | 2 +- ...__tag-cloud__showTagCounts.serialized.html | 2 +- .../full-content/server-registered.json | 2 +- 10 files changed, 16 insertions(+), 41 deletions(-) diff --git a/packages/block-library/src/latest-comments/edit.js b/packages/block-library/src/latest-comments/edit.js index 0f44f30b8ac5ad..1bc21e552939e0 100644 --- a/packages/block-library/src/latest-comments/edit.js +++ b/packages/block-library/src/latest-comments/edit.js @@ -1,20 +1,16 @@ /** * WordPress dependencies */ -import { Component, Fragment } from '@wordpress/element'; +import { InspectorControls } from '@wordpress/block-editor'; import { Disabled, PanelBody, RangeControl, ToggleControl, } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; -import { - InspectorControls, - BlockAlignmentToolbar, - BlockControls, -} from '@wordpress/block-editor'; import { ServerSideRender } from '@wordpress/editor'; +import { Component, Fragment } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; /** * Minimum number of comments a user can show using this block. @@ -33,7 +29,6 @@ class LatestComments extends Component { constructor() { super( ...arguments ); - this.setAlignment = this.setAlignment.bind( this ); this.setCommentsToShow = this.setCommentsToShow.bind( this ); // Create toggles for each attribute; we create them here rather than @@ -53,17 +48,12 @@ class LatestComments extends Component { }; } - setAlignment( align ) { - this.props.setAttributes( { align } ); - } - setCommentsToShow( commentsToShow ) { this.props.setAttributes( { commentsToShow } ); } render() { const { - align, commentsToShow, displayAvatar, displayDate, @@ -72,12 +62,6 @@ class LatestComments extends Component { return ( - - - array( + 'align' => array( + 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), + ), 'className' => array( 'type' => 'string', ), @@ -175,10 +179,6 @@ function render_block_core_latest_comments( $attributes = array() ) { 'type' => 'boolean', 'default' => true, ), - 'align' => array( - 'type' => 'string', - 'enum' => array( 'center', 'left', 'right', 'wide', 'full', '' ), - ), ), 'render_callback' => 'render_block_core_latest_comments', ) diff --git a/packages/e2e-tests/fixtures/blocks/core__rss.html b/packages/e2e-tests/fixtures/blocks/core__rss.html index 69b41ce041862b..5a69011df61e03 100644 --- a/packages/e2e-tests/fixtures/blocks/core__rss.html +++ b/packages/e2e-tests/fixtures/blocks/core__rss.html @@ -1 +1 @@ - + diff --git a/packages/e2e-tests/fixtures/blocks/core__rss.serialized.html b/packages/e2e-tests/fixtures/blocks/core__rss.serialized.html index 69b41ce041862b..bcb7f0c0f760bb 100644 --- a/packages/e2e-tests/fixtures/blocks/core__rss.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__rss.serialized.html @@ -1 +1 @@ - + diff --git a/packages/e2e-tests/fixtures/blocks/core__search__custom-text.html b/packages/e2e-tests/fixtures/blocks/core__search__custom-text.html index bb6e6a56c9a339..de15a05a22774b 100644 --- a/packages/e2e-tests/fixtures/blocks/core__search__custom-text.html +++ b/packages/e2e-tests/fixtures/blocks/core__search__custom-text.html @@ -1 +1 @@ - + diff --git a/packages/e2e-tests/fixtures/blocks/core__search__custom-text.serialized.html b/packages/e2e-tests/fixtures/blocks/core__search__custom-text.serialized.html index bb6e6a56c9a339..de15a05a22774b 100644 --- a/packages/e2e-tests/fixtures/blocks/core__search__custom-text.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__search__custom-text.serialized.html @@ -1 +1 @@ - + diff --git a/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.html b/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.html index 3f22f21fc6cfe9..c58be50bf6a2d5 100644 --- a/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.html +++ b/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.serialized.html b/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.serialized.html index 9711e8c6ad6c0b..8a0a951d49efb3 100644 --- a/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__tag-cloud__showTagCounts.serialized.html @@ -1 +1 @@ - + diff --git a/test/integration/full-content/server-registered.json b/test/integration/full-content/server-registered.json index eeae11cb99e9ce..bdb2ffdd1fa5dc 100644 --- a/test/integration/full-content/server-registered.json +++ b/test/integration/full-content/server-registered.json @@ -1 +1 @@ -{"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/latest-comments":{"attributes":{"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true},"align":{"type":"string","enum":["center","left","right","wide","full",""]}}},"core\/archives":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/calendar":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"month":{"type":"integer"},"year":{"type":"integer"}}},"core\/latest-posts":{"attributes":{"categories":{"type":"string"},"className":{"type":"string"},"postsToShow":{"type":"number","default":5},"displayPostDate":{"type":"boolean","default":false},"postLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":3},"align":{"type":"string"},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"}}},"core\/rss":{"attributes":{"columns":{"type":"number","default":2},"blockLayout":{"type":"string","default":"list"},"feedURL":{"type":"string","default":""},"itemsToShow":{"type":"number","default":5},"displayExcerpt":{"type":"boolean","default":false},"displayAuthor":{"type":"boolean","default":false},"displayDate":{"type":"boolean","default":false},"excerptLength":{"type":"number","default":55}}},"core\/search":{"attributes":{"label":{"type":"string","default":"Search"},"placeholder":{"type":"string","default":""},"buttonText":{"type":"string","default":"Search"}}},"core\/tag-cloud":{"attributes":{"taxonomy":{"type":"string","default":"post_tag"},"className":{"type":"string"},"showTagCounts":{"type":"boolean","default":false},"align":{"type":"string"}}}} \ No newline at end of file +{"core\/archives":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/calendar":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"month":{"type":"integer"},"year":{"type":"integer"}}},"core\/latest-comments":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true}}},"core\/latest-posts":{"attributes":{"categories":{"type":"string"},"className":{"type":"string"},"postsToShow":{"type":"number","default":5},"displayPostDate":{"type":"boolean","default":false},"postLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":3},"align":{"type":"string"},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"}}},"core\/rss":{"attributes":{"blockLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":2},"displayAuthor":{"type":"boolean","default":false},"displayDate":{"type":"boolean","default":false},"displayExcerpt":{"type":"boolean","default":false},"excerptLength":{"type":"number","default":55},"feedURL":{"type":"string","default":""},"itemsToShow":{"type":"number","default":5}}},"core\/search":{"attributes":{"buttonText":{"type":"string","default":"Search"},"label":{"type":"string","default":"Search"},"placeholder":{"type":"string","default":""}}},"core\/tag-cloud":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"showTagCounts":{"type":"boolean","default":false},"taxonomy":{"type":"string","default":"post_tag"}}}}