Repository navigation
Conversation
This is an automated check which relies on |
Oh, I thought this is already visible in the block picker even on the free plan? I might be wrong, would be good to double-check tho. |
brbrr
left a comment
There was a problem hiding this comment.
It works well in my tests, although Recurring Payments require any paid plan. Any reason we ask for Premium instead of Personal here?
That's the issue: The logic that adds the Upgrade Nudge only kicks in if the block is reported as unavailable because of a missing plan. |
Good point -- my bad 😅 I'll fix. |
|
Works, I see this as expected: When I press "connect to stripe" (instead of upgrade banner), I get to stripe flow which lands me at:
Note no success banner or CTA button here. If we ship this iteration, I think we need to prepare a temporary solution for Calypso side first:
... or just orchestrate more PRs and changes ready before deploying. After connecting to stripe, I was able to modify the block: As per conversation at p7rd6c-22L-p2#comment-2748 , let's do more testing around that to ensure nothing breaks before shipping this. |
chriskmnds
left a comment
There was a problem hiding this comment.
Some minor comments from own curiosity.
| /** | ||
| * Register the Recurring Payments Gutenberg block | ||
| */ | ||
| public function register_gutenberg_block() { |
There was a problem hiding this comment.
The name (register_gutenberg_block) feels a little generic vs the enclosed logic that only deals with a particular block (recurring-payments). I presume this is likely going to evolve into a more general block registration handler (?).
That said, is the underlying logic here a little specific for a general memberships class (or what appears to be)? I prefer to decouple things like these early on if that's the case. Fear being, it can get cluttered with specific block type references sooner than later, and harder to refactor later (or nobody bothers to do so). I do see the class is only a few months old though, so it probably makes sense for v1. 🤔
Just curious on perspective - and the little I understand so far. :-)
p.s. I guess there is the option of moving "block registration" to a trait as an intermediate solution.
There was a problem hiding this comment.
The name (
register_gutenberg_block) feels a little generic vs the enclosed logic that only deals with a particular block (recurring-payments).
Hmm, I was thinking of this method to mean "register this Jetpack module's Gutenberg block". I didn't really want to do a method named register_xyz_gutenberg_block inside of a class named XYZ, that seemed to redundant. (Okay, in this case, it would probably be Jetpack_Memberships::register_recurring_payments_gutenberg_block() rather than Jetpack_Memberships::register_memberships_gutenberg_block(), but I'd argue that memberships and recurring_payments are mostly used synonymously in this file (and that the fact that two names exist for the same thing is mostly circumstantial).
I presume this is likely going to evolve into a more general block registration handler (?).
I didn't intend to evolve it into somehting more general, TBH. The logic driving whether a block should be registered, or whether it should be set as unavailable, and for what reason, is something fairly specific to each individual block.
That said, is the underlying logic here a little specific for a general memberships class (or what appears to be)? I prefer to decouple things like these early on if that's the case. Fear being, it can get cluttered with specific block type references sooner than later, and harder to refactor later (or nobody bothers to do so). I do see the class is only a few months old though, so it probably makes sense for
v1.Just curious on perspective - and the little I understand so far. :-)
p.s. I guess there is the option of moving "block registration" to a trait as an intermediate solution.
I agree in principle; but as stated above, I'm not sure we can make things a lot more homogenous here. We have fairly indidivual Jetpack modules (a somewhat legacy concept) each of which does things quite differently, and we often have to find the best place to register the corresponding block (or set their (un)availability).
I've so far considered the jetpack_register_block() and Jetpack_Gutenberg::set_extension_unavailable our interface; modules can essentially use them at whatever point into their lifecycle (as long as it's soon enough for the consumer -- mostly the REST API -- to get accurate information). I guess for the purpose of the required plan check, we could require each module to provide information about the minimum plan it nees, and evaluate that information and register/set availability based on that.
But this is complicated by the heterogenity of modules themselves. Note that not all modules come with a block; and not all blocks are tied to a module. Furthermore, a lot of modules exist both on JP and WP.com, but are implemented differently in both places.
And finally, there are other criteria besides required plan that can determine whether or not to show a block as available.
(That turned out a bit verbose 😅 I hope I didn't squash that -- commendable! -- idea of better consistency. If I'm beside the point, or if you had any other idea on how to do this, please let me know!)
There was a problem hiding this comment.
Well, this was an excellent overview writeup of the problem space to explain the why's of the current setup. :-)
Would some of it deserve a place in the docs?
There was a problem hiding this comment.
Verbose is good. Thanks for the extra clarifications! :-)
I think the "modules" folder is a bit of a scary place for one to be (glad to see you mentioning "legacy" above)!
I can see this is following along how simple-payments is registering blocks. What I find missing I think is a contract binding these on common characteristics, or some abstraction of the things they do in common (which they apparently do - registering blocks for one). I believe you implied that in your answer above.
if you had any other idea on how to do this, please let me know!
I don't, concretely, but I can throw some likely obvious ideas.
Modules seems to be an all-encompassing folder here - so I guess I would start with that - add some structure to the things we know (in this case, "modules that register blocks"). I think I would approach this along these lines:
Centralise the common logic elsewhere - provide a "yet another module" to handle block registration. I think I'd be happy if a module that registers a block defines some options for that block and only registers an action that takes care of the rest e.g.
- define block options in the respective module (to be worked out in form, obviously):
class Simple_Payments {
...
const OPTIONS = array( name => "simple-payments", ... );
- pass a callback to the action hooks:
class Simple_Payments {
...
private function register_init_hooks() {
add_action( 'jetpack_register_gutenberg_extension', Fancy_Module_Name::init( self::OPTIONS ) );
}
- with
Fancy_Module_Namehandling block registration. Simple, and presumably of the form:
class Fancy_Module_Name {
static function init( $options ) {
return function() use ( $options ) {
// do stuff to register block with passed options/config
};
}
}
Alternatively, I guess the more OO way - a parent class that these modules can extend from, contract block registration functions via an interface, a trait that these modules can mix in, etc. Just stating the obvious perhaps - but something along these lines! (assuming my naive understanding of any underlying complexities)
There was a problem hiding this comment.
and my understanding is indeed fairly naive right now! I can hardly even tell how tightly-coupled the terms "membership" and "recurring-payments" are for one.
Turn out this was a bug, opened an issue to track: Automattic/wp-calypso#35455 |
There was a problem hiding this comment.
I found this a bit confusing; I didn't expect to be able to go through the whole connection flow before the upgrade. It does feel a lot more aggressive this way in my opinion, as folks go through a lot of trouble to set this up, only to be told they can't use it (yet). imo it may be better to not display the button to connect to Stripe until you upgrade.
Was this discussed somewhere already?
@jeherve Yeah, sorry for the confusion. Our plan is to also move the Stripe connection prompt into a Nudge (akin to the Upgrade Nudge), which will only appear if the site has been upgraded to the required plan. (We're planning to this in a follow-up PR.) We want the block itself to ideally always contain the UI that it'll have if all requirements (paid plan and Stripe connection) are met, so the user can play with it prior to actually upgrading. Here's a mockup (from p7rd6c-22L-p2#comment-2738): (There might be technical obstacles limiting how much we can actually reflect the 'fully functional' block behvior before all requirements are met -- see that same P2 thread, p7rd6c-22L-p2 -- but in that case, we can still e.g. display a pruned-down preview.) |
|
Setting status to Blocked/Hold, since we should figure out a strategy how to deploy this to WP.com first without disrupting everybody's flows. |
…ships Also, rename it to `get_connection_status()`, and make it static. This will allow us to re-use the same logic to set Gutenberg block availability.
cc8bb1d to
161bad0
Compare
|
Closing in favor of #13394 |




Changes proposed in this Pull Request:
Add an UpgradeNudge to the Recurring Payments block to replace UI that's currently part of the block itself.
Step 1 for the the Recurring Payments block project. Next steps will include adding a nudge for connecting to Stripe, and improvements to the overall flow.
Caveat
We're planning to remove the upgrade nudge from Jetpack for the next release (see #13203 and #13228). However, this would mean that per this PR, the Recurring Payments block would be hidden altogether for users on a Free Plan. Our options (AFAICS):
Screenshots
Before
After
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Nah.
Testing instructions:
yarn build), and start Docker (yarn docker:up)Proposed changelog entry for your changes:
Add an UpgradeNudge to the Recurring Payments block to replace UI that's currently part of the block itself.