-
Notifications
You must be signed in to change notification settings - Fork 812
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
My Jetpack: Add red bubble and notice when paid plan needs plugin install or activation. #41013
My Jetpack: Add red bubble and notice when paid plan needs plugin install or activation. #41013
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Protect plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
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 am not sure why, but when running through the testing instructions with 0 standalone plugins installed, I am only seeing "CRM" as a missing plugin, not Boost
After clicking the CTA, just as described, the banner disappears after installing the plugins (FYI it also only installed CRM, not Boost). I think this could be jarring for users. Like ".... okay? did it work?" I think it would be much better for the user experience if we had a success message after letting them know the plugins were installed. I see that this PR is pretty large already, if you'd like to handle that separately I think that'd be okay
I found a bug during testing, and I can't really tell what it causing it from the browser testing site as it seems to be PHP related. I get a critical error like this:
Steps to reproduce:
- Uninstall main Jetpack plugin
- Install standalone Boost plugin
- With the beta tester, checkout this branch for the Boost plugin
- Go to My Jetpack
I tried these steps with the stable version of boost and it's not happening so I assume it has to do with this PR. There could be other similar situations where this error takes place, I haven't yet tested all possibilities
public static function activate_multiple_products( $request ) { | ||
$products_array = $request->get_param( 'products' ); | ||
|
||
foreach ( $products_array as $product_slug ) { |
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 have some thoughts on the notion that we need to create separate plugin endpoints for activating multiple products like this 🤔
If we had a function to bulk activate or install plugins without requiring multiple actions, I would understand it. However, it looks like here we are essentially doing the same thing as activate_product
with the only difference being we are looping through an array of product slugs instead of just handling one product slug.
I could be missing something that makes my approach not the best way to go, but I think it may be better to alter the activate_product
endpoint to optionally accept multiple products. It may require a re-naming to just activate_products
but I think it would simplify the changes on the backend by a lot, and then on the front-end we wouldn't need the new hooks that handle multiple products that and calls a different endpoint. Let me know what you think of this, hopefully that could make this PR much smaller and simpler 😄
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.
Thanks @CodeyGuyDylan ! Yeah I agree it would be ideal to have a shared endpoint for activating either 1 product or multiple products, but the way the My Jetpack REST endpoints are currently set up are:
Activate endpoint:
Path: /my-jetpack/v1/site/products/{PRODUCT_SLUG}
If it's a GET request: get_product()
If it's a POST request: activate_product()
if it's a DELETE request: deactivate_product()
Install endpoint:
Path: /my-jetpack/v1/site/products/{PRODUCT_SLUG}/install-standalone
So as you can see, the the endpoint route/path takes in 1 product_slug as part of the endpoint path.
Therefore I don't see how we can use that endpoint for doing anything with multiple products because we can't put multiple product slugs into the endpoint route/path, unless I'm missing something, let me know.
So that's why I had to create new endpoints. I'm not sure how else I could do it.
Thanks for reviewing @CodeyGuyDylan!
The bug was fixed in: #41192
Hmm, that is really strange, I'm not able to reproduce that. The only think I can think to do is maybe try a new JN site? 🤷♂️ Or maybe it has something to do with the bug mentioned above (that is now fixed)?
I added a Global Notice (a toast/snackbar popup) after the CTA action (plugins installed/activated) completes successfully. Let me know if this improves the user experience the way you had in mind.
I responded to this in the inline code comments. Let me know your thoughts. 🙂 |
@CodeyGuyDylan, I've refactored and cleaned up the My Jetpack Product endpoints, allowing them to act upon multiple products, and removed any endpoints that were strictly limited to acting upon only a single product, then updated the front-end to work with these changes. Also updated PHP tests. |
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 looks very good!
I did find one strange bug where the Jetpack plugin shows up twice as needing installed
Steps to reproduce
- Install only the Jetpack Boost standalone plugin
- Purchase Jetpack Complete
- Go to My Jetpack
Not sure what's causing that, but perhaps a check to make sure every item in the list is unique would fix it? FYI the activation of the plugins does still work, so that's a plus 😄
I left 2 other comments, one being very minor, but thank you for doing the work to update this PR. I think it's looking great and is almost ready
return isPluginActive; | ||
}; | ||
|
||
const useActivatePlugins = ( productIds: string[] ) => { |
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 think a QOL improvement for developers would be to allow either the string[]
or string
type, and just convert the string to an array automatically if it is not already one. That way we don't have to pass in [ slug ]
everywhere we activate only one plugin at a time. Same with the useInstallPlugins
and useProducts
hooks. Do you think that would be a good idea?
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.
Yes, thats a good idea, thanks! 👍
|
||
$response = $this->server->dispatch( $request ); | ||
$data = $response->get_data(); | ||
print_r( $data ); |
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 think we have a leftover testing line here 😄
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.
Oops, thanks for catching that!
@CodeyGuyDylan, Thanks again for reviewing and for your feedback!
I really appreciate all your time, attention, and effort with reviewing this PR (and all the PR's of this project!) 🙌 |
Code Coverage SummaryCoverage changed in 7 files. Only the first 5 are listed here.
6 files are newly covered. Only the first 5 are listed here.
|
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'm getting an issue where, if I have Complete and only Boost installed, I click the CTA and it doesn't install all the plugins it listed out in the banner. It seemed to stop after it downloaded the main Jetpack plugin. Then when I uninstall that, the banner shows me the main plugin plus the standalone's it didn't install last time. I don't think this is blocking as all the products will work (as far as I can tell) after clicking the CTA and the banner will go away.
sprintf( | ||
/* translators: %s is the word "Plugin" or "Pluigns" (singular or plural). */ | ||
__( '%s installed successfully!', 'jetpack-my-jetpack' ), | ||
products?.length === 1 ? products[ 0 ].title : __( 'Plugins', 'jetpack-my-jetpack' ) |
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.
Would it be possible to update the plural strings to account for localization? Instead of "'%s installed successfully!", we would prefer 2 strings or a proper plural:
- plugin installed successfully!
- plugins installed successfully!
In many languages, the words will need to change depending on whether the word "plugin" is singular or plural.
There are many instances of this in this PR. If it's not changed, some languages will not read correctly.
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.
Hey @emilyaudela 👋!
Thanks for your feedback! Yes! Thank you! I'll get it fixed asap. 👍🙂
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.
Oh wait... yeah the translation comment is incorrect. The %s
is not the word "Plugin" or "Plugins", but rather %s
is the Jetpack product name, i.e.- VaultPress Backup or Boost or Social or Search or VideoPress, etc. if it's in the singular context, or %s
is the word "Plugins" if it's in the plural context.
So yeah, anyway still, I'll fix the translation comment and make it 2 separate strings (or proper plural, whichever seems to be the best approach). 👍
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've created PR #41756 which separates the above translations into separate strings.
This PR adds a red-bubble and notice-banner when the site detects that a paid plan provides features to a plugin (or multiple plugins) that are not installed and/or activated. The notice recommends that the plugin(s) should be installed and/or activated and provides a CTA to install and activate all in one click.
To summarize, basically it adds a red-bubble and notice for missing plugins that are needed for purchased products to work. See screenshot:
Fixes: https://github.com/Automattic/jetpack-roadmap/issues/1393
Fixes: #35593
Other information:
Jetpack product discussion
Project Thread - pbNhbs-bJN-p2
Github Task - https://github.com/Automattic/jetpack-roadmap/issues/1393
Does this pull request change what data or activity we track or use?
No
Testing instructions: