-
Notifications
You must be signed in to change notification settings - Fork 798
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
Blocks: add paid label next to block title when it requires a plan #14739
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 7, 2020. |
Thank you for getting this started and providing direction, @jeherve! I have a questions that is likely just related to my newness to Jetpack. The only paid plan block I'm seeing is Recurring Payments, and it's not showing the This is for both my local docker ngrok'd site and the PR-generated site. They're both connected to my WP account via a free Jetpack plan. I've looked in both wp-admin and WordPress.com's editor for more beta and upgrade-required blocks. Am I looking in the wrong area, or is there some other set-up I need to do to see more beta and paid blocks like in your screenshot? |
I've added a note to the PR description: to see paid blocks when you don't have a plan in Jetpack, you need to use this filter: Beta blocks, on the other hand, can be enabled by adding the following to your site's |
Thanks for opening this PR and for the detailed description, @jeherve! 🙌
How about joining those tags/badges/labels? We'd get something like:
I'm not sure here either, but when I drop it in Google Translate, e.g. the Russian version is "бета". I guess the question is if we want to make it translatable? For the implementation of the above, how about creating const blockTags = {
paid: __( 'paid' ),
beta: __( 'beta' ),
}; ...and append (& join) them accordingly to the block's name when needed. What do you think? |
Thanks for kicking this off @jeherve! Combining beta and paid when appropriate sounds fine. |
jeherve, Your synced wpcom patch D39107-code has been updated. |
jeherve, Your synced wpcom patch D39107-code has been updated. |
…BlockTags.paid The availableBlockTags object has the property paid, and not plan. The check to add the (paid) label was looking for the availableBlockTags.plan property, which was undefined. I updated this to look for availableBlockTags.paid.
jeherve, Your synced wpcom patch D39107-code has been updated. |
I made the requested changes to the code. I think this is ready for another round of review 👍 |
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 job. Looks good from a code perspective. I haven't been able to test manually yet. Still working on env setup.
@@ -44,9 +57,23 @@ export default function registerJetpackBlock( name, settings, childBlocks = [] ) | |||
return false; | |||
} | |||
|
|||
let blockTitle = settings.title; | |||
const blockTags = []; |
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.
Minor: it might seem obvious when you've been working on it for a while, but I wonder whether it could be helpful to add a comment here detailing what we're doing here. It was immediately obvious to me even though I had some context. For others it could be even less clear.
For example:
Some Blocks should be "tagged" to highlight various attributes such as being part of a paid plan or being in a beta programme. We add these to the Block's visible
title
in order that they show up in the picker.
Alternatively, perhaps it would be better to handle adding "tags" in a dedicated method. This might remove the need to document with a comment as the code would be self describing. Perhaps:
buildBlockTags
and buildBlockTitle
?
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 refactored the implementation here: 25129a6
This adds buildBlockTags
and buildBlockTitle
functions and builds the title with buildBlockTitle( settings.title, buildBlockTags( name, requiredPlan ) )
…solated build functions. - Adds buildBlockTags( name, requiredPlan) - Adds buildBlockTitle( blockTitle, blockTags ) - Builds the title in registerJetpackBlock with buildBlockTitle( settings.title, buildBlockTags( name, requiredPlan ) )
jeherve, Your synced wpcom patch D39107-code has been updated. |
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.
Looks much better. Thanks for the refactor 👍
I'm still setting up my env for testing so please can you source another manual review?
I'm sorry about this.
*/ | ||
function buildBlockTitle( blockTitle, blockTags = [] ) { | ||
if ( blockTags.length ) { | ||
blockTitle = `${ blockTitle } (${ blockTags.join( ', ' ) })`; |
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.
blockTitle = `${ blockTitle } (${ blockTags.join( ', ' ) })`; | |
blockTitle = `${ blockTitle } (${ blockTags.join() })`; |
If omitted, the array elements are separated with a comma
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.
True, but there's no space between them, so it would end up being (paid,beta)
instead of (paid, beta)
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.
Tested locally, everything looks great!
I refactored and I believe I addressed all the raised comments. Could I please get another review? 🙏 |
r203949-wpcom |
* Initial changelog entry * Changelog: add #14904 * Changelog: add #14910 * Changelog: add #14913 * Changelog: add #14916 * Changelog: add #14922 * Changelog: add #14924 * Changelog: add #14925 * Changelog: add #14928 * Changelog: add #14840 * Changelog: add #14841 * Changelog: add #14842 * Changelog: add #14826 * Changelog: add #14835 * Changelog: add #14859 * Changelog: add #14884 * Changelog: add #14888 * Changelog: add #14817 * Changelog: add #14814 * Changelog: add #14819 * Changelog;: add #14797 * Changelog: add #14798 * Changelog: add #14802 * Changelog: add #13676 * Changelog: add #13744 * Changelog: add #13777 * Changelog: add #14446 * Changelog: add #14739 * Changelog: add #14770 * Changelog: add #14784 * Changelog: add #14897 * Changelog: add #14898 * Changelog: add #14968 * Changelog: add #14985 * Changelog: add #15044 * Changelog: add #15052 * Update to remove Podcast since it remains in Beta * Changelog: add #14803 * Changelog: add #15028 * Changelog: add #15065 * Changelog:add #14886 * Changelog: add #15118 * Changelog: add #14990 * Changelog: add #14528 * Changelog: add #15120 * Changelog: add #15126 * Changelog: add #15049 * Chanegelog: add #14852 * Changelog: add #15090 * Changelog: add #15138 * Changelog: add #15124 * Changelog:add #15055 * Changelog: add #15017 * Changelog: add #15109 * Changelog: add #15145 * Changelog:add #15096 * Changelog:add #15153 * Changelog: add #15133 * Changelog: add #14960 * Changelog: add #15127 * Changelog: add #15056 * Copy current changelog to changelog archive. * Clarify changelog description
Changes proposed in this Pull Request:
Related: #11875, #13490
(paid)
label next to block titles whenever a block requires a plan.A few notes:
(beta)
take priority whenever a block is both paid and in Beta. I am not sure that's the best approach.@jeryj Do you think you could take a look and take over?
Thank you!
Testing instructions:
add_filter( 'jetpack_block_editor_enable_upgrade_nudge', '__return_true' );
Proposed changelog entry for your changes: