-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
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. |
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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, {} ); |
There was a problem hiding this comment.
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) ?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 😭
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. |
Gotcha! Ok. 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. |
5d278bc
to
372675b
Compare
Rebased+ It looks like Core changed a couple things, so there are still some updates to make for this. |
I "think" this is working as intended again. 😄 |
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' ); |
There was a problem hiding this comment.
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.
@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:
or
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. :) |
@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 Feel free to test! |
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. |
Just noting that once we enable this, we'll need to update E2E tests to close it. |
@Addison-Stavlo I retested this and everything seems to work as expected on my end. |
I just made this change so that it references .com support now in #39846
However, I did not realize I needed this update because I didn't see any failing e2e tests.... 🤔 |
Even though all of the e2e tests are failing in #39853, it turns out that we already do dismiss the modal in e2e tests: wp-calypso/test/e2e/lib/gutenberg/gutenberg-editor-component.js Lines 433 to 443 in 8cb9bff
And these classnames are still correct with what we've just shipped. |
Turns out the failures are just related to the gutenberg 7.6+ updates. Nothing amiss with the NUX :) |
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. |
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 |
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. |
@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. |
@noahtallen Cool, thank you! I'll keep an eye out for it happening. |
@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. |
Changes proposed in this Pull Request
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.
It's the first time, so it's expected to show up even if we had previously dismissed the Core NUX already.
Fixes #38299 & #39320