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

Fix/post statuses in query #1114

Merged
merged 9 commits into from
May 17, 2022
Merged

Fix/post statuses in query #1114

merged 9 commits into from
May 17, 2022

Conversation

adekbadek
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

Closes #38

A question – is checking for edit_others_posts capability a safe-enough check?

For design review – the label which marks non-published posts:

image

How to test the changes in this Pull Request:

  1. Insert Homepage Posts and Carousel blocks on a page
  2. Ensure you have some recent draft and scheduled posts
  3. For both, observe a new panel in block settings – "Post Statuses". Set different values for this attribute, and observe the post list is updated – non-published posts should be displayed with a label
  4. Publish and visit the page as the logged-in editor user – observe the posts are shown as in the editor
  5. Visit the page as a non-logged-in user – observe only published posts are displayed

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well as described, but I'm uncertain about the idea of introducing a block attribute to show or not show preview posts.

Would it be enough and easier to understand if we simply showed all draft, scheduled, and published posts with labels for each non-published status in the block editor? On the front-end side, we could show these non-published posts if the user is logged in, has the edit_others_posts capability, and there's a preview=true param on the URL (meaning the post is visited from the "Preview" functionality in the editor).

Or, to make it even simpler, just always show all of the draft, scheduled and published posts to logged-in users with the right capabilities. In this case if an editor really wants to see a post "as it would appear to readers" they can view it in an incognito window.

At the very least, I would advocate for a simpler interface: instead of being able to select Publish, Draft, and/or Scheduled, just make it a single toggle (off by default) to "Show draft and scheduled posts" with the same explanation instead. Right now I can't really think of a good use case for not showing published posts since these will always be shown to readers, right?

A question – is checking for edit_others_posts capability a safe-enough check?

If we want to further lock it down we could add a nonce verification, but I think checking the login state plus edit_others_posts is probably enough.

@adekbadek
Copy link
Member Author

Thank you for your input, but I think it's based on assumptions about publishing workflows that we cannot make.

Would it be enough and easier to understand if we simply showed all draft, scheduled, and published posts with labels for each non-published status in the block editor?

to make it even simpler, just always show all of the draft, scheduled and published posts to logged-in users

I imagine a WP user might:

  • Have a ton of insignificant drafts, and a few scheduled posts. They want to see how the block would look like after the scheduled posts are published.
  • Have a few drafts, which are planned for publication this week, and a couple of posts scheduled further into the future. They want to see the block as it would appear at the end of the week (drafts only).
  • Not use scheduling and have a ton of insignificant drafts, which they don't ever want to see in the block.

This PR would support all these workflows, while the proposition in the comment would impair all of these, assuming drafts and scheduled posts are always few and desired when previewing.

I'm all for simplification, but this is an non-core feature, and one which which uses established CMS concepts, so I don't think it's too complicated.

Right now I can't really think of a good use case for not showing published posts since these will always be shown to readers, right?

That's right – how about removing the "published" status from the UI, so user can only select what they want to see in addition to the published posts/

@dkoo
Copy link
Contributor

dkoo commented Apr 20, 2022

Thank you for your input, but I think it's based on assumptions about publishing workflows that we cannot make.

That's true—I think this is a feature which might benefit from some user feedback across sites of various sizes. I can certainly imagine the scenarios you describe but can't really say how many sites will actually encounter them.

That's right – how about removing the "published" status from the UI, so user can only select what they want to see in addition to the published posts

I'm okay with this approach for now if you just want to get the feature out there.

@adekbadek
Copy link
Member Author

After an internal discussion:

  • changed labels to specific posts status instead of generic "preview"
  • removed "published" option from the checkbox-selection

@adekbadek adekbadek requested a review from dkoo May 13, 2022 12:43
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor style issue with Post Carousels, otherwise looking 👍

@@ -758,3 +758,17 @@ amp-script .wpnbha.has-more-button.is-error {
}
}
/* stylelint-enable */

// Also used by the Carousel block.
.newspack-preview-label {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These styles aren't enqueued if a post only contains a Carousel block and not the Homepage Posts block.

Copy link
Member Author

@adekbadek adekbadek May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that! Fixed in b9bf681

@adekbadek adekbadek requested a review from dkoo May 16, 2022 10:05
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good now! 👍

@adekbadek adekbadek merged commit 7ec20a3 into master May 17, 2022
@adekbadek adekbadek deleted the fix/post-statuses-in-query branch May 17, 2022 15:54
matticbot pushed a commit that referenced this pull request May 19, 2022
# [1.51.0-alpha.1](v1.50.0...v1.51.0-alpha.1) (2022-05-19)

### Features

* **homepage-posts:** query by post statuses ([#1114](#1114)) ([7ec20a3](7ec20a3)), closes [#38](#38)
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.51.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request May 30, 2022
# [1.51.0](v1.50.1...v1.51.0) (2022-05-30)

### Features

* **homepage-posts:** query by post statuses ([#1114](#1114)) ([7ec20a3](7ec20a3)), closes [#38](#38)
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.51.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Homepage blocks: How to handle previewing article changes
3 participants