VideoPress: Only intercept video uploads when VideoPress is available#46894
VideoPress: Only intercept video uploads when VideoPress is available#46894
Conversation
When a user drags a video file into the block editor, the VideoPress block was intercepting the upload even when VideoPress was disabled or the user couldn't upload to VideoPress. This resulted in confusing error messages instead of the expected core/video block behavior. This fix adds a `canUploadToVideoPress` flag that checks: - On Dotcom sites (simple/atomic): always true (VideoPress handles uploads) - On Jetpack sites: VideoPress must be active AND (user has plan OR free video available) When the flag is false on Jetpack sites, the core/video block handles the upload to the local server instead. Fixes #44891
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
- Add PHP tests for can_upload_to_videopress() Dotcom behavior - Add JS tests for canUploadToVideoPress check in transformFromFile.isMatch() - Fix plan check to use 'videopress-1tb-storage' feature
Code Coverage SummaryCoverage changed in 3 files.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the VideoPress block was forcibly inserted when dragging video files into the editor, even when VideoPress was disabled or unavailable on Jetpack sites. The fix introduces a new flag that determines whether VideoPress should intercept video uploads.
Changes:
- Adds a
canUploadToVideoPressflag to the block editor state that controls whether VideoPress handles video uploads - Implements logic to determine upload eligibility: always enabled on Dotcom sites, conditionally enabled on Jetpack sites based on VideoPress status and plan/quota availability
- Updates the VideoPress block's file transform to check the flag before intercepting uploads, allowing core/video to handle uploads when VideoPress is unavailable
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
projects/packages/videopress/src/class-block-editor-extensions.php |
Adds the can_upload_to_videopress() method that determines upload eligibility based on site type, VideoPress status, plan support, and free video availability; exposes this as canUploadToVideoPress in the editor state |
projects/packages/videopress/src/client/block-editor/global.d.ts |
Adds TypeScript type definition for canUploadToVideoPress as '' | '1' to match WordPress localization pattern |
projects/packages/videopress/src/client/block-editor/blocks/video/transforms/index.tsx |
Updates the file transform's isMatch method to check the canUploadToVideoPress flag before intercepting video uploads |
projects/packages/videopress/src/client/block-editor/blocks/video/transforms/test/index.tsx |
Adds comprehensive test coverage for the new flag checking logic including edge cases |
projects/packages/videopress/tests/php/Block_Editor_Extensions_Test.php |
Adds PHP unit tests for the can_upload_to_videopress() method covering Dotcom and Jetpack scenarios |
projects/packages/videopress/changelog/fix-videopress-block-forced-when-disabled |
Adds changelog entry documenting the fix |
Fixes #44891
Fixes VIDP-42
Proposed changes:
canUploadToVideoPressflag to the block editor state that determines whether VideoPress should handle video file uploadsOther information:
Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Self-hosted Jetpack site with VideoPress module disabled:
Self-hosted Jetpack site with VideoPress enabled but no plan (after using free video):
Self-hosted Jetpack site with VideoPress enabled and plan:
WordPress.com site: