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

[Gutenberg] Enable reusable block only in WP.com sites #14623

Merged
merged 19 commits into from
May 26, 2021

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented May 11, 2021

gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#3490
guteberg PR: WordPress/gutenberg#31744
WordPress-iOS PR: wordpress-mobile/WordPress-iOS#16475

Depends on: #14529

This PR enables the reusable block and adds a capability into the editor to limit the availability of this type of block to only WP.com sites.

Why reusable block is disabled in self-hosted sites

Related issue: wordpress-mobile/gutenberg-mobile#3457

The main reason for disabling this block in self-hosted sites is related to the case of having a reusable block that contains a self-reference (a reference to the same reusable block). While in WP.com sites this is working properly, in self-hosted sites, fetching data from the endpoint that holds the data for reusable blocks (/wp-json/wp/v2/blocks) in this case, the site returns a bad response so we don't have data for displaying them.

NOTE: This is reproducible on self-hosted sites with and without Jetpack, although the error response is different.

Regression Notes

  1. Potential unintended areas of impact

The Reusable block has been enabled so it could affect those posts/pages that contain this type of block.

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

General testing

The following tests have been performed to assure that the editor works as expected:

Present block content (preview mode)

PR: WordPress/gutenberg#25265

This was tested in the following 3 different scenarios:

WordPress.com site

Create a WordPress.com site or use an already created one.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the WordPress.com site
  • Edit the previous created post
  • Check that the Reusable block is shown
  • Tap on it and check that the title of the Reusable blocks is shown
Self-hosted site with Jetpack

Create a self-hosted site with Jetpack (I used https://jurassic.ninja/create/) or use an already created one.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the self-hosted site
  • Edit the previous created post
  • Check that the Reusable block is shown
  • Tap on it and check that the title of the Reusable blocks is shown
Self-hosted site without Jetpack

Create a self-hosted site without Jetpack (I created a local one using this instructions) or use your own.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the self-hosted site
  • Edit the previous created post
  • Check that the Reusable block is shown
  • Tap on it and check that the title of the Reusable blocks is shown
Additional improvements for rendering Reusable block

PR: WordPress/gutenberg#30966

NOTE: Reusable blocks can be managed by navigating to the "Reusable blocks page":

  • WP.com: https://wordpress.com/types/wp_block/<YOUR_WPCOM_SITE_DOMAIN>
  • Self-hosted: https://<YOUR_SELF_HOSTED_SITE_DOMAIN>/wp-admin/edit.php?post_type=wp_block

Here are the steps for creating reusable blocks in the web version:

Option 1:

  1. Edit a post/page
  2. Add some blocks
  3. Select multiple blocks
  4. Click on options (three dots button)
  5. Click on "Add to Reusable blocks" button
  6. Input a name for the block
  7. Save the post/page

Option 2:

  1. Navigate to "Reusable blocks page" (referenced above)
  2. Click on "Add new reusable block"/"Add new" button
  3. Add a title
  4. Add some blocks
  5. Publish it

Preview content

  1. Create a reusable block and add it to a post/page
  2. Edit the post/page in the mobile app
  3. Observe that the reusable block is shown
  4. Tap on it and observe that the title of the reusable blocks is shown

Deleted reusable block

  1. Create two reusable blocks
  2. Add the second reusable block as part of the content of the first one and save it
  3. Delete the second reusable block from the "Reusable blocks page" (referenced above)
  4. The second reusable block will go to the trashed tab, delete it permanently
  5. Add the first reusable block to a post/page
  6. Edit the post/page in the mobile app
  7. Observe that the reusable block is shown and that no errors are displayed
  8. Observe that the second reusable block is not rendered but displays a warning

Recursive block rendering

  1. Create a reusable block
  2. Edit the reusable block, add the same reusable block as part of the content and save it
  3. Add the reusable block to a post/page
  4. Edit the post/page in the mobile app
  5. Observe that the reusable block is shown and that no errors are displayed
  6. Observe that it displays a warning instead of rendering multiple times the same block
Add convert to regular blocks action to Reusable block

PR: WordPress/gutenberg#31012

  1. Create a reusable block in the web version
  2. Add the reusable block to a post/page
  3. Edit the post/page in the mobile app
  4. Tap on the reusable block
  5. Tap on the three dots button to display the block actions menu
  6. Tap on "Convert to regular blocks"
  7. Observe that the reusable block is converted to regular blocks

Undo/redo

It's important that we verify that the undo/redo actions work as expected when converting to regular blocks.

  1. [Follow the same steps described above for converting to regular blocks]
  2. Tap the undo button from the toolbar
  3. Observe that the reusable block is displayed again
  4. Tap the redo button from the toolbar
  5. Observe that the regular blocks are displayed again

Verify that the reusable block is only available in WP.com sites

WordPress.com site - Reusable block is enabled

Create a WordPress.com site or use an already created one.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the WordPress.com site
  • Edit the previous created post
  • Check that the Reusable block is shown
  • Tap on it and check that the title of the Reusable blocks is shown
WordPress.com site (Atomic) - Reusable block is enabled

Create an Atomic site via WordPress.com site or use an already created one.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the WordPress.com site
  • Edit the previous created post
  • Check that the Reusable block is shown
  • Tap on it and check that the title of the Reusable blocks is shown
Self-hosted site with Jetpack - Reusable block is disabled

Create a self-hosted site with Jetpack (I used https://jurassic.ninja/create/) or use an already created one.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the self-hosted site
  • Edit the previous created post
  • Check that the Reusable block is displayed as unsupported
Self-hosted site without Jetpack - Reusable block is disabled

Create a self-hosted site without Jetpack (I created a local one using this instructions) or use your own.

  • Create a post in the web version
  • Add some blocks and create a Reusable block
  • Open the app with metro running (Gutenberg-mobile)
  • Add the self-hosted site
  • Edit the previous created post
  • Check that the Reusable block is displayed as unsupported
  1. What automated tests I added (or what prevented me from doing so)

No automated tests have been added but I plan to add them in the future.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@fluiddot fluiddot added Gutenberg Editing and display of Gutenberg blocks. gutenberg-mobile labels May 11, 2021
@fluiddot fluiddot self-assigned this May 11, 2021
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented May 11, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@fluiddot
Copy link
Contributor Author

The installable build is failing because it requires this PR to be merged first.

@fluiddot fluiddot requested a review from jd-alexander May 12, 2021 12:05
@fluiddot fluiddot marked this pull request as ready for review May 12, 2021 12:12
@fluiddot fluiddot changed the title [Gutenberg] Add enableReusableBlock into Gutenberg props [Gutenberg] Enable reusable block only in WP.com sites May 13, 2021
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented May 13, 2021

You can test the changes on this Pull Request by downloading the APK here.

Copy link
Contributor

@jd-alexander jd-alexander left a comment

Choose a reason for hiding this comment

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

Hi @fluiddot thanks for these changes. I tested on WP.com sites ( including atomic) and the reusable block behavior worked as expected. While testing on self hosted sites, I can see that the block is unsupported. However, I got undefined for the block's name. Let me know if you are able to reproduce. I utilized the APK here for testing.

@fluiddot
Copy link
Contributor Author

Hi @fluiddot thanks for these changes. I tested on WP.com sites ( including atomic) and the reusable block behavior worked as expected. While testing on self hosted sites, I can see that the block is unsupported. However, I got undefined for the block's name. Let me know if you are able to reproduce. I utilized the APK here for testing.

Thank you very much @jd-alexander for reviewing it ❤️ !

Regarding the unsupported block issue, there’s already an opened issue related to this. In fact, I have a PR with the fix but it’s blocked due to other translation problems.

@jd-alexander
Copy link
Contributor

Regarding the unsupported block issue, there’s already an opened issue related to this. In fact, I have a PR with the fix but it’s blocked due to other translation problems.

Ah, I didn't notice it. Thanks for the sharing @fluiddot . So it a case where we will wait until that PR is ready before merging this?

@fluiddot
Copy link
Contributor Author

Regarding the unsupported block issue, there’s already an opened issue related to this. In fact, I have a PR with the fix but it’s blocked due to other translation problems.

Ah, I didn't notice it. Thanks for the sharing @fluiddot . So it a case where we will wait until that PR is ready before merging this?

The issue is happening for all unsupported blocks so it’s not necessarily blocking this PR. Anyways, as the fix has to land in the current release 1.53.0 (it will be included as a beta fix) because it’s a major issue, it will most likely be merged before this one 😄 .

@jd-alexander
Copy link
Contributor

The issue is happening for all unsupported blocks so it’s not necessarily blocking this PR. Anyways, as the fix has to land in the current release 1.53.0 (it will be included as a beta fix) because it’s a major issue, it will most likely be merged before this one 😄 .

Understood! In that case, I will give approval to these PRs.

jd-alexander
jd-alexander previously approved these changes May 17, 2021
Copy link
Contributor

@jd-alexander jd-alexander left a comment

Choose a reason for hiding this comment

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

@fluiddot
Copy link
Contributor Author

I created the Gutenberg Mobile tag v1.54.0-alpha1 that points to the merge commit of wordpress-mobile/gutenberg-mobile#3490 and the reference has been updated, once the PR checks pass the PR will be merged 🎊 .

@fluiddot
Copy link
Contributor Author

I did a quick test with the last installable build and the editor crashes upon opening 😨 , I'm going to hold the merge of this PR until I find the cause.

@fluiddot
Copy link
Contributor Author

fluiddot commented May 21, 2021

I did a quick test with the last installable build and the editor crashes upon opening 😨 , I'm going to hold the merge of this PR until I find the cause.

I made a build locally (using local GB-mobile, not the binary) and it's not happening so I'm wondering if it has to do with the RN binaries 🤔 .

@fluiddot
Copy link
Contributor Author

I'll try to generate new RN binaries once the CircleCI outage ends and test again.

@cameronvoell cameronvoell mentioned this pull request May 24, 2021
4 tasks
@fluiddot fluiddot added this to the 17.5 milestone May 24, 2021
@cameronvoell cameronvoell dismissed jd-alexander’s stale review May 24, 2021 15:43

Just wanted to mark this PR as needing review since I also saw the crash when opening the editor from the Peril APK build. Didnt want someone to accidentally merge. Thanks!

@fluiddot
Copy link
Contributor Author

After testing further, I noticed that the crash was introduced in a previous commit on GB-mobile develop, not the one related to this PR. Looks like this is the PR that introduced the issue in this merge commit.

@fluiddot
Copy link
Contributor Author

@jd-alexander @cameronvoell Looks like the crash is not caused by this PR so I think we could merge this PR and fix the crash on a new PR, wdyt?

@fluiddot
Copy link
Contributor Author

fluiddot commented May 25, 2021

@jd-alexander @cameronvoell Looks like the crash is not caused by this PR so I think we could merge this PR and fix the crash on a new PR, wdyt?

The crash will be fixed after merging this PR 🎊 .

fluiddot added 3 commits May 26, 2021 12:31
The ref was accidentally changed when resolving conflicts with develop branch.
@@ -7,7 +7,7 @@ buildscript {
ext.kotlin_ktx_version = '1.2.0'
ext.wordPressUtilsVersion = '1.40.0'
ext.detektVersion = '1.15.0'
ext.gutenbergMobileVersion = 'v1.53.1'
ext.gutenbergMobileVersion = 'develop-c55652b5fabf0e4edd08b79da4b78418aa886410'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This reference is pointing to the commit that introduced the fix for the Android crash referenced in this comment.

@fluiddot
Copy link
Contributor Author

I've tested the last installable build and the crash is no longer happening 🎊 .

@jd-alexander @cameronvoell the PR is ready to review and merge, let me know if I can help with anything else 🙇 .

Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Great work @fluiddot 👍
Thank you for bringing this functionality to the mobile side 🙇
I did a quick sanity using the produced APK and the availability of the block works as expected 🎉
The code changes are consistent and look great too 👍

@fluiddot
Copy link
Contributor Author

fluiddot commented May 26, 2021

I've tested the last installable build and the crash is no longer happening 🎊 .

@jd-alexander @cameronvoell the PR is ready to review and merge, let me know if I can help with anything else 🙇 .

@antonis just reviewed and approved the PR so I'm going to merge it, let me know @jd-alexander and @cameronvoell if you have any concerns regarding this, thank you all for the help provided in this PR 🙇 !

@fluiddot fluiddot merged commit 4198e06 into develop May 26, 2021
@fluiddot fluiddot deleted the gutenberg/add/reusable-block-capability branch May 26, 2021 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants