-
Notifications
You must be signed in to change notification settings - Fork 56
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
Register VideoPress block behind a DEV flag #5459
Conversation
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
2b28464
to
a205ac6
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.
LGTM
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.
LGTM 🎊 !
NOTE: I've restarted the CI jobs because the CircleCI ones didn't start in the last commit.
src/jetpack-editor-setup.js
Outdated
@@ -85,9 +85,16 @@ export function registerJetpackBlocks( { capabilities } ) { | |||
capabilities.tiledGalleryBlock, | |||
'jetpack/tiled-gallery' | |||
); | |||
hideBlockByCapability( | |||
__DEV__ && capabilities.videoPressBlock, |
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.
Adding the __DEV__
flag here (vs. only as part of the supportedJetpackBlocks
object, like the Tiled Gallery block) because the VideoPress block lives in a separate package and is never passed to this function for checking availability.
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.
Good catch! I checked this change using the iOS installable build and although I can't insert the VideoPress block, it's still being rendered. The main reason for this is that hideBlockByCapability
function hides the block but doesn't prevent being registered, hence being rendered as a regular block instead of unsupported.
As a workaround, we could implement a native version of videopress/src/client/block-editor/blocks/video/index.ts
file (where the block is registered), and either:
- Expose a
registerVideoPressBlock
function that registers the block in order to be used in Gutenberg Mobile. - Add the needed checks to conditionally register the block.
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.
Ah, thank you for spotting that, I'll work on a registerVideoPressBlock
function.
5fe7860
to
2209d48
Compare
The VideoPress block was previously displaying in all builds, as the __DEV__ flag had been incorrectly added to the 'supportedJetpackBlocks' object. As the block belongs in a different packages to 'regular' Jetpack blocks, it was not passed to the 'register-jetpack-block.native.js' file, so didn't go through the usual availability checks. As a way around this, the __DEV__ flag has been added alongside the 'hideBlockByCapability' function. The unnecessary inclusion of VideoPress in the 'supportedJetpackBlocks' object has been removed.
src/jetpack-editor-setup.js
Outdated
@@ -85,9 +85,16 @@ export function registerJetpackBlocks( { capabilities } ) { | |||
capabilities.tiledGalleryBlock, | |||
'jetpack/tiled-gallery' | |||
); | |||
hideBlockByCapability( | |||
__DEV__ && capabilities.videoPressBlock, |
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.
Good catch! I checked this change using the iOS installable build and although I can't insert the VideoPress block, it's still being rendered. The main reason for this is that hideBlockByCapability
function hides the block but doesn't prevent being registered, hence being rendered as a regular block instead of unsupported.
As a workaround, we could implement a native version of videopress/src/client/block-editor/blocks/video/index.ts
file (where the block is registered), and either:
- Expose a
registerVideoPressBlock
function that registers the block in order to be used in Gutenberg Mobile. - Add the needed checks to conditionally register the block.
As we're now checking for the block's availability in the Jetpack repository, the conditional being removed with this commit is now redundant.
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.
LGTM 🎊 !
- VideoPress block is displayed as unsupported in the installable builds (i.e. production version) ✅ .
- VideoPress block is rendered when using local development environment ✅ .
With this PR, the VideoPress block has been registered behind a DEV flag. The block itself is not complete or fully functional, but is intended to serve as a useful placeholder that to be iterated on.
Related PRs
Gutenberg
: [RNMobile] Enable new block in Gutenberg Mobile WordPress/gutenberg#47836Jetpack
: [RNMobile] Register VideoPress block Automattic/jetpack#28812iOS
: Enable VideoPress block on iOS WordPress-iOS#20100Android
: Enable VideoPress block on Android WordPress-Android#17928To Test
Run the editor locally with both Android and iOS, then go through the following checks:
PR submission checklist: