-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Jetpack Blocks: add index.js for each block #29298
Conversation
import JetpackFieldMultiple from './components/jetpack-field-multiple'; | ||
import { __ } from 'gutenberg/extensions/presets/jetpack/utils/i18n'; | ||
import renderMaterialIcon from 'gutenberg/extensions/presets/jetpack/utils/render-material-icon'; | ||
import * as form from './index'; |
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'd prefer named imports here (import { fields, name, settings } from './index'
) since it makes clearer what it is that we're requiring from that file.
@@ -26,7 +26,6 @@ const WPCOM_UNSUPPORTED_CORE_BLOCKS = [ | |||
const loadA8CExtensions = () => { | |||
// This will also load required TinyMCE plugins via Calypso's TinyMCE component | |||
require( '../extensions/classic-block/editor' ); | |||
require( 'gutenberg/extensions/presets/jetpack/editor.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.
This is obsolete, since block registration/unregistration in Calypso is handled by refreshRegistrations()
in the route handler.
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.
VR block isn't registered on Jetpack sites, even when JETPACK_BETA_BLOCKS
constant is true.
* Internal dependencies | ||
*/ | ||
import { __, _x } from 'gutenberg/extensions/presets/jetpack/utils/i18n'; | ||
import { default as edit } from './edit'; |
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 know this was like that before, but couldn't we just have import edit from './edit'
here?
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.
yeah, that would read better
edit: VRImageEdit, | ||
save: VRImageSave, | ||
} ); | ||
registerJetpackBlock( name, settings ); |
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.
Seems like this should use registerBlockType()
here - there is no VR module, so the VR block should always be registered.
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.
Hmm, thinking about it some more -- we should address this on the JP side, since otherwise, the VR block will always be visible (regardless of plan or other criteria). We have precedent -- there's no Map module either, so we're registering it in https://github.com/Automattic/jetpack/blob/b25ebc43d48f32d587f9a5c8b9ab4c4f96e3767a/modules/blocks.php
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.
That's fair, let's do that on the Jetpack side. Consistency wins.
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.
Jetpack PR to register it on the server side: Automattic/jetpack#10934
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.
Tests great in Calypso and Jetpack. LGTM 🚢
We should only follow up in Jetpack and register the VR block on the server side.
In this change we are refactoring editor.js files into tow files ediort.js and index.js.
editor.js is now responsible for just registering the block and index.js is there to define all the blocks.
This makes it easier to separate the code that defines the block from calling it. Which provides us with the flexibility in terms of when we call the register block code.
Testing instructions
Make sure all the blocks still work as expetected in calypso
Create a jetpack bundle. Does the jetpack side still work as expected?
Does the .com wp-admin side still work as expected.