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

Upgrade Nudge: Fix redirect_to for Jetpack wp-admin #13165

Merged
merged 8 commits into from
Aug 5, 2019

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Aug 1, 2019

Required for #13081, and implementing musings found at #13081 (comment). Related: Automattic/wp-calypso#35027.

Changes proposed in this Pull Request:

Change the post-checkout redirect target to the wp-admin block editor for Jetpack sites, both in the editor (JS), and the frontend (PHP).

Is this a new feature or does it add/remove features to an existing part of Jetpack?

Modifies the existing UpgradeNudge.

Testing instructions:

  • Switch to this branch locally, build Jetpack (yarn build), and start Docker (yarn docker:up)
  • Now add the following line to any file in docker/mu-plugins, e.g. a newly created 0-blocks-upgrade.php (needs to start with <?php): define ( 'JETPACK_SHOW_BLOCK_UPGRADE_NUDGE', true );
  • Make sure you're connected to WP.com, and on a free plan
  • Start a new post, and insert the 'Simple Payments' block
  • Select the block, and enter some information into its text fields.
  • Click the nudge's "Upgrade" CTA button
  • Pay for the premium plan
  • Verify that you're redirected back to where you came from (the wp-admin block editor) (without any intermediate redirects on WP.com)

Verify that on WP.com, the redirect target is still the iframed Gutenberg editor (well, if you have enabled it, see PCYsg-hNB-p2):

  • Apply the WP.com counterpart patch (D31062-code) to your sandbox
  • Make sure your sandbox is on a free plan, and that you have enabled it to use Gutenberg
  • Open the block editor for your sandbox site from within Calypso
  • Insert the 'Simple Payments' block
  • Click the nudge's "Upgrade" CTA button
  • Pay for the premium plan
  • Verify that you're redirected back to where you came from (the iframed Gutenberg editor in Calypso)

Proposed changelog entry for your changes:

N/A (The UpgradeNudge hasn't been enabled in any previous JP version, so no need to add a ChangeLog entry.)

@ockham ockham added [Status] In Progress [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Aug 1, 2019
@ockham ockham requested a review from a team August 1, 2019 11:32
@ockham ockham self-assigned this Aug 1, 2019
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello ockham! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D31062-code before merging this PR. Thank you!

@jetpackbot
Copy link
Collaborator

jetpackbot commented Aug 1, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: August 6, 2019.
Scheduled code freeze: July 30, 2019

Generated by 🚫 dangerJS against 8a768f9

@ockham ockham force-pushed the add/upgrade-nudge/jetpack-redirect branch from f0712ff to 9043ec6 Compare August 2, 2019 10:55
@matticbot
Copy link
Contributor

ockham, Your synced wpcom patch D31062-code has been updated.

@matticbot
Copy link
Contributor

ockham, Your synced wpcom patch D31062-code has been updated.

@matticbot
Copy link
Contributor

ockham, Your synced wpcom patch D31062-code has been updated.

? '/' +
compact( [ postTypeEditorRoutePrefix, postType, getSiteFragment(), postId ] ).join( '/' )
: addQueryArgs(
window.location.protocol +
Copy link
Contributor Author

@ockham ockham Aug 2, 2019

Choose a reason for hiding this comment

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

Unfortunately, we don't seem to be exposing the site's protocol through any utilties available to JS (neither from Gutenberg/core nor Jetpack), so I'm falling back to window.location.protocol.

Devil's advocate: Why even bother constructing the URL from 'reliable' data and not just window.location.href for the entire redirect_to URL I'm building?

@ockham ockham added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Aug 2, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This seems to test well on Jetpack (I tested on both HTTP and HTTPS sites). I have not tested on WordPress.com though. I'll let someone else review that!

@ockham ockham merged commit d69f233 into master Aug 5, 2019
@ockham ockham deleted the add/upgrade-nudge/jetpack-redirect branch August 5, 2019 11:16
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Needs Review This PR is ready for review. labels Aug 5, 2019
@jeherve jeherve added this to the 7.7 milestone Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants