-
Notifications
You must be signed in to change notification settings - Fork 813
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 blocks categories #16363
Update blocks categories #16363
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 E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16363 Scheduled Jetpack release: August 4, 2020. |
1f0f910
to
3c98401
Compare
3c98401
to
c168da6
Compare
Since we aren't using TypeScript in this repo yet, and consequently have no linting configuration set up for it, I wonder if it wouldn't be best to stick to JavaScript for now? I suppose this could be the opportunity to introduce TypeScript to Jetpack, but if we do so I'd rather we do in a separate PR, by starting with introducing the necessary linting plugins and updating our tools to take into account the new file type. |
Thank you for sharing your thoughts about this. I was on the fence about this one as the actual benefits of using TS for this function are few, if any. As you said, it's more of an attempt to introduce/encourage the use of TypeScript.
Regarding the linting rules, I'm using the ones that ship with Jetpack (there's one for If the Jetpack crew is not yet comfortable with that change, I can change it to plain JS and gather feedback on introducing TypeScript to Jetpack at a later time, to make sure everyone is on the same page :) |
I'd rather we do this for now. I created #16375 to keep track of the things we'd need to do to introduce TypeScript here. I think we can work on that later; I also don't think it's a high priority change right now.
Since not everyone uses VS Code and / or a TS extension in their editor, I don't think we can rely on just that for now. |
I see, so you meant to integrate the lint tooling in the dev build process.
Cool, I'll change it to plain JS then 👍 |
c7135bb
to
00490ef
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.
Thanks for working on this, @fullofcaffeine!
One more code comment here, cause I couldn't leave it on an empty file - Looks like the docker/wordpress/.gitkeep file got here by an accident.
Because the getCategoryWithFallbacks
helper will be needed in a couple of other repositories, what do you think about turning it into an npm module (placed inside Calypso packages)?
fba7b25
to
27fa907
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.
Tested with both pre- & post-category-update Gutenberg versions and it looks good! Thanks!
There still is one comment that should be addressed but it's not a blocker https://github.com/Automattic/jetpack/pull/16363/files#r452120934
9f5648f
to
6700cc4
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 is looking great. I tested it and it's working well. I left a few suggestions on code organization and the new categories that I think better follow the categories Core is using.
@@ -22,8 +23,7 @@ export const settings = { | |||
), | |||
|
|||
icon, | |||
|
|||
category: 'layout', | |||
category: getCategoryWithFallbacks( 'design', 'layout' ), |
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.
Image block is in media
, that seems like a better fit for this.
category: getCategoryWithFallbacks( 'design', 'layout' ), | |
category: getCategoryWithFallbacks( 'media', 'layout' ), |
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.
👍
extensions/blocks/slideshow/index.js
Outdated
@@ -111,7 +112,7 @@ export const name = 'slideshow'; | |||
|
|||
export const settings = { | |||
title: __( 'Slideshow', 'jetpack' ), | |||
category: 'layout', | |||
category: getCategoryWithFallbacks( 'design', 'layout' ), |
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.
Also seems like a media block:
category: getCategoryWithFallbacks( 'design', 'layout' ), | |
category: getCategoryWithFallbacks( 'media', 'layout' ), |
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.
👍
@@ -201,7 +202,7 @@ export const icon = ( | |||
|
|||
export const settings = { | |||
attributes: blockAttributes, | |||
category: 'layout', | |||
category: getCategoryWithFallbacks( 'design', 'layout' ), |
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.
The core gallery is in media
, let's follow:
category: getCategoryWithFallbacks( 'design', 'layout' ), | |
category: getCategoryWithFallbacks( 'media', 'layout' ), |
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.
👍
@@ -0,0 +1,35 @@ | |||
/** |
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 put this right into the extensions/shared
directory: extensions/shared/get-category-with-fallbacks.js
(or add something block-specific in the name if you like).
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.
Sounds good 👍
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.
Actually, why not add this file to extensions/shared/blocks
?
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 don't know why the blocks
subdirectory was added or whether it serves much organizational purpose. There seems to be block-specific functionality in extensions/shared
.
If you have reason to believe it's justified and preferable to put it under blocks
, I won't object.
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.
As in extensions/shared/blocks/get-category-with-fallbacks.js
.
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.
You're right, the extensions
folder already seems to be mainly about the blocks. I'll just add there as you suggested. 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.
I don't know why the blocks subdirectory was added or whether it serves much organizational purpose.
That directory is used for modifications of single, non-Jetpack, blocks today, such as the Cover block on WordPress.com.
Since your changes will impact multiple blocks, I would recommend having your changes in extensions/shared
.
A brief summary of changes. 6 update blocks, one doesn't appear in the inserter.
|
…ated ones - Also add a helper function that can bE used to check if old category names are still being used, and fallback to the old name if so. This should ideally be used in a ternary expression while setting the category name for blocks to provide the fallback old category name in order to support WP environments with older versions of Gutenberg. - Legacy categories were explicitly set to the new updated ones, following this example: https://github.com/WordPress/gutenberg/blob/84df4bd6082e7793a2befddb2a652cb42f445d21/packages/blocks/src/api/registration.js#L131-L135 - Some blocks might not have followed the example above and might have been moved to a category that made more sense for them
6700cc4
to
30e4d67
Compare
It looks like |
Only a previous version of the block is deprecated. The block is still available, but requires your Jetpack site to be connected with WordPress.com. |
Thanks for explaining, Jeremy. I could see in the right category when testing the diff in my simple sandboxed site. |
I updated and tested the in my sandboxed simple site and can confirm it's working as expected there, too. D45795-code |
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 tests well for me. 👍
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.
Testing well, thanks!
Merging this for you now, before we start running into rebase issues. Let's wait until release day for the matching WordPress.com changes. |
r211580-wpcom |
Changes proposed in this Pull Request:
wp-calypso
.Related PRs
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Atomated tests
yarn test-extensions
To manually test the changes
Categories
amazon
in theearn
business-hours
in thegrow
button
fromlayout
->design
*[1] (could not test, didn't find it in the picker)calendly
ingrow
contact-form
ingrow
contact-info
ingrow
eventbrite
inembed
gathering-tweetstorms
as is (category doesn't seem to be explicitely set)gif
inembed
google-calendar
inembed
image-compare
fromlayout
->media
instagram-gallery
inembed
likes
as is (category doesn't seem to be explicitely set)mailchimp
ingrow
map
inembed
(has many internal sub-blocks that I think are safe to ignore?)formatting
->text
opentable
inearn
pinterest
inembed
podcast-player
inembed
publicize
as is (category doesn't seem to be explicitely set)rating-star
fromformatting
->widgets
payments
inearn
related-posts
inembed
repeat-visitor
inwidgets
revue
ingrow
send-a-message
ingrow
seo
as is (category doesn't seem to be explicitely set)sharing
as is (category doesn't seem to be explicitely set)shortlinks
as is (category doesn't seem to be explicitely set)simple-payments
inearn
slideshow
fromlayout
->media
subscriptions
ingrow
tiled-gallery
fromlayout
->media
videopress
as is (category doesn't seem to be explicitely set)wordads
inearn
Proposed changelog entry for your changes:
Note: If this PR gets approved and merged, then I'll remove the helper function and tests from here (including the installation/configuration of jest).