-
Notifications
You must be signed in to change notification settings - Fork 800
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
Update/statuses to make more sense with ownership #38390
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. 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. Videopress plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
2bb9bae
to
710e190
Compare
1737bad
to
02c4512
Compare
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 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' ); |
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! Wow, TIL you can pass a key into getMyJetpackInitialState( key )
! I didn't know that previously. Thanks! 😊
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 yes! @robertsreberski had that idea when we were updating the state in 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.
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
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; |
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.
Clever - this is a nice little text variance that keeps the same CTA action 👍
* | ||
* @return boolean | ||
*/ | ||
public static function is_owned() { |
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.
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; |
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.
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 🤔
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 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; |
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 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; |
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.
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 ) { |
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.
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.
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 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 😄
cb7ab07
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.
Reviewing changes since last review - code LGTM 👍
Proposed changes:
Other information:
Jetpack product discussion
P2: pbNhbs-b6Y-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions:
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