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

JITM: Show ToS update notice #14541

Merged
merged 9 commits into from
Feb 17, 2020
Merged

JITM: Show ToS update notice #14541

merged 9 commits into from
Feb 17, 2020

Conversation

mmtr
Copy link
Member

@mmtr mmtr commented Jan 31, 2020

Changes proposed in this Pull Request:

  • Allows JITMs to trigger AJAX actions when the CTA button is clicked.
  • Adds an AJAX action for the ToS JITM to mark the ToS as accepted.

image

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

Enhances the JITMs so they can display legal updates that need to be accepted such as the ToS 2020 update notice. See p58i-8v7-p2

Testing instructions:

  • Apply D38880-code to your WP.com sandbox.
  • Make sure you don't have ToS marked as accepted. See D38880-code for instructions on how to reset ToS acceptance.
  • Spin up a JN site running this branch.
  • Set up Jetpack and connect the JN site to WP.com.
  • Open the Blog RC and add the tos-test blog sticker to the JN site.
  • Go to WP Admin > Settings > Jetpack Constants.
  • Set JETPACK__SANDBOX_DOMAIN to the URL of your WP.com sandbox.
  • Access any WP Admin page of your Jetpack test site.
  • You should see a ToS update notice.
  • Click on Accept.
  • Make sure the JITM is hidden and the ToS are accepted.
  • Reload the WP Amin page.
  • Make sure the ToS update notice doesn't show up.
  • Reset ToS acceptance and repeat steps with a JN site running the master branch.
  • Sandbox jetpack.com and wordpress.com.
  • Since the AJAX handler is not available, clicking on the CTA button should perform a fallback redirect:
    • CTA links to jetpack.com/redirect?source=jitm-tos
    • That link redirects to wordpress.com/tos/accept which marks ToS as accepted
  • Make sure you're redirected back to the same WP Admin where you saw the JITM.
  • Make sure the ToS update notice doesn't show up.

Proposed changelog entry for your changes:

JITM: Show ToS update notice

@mmtr mmtr requested a review from a team January 31, 2020 16:44
@mmtr mmtr requested a review from a team as a code owner January 31, 2020 16:44
@mmtr mmtr self-assigned this Jan 31, 2020
@jetpackbot
Copy link

jetpackbot commented Jan 31, 2020

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: March 3, 2020.
Scheduled code freeze: February 25, 2020

Generated by 🚫 dangerJS against b49281c

@mmtr mmtr added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Jan 31, 2020
@jeherve jeherve added [Feature] JITM Just In Time Messages - pop-up tips and suggestions that appear on the dashboard and sidebar. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Jan 31, 2020
@jeherve jeherve added this to the 8.3 milestone Jan 31, 2020
@kwight
Copy link
Contributor

kwight commented Jan 31, 2020

Oh nice, I like this addition. Using D38262-code as a test, I was able to dismiss the banner and see an AJAX call fired.

@mmtr mmtr changed the title JITM: Support AJAX actions on CTA clicks JITM: Show ToS update notice Feb 4, 2020
@mmtr mmtr changed the title JITM: Show ToS update notice [WIP] JITM: Show ToS update notice Feb 4, 2020
@mmtr mmtr added [Status] In Progress and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 4, 2020
@mmtr mmtr changed the title [WIP] JITM: Show ToS update notice JITM: Show ToS update notice Feb 4, 2020
@mmtr mmtr added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Feb 4, 2020
@gwwar
Copy link
Contributor

gwwar commented Feb 4, 2020

@mmtr in the summary for:

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

We can note that this allows us to create banners for policy or terms of service updates, and anything else that might need an accept button. It's nice to paraphrase reasoning/context to folks if we link to additional internal context.

_inc/jetpack-jitm.js Outdated Show resolved Hide resolved
@kwight
Copy link
Contributor

kwight commented Feb 5, 2020

This is all perfecto, I <3 it! I do find the slow fadeOut to be a little... 2004, but I can see that it's the same as other JITM fades.

I was also curious what happens if we click on a CTA button with an invalid action. It's a little confusing for the user, since the button disables, then becomes active again with no real feedback (other than a 400 error for the ajax call in the console), but I don't think we want to go any further handling odd situations like that.

Works great!

kwight
kwight previously approved these changes Feb 5, 2020
@github-actions github-actions bot added the [Status] Needs Package Release This PR made changes to a package. Let's update that package now. label Feb 6, 2020
@dereksmart
Copy link
Member

Just a note to make sure that from the WPCOM side of things, we're only displaying this JITM to sites that are running Jetpack 8.3+, as older versions will not include this ajax handler and will get errors anytime they try to click.

@kwight
Copy link
Contributor

kwight commented Feb 12, 2020

Just a note to make sure that from the WPCOM side of things, we're only displaying this JITM to sites that are running Jetpack 8.3+, as older versions will not include this ajax handler and will get errors anytime they try to click.

Ooooh, that... brings up an interesting point: if we need to show the JITM to users with old JP versions, and can't rely on a client click handler needed for the user to accept, then... are we full-circle and back to the hacky redirect @mmtr ?

@kwight
Copy link
Contributor

kwight commented Feb 12, 2020

Noting that in the future for other JITMs, we can do version compares in the JITM engine with with_option_matching:

->with_CTA_ajax_action( 'jetpack_accept_tos' )
->with_option_matching(
	'jetpack_version',
	function( $version ) {
		return version_compare( $version, '8.3', '>=' );
	}
),

@mmtr mmtr added [Status] In Progress and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 13, 2020
@mmtr
Copy link
Member Author

mmtr commented Feb 13, 2020

Fallback for sites running older versions of Jetpack available at D38880-code.

@mmtr mmtr added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Feb 13, 2020
@kbrown9
Copy link
Member

kbrown9 commented Feb 13, 2020

I’m having some trouble with testing these changes. My test site is a JN site running this branch. The TOS JITM displays as expected. However, when I click the CTA, I’m redirected to a plans page. Also, the JITM still displays when I navigate back to a wp-admin page.

Is anyone else running into problems when testing this branch?

@mmtr
Copy link
Member Author

mmtr commented Feb 14, 2020

I’m having some trouble with testing these changes. My test site is a JN site running this branch. The TOS JITM displays as expected. However, when I click the CTA, I’m redirected to a plans page.

That's weird. The click handler should intercept any click on the button and trigger an AJAX action rather than following the CTA link (which ends up redirecting to the plans pages if D38880-code it's not in place). I'll take a look at this to see if I can reproduce your issue.

Also, the JITM still displays when I navigate back to a wp-admin page.

Yup, this one has been identified by @kwight (D38262-code#771154) since we changed the signature of a function but didn't update its usage in the JITMs. Will prepare a fix for this today.

Edit: He beat me to it D38890-code

@mmtr
Copy link
Member Author

mmtr commented Feb 14, 2020

when I click the CTA, I’m redirected to a plans page

Confirmed and fixed the issue in b49281c

@kwight
Copy link
Contributor

kwight commented Feb 14, 2020

Edit: He beat me to it D38890-code

Which has been deployed 👍

@kwight
Copy link
Contributor

kwight commented Feb 14, 2020

Fantastic ❤️

Copy link
Member

@kbrown9 kbrown9 left a comment

Choose a reason for hiding this comment

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

I tested this using the provided testing instructions, and everything was successful!

When using this branch, clicking the CTA button triggered the ajax action. When using the master branch, clicking the CTA button caused a redirect to wordpress.com/tos/accept. In both cases, the ToS was marked as accepted, and the ToS JITM no longer displayed.

@kbrown9 kbrown9 added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 15, 2020
@mmtr mmtr merged commit cb1e169 into master Feb 17, 2020
@mmtr mmtr deleted the add/jitm-ajax branch February 17, 2020 09:27
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Feb 17, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
@jeherve jeherve removed the [Status] Needs Package Release This PR made changes to a package. Let's update that package now. label Feb 25, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
* 8.3 release: changelog

* Changelog: add #14516

* Changelog: add #14574

* Bring in changes from 8.2.1 and 8.2.2

* Update stable version

* Bring in 8.2.3 changes

* Changelog: add #14714

* Changelog: add #14639

* Changelog: add #14678

* Changelog: add #14673

* Changelog: add #14687

* Changelog: add #14704

* Changelog: add #14702

* Changelog: add #14541

* Changelog: add #14657

* Changelog: add #14622

* Changelog: add #14582

* Changelog: add #14638

* Changelog: add #14633

* Changelog: add #14571

* Changelog: add #14592

* Changelog: add #14539

* Changelog: add #14514

* Changelog: add #14643

* Changelog: add #14494

* Changelog: add #13739

* Changelog: add #14707

* Changelog: add #14736

* Changelog: add #14706

* Changelog: add #14730

* Changelog: add #14685

* Changelog: add #14727

* Changelog: add #14711

* Changelog: add #14742

* Changelog: add #14746

* Changelog: add #14725

* Changelog: add #13999

* Changelog: add #14740

* Changelog: add #14759

* Changelog: add #14703

* Changelog: add #14753

* Changelog: add #14754

* Changelog: add #14645

* Cahngelog: add #14599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] JITM Just In Time Messages - pop-up tips and suggestions that appear on the dashboard and sidebar. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants