Skip to content
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

Merged
merged 32 commits into from
Feb 15, 2023
Merged

Conversation

SiobhyB
Copy link
Contributor

@SiobhyB SiobhyB commented Feb 8, 2023

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

To Test

Run the editor locally with both Android and iOS, then go through the following checks:

  • Verify that the VideoPress block can be inserted into a post via the block inserter, the block inserter search, and the slash inserter.
  • Verify that the block is only visible when running via your local development environment, it shouldn't be visible with the PR's associated installable build.
  • Verify that all automated tests pass and that there are no obvious errors associated with the addition of the block.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes more info and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Feb 8, 2023

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

@SiobhyB SiobhyB changed the title Register videopress block Register VideoPress block behind a DEV flag Feb 8, 2023
@SiobhyB SiobhyB added the Jetpack Bug or feature related to Jetpack label Feb 8, 2023
Copy link
Collaborator

@renatoagds renatoagds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@fluiddot fluiddot left a 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/block-support/supported-blocks.json Outdated Show resolved Hide resolved
@@ -85,9 +85,16 @@ export function registerJetpackBlocks( { capabilities } ) {
capabilities.tiledGalleryBlock,
'jetpack/tiled-gallery'
);
hideBlockByCapability(
__DEV__ && capabilities.videoPressBlock,
Copy link
Contributor Author

@SiobhyB SiobhyB Feb 10, 2023

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.

Copy link
Contributor

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:

  1. Expose a registerVideoPressBlock function that registers the block in order to be used in Gutenberg Mobile.
  2. Add the needed checks to conditionally register the block.

Copy link
Contributor Author

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.

Siobhan added 5 commits February 13, 2023 09:30
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.
@@ -85,9 +85,16 @@ export function registerJetpackBlocks( { capabilities } ) {
capabilities.tiledGalleryBlock,
'jetpack/tiled-gallery'
);
hideBlockByCapability(
__DEV__ && capabilities.videoPressBlock,
Copy link
Contributor

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:

  1. Expose a registerVideoPressBlock function that registers the block in order to be used in Gutenberg Mobile.
  2. Add the needed checks to conditionally register the block.

Siobhan added 3 commits February 13, 2023 21:30
As we're now checking for the block's availability in the Jetpack repository, the conditional being removed with this commit is now redundant.
Copy link
Contributor

@fluiddot fluiddot left a 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 ✅ .

@SiobhyB SiobhyB merged commit a3b9884 into trunk Feb 15, 2023
@SiobhyB SiobhyB deleted the register-videopress-block branch February 15, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Jetpack Bug or feature related to Jetpack Media
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants