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

Coming Soon: check to see if the ETK plugin is installed and hide the setting if so #47569

Merged
merged 5 commits into from
Nov 23, 2020

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Nov 19, 2020

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

Screen Shot 2020-11-19 at 2 36 03 pm

The badge should be visible when Coming Soon mode is on

Screen Shot 2020-11-19 at 3 18 11 pm

Now deactivate the plugin

Screen Shot 2020-11-19 at 2 36 09 pm

Return to the settings page: http://calypso.localhost:3000/settings/general/{your_site}?flags=coming-soon-v2

You should see the following

Screen Shot 2020-11-19 at 7 20 44 pm

And the badge should be gone

Screen Shot 2020-11-19 at 3 17 39 pm

Switch to a simple site

Ensure that Coming Soon mode is working and you can toggle it on and off.

@ramonjd ramonjd added [Feature] Site Settings All other general site settings. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Plugins Features related to plugins on WordPress.com, including search, management, and installation. Coming Soon labels Nov 19, 2020
@ramonjd ramonjd requested a review from a team November 19, 2020 04:19
@ramonjd ramonjd self-assigned this Nov 19, 2020
@matticbot
Copy link
Contributor

@ramonjd ramonjd requested a review from roo2 November 19, 2020 04:21
@matticbot
Copy link
Contributor

matticbot commented Nov 19, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~10689 bytes added 📈 [gzipped])

name                    parsed_size           gzip_size
settings                    +6253 B  (+1.2%)    +1504 B  (+1.1%)
zoninator                    +626 B  (+0.2%)     +167 B  (+0.2%)
wp-super-cache               +626 B  (+0.3%)     +167 B  (+0.3%)
woocommerce                  +626 B  (+0.0%)     +167 B  (+0.0%)
themes                       +626 B  (+0.2%)     +167 B  (+0.2%)
theme                        +626 B  (+0.2%)     +167 B  (+0.2%)
stats                        +626 B  (+0.1%)     +167 B  (+0.1%)
sites                        +626 B  (+0.7%)     +167 B  (+0.6%)
site-purchases               +626 B  (+0.1%)     +167 B  (+0.1%)
site-blocks                  +626 B  (+0.2%)     +167 B  (+0.2%)
settings-writing             +626 B  (+0.1%)     +167 B  (+0.1%)
settings-security            +626 B  (+0.2%)     +167 B  (+0.2%)
settings-performance         +626 B  (+0.1%)     +167 B  (+0.1%)
settings-jetpack             +626 B  (+0.3%)     +167 B  (+0.2%)
settings-discussion          +626 B  (+0.2%)     +167 B  (+0.2%)
sensei                       +626 B  (+0.6%)     +167 B  (+0.5%)
security                     +626 B  (+0.1%)     +167 B  (+0.1%)
scan                         +626 B  (+0.2%)     +167 B  (+0.2%)
reader                       +626 B  (+0.1%)     +167 B  (+0.1%)
purchases                    +626 B  (+0.1%)     +167 B  (+0.1%)
privacy                      +626 B  (+0.2%)     +167 B  (+0.2%)
preview                      +626 B  (+0.4%)     +167 B  (+0.4%)
posts-custom                 +626 B  (+0.2%)     +167 B  (+0.2%)
posts                        +626 B  (+0.2%)     +167 B  (+0.2%)
plugins                      +626 B  (+0.1%)     +167 B  (+0.1%)
plans                        +626 B  (+0.1%)     +167 B  (+0.1%)
people                       +626 B  (+0.2%)     +167 B  (+0.2%)
pages                        +626 B  (+0.2%)     +167 B  (+0.2%)
notification-settings        +626 B  (+0.2%)     +167 B  (+0.2%)
migrate                      +626 B  (+0.4%)     +167 B  (+0.4%)
media                        +626 B  (+0.1%)     +167 B  (+0.1%)
me                           +626 B  (+0.2%)     +167 B  (+0.2%)
marketing                    +626 B  (+0.1%)     +167 B  (+0.1%)
jetpack-connect              +626 B  (+0.1%)     +167 B  (+0.1%)
jetpack-cloud-settings       +626 B  (+0.3%)     +167 B  (+0.3%)
jetpack-cloud                +626 B  (+0.7%)     +167 B  (+0.6%)
import                       +626 B  (+0.3%)     +167 B  (+0.2%)
hosting                      +626 B  (+0.2%)     +167 B  (+0.2%)
home                         +626 B  (+0.1%)     +167 B  (+0.1%)
help                         +626 B  (+0.1%)     +167 B  (+0.1%)
hello-dolly                  +626 B  (+0.6%)     +167 B  (+0.5%)
happychat                    +626 B  (+0.2%)     +167 B  (+0.2%)
gutenberg-editor             +626 B  (+0.1%)     +167 B  (+0.1%)
google-my-business           +626 B  (+0.2%)     +167 B  (+0.2%)
export                       +626 B  (+0.3%)     +167 B  (+0.3%)
email                        +626 B  (+0.2%)     +167 B  (+0.2%)
earn                         +626 B  (+0.2%)     +167 B  (+0.2%)
domains                      +626 B  (+0.1%)     +167 B  (+0.1%)
customize                    +626 B  (+0.3%)     +167 B  (+0.3%)
concierge                    +626 B  (+0.2%)     +167 B  (+0.2%)
comments                     +626 B  (+0.1%)     +167 B  (+0.1%)
checkout                     +626 B  (+0.0%)     +167 B  (+0.0%)
backup                       +626 B  (+0.1%)     +167 B  (+0.1%)
activity                     +626 B  (+0.1%)     +167 B  (+0.1%)
account-close                +626 B  (+0.2%)     +167 B  (+0.2%)
account                      +626 B  (+0.2%)     +167 B  (+0.2%)

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])

name                                                 parsed_size           gzip_size
async-load-calypso-blocks-inline-help-popover            +9984 B  (+2.6%)    +1628 B  (+1.6%)
async-load-signup-steps-site-picker                       +626 B  (+1.0%)     +167 B  (+0.9%)
async-load-design-blocks                                  +626 B  (+0.0%)     +167 B  (+0.0%)
async-load-calypso-components-web-preview-component       +626 B  (+0.1%)     +167 B  (+0.1%)
async-load-calypso-components-sites-popover               +626 B  (+1.0%)     +167 B  (+0.9%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@andrewserong
Copy link
Member

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?

@andrewserong
Copy link
Member

andrewserong commented Nov 20, 2020

Screenshot of the UI for me after de-activating the plugin while it's set to Coming Soon mode. Note that it looks like it displays as "Private" but still has the Coming Soon badge... (The front end of the site displays the Coming Soon screen)

image

@ramonjd
Copy link
Member Author

ramonjd commented Nov 20, 2020

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 ?flags=coming-soon-v2 we should only be toggling Coming Soon mode 2

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)

Copy link
Member

@andrewserong andrewserong left a 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
Copy link
Member

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!)

Copy link
Member Author

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.

Copy link
Member

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 🤔

Copy link
Member Author

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 } />

Copy link
Member

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 😅

Copy link
Member Author

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?

Copy link
Member

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!

Copy link
Member Author

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. 🙇

@ramonjd ramonjd force-pushed the add/jetpack-query-plugins-check-for-etk branch from 1059554 to 45d0844 Compare November 20, 2020 10:00
@matticbot
Copy link
Contributor

Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

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

Copy link
Collaborator

@wp-desktop wp-desktop left a comment

Choose a reason for hiding this comment

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

WordPress Desktop CI Failure for job "wp-desktop-mac".

@ramonjd please inspect this job's build steps for breaking changes at this link. For temporal failures, you may try to "Rerun Workflow from Failed".

Please also ensure this branch is rebased off latest Calypso.

@ramonjd ramonjd force-pushed the add/jetpack-query-plugins-check-for-etk branch from 45d0844 to 0caccaf Compare November 20, 2020 10:18
@sarayourfriend sarayourfriend changed the base branch from master to trunk November 20, 2020 16:10
@ramonjd ramonjd force-pushed the add/jetpack-query-plugins-check-for-etk branch from 655adbb to a6a633c Compare November 21, 2020 08:23
…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
repurposing the selector so that it tells us if a site is atomic and the ETK is not available
it's not needed
@ramonjd ramonjd force-pushed the add/jetpack-query-plugins-check-for-etk branch from a6a633c to 5d3b041 Compare November 22, 2020 22:52
@ramonjd ramonjd added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 22, 2020
@ramonjd ramonjd merged commit 3b5178d into trunk Nov 23, 2020
@ramonjd ramonjd deleted the add/jetpack-query-plugins-check-for-etk branch November 23, 2020 00:19
@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 Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Coming Soon [Feature] Plugins Features related to plugins on WordPress.com, including search, management, and installation. [Feature] Site Settings All other general site settings. [Pri] Normal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants