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

Add the WPCOM Block Editor NUX #38511

Merged
merged 8 commits into from
Feb 18, 2020
Merged

Conversation

Copons
Copy link
Contributor

@Copons Copons commented Dec 18, 2019

Changes proposed in this Pull Request

⚠️ I've opened this for reviews, but I definitely need to double check the test steps to make sure it actually works as expected.

  • Add a custom WPCOM Block Editor NUX to the FSE plugins.
  • Override the Core NUX (Welcome Guide) to trigger WPCOM's instead.
  • If on WPCOM, the NUX is per-user instead of per-site. (See D36911-code)

Screenshot 2019-12-18 at 18 54 33

Notes

Currently the WPCOM NUX has the exact same copy as the Core NUX.

Although, the WPCOM NUX is intentionally without images, so that it won't be confused with the Core NUX while testing.

Testing instructions

For the WPCOM instructions, please refer to D36911-code.

  • Open the block editor and make sure the WPCOM NUX show up.
    It's the first time, so it's expected to show up even if we had previously dismissed the Core NUX already.
  • Dismiss the NUX.
  • Reload the editor: make sure the NUX does not show up.
  • Open the browser dev tools, and navigate to: Application -> Local Storage -> [site URL, e.g. localhost:8889]. Wipe the local storage for your site by clicking on the 🚫icon.

Screenshot 2019-12-18 at 18 47 10

  • Reload the editor: make sure the NUX does not show up.
  • From the More menu, click on Welcome Guide. The NUX will show up again.
  • Without dismissing the NUX, reload the editor: make sure the NUX will show up again.

Fixes #38299 & #39320

@Copons Copons requested review from a team as code owners December 18, 2019 16:03
@Copons Copons self-assigned this Dec 18, 2019
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@Copons Copons added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Dec 18, 2019
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo 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 given the current instructions, everything seems to be working as expected.

From what I can understand the endpoint and apitFetch are what is allowing this to be per user as opposed to per site?

import { select, dispatch, subscribe } from '@wordpress/data';
import '@wordpress/nux'; //ensure nux store loads

dispatch( 'core/nux' ).disableTips();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this dispatch necessary given what is below in subscribe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it wasn't necessary too, but it turns out it is! 😄

This ensures that the Core NUX doesn't open on editor load, even if it's supposed to.
Removing it would mean that, if the Core NUX tries to open on editor load, we instead open the WPCOM NUX regardless of the stored user preference.

Basically the reason for that subscribe is so that if the user manually triggers the Core NUX (AFAIK the only way is with the Welcome Guide item in the More menu), we incept, disable it and open the WPCOM NUX instead, by also setting the user attribute as "is_nux_enabled = true" in the DB.

On editor load, this is not necessarily what we want.
E.g.

  • User dismissed the WPCOM NUX on Site A. The cross-site user preference is now: is_nux_enabled = false.
  • User creates Site B.
  • On first editor load, the Core NUX tries to open (as we aren't disabling it beforehand anymore).
  • Our inception intervenes disabling the Core NUX, and force-enabling the WPCOM NUX instead, even though the user already dismissed it on Site A (and the user preference is is_nux_enabled = false).
  • Additionally, the inception also force-updates the user preference as is_nux_enabled = true (until the WPCOM NUX is dismissed again).

It's super hard to follow, I know!
Let me know if you need me to clear up this comment a little bit 😄

import apiFetch from '@wordpress/api-fetch';
import { plugins, registerStore, use } from '@wordpress/data';

use( plugins.persistence, {} );
Copy link
Contributor

Choose a reason for hiding this comment

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

Im a little confused how this is working and what it is doing for us. It reads to me like we are inheriting persistence functionality onto an empty object. How does this effect what we end up registering with registerStore (which seems to be using persist: true anyways) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well pointed out, @Addison-Stavlo!

I'm not super clear on how the persistence works, and the Guten readme got me confused.
I've tried removing this line, and it seems it's persisting as good as before.

Apparently, use( plugins.persistence, {} ); creates a new localStorage item, which in this case contained only the automattic/nux state.
But, the persist: true added the automattic/nux state to the default WP localStorage, so it was indeed plenty enough.

Copy link
Contributor Author

@Copons Copons left a comment

Choose a reason for hiding this comment

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

Improve the state persistence and use modern PHP array notation

Apparently the modern PHP array notation is killed by phpcbf on commit 😭

@Addison-Stavlo
Copy link
Contributor

Although, the WPCOM NUX is intentionally without images, so that it won't be confused with the Core NUX while testing.

Is the intention to add the images back in before merging?

@Copons
Copy link
Contributor Author

Copons commented Dec 19, 2019

Is the intention to add the images back in before merging?

The intention of this PR is to provide a foundation for having a custom WPCOM NUX.
My plan is to ask for new images and copy, once this has got a technical approoval.

@Addison-Stavlo
Copy link
Contributor

My plan is to ask for new images and copy, once this has got a technical approoval.

Gotcha! Ok.
I approve as far as I can tell on the technical standpoint (it may be good to have another set of eyes glance over the PHP parts, but from what I can tell it looks good), but I also assume that part of the "technical approval" at this point may be allowing some more time for discussion on the corresponding p2 post?

Either way, if this gets to the point where you are ready to merge and this is just being held up by not having the 'approved' flag here on github, feel free to ping me for it. I am just holding off now b/c I don't want to move it into the 'Ready to Merge' column before we have the images ready, discussion finished, etc.

@Addison-Stavlo Addison-Stavlo force-pushed the add/wpcom-block-editor-nux branch from 5d278bc to 372675b Compare February 3, 2020 20:52
@Addison-Stavlo
Copy link
Contributor

Rebased+

It looks like Core changed a couple things, so there are still some updates to make for this.

@Addison-Stavlo Addison-Stavlo added [Status] In Progress and removed [Status] Needs Rebase [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 3, 2020
@Addison-Stavlo
Copy link
Contributor

I "think" this is working as intended again. 😄

@Addison-Stavlo Addison-Stavlo added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Feb 4, 2020
@vindl
Copy link
Member

vindl commented Feb 14, 2020

This works as expected in testing, but if we land this the override will be live in production and we still don't show appropriate images for the Dotcom case. What do you think about commenting out the override init to unblock merging of this, and we can enable it once the images are ready?

function load_wpcom_block_editor_nux() {
require_once __DIR__ . '/wpcom-block-editor-nux/class-wpcom-block-editor-nux.php';
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_wpcom_block_editor_nux' );
Copy link
Member

Choose a reason for hiding this comment

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

Related to my other comment, we could temporarily comment this action until Dotcom side of things is ready.

@Addison-Stavlo
Copy link
Contributor

@vindl - Yeah we could do that, and then would we go ahead with merging the diff now as well? (I guess we wouldn't NEED to, but it may be good to have that taken care of) We would also need to comment out some of the subscribers that block the core welcome guide from popping up in this PR, otherwise there would be no welcome guide available at all after it ships.

The other option is re-adding the core images to this and merge it as a replica of the core one for now. That may be more desirable as the 'site-wide' preference would go into effect and the core nux/welcome guide would stop popping up on every new site or clear browser state.

I guess the downside of the second idea is shipping the new nux will force the new guide to pop up on EVERYONE's account the first time they load up the editor after it launches, and that does provide an opportunity to show off whatever 'new' design we will have as opposed to a copy of core's current version.

So I guess it comes down to, would we rather:

  • Move the welcome guide to being an account wide setting sooner rather than later.

or

  • Hold off for the opportunity to 'show off' whatever new design by pairing it with the launch of the account-wide setting?

I guess since we haven't heard much noise about the core Welcome Guide being super annoying since it went live like this, then holding off for the second option might be best. Commenting things out and shipping this the way you mention goes along with that.

@vindl
Copy link
Member

vindl commented Feb 14, 2020

I guess since we haven't heard much noise about the core Welcome Guide being super annoying since it went live like this, then holding off for the second option might be best. Commenting things out and shipping this the way you mention goes along with that.

Since you also prefer this option let's go with it then. I'd try to land both the PR and the diff, but make sure that they don't cause changes in prod behavior now (I haven't checked if we need to comment something out on Dotcom side too but we'll likely have to). Then when we have the designs ready we can flip the switch. That way I think it will require less work to introduce this, instead of keeping this PR open for a long time and going through rebase hell. :)

@Addison-Stavlo
Copy link
Contributor

@vindl - I commented out the loader and tested things out. Things seem to work well and I am thinking this is the only thing we need to comment out on either side (will write another note on the diff). But since all of the apply_filters and do_actions are nested behind the commented out loader, I am thinking shipping the diff without anything commented out makes sense and won't be effected.

Feel free to test!

@simison
Copy link
Member

simison commented Feb 18, 2020

One reason to update to our own would be to just override the link to .org guide with https://en.support.wordpress.com/wordpress-editor/ — but I don't think that's necessarily big need.

@simison
Copy link
Member

simison commented Feb 18, 2020

Just noting that once we enable this, we'll need to update E2E tests to close it.

@vindl
Copy link
Member

vindl commented Feb 18, 2020

@vindl - I commented out the loader and tested things out. Things seem to work well and I am thinking this is the only thing we need to comment out on either side (will write another note on the diff). But since all of the apply_filters and do_actions are nested behind the commented out loader, I am thinking shipping the diff without anything commented out makes sense and won't be effected.

@Addison-Stavlo I retested this and everything seems to work as expected on my end.

@Addison-Stavlo Addison-Stavlo merged commit 6732750 into master Feb 18, 2020
@Addison-Stavlo Addison-Stavlo deleted the add/wpcom-block-editor-nux branch February 18, 2020 16:21
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 18, 2020
@noahtallen
Copy link
Contributor

One reason to update to our own would be to just override the link to .org guide

I just made this change so that it references .com support now in #39846

we'll need to update E2E tests to close it.

However, I did not realize I needed this update because I didn't see any failing e2e tests.... 🤔

@noahtallen
Copy link
Contributor

Even though all of the e2e tests are failing in #39853, it turns out that we already do dismiss the modal in e2e tests:

async dismissEditorWelcomeModal() {
if (
await driverHelper.isElementPresent( this.driver, By.css( '.edit-post-welcome-guide' ) )
) {
await driverHelper.clickWhenClickable(
this.driver,
By.css( '.edit-post-welcome-guide .components-modal__header .components-button' )
);
}
}
}

And these classnames are still correct with what we've just shipped.

@noahtallen
Copy link
Contributor

Turns out the failures are just related to the gutenberg 7.6+ updates. Nothing amiss with the NUX :)

@lancewillett
Copy link
Contributor

Hi team — is there a P2 thread to reference for this project? I'd like to chime in with my own personal experience (and please tell me if there's a better place).

With the core guide I find it very annoying to see the tutorial on every internal P2 site that I change over to the block editor (per user, per site).

How might we only show it once per user (regardless of the site where they are opting in)?

With a typical end user, this might be less of an issue, of course.

@simison
Copy link
Member

simison commented Mar 11, 2020

How might we only show it once per user (regardless of the site where they are opting in)?

That would be a good improvement indeed. Apart from it, and this is not very urgent, we should just hide the welcome modal for internal sites methinks. It doesn't make sense there and is just on the way.

Logged at #40040

@simison
Copy link
Member

simison commented Mar 11, 2020

is there a P2 thread to reference for this project?

Nope, we've tracked this here originally: #38299

It's not much of a project, more of maintenance task to adapt the core feature to .com infra. That kind of adaptations are always related to the process of just keeping Gutenberg plugin up-to-date on .com. Each Gutenberg version bump has its own P2, but this specific feature spans over several version upgrades.

@noahtallen
Copy link
Contributor

@lancewillett let me know if you continue seeing the issue. The option should be persisted to the database as of yesterday, so you should no longer see the welcome modal on other sites if you dismiss it.

@lancewillett
Copy link
Contributor

@noahtallen Cool, thank you! I'll keep an eye out for it happening.

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Mar 12, 2020

@lancewillett - for a p2 about this specifically: pbAok1-qw-p2

This is currently running per user on simple sites, and should be extended to atomic as well with the next release of the FSE plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-enable Gutenberg tips on WordPress.com and update the copy to be specific and relevant for new users.
7 participants