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

Update/statuses to make more sense with ownership #38390

Merged
merged 10 commits into from
Jul 22, 2024

Conversation

CodeyGuyDylan
Copy link
Contributor

@CodeyGuyDylan CodeyGuyDylan commented Jul 17, 2024

Proposed changes:

  • Update statuses to avoid showing the "Learn More/Inactive" state when a product is "owned"
  • If product is owned, allow activation if there is a free offering that does not require a plan
  • If product is owned but requires a plan (even a free one) show a "Needs plan" status with a "Get plan" CTA
  • If product needs first site connection, but product is owned, show a "Needs Connection" status with the CTA of "Connect" instead of "Learn More/Inactive"

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

P2: pbNhbs-b6Y-p2

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  1. Create a new JN site with Jetpack Beta installed (no Jetpack plugin)
  2. Activate Jetpack Protect with this branch
  3. Deactivate the Akismet plugin
  4. Go to My Jetpack and confirm you see Protect with the status of "Needs Connection" and a CTA of "Connect" with Akismet being "Inactive" but with the option to "Activate"
    image
  5. Activate the base Jetpack plugin with this branch and install the Jetpack VaultPress Backup standalone plugin. Make sure you see the new "Needs Plan" status with the CTA of "Get plan"
    image
  6. Install the Boost plugin and make sure you see the option to Activate Boost in My Jetpack
    image
  7. Connect your site and make sure the statuses look correct
    image
  8. Now connect your user and make sure they still look correct
    image
  9. Uninstall Jetpack Protect and add a paid plan for it from SA and make sure you see the "Needs plugin" status
    image
  10. Try activating some of the plugins (such as Boost) and make sure they remain active
    image
  11. Try disconnecting your user account and activating a plugin that requires a user connection and make sure the card updates to needing a connection
    image

Statuses have a lot of different scenarios, so I can't account for all of them here so feel free to play around and try out anything you can think of

Copy link
Contributor

github-actions bot commented Jul 17, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the update/statuses-to-make-more-sense-with-ownership branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/statuses-to-make-more-sense-with-ownership
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Jul 17, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Videopress plugin:

  • Next scheduled release: August 6, 2024.
  • Scheduled code freeze: July 29, 2024.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Tests] Includes Tests labels Jul 17, 2024
@CodeyGuyDylan CodeyGuyDylan force-pushed the update/statuses-to-make-more-sense-with-ownership branch from 2bb9bae to 710e190 Compare July 17, 2024 21:06
@github-actions github-actions bot added [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. Docs E2E Tests [Plugin] Dumb Videopress labels Jul 17, 2024
@CodeyGuyDylan CodeyGuyDylan force-pushed the update/statuses-to-make-more-sense-with-ownership branch from 1737bad to 02c4512 Compare July 17, 2024 21:28
Copy link
Contributor

@elliottprogrammer elliottprogrammer left a comment

Choose a reason for hiding this comment

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

This tested very good, as described. Code looks good and reasonable. I don't see any issues.
LGTM! 👍

@@ -88,12 +75,13 @@ const ProductCard = inprops => {
onMouseLeave,
} = props;

const { ownedProducts } = getMyJetpackWindowInitialState( 'lifecycleStats' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh! Wow, TIL you can pass a key into getMyJetpackInitialState( key )! I didn't know that previously. Thanks! 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes! @robertsreberski had that idea when we were updating the state in My Jetpack 😃

jboland88
jboland88 previously approved these changes Jul 19, 2024
Copy link
Contributor

@jboland88 jboland88 left a comment

Choose a reason for hiding this comment

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

This LGTM - it tested well. Overall, I think the statuses are more clear as a result of the change. It seems more clear what to do to get each product to "Active".

I had a few notes, but no blockers.

I noticed when clicking "Activate" on Boost - the status did not update to "Active" without me reloading the page. Let's add a separate maintenance item to follow up there.

Not for this PR, but would be nice to have upgrade and view options for Creator as well
Screenshot 2024-07-19 at 5 25 30 PM

label: __( 'Learn more', 'jetpack-my-jetpack' ),
onClick: onAdd,
...( primaryActionOverride &&
PRODUCT_STATUSES.NEEDS_FIRST_SITE_CONNECTION in primaryActionOverride &&
primaryActionOverride[ PRODUCT_STATUSES.NEEDS_FIRST_SITE_CONNECTION ] ),
};
case PRODUCT_STATUSES.NEEDS_PURCHASE: {
const getPlanText = __( 'Get plan', 'jetpack-my-jetpack' );
const learnMoreText = __( 'Learn more', 'jetpack-my-jetpack' );
const buttonText = isOwned ? getPlanText : learnMoreText;
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever - this is a nice little text variance that keeps the same CTA action 👍

*
* @return boolean
*/
public static function is_owned() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice - I like that this is a method on the product now.

@@ -472,19 +496,19 @@ public static function get_status() {
// However if the standalone plugin for this product is active, then we will defer to showing errors that prevent the module from being active
// This is because if a standalone plugin is installed, we expect the product to not show as "inactive" on My Jetpack
if ( static::$requires_plan || ( ! static::has_any_plan_for_product() && static::$has_standalone_plugin && ! self::is_plugin_active() ) ) {
$status = static::$has_free_offering ? Products::STATUS_NEEDS_PURCHASE_OR_FREE : Products::STATUS_NEEDS_PURCHASE;
$status = static::is_owned() && static::$has_free_offering && ! static::$requires_plan ? Products::STATUS_NEEDS_ACTIVATION : Products::STATUS_NEEDS_PURCHASE;
Copy link
Contributor

Choose a reason for hiding this comment

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

So in this case, I suppose "NEEDS_PURCHASE" will mean it needs a plan of some kind, even if that purchase is $0?

It would be good to document what we mean by "NEEDS_PURCHASE" so folks don't assume it's only paid stuff.

We could refactor it to be "NEEDS_PLAN" or something else more descriptive in a later iterations 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is correct, and I think you're right. NEEDS_PLAN would probably be a better name for this. I'll go ahead and update that in this PR since I'm already updating one of the status names

@@ -455,7 +479,7 @@ public static function get_status() {
if ( static::$requires_site_connection && ! ( new Connection_Manager() )->is_connected() ) {
// Site has never been connected before
if ( ! Jetpack_Options::get_option( 'id' ) ) {
$status = Products::STATUS_NEEDS_FIRST_SITE_CONNECTION;
$status = static::is_owned() ? Products::STATUS_SITE_CONNECTION_ERROR : Products::STATUS_NEEDS_FIRST_SITE_CONNECTION;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you mean about the conditionals getting insane here 😅

You could potentially add && !static::is_owned to the if statement above to remove the ternary if here - slightly cleaner.

} elseif ( static::$requires_site_connection && ! ( new Connection_Manager() )->is_connected() ) {
// Site has never been connected before
if ( ! Jetpack_Options::get_option( 'id' ) ) {
$status = Products::STATUS_NEEDS_FIRST_SITE_CONNECTION;
$status = static::is_owned() ? Products::STATUS_SITE_CONNECTION_ERROR : Products::STATUS_NEEDS_FIRST_SITE_CONNECTION;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, you might be able to add !static::is_owned() to the containing if condition to remove the need for the ternary

@@ -176,23 +176,16 @@ public static function get_products() {
* @return array
*/
public static function get_products_by_ownership( $type ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR directly - but this is a method that we should avoid calling outside of the My Jetpack context. Even though we don't load the full product array by calling get_products, the get_status call is still going to do checks for the presence of plans by sending requests to WPCOM.

That should be fine in the context of My Jetpack where we have already loaded products once and cached the results for that request lifecycle. But if we call this elsewhere, it will likely end up making some unintended API requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I also had that in mind 😅 Fortunately we really only need this for the segmentation of the products (for now) so we should be okay 😄

Copy link
Contributor

@jboland88 jboland88 left a comment

Choose a reason for hiding this comment

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

Reviewing changes since last review - code LGTM 👍

@CodeyGuyDylan CodeyGuyDylan merged commit a6a641f into trunk Jul 22, 2024
70 checks passed
@CodeyGuyDylan CodeyGuyDylan deleted the update/statuses-to-make-more-sense-with-ownership branch July 22, 2024 17:53
@github-actions github-actions bot removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jul 22, 2024
@github-actions github-actions bot added this to the videopress/1.7.0 milestone Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs E2E Tests [Package] My Jetpack [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants