-
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
Blocks: Add support for Collections #14454
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 7, 2020. |
This might make sense to be done in tandem with this PR: WordPress/gutenberg#19279 Since the categories are set to change |
When merged, we should confirm that re-organizing categories on wpcom is still functional: Automattic/wp-calypso#37057 |
@@ -82,7 +83,7 @@ export const settings = { | |||
title: __( 'Business Hours', 'jetpack' ), | |||
description: __( 'Display opening hours for your business.', 'jetpack' ), | |||
icon, | |||
category: 'jetpack', | |||
category: typeof registerBlockCollection === 'function' ? 'widgets' : '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.
I would centralize @wordpress/blocks
import and typeof check into a helper function at extensions/shared/block-category.js
and do supportsCollections()
or similar. Not a biggie, just seems neater.
See example in coblocks: https://github.com/godaddy-wordpress/coblocks/pull/1367/files#diff-9996de4f1fe7baae35dfc23d3e0e3f3fR33
Would be nice to get this in before code freeze on Monday evening in time for WP 5.4 release which supports this feature. @lessbloat |
Perhaps:
Register new category: Earn or Premium.
|
1f84644
to
08ba2be
Compare
Rebased and not finished yet, but need to log off. What categories for these blocks:
Still need to add the new category for Ads, Simple, Recurring Payments. |
@kraftbj Let me know if you need any help getting this one finished off. |
#14598 has a spreadsheet with suggested categories based on the discussion in p58i-8yl-p2. #14721 is the corresponding PR. It does away with the |
I'm hesitant to do that since documentation notes you can find the JP blocks under "Jetpack" and existing users who aren't updated would lose that flow. When 5.4 is Jetpack's minimum, we can remove the fallback. Thanks for the link to the spreadsheet. |
Updated the PR with the two new categories and updating all blocks with the spreadsheet. OpenTable struck me as odd being "Earn" instead of "Marketing" or "Embed", but included it as is. Pinterest also was the only "social" one and there isn't that category yet. I made it "embed" instead for now. Podcast Player wasn't in the spreadsheet. Marked it as an embed. Rating Star wasn't in the spreadsheet. Deferred to the suggestion in the comment above. Related Posts is listed as the only one in a non-existent "blog" category. Marked it as Embed. |
08ba2be
to
182e7e8
Compare
Caution: This PR has changes that must be merged to WordPress.com |
Noting that the wp.com patch needs a little massaging for the maps block. Nothing major, but I'll wait until this has landed to work on it so it isn't overridden with future work in this PR. |
kraftbj, Your synced wpcom patch D41358-code has been updated. |
@jeherve there is separate script on wpcom that reorganizes categories in case we want to do that only there. |
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.
Let's add the textdomains here.
kraftbj, Your synced wpcom patch D41358-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.
This looks good to me now. I'd suggest merging this as is for the 8.4 release, and work on improving these collections in a future PR:
- Handle wpcom differently
- Have Jetpack blocks come after core blocks in core categories.
To close the loop on this: #15310
I have been thinking about this some more, and I'm honestly not quite sure what we should aim for. Should Jetpack blocks be available before Core blocks in categories like Embeds? My first instinct was to say no, our blocks should come after Core's. Core's blocks would most likely be used more often; they were added to Core more often. On the other hand I can see why having our own blocks first should give us some extra visibility. Furthermore, Core currently adds custom blocks before core blocks in core categories, which seems to indicate that they're okay wit this? |
Could they just be listed alphabetically? |
I suppose it could be another option. Would we then change all block ordering to alphabetical as soon as Jetpack is active, or only in categories that include Jetpack blocks? |
* Add Jetpack blocks collection * Add Earn and Grow categories Co-authored-by: Jeremy Herve <[email protected]>
Cherry-picked to |
r205423-wpcom |
Supports #14598
Replaces and closes #14721
In Gutenberg 7.3, the block editor now supports "Collections". In the block picker, a Collection looks like a category, except blocks can also have a category.
The use case here is when do people think "I need a business hours block. I bet that's in the Jetpack category!"... probably not. They probably think of the function -- an embed, a widget, etc.
The problem is a block can only be in one category so devs have generally grouped them by the block provider.
Collections allow the block provider (Jetpack in our case) present all of our blocks together—like we have done with a custom category—while also listing it in a context-appropriate category.
For those running Gutenberg 7.3 or WordPress 5.4:
For those not running Gutenberg 7.3 or on WordPress 5.3, it retains the original behavior:
Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
AS OF NOW, when running G 7.3, the rest of Jetpack's blocks will fail since we're not adding them to a
Jetpack
category. We'll need to update the other blocks before landing it, but opening the PR now to get opinions on the implementation.I opted to need to update blocks since if we allow those blocks with other categories to be added to a collection and those with the 'legacy' Jetpack category, the inserter will have two "Jetpack" entries -- the category and the collection -- so that's not really an option.
Proposed changelog entry for your changes: