From d8eb4c5f3c7b505c452b62ec647f8401abb8b0a5 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 3 May 2022 11:15:10 +0200 Subject: [PATCH] Comments Query Loop block: Rename to Comments (but keep ID) (#40763) Co-authored-by: Carlos Bravo Co-authored-by: Michal Czaplinski --- .github/CODEOWNERS | 2 +- docs/reference-guides/core-blocks.md | 22 +++++++++---------- lib/blocks.php | 2 +- .../block.json | 2 +- .../{comments-query-loop => comments}/edit.js | 2 +- .../edit/comments-inspector-controls.js | 0 .../editor.scss | 0 .../index.js | 0 .../{comments-query-loop => comments}/save.js | 4 +--- packages/block-library/src/editor.scss | 2 +- packages/block-library/src/index.js | 5 ++--- .../block-library/src/post-comment/block.json | 2 +- .../src/post-comments/block.json | 2 +- .../block-library/src/post-comments/edit.js | 2 +- ...omments-query.test.js => comments.test.js} | 8 +++---- 15 files changed, 26 insertions(+), 29 deletions(-) rename packages/block-library/src/{comments-query-loop => comments}/block.json (94%) rename packages/block-library/src/{comments-query-loop => comments}/edit.js (94%) rename packages/block-library/src/{comments-query-loop => comments}/edit/comments-inspector-controls.js (100%) rename packages/block-library/src/{comments-query-loop => comments}/editor.scss (100%) rename packages/block-library/src/{comments-query-loop => comments}/index.js (100%) rename packages/block-library/src/{comments-query-loop => comments}/save.js (69%) rename packages/e2e-tests/specs/editor/blocks/{comments-query.test.js => comments.test.js} (95%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9cabbc4936894..f3d23c778bd3e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -19,7 +19,7 @@ /packages/block-library/src/navigation-submenu @tellthemachines /packages/block-library/src/page-list @tellthemachines /packages/block-library/src/comment-template @michalczaplinski -/packages/block-library/src/comments-query-loop @michalczaplinski +/packages/block-library/src/comments @michalczaplinski # Duotone /lib/block-supports/duotone.php @ajlende diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 260212e376174..045bfc7b401eb 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -170,6 +170,15 @@ Contains the block elements used to display a comment, like the title, date, aut - **Supports:** align, ~~html~~, ~~reusable~~ - **Attributes:** +## Comments + +An advanced block that allows displaying post comments using different visual configurations. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/comments)) + +- **Name:** core/comments-query-loop +- **Category:** theme +- **Supports:** align (full, wide), color (background, gradients, link, text), ~~html~~ +- **Attributes:** tagName + ## Comments Pagination Displays a paginated navigation to next/previous set of comments, when applicable. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/comments-pagination)) @@ -206,15 +215,6 @@ Displays the previous comment's page link. ([Source](https://github.com/WordPres - **Supports:** color (background, gradients, ~~text~~), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~ - **Attributes:** label -## Comments Query Loop - -An advanced block that allows displaying post comments using different visual configurations. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/comments-query-loop)) - -- **Name:** core/comments-query-loop -- **Category:** theme -- **Supports:** align (full, wide), color (background, gradients, link, text), ~~html~~ -- **Attributes:** tagName - ## Comments Title Displays a title with the number of comments ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/comments-title)) @@ -478,7 +478,7 @@ The author name. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/pac ## Post Comment (deprecated) -This block is deprecated. Please use the Comments Query Loop block instead. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-comment)) +This block is deprecated. Please use the Comments block instead. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-comment)) - **Name:** core/post-comment - **Category:** theme @@ -487,7 +487,7 @@ This block is deprecated. Please use the Comments Query Loop block instead. ([So ## Post Comments (deprecated) -This block is deprecated. Please use the Comments Query Loop block instead. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-comments)) +This block is deprecated. Please use the Comments block instead. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-comments)) - **Name:** core/post-comments - **Category:** theme diff --git a/lib/blocks.php b/lib/blocks.php index 816aceb777d88..10c052954ad7d 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -21,7 +21,7 @@ function gutenberg_reregister_core_block_types() { 'code', 'column', 'columns', - 'comments-query-loop', + 'comments', 'group', 'heading', 'html', diff --git a/packages/block-library/src/comments-query-loop/block.json b/packages/block-library/src/comments/block.json similarity index 94% rename from packages/block-library/src/comments-query-loop/block.json rename to packages/block-library/src/comments/block.json index fecbd7c92f6bb..fbdfdd253b278 100644 --- a/packages/block-library/src/comments-query-loop/block.json +++ b/packages/block-library/src/comments/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "core/comments-query-loop", - "title": "Comments Query Loop", + "title": "Comments", "category": "theme", "description": "An advanced block that allows displaying post comments using different visual configurations.", "textdomain": "default", diff --git a/packages/block-library/src/comments-query-loop/edit.js b/packages/block-library/src/comments/edit.js similarity index 94% rename from packages/block-library/src/comments-query-loop/edit.js rename to packages/block-library/src/comments/edit.js index fa7f048a285f0..14303fe7c5458 100644 --- a/packages/block-library/src/comments-query-loop/edit.js +++ b/packages/block-library/src/comments/edit.js @@ -68,7 +68,7 @@ const TEMPLATE = [ [ 'core/post-comments-form' ], ]; -export default function CommentsQueryLoopEdit( { attributes, setAttributes } ) { +export default function CommentsEdit( { attributes, setAttributes } ) { const { tagName: TagName } = attributes; const blockProps = useBlockProps(); diff --git a/packages/block-library/src/comments-query-loop/edit/comments-inspector-controls.js b/packages/block-library/src/comments/edit/comments-inspector-controls.js similarity index 100% rename from packages/block-library/src/comments-query-loop/edit/comments-inspector-controls.js rename to packages/block-library/src/comments/edit/comments-inspector-controls.js diff --git a/packages/block-library/src/comments-query-loop/editor.scss b/packages/block-library/src/comments/editor.scss similarity index 100% rename from packages/block-library/src/comments-query-loop/editor.scss rename to packages/block-library/src/comments/editor.scss diff --git a/packages/block-library/src/comments-query-loop/index.js b/packages/block-library/src/comments/index.js similarity index 100% rename from packages/block-library/src/comments-query-loop/index.js rename to packages/block-library/src/comments/index.js diff --git a/packages/block-library/src/comments-query-loop/save.js b/packages/block-library/src/comments/save.js similarity index 69% rename from packages/block-library/src/comments-query-loop/save.js rename to packages/block-library/src/comments/save.js index dc080f0f41344..47c774fc4b9bb 100644 --- a/packages/block-library/src/comments-query-loop/save.js +++ b/packages/block-library/src/comments/save.js @@ -3,9 +3,7 @@ */ import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; -export default function CommentsQueryLoopSave( { - attributes: { tagName: Tag }, -} ) { +export default function CommentsSave( { attributes: { tagName: Tag } } ) { return ( diff --git a/packages/block-library/src/editor.scss b/packages/block-library/src/editor.scss index 5e1b6d7afa733..ba031d6cbdeaa 100644 --- a/packages/block-library/src/editor.scss +++ b/packages/block-library/src/editor.scss @@ -6,8 +6,8 @@ @import "./buttons/editor.scss"; @import "./categories/editor.scss"; @import "./columns/editor.scss"; +@import "./comments/editor.scss"; @import "./comment-author-avatar/editor.scss"; -@import "./comments-query-loop/editor.scss"; @import "./comments-pagination/editor.scss"; @import "./comments-pagination-numbers/editor.scss"; @import "./comments-title/editor.scss"; diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 4db6f860b6cd3..b4ef7507f368a 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -23,6 +23,7 @@ import * as classic from './freeform'; import * as code from './code'; import * as column from './column'; import * as columns from './columns'; +import * as comments from './comments'; import * as commentAuthorAvatar from './comment-author-avatar'; import * as commentAuthorName from './comment-author-name'; import * as commentContent from './comment-content'; @@ -31,7 +32,6 @@ import * as commentEditLink from './comment-edit-link'; import * as commentReplyLink from './comment-reply-link'; import * as commentTemplate from './comment-template'; import * as commentsPaginationPrevious from './comments-pagination-previous'; -import * as commentsQueryLoop from './comments-query-loop'; import * as commentsPagination from './comments-pagination'; import * as commentsPaginationNext from './comments-pagination-next'; import * as commentsPaginationNumbers from './comments-pagination-numbers'; @@ -206,6 +206,7 @@ export const __experimentalGetCoreBlocks = () => [ queryPaginationPrevious, queryNoResults, readMore, + comments, commentAuthorName, commentContent, commentDate, @@ -213,12 +214,10 @@ export const __experimentalGetCoreBlocks = () => [ commentReplyLink, commentTemplate, commentsTitle, - commentsQueryLoop, commentsPagination, commentsPaginationNext, commentsPaginationNumbers, commentsPaginationPrevious, - postComments, postCommentsForm, homeLink, diff --git a/packages/block-library/src/post-comment/block.json b/packages/block-library/src/post-comment/block.json index 5210253b6447c..cc8311cfce547 100644 --- a/packages/block-library/src/post-comment/block.json +++ b/packages/block-library/src/post-comment/block.json @@ -4,7 +4,7 @@ "name": "core/post-comment", "title": "Post Comment (deprecated)", "category": "theme", - "description": "This block is deprecated. Please use the Comments Query Loop block instead.", + "description": "This block is deprecated. Please use the Comments block instead.", "textdomain": "default", "attributes": { "commentId": { diff --git a/packages/block-library/src/post-comments/block.json b/packages/block-library/src/post-comments/block.json index 6c5c4e16b8f74..dc719fff5d708 100644 --- a/packages/block-library/src/post-comments/block.json +++ b/packages/block-library/src/post-comments/block.json @@ -4,7 +4,7 @@ "name": "core/post-comments", "title": "Post Comments (deprecated)", "category": "theme", - "description": "This block is deprecated. Please use the Comments Query Loop block instead.", + "description": "This block is deprecated. Please use the Comments block instead.", "textdomain": "default", "attributes": { "textAlign": { diff --git a/packages/block-library/src/post-comments/edit.js b/packages/block-library/src/post-comments/edit.js index 248922da8b19e..723280d6416cf 100644 --- a/packages/block-library/src/post-comments/edit.js +++ b/packages/block-library/src/post-comments/edit.js @@ -53,7 +53,7 @@ export default function PostCommentsEdit( { ); let warning = __( - 'Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the "Comments Query Loop" block.' + 'Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the "Comments" block.' ); let showPlaceholder = true; diff --git a/packages/e2e-tests/specs/editor/blocks/comments-query.test.js b/packages/e2e-tests/specs/editor/blocks/comments.test.js similarity index 95% rename from packages/e2e-tests/specs/editor/blocks/comments-query.test.js rename to packages/e2e-tests/specs/editor/blocks/comments.test.js index 5f142aee56c75..19b4704b676fb 100644 --- a/packages/e2e-tests/specs/editor/blocks/comments-query.test.js +++ b/packages/e2e-tests/specs/editor/blocks/comments.test.js @@ -11,7 +11,7 @@ import { trashAllComments, } from '@wordpress/e2e-test-utils'; -describe( 'Comment Query Loop', () => { +describe( 'Comments', () => { let previousPageComments, previousCommentsPerPage, previousDefaultCommentsPage; @@ -27,12 +27,12 @@ describe( 'Comment Query Loop', () => { it( 'We show no results message if there are no comments', async () => { await trashAllComments(); await createNewPost(); - await insertBlock( 'Comments Query Loop' ); + await insertBlock( 'Comments' ); await page.waitForXPath( '//p[contains(text(), "No results found.")]' ); } ); it( 'Pagination links are working as expected', async () => { await createNewPost(); - await insertBlock( 'Comments Query Loop' ); + await insertBlock( 'Comments' ); await insertBlock( 'Post Comments Form' ); await publishPost(); // Visit the post that was just published. @@ -93,7 +93,7 @@ describe( 'Comment Query Loop', () => { it( 'Pagination links are not appearing if break comments is not enabled', async () => { await setOption( 'page_comments', '0' ); await createNewPost(); - await insertBlock( 'Comments Query Loop' ); + await insertBlock( 'Comments' ); await insertBlock( 'Post Comments Form' ); await publishPost(); // Visit the post that was just published.