Skip to content
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

Comments Blocks Warnings: Add buttons to resolve warnings #40614

Open
ockham opened this issue Apr 26, 2022 · 2 comments
Open

Comments Blocks Warnings: Add buttons to resolve warnings #40614

ockham opened this issue Apr 26, 2022 · 2 comments
Labels
[Block] Comments Affects the Comments Block - formerly known as Comments Query Loop [Type] Enhancement A suggestion for improvement.

Comments

@ockham
Copy link
Contributor

ockham commented Apr 26, 2022

Based on #40563 (comment) and #40563 (comment).

The Comments Query Loop block (soon to be renamed to just "Comments") and its child blocks currently use the <Warning /> component in a few places, in order to indicate that what the user will see on the frontend might not match their expectations, e.g. if comments are not enabled for the entire site, the current post (or page), or the corresponding post type.

image

While it's debatable whether or not the <Warning /> component is the best fit here, that's for another issue.

However, regardless of how we preset this information to the user, it'd be better if we actually gave them the agency to change whatever is preventing the Comments Query Loop (or part of it) to show up on the frontend. I.e. if comments are disabled for a post or page with a certain ID, we could add a button to enable them; or if they're disabled for an entire post type, we could add a button that either enables them right away, or at least takes them to the relevant settings screen.

(It's much less frustrating for a user if they're presented with a problem and a potential solution, rather than just the problem, and they're on their own to figure out the solution.)

FWIW, the <Warning /> components supports adding primary and secondary actions: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/warning/README.md

As seen in BlockInvalidWarning:

warning-block-invalid

As seen in withMultipleValidation:

warning-block-use-once

Where possible, we should add one primary button per warning that will immediately change the setting such that the corresponding part of the block will be displayed on the frontend, and make the warning go away. If that's not possible, let's add a secondary button that takes the user to the relevant settings page where they can change that setting.

I'll post a live comment below with a list of Warnings that need those changes.

@ockham ockham added the [Block] Comments Affects the Comments Block - formerly known as Comments Query Loop label Apr 26, 2022
@ockham
Copy link
Contributor Author

ockham commented Apr 26, 2022

Live comment to track Warning that need action buttons.

Comments Pagination:

<Warning>
{ __(
'Comments Pagination block: paging comments is disabled in the Discussion Settings'
) }
</Warning>

Post Comments Form:

warning = sprintf(
/* translators: 1: Post type (i.e. "post", "page") */
__(
'Post Comments Form block: Comments on this %s are not allowed.'
),
postType
);

warning = sprintf(
/* translators: 1: Post type (i.e. "post", "page") */
__(
'Post Comments Form block: Comments for this post type (%s) are not enabled.'
),
postType
);

warning = __(
'Post Comments Form block: Comments are not enabled.'
);

Post Comments:
(Note that this block shares warnings with Post Comments Form. We might want to try de-duplicating the relevant code.)

warning = sprintf(
/* translators: 1: Post type (i.e. "post", "page") */
__(
'Post Comments block: Comments to this %s are not allowed.'
),
postType
);

warning = sprintf(
/* translators: 1: Post type (i.e. "post", "page") */
__(
'Post Comments block: Comments for this post type (%s) are not enabled.'
),
postType
);

warning = __( 'Post Comments block: Comments are not enabled.' );

@ockham
Copy link
Contributor Author

ockham commented Apr 26, 2022

Note that we might avoid most of these changes if we decide to implement this proposal: #40617 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comments Affects the Comments Block - formerly known as Comments Query Loop [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants