-
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
Coming Soon: check to see if the ETK plugin is installed and hide the setting if so #47569
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~10689 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~2296 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
The UI behaviour in this PR is testing nicely for me, thanks for putting it together! There's a bit of behaviour that I'm finding confusing, though when activating / deactivating the plugin. If my test site https://andysfakeatomicsite.wpcomstaging.com/ is set to Coming Soon mode, and then I deactivate the plugin, when I request https://andysfakeatomicsite.wpcomstaging.com/ I still get the Coming Soon page. So it looks like Coming Soon is still working somehow? Is this it falling back to Coming Soon v1? |
Firstly, thanks for testing this one @andrewserong 🙇 I didn't see that in my testing, which doesn't mean that it's not true :) So long as the flag exists on the setting page If that flag isn't there, even once, it will use v1. Just guessing, but maybe it's the reason behind what you're seeing here too? #47569 (comment) |
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.
These UI changes are testing well for me with both a simple site, and an Atomic site with the ETK plugin active, and then with it deactivated. The concerns about unusual behaviour appear to be due to known and unrelated issues 👍
Just left a comment about forceRefresh
because I couldn't see how it was changing anything, but otherwise LGTM!
if ( isEqual( nextProps.siteIds, this.props.siteIds ) ) { | ||
if ( | ||
isEqual( nextProps.siteIds, this.props.siteIds ) || | ||
nextProps.forceRefresh === this.props.forceRefresh |
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.
This change looks fine to me, but I can't see forceRefresh
referenced elsewhere in the PR. What does this change do? Are we passing in forceRefresh
to QueryJetpackPlugins
anywhere? (I might have missed something obvious!)
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.
What does this change do?
It's a hacky way of getting around isEqual( nextProps.siteIds, this.props.siteIds )
. The siteIds barely ever change in a single Calypso session and therefore the query component will never perform another fetch to get the plugin list.
Are we passing in forceRefresh to QueryJetpackPlugins anywhere?
No, but we could! :P
Once I got it working I stopped asking questions.
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.
@ramonjd just thinking, could this have an unintended side-effect that if the list of siteIds changes but forceRefresh
remains unchanged, then it won't refresh, when it usually should? From taking a second look at this change, it seems like it'll result in fewer refreshes for fetching plugins, rather than more 🤔
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.
From taking a second look at this change, it seems like it'll result in fewer refreshes for fetching plugins, rather than more
Hmmm. What do you think we could better here?
I was thinking that forceRefresh could work like:
const forceRefresh = needToRefresh ? true : false;
...
< QueryJetpackPlugins forceRefresh={ forceRefresh } />
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.
Should the logic be something like:
if (
isEqual( nextProps.siteIds, this.props.siteIds ) &&
! nextProps.forceRefresh
) {
That way, if forceRefresh
is set, then it won't skip refreshing just because the siteIds match? The only problem there is you then need to know when to switch forceRefresh
to false
or it'll just keep refreshing when the props change (which mightn't be all that frequent, so maybe it's fine?)
I see in #46070 for notifications, they went with the approach of storing in state e.g. didForceRefresh
and setForceRefresh
so that it isn't constantly switched on to true
. This might be a bit overkill for us, here.
Alternately, do we need this change to <QueryJetpackPlugins
in this PR? I don't think it's doing anything currently because we're not passing forceRefresh
to it from the settings page, so perhaps it could be skipped? Or is this needed for a follow-up change? If we do need the change, then we might want to do a quick smoke test of the other places <QueryJetpackPlugins>
is used, just to be sure.
Apologies if I'm being overly cautious! I just realised that I didn't quite know as much about how this component is used as I thought I did when I started reviewing 😅
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.
You're right. It's best to be sure.
I don't think it's doing anything currently because we're not passing forceRefresh to it from the settings page, so perhaps it could be skipped? Or is this needed for a follow-up change?
I wasn't planning on doing anything really. I did smoke test the other pages, e.g., activity-log
and it still runs once over there.
Alternately, do we need this change to <QueryJetpackPlugins in this PR?
We need it for the functionality in this PR to work at all. We could extract it into another PR, which would have to be merged first.
I see in #46070 for notifications, they went with the approach of storing in state e.g. didForceRefresh and setForceRefresh so that it isn't constantly switched on to true. This might be a bit overkill for us, here.
Thanks for looking into that. It would be nice to have. Maybe in a follow up? Or do you think we should defend ourselves first?
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.
We need it for the functionality in this PR to work at all.
Ah, gotcha. Because I couldn't see forceRefresh
passed in anywhere, I wasn't sure if it was needed. If it gets it working, then I say go for it!
I think if it's enabled the PR to work the way we expect, and if it isn't causing any trouble for the other uses of QueryJetpackPlugins
, then I'd just double-check that it's firing when you expect it to and merge it in. Any of the other improvements we can totally do as follow-ups if we run into any issues 👍
Thanks for your patience with this review!
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.
Because I couldn't see forceRefresh passed in anywhere, I wasn't sure if it was needed.
Andy, your reason strikes again... for the good of the world!
I don't need it. I was hallucinating. Thanks for such a thorough review and for discussing this.
Reverting, and merging without. 🙇
1059554
to
45d0844
Compare
Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com D53081-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing the Editing Toolkit Plugin for more info: PCYsg-ly5-p2 |
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.
45d0844
to
0caccaf
Compare
655adbb
to
a6a633c
Compare
…omic/jetpack sites updated setting form to display warning that etk is disabled Ensuring that we run the plugins query refresh every time the component is called, not just when the siteid list changes
Also remove the site badge
repurposing the selector so that it tells us if a site is atomic and the ETK is not available
it's not needed
… coming soon mode
a6a633c
to
5d3b041
Compare
Changes proposed in this Pull Request
Hi friends!
Because the new coming soon functionality lives in the WordPress.com Editing Toolkit, if an Atomic users wishes to deactivate or delete that plugin we don't wish to allow them to toggle Coming Soon in the WPCOM settings (because it won't have any effect!)
So we're going to hide the coming soon option when the ETK plugin is disabled/deleted.
Testing instructions
Create an Atomic site by upgrading to Business/Ecommerce
Check that the WordPress.com Editing Toolkit plugin is installed and activated at {your_site}/wp-admin/plugins.php?plugin_status=all&paged=1&s
Head over to http://calypso.localhost:3000/settings/general/{your_site}?flags=coming-soon-v2
You should be able to toggle Coming Soon mode
The badge should be visible when Coming Soon mode is on
Now deactivate the plugin
Return to the settings page: http://calypso.localhost:3000/settings/general/{your_site}?flags=coming-soon-v2
You should see the following
And the badge should be gone
Switch to a simple site
Ensure that Coming Soon mode is working and you can toggle it on and off.