-
Notifications
You must be signed in to change notification settings - Fork 803
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
Add has_required_plan to product info and implement it in Search #22682
Conversation
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 (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
Backup plugin:
|
I wonder about |
Makes sense? |
yes, it seems to be a matter of verb tense :-) |
public static function get_status() { | ||
if ( static::is_active() ) { | ||
$status = 'active'; | ||
if ( ! static::has_required_plan() ) { | ||
$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.
something we've been talking about. I thought.
I though we could check whether the product requires a plan at top of this method:
public static function get_status() { | |
if ( static::is_active() ) { | |
$status = 'active'; | |
if ( ! static::has_required_plan() ) { | |
$status = 'needs_purchase'; | |
} | |
public static function get_status() { | |
if ( ! static::has_required_plan() ) { | |
$status = 'needs_purchase'; | |
} elseif ( static::is_active() ) { | |
$status = 'active'; |
It's ok to me, just wanted to put in code the way that we'll have to take to deal with the product activation flow.
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.
has_required_plan
will return true by default. If the product doesn't need a plan, it will return true.
But I agree that could be useful to have another property that specifically says if the product is free or not
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.
LGTM.
👍
* @return boolean | ||
*/ | ||
public static function has_required_plan() { | ||
return ( new Search_PLan() )->supports_search(); |
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.
Is Search_PLan
a typo? Looks like it ought to be Search_Plan
🙂
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.
wow, I wonder how it didnt throw any errors
Since the Search package is quite big, I wonder if there would be a way to do this without adding the whole package as a new dependency to the My Jetpack package? By doing so, we'll end up shipping the Search feature in multiple standalone features. |
It might be a bit big in MB for the package (around 4,9M?) but it should not influence what's loaded at runtime as it will only load the classes we actually use... We could duplicate some of the things in My Jetpack, but I think in the long each product will provide its own class to handle how it will behave in the My Jetpack page, with all the labels, possible states, actions, etc. Anyway we are still in the early stages. If you think this is a blocker we can think of an alternative, otherwise it seems like a good way to go for now. |
@jeherve I'm giving it a second thought, maybe it's not a bad idea to just copy and paste what we need for the MVP, and hold more dependencies and abstractions for later. Also, the Search package is still under development and might change and break things: p1644012854589339-slack-C82FZ5T4G?thread_ts=1644003501.536539&cid=C82FZ5T4G So I'll probably revisit it and exclude the dependency |
This PR starts to check whether the site's current plan (or purchase) supports the product.
The first product we are checking is "Search", by using the search package.
Changes proposed in this Pull Request:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
N/A
Testing instructions:
myJetpackInitialState
varhas_required_plan
equalstrue
except from Searchtrue