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] UBE: Pressenting Jetpack Security settings on Missing Block #13011

Merged

Conversation

marecar3
Copy link
Contributor

@marecar3 marecar3 commented Sep 24, 2020

Gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#2610

This PR implements changes from wordpress-mobile/gutenberg-mobile#2610 to present the Jetpack Security settings modally over Gutenberg, and refresh the editor capabilities to enable the Unsupported Block Editor.

NOTE: The action button text for UBE Enabled has been updated to Edit using web editor.
jetpack_ube

To test:

Jetpack connected sites (Self-Hosted and Atomic)

  • Have a Jetpack connected site with a post with an unsupported block on it.
  • Be sure to have SSO disabled for this site.
  • Open the post with the mobile app.
  • Press the (?) button on the missing block.
    • Check that the bottom sheet looks like the one from the image Jetpack - UBE Disabled.
  • Press the action button Open Jetpack security settings.
  • Check that the Jetpack Security Settings appears modally.
  • Activate the option Allow WordPress.com login and press Done.
  • Press (?) button again.
    • Check that now the bottom sheet has changes, and looks like Jetpack - UBE Enabled from the image.
  • Press again the action button Edit using web editor.
    • Check that UBE works as expected. (If its a new site, you might need to allow WordPress.com login on the web view. This is expected behaviour.

Self-Hosted sites.

  • Add a self-hosted site to the mobile app (not connected to wpcom).
  • Open a post with an unsupported block in it.
  • Press the (?) button on the missing block.
    • Check that it looks like the one from the image Self-Hosted - Disabled.

WPCom Simple sites.

  • On a WPCom Simple site:

  • Open a post with an unsupported block in it.

  • Press the (?) button on the missing block.

    • Check that it looks like the one from the image WPCom Simple - Enabled.
  • Press the action button Edit using web editor.

    • Check that UBE loads as expected.
  • I have considered adding unit tests where possible.

  • 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.

@marecar3 marecar3 added this to the 15.9 milestone Sep 24, 2020
@marecar3 marecar3 self-assigned this Sep 24, 2020
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Sep 24, 2020

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

Comment on lines 2173 to 2177
boolean unsupportedBlockEditorSwitch = !mIsJetpackSsoEnabled && "gutenberg".equals(mSite.getWebEditor());
return new GutenbergPropsBuilder(
enableMentions,
isUnsupportedBlockEditorEnabled,
unsupportedBlockEditorSwitch,
Copy link
Contributor

Choose a reason for hiding this comment

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

unsupportedBlockEditorSwitch is true if the site is a Jetpack site. Meaning that the site can switch the SSO settings. Just Jetpack sites have this capability.
Naming is not the best, but we are trying to make its usage generic, and not refer to SSO or Jetpack directly on gutenberg.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Sep 24, 2020

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

@marecar3 marecar3 marked this pull request as ready for review September 24, 2020 19:18
Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

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

All three scenarios are working as expected 🎉. I've left some comments on the gutenberg and gutenberg-mobile PRs.

private void setupToolbar() {
setTitle(getResources().getText(R.string.jetpack_security_setting_title));

Toolbar toolbar = findViewById(org.wordpress.mobile.ReactNativeGutenbergBridge.R.id.toolbar);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the full package name here for the String?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah no, thanks!
Fixed.

} else if (preference == mJpUseTwoFactorPref) {
mJpUseTwoFactorPref.setChecked((Boolean) newValue);
mSiteSettings.enableJetpackSsoTwoFactor((Boolean) newValue);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal, but I think it would help readability a bit if we extracted out the Boolean cast so that we don't have to do the cast repeatedly in the if-else block:

Boolean prefBool = (Boolean) newValue;
if (preference == mJpMonitorActivePref) {
    mJpMonitorActivePref.setChecked(prefBool);
    mSiteSettings.enableJetpackMonitor(prefBool);
} else if (preference == mJpMonitorEmailNotesPref) {
    mJpMonitorEmailNotesPref.setChecked(prefBool);
    mSiteSettings.enableJetpackMonitorEmailNotifications(prefBool);
} else if ...

If we had written this file in Kotlin, we could have also used a when statement to make this a bit more readable:

when (preference) {
    mJpMonitorActivePref -> {
        mJpMonitorActivePref.setChecked(prefBool);
        mSiteSettings.enableJetpackMonitor(prefBool);
    }
    mJpMonitorEmailNotesPref -> {
        mJpMonitorEmailNotesPref.setChecked(prefBool);
        mSiteSettings.enableJetpackMonitorEmailNotifications(prefBool);
    }
}
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. Thanks! Fixed.

Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

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

Reviewed the code, and this looks good. Left a couple of small comments, but nothing I consider blocking. Nice job! 👍

@marecar3
Copy link
Contributor Author

All three scenarios are working as expected 🎉. I've left some comments on the gutenberg and gutenberg-mobile PRs.

Thanks a lot for extra effort!

@marecar3
Copy link
Contributor Author

Reviewed the code, and this looks good. Left a couple of small comments, but nothing I consider blocking. Nice job! 👍

Many thanks!!!

@etoledom etoledom merged commit 3648171 into develop Sep 28, 2020
@etoledom etoledom deleted the gutenberg/unsupported-block-editor-switch-to-enable-jetpack-sso branch September 28, 2020 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants