New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Site Editor: Add new Comments Query Loop block #35231
Site Editor: Add new Comments Query Loop block #35231
Conversation
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @michalczaplinski! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
1f39143
to
16ee987
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query Loop is quite a big block with several functionalities added over time. It took months to develop it. I guess the best approach would be to start simple and code only a small subset of features. @ntsekouras might have the best recommendation here. Definitely, a good start would be to have a Comments Query Loop and Comment template block with some enforced layout for start with simple controls that change some common query attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments @gziolo! I've reduced the scope of this PR to remove the variations, and CommentsQuerySetup and kept just the 3 attributes: perPage, pages and offset for now.
I would appreciate some more eyes on this PR - perhaps @ntsekouras also could take a look to let me know what else you would like to see here in order for this PR to land?
|
No idea why e2e tests are failing but it seems unrelated...? 🤔 |
|
I think this block should have e2e tests similar to ones for the |
|
Thanks for working on this @michalczaplinski - this is awesome! I'll take a closer look later to review properly but for now I was just wondering if it makes sense to revisit the design/position of the controls. On one hand it would be good to be consistent between similar blocks, on the other hand if the attributes are fewer, we could move them to the --cc @jameskoster @jasmussen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this Michal!
This is probably a chance for us to enforce all the new stuff (like layout) and handle better some challenges that we faced with Query Loop. In general I think more things to discuss will be exposed when you start the implementation of Comments Loop client and server side.
I would be in favour of maintaining consistency across the query blocks for now, then addressing the issues of the current UX subsequently and applying any fixes to all blocks at the same time. |
1bca6cc
to
8fe3842
Compare
|
We need to sort out the execution plan before we land this PR. At the moment there are two existing blocks:
They are going to be replaced with:
Now the question is how we approach that:
Do we have other options available that I missed? Is it something that you already know how to address? /cc @mtias and @youknowriad. |
|
Potentially, we could keep the old block only in the plugin and only backport one of them to Core. For Post, we did keep both blocks (latest posts and Query Loop). |
I forgot about Latest Comments. It is there as well:
At the moment, we have the experimental Post Comments block that is very simple and seems to be a blocky version of
There is also an existing experimental Post Comment block that requires providing the comment id by the user in the editor: gutenberg/packages/block-library/src/post-comment/edit.js Lines 42 to 47 in 39be23f
This PR proposes a Comments Query Loop block that is a more advanced version of Post Comments. The other block Comments Template is very similar to the existing Post Comment block. |
df17429
to
0a97105
Compare
|
I'd like to understand what else would be needed in order to land this PR? I only have this on my todo list but there's probably more that I'm missing:
@gziolo @ntsekouras would you like to give it another look? |
f6c69a4
to
0264d67
Compare
Yeah, I was also thinking of |
|
My current concern is how to handle the nested comments. It seems to me that that the best way would be to convert the list of comments passed in gutenberg/packages/block-library/src/comment-template/edit.js Lines 47 to 52 in 1668cd3
to a format that includes an array of [
{ commentId: 1, children: [] },
{
commentId: 2, children: [
{ commentId: 3, children: [] },
{ commentId: 4, children: [
{ commentId: 5, children: [] }
] },
],
},
{ commentId: 3, children: [] },
];You get the idea. Probably would need to split the ` into 2 components. The first one that contains the logic and the second one that "just" renders the content given some props. Then, that second component call itself recursively (if the comment has children) so that I can represent each level of comment nesting. |
I think the first iteration could skip this and after landing, create a quick follow up for the nested handling. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work. I think it's in good shape already so we can land it to start testing in the Gutenberg plugin. We still have almost a week before the 11.9 RC1 happens to implement more features necessary for the Comments Query Loop block. The biggest benefit of landing this PR early is that we can start deprecating the Post Comment block in favor of the Comment Template block.
|
Great work! 🚀 |
* Add most basic skeleton for Comments Query Loop block * Add a stub for core/comments-template block * Clean up the implementation of core/comments-query * Move query-content & query-setup to separate files * Remove the post-comments-query block * Refactor getFirstQueryClientIdFromBlocks to utils.js * Add the variations of the comments query block * Remove unnecesary parameters from block.json * Add a proper query-placeholder component * Add instruction about where to add new integration test fixtures * Fix typo in comments-template block.json * Add extra space in error message in full-content.test.js * Add integration test fixtures for new blocks * Add postComments icon to core/comments-query block * Add offset back to comments-query block * Delete files that are out of scope for this PR * Remove variations from comments-query * Refactor edit component of comments-query * Remove unused utils * Comments Query: Refactor edit and toolbar * Comments Query: Update values of perPage, page & offset attributes * Add a CSS class to the QueryToolbar * CommentsQuery: Update function name * Remove order and orderBy from block.json * Comments Template: Stringify the query * Update the integration test fixture * Update icon for comments-template * Remove unnecessary CSS * Comments Query: Remove the unnecessary "div" * Comments Query: Remove `displayLayout` from block.json * Comments Query: remove _experimentalLayout * Comments Query: Remove unused queryContext * Comments Query: Remove inherit & pages attribute * Comments Query: Refactor the attributes * Comments Query: Update the offset label * Comments Query: Simplify passing of setAttributes * Comments Query: update the snapshot * Update lib/blocks.php Update the naming Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> * Comments Query rename: - comments-template -> comment-template - comments-query -> comments-query-loop * Comment Template block: Add index.php * Comments Query: Remove offset attribute * Comments Query: Remove outdated fixtures * Comments Query: Add @wordpress/editor to deps * Comments Query: Add displaying basic comments content * Comments Query: Remove more old fixtures * Comments Query: Add a very basic server-side render * Comments Query: Simplify query for more comments * Comments Query: Reformat comment-template.php * Comments Query: Use the postId from the block context * Comments Query: Remove redundant Fragment in toolbar * Comments Query: Remove unnecessary layout stuff * Comments Query: Remove .php file and list block.json * Comments Query: Get postId from context on server * Comments Query: Pass queryPerPage to getEntityRecords * Comments Query: Pass queryPerPage to get_approved_comments * Fix block names array that I messed up while rebasing * Update packages/block-library/src/comment-template/edit.js Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
Description
Fixes #34996
Fixes #35000
block-library.core/comment-templateblock which is kept to the bare minimum to make the comments query work.How has this been tested?
Tested manually:
/commentComment Query LoopblockperPage,pagesoroffsetattributes in the toolbar and observe them change in the UIEnvironment details
wp-envdefaultwp-envdefault14.17.66.14.15Screenshots
Types of changes
Checklist:
*.native.jsfiles for terms that need renaming or removal).