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

Related Posts Block: make the block available even when the module is disabled #32930

Merged
merged 15 commits into from
Sep 19, 2023

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Sep 7, 2023

Fixes #11861

Proposed changes:

This PR changes the behavior of the Related Posts block when the feature is not available.

Current behavior

On WordPress.com Simple

On simple, you're able to disable the Related Posts feature via the enabled option of the relatedposts Jetpack option. This setting is available under Settings > Reading:

https://yourdotcomsimplesite.com/wp-admin/options-reading.php

When this happens, the block is still available in the editor but will not work properly, as outlined in #11861.

On self-hosted sites

On self-hosted sites (WoA and Jetpack), you can disable the Related Posts module, under Jetpack > Settings > Traffic

In this scenario, the block isn't registered in the editor.

Future behavior

On both environments, the Related Posts block will remain registered and available. When the feature or the module will be disabled:

  • We do not display anything on the frontend.
  • In the block and site editors, we display a placeholder with a button inviting you to activate the feature. The placeholder contents and the support links should be a bit different whether you're on WordPress.com simple or self-hosted.
Screenshot 2023-09-15 at 17 44 14
  • When the feature is enabled (either the module or the option), we display the block contents just like before.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

  • This PR introduces new Tracks events when the placeholder is displayed, and when one enables the feature via the placeholder button.

Testing instructions:

This needs to be tested on simple and on self-hosted. To test this, it's best if you use a site with a lot of existing content, so related posts can be displayed.

On WordPress.com Simple

Note
You will need to apply this diff, as well as D121657-code to bring in the new endpoint.

  1. Start a new post in the block editor, and add a 'Related Posts' block.
  2. Publish and view the post to verify that the block is present on the frontend.
  3. At https://wordpress.com/settings/traffic/, disable the Related Posts toggle
  4. Reload the published posts, and verify that the Related Posts block is no longer visible
  5. Edit the post again ; the block should be there, but with a placeholder content.
  6. Click on the button to enable related posts back.
  7. Verify that the related posts appear again on the frontend.

On self-hosted

  1. Go to Jetpack > Settings > Traffic
  2. Disable the Related Posts module
  3. Go to Posts > Add New
  4. Add some content and save your draft.
  5. Add a Related Posts Block
  6. See the placeholder content
  7. Enable the module from the button.
  8. Publish and verify that you can see the related posts on the frontend.

Whether the module is active or not, we'll register the Related Posts block.
- The placeholder includes a button inviting you to activate the module.
- While the module status loads, we display placeholder block contents.
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta > Jetpack and enable the update/related-posts-availability branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/related-posts-availability
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Sep 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

  • Next scheduled release: October 3, 2023.
  • Scheduled code freeze: September 25, 2023.

- Include module status check
- Move to function component
- Mock additional functions
Modules behave differently there
One can also disable Related Posts (while the module is active) via a toggle in Settings > Reading in Calypso. Let's add:

- 2 new endpoints to fetch and update that info.
- a new hook to handle this new status info in the block editor.
- hook the new hook into the Related Posts' block in the editor.
@jeherve jeherve added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Status] Needs Team Review and removed [Status] In Progress labels Sep 15, 2023
@jeherve jeherve requested a review from a team September 18, 2023 15:37
@anomiex
Copy link
Contributor

anomiex commented Sep 18, 2023

Seems to work in self-hosted.

On Simple, when adding the block with the feature enabled I get a flash of "You'll need to activate the Related Posts feature" before it switches over to displaying the block. I think your new useRelatedPostsStatus needs to differentiate "loading status" from "changing status" like useModuleStatus does, so you can use the "loading status" indicator at

along with that one from useModuleStatus.

@jeherve
Copy link
Member Author

jeherve commented Sep 18, 2023

On Simple, when adding the block with the feature enabled I get a flash of "You'll need to activate the Related Posts feature" before it switches over to displaying the block.

ah that's a good point, thank you! I just committed 4fda28d to help with that.

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Seems to work.

@fgiannar fgiannar added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Sep 19, 2023
@jeherve jeherve dismissed ice9js’s stale review September 19, 2023 08:52

I addressed feedback.

@jeherve jeherve merged commit f25727b into trunk Sep 19, 2023
54 checks passed
@jeherve jeherve deleted the update/related-posts-availability branch September 19, 2023 08:52
@github-actions github-actions bot added this to the jetpack/12.5.1 milestone Sep 19, 2023
@github-actions github-actions bot removed [Status] Ready to Merge Go ahead, you can push that green button! [Status] Needs Team Review labels Sep 19, 2023
@sajmes
Copy link

sajmes commented Sep 20, 2023

On several simple sites, I am seeing the prompt to activate the related posts block in the editor, even when the setting in yoursimplesite.com/wp-admin/options-reading.php for related posts is enabled.

Clicking the activate option in the editor does nothing.

A user reported this across three sites, and I can replicate on a test site. All previously added related posts blocks are no longer working on their site.

I'm not sure if this is related to this, but it seems possible @jeherve

Ticket: 7012332-zd-a8c

@github-actions
Copy link
Contributor

Support References

This comment is automatically generated. Please do not edit it.

  • 7012332-zen

@github-actions github-actions bot added the Customer Report Issues or PRs that were reported via Happiness. Previously known as "Happiness Request". label Sep 20, 2023
@jeherve
Copy link
Member Author

jeherve commented Sep 20, 2023

@sajmes Thanks for letting me know. Could you try on your test sites and on the customer's site again? It should work now.

@sajmes
Copy link

sajmes commented Sep 20, 2023

@jeherve - I checked this and it appears that for existing related post blocks to work, the block needs to be activated from any post on the site. On one of the user's sites, I activated this and the block is displaying related posts on their existing posts.

On their other site, I did not click the activate option on the related posts block, and the site is still not displaying related posts on posts where that block was previously added.

Can you replicate that?

Is this something we can automatically activate for existing blocks if so?

@jeherve
Copy link
Member Author

jeherve commented Sep 20, 2023

As discussed in Slack, I'm thinking that this may happen for all the folks who had added Related Posts blocks to their site without fully activating the feature in Settings > Reading.

To fix this issue, one would have to do the following:

  1. Go to Settings > Reading
  2. If the Related Posts are set to be displayed, set them to be hidden, and then save changes.
  3. When the settings reload, mark the related posts to be displayed again.
  4. Save your changes.

That should hopefully fix things.

@renata-franco
Copy link

Is this issue related to this change?

CleanShot 2023-09-25 at 12 47 51

@jeherve
Copy link
Member Author

jeherve commented Sep 25, 2023

@renata-franco No, this isn't related. You'll see this grayed out block whenever the block has already been inserted elsewhere on the page, and when the block has a restriction of one block per page.

@renata-franco
Copy link

@renata-franco No, this isn't related. You'll see this grayed out block whenever the block has already been inserted elsewhere on the page, and when the block has a restriction of one block per page.

Thank you, Jeremy! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Related Posts Customer Report Issues or PRs that were reported via Happiness. Previously known as "Happiness Request". [Feature] Related Posts [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Related Posts Block: Available in Block Picker even if Disabled
6 participants