Skip to content

Conversation

@fluiddot
Copy link
Contributor

@fluiddot fluiddot commented Feb 15, 2023

Related PRs:

Fixes wordpress-mobile/gutenberg-mobile#5470

Add metadata parameter to the media upload success event that is passed to the Gutenberg editor. This parameter is open to any information around the media that can be useful to have when the upload finishes successfully.

This PR also includes the VideoPress GUID to the metadata parameter as it's needed to render the VideoPress block.

To test

NOTE: This change can only be tested on development using a patch file in Gutenberg.

  1. Apply the following patch in Gutenberg codebase:
diff --git forkSrcPrefix/packages/block-library/src/video/edit.native.js forkDstPrefix/packages/block-library/src/video/edit.native.js
index 99225ba5d5c569d19a158f5b1a203c68aa353c33..da4e3418c46305386a68ceaec618f818dc0ffb4a 100644
--- forkSrcPrefix/packages/block-library/src/video/edit.native.js
+++ forkDstPrefix/packages/block-library/src/video/edit.native.js
@@ -138,6 +138,9 @@ class VideoEdit extends Component {
 
 	finishMediaUploadWithSuccess( payload ) {
 		const { setAttributes } = this.props;
+
+		console.log( 'finishMediaUploadWithSuccess', payload );
+
 		setAttributes( { src: payload.mediaUrl, id: payload.mediaServerId } );
 		this.setState( { isUploadInProgress: false } );
 	}

  1. Build the app and connect it with your Metro local server.
  2. Open a post/page in a simple site.
  3. Insert a Video block.
  4. Upload a video from the device.
  5. Once the upload finishes, check the console logs and observe an entry that displays the metadata and VideoPress GUID, e.g.:
finishMediaUploadWithSuccess:
{
    "mediaServerId": <MEDIA_SERVER_ID>,
    "progress": 1,
    "state": 2,
    "mediaUrl": "https://videos.files.wordpress.com/<VIDEOPRESS_GUID>/file_example_mp4_480_1_5mg-23.mp4",
    "metadata": {
        "videopressGUID": "<VIDEOPRESS_GUID"
    },
    "mediaId": <MEDIA_ID>
}

Regression Notes

  1. Potential unintended areas of impact
    This change shouldn't produce any side effects but if any, it would affect the media uploads in the editor.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Tested uploads on the different media blocks:

    • Image block ✅
    • Video block ✅
    • Cover block ✅
    • Media & Text block ✅
    • File block ✅
    • Gallery block ✅
  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 15, 2023

You can test the changes in WordPress from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr20144-dbe75d8 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 15, 2023

You can test the changes in Jetpack from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr20144-dbe75d8 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@fluiddot fluiddot added this to the 21.9 milestone Feb 16, 2023
@fluiddot fluiddot marked this pull request as ready for review February 16, 2023 13:14
@jhnstn jhnstn self-requested a review February 17, 2023 20:06
Copy link
Member

@jhnstn jhnstn left a comment

Choose a reason for hiding this comment

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

Test plan works as expected and changes look good. :shipit:

@fluiddot fluiddot force-pushed the gutenberg/add-media-upload-metadata branch from 4e5159c to bf9694f Compare February 23, 2023 21:34
@fluiddot fluiddot merged commit 4644af9 into trunk Feb 27, 2023
@fluiddot fluiddot deleted the gutenberg/add-media-upload-metadata branch February 27, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Editing and display of Gutenberg blocks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload - Pass VideoPress GUID in media upload events [WP-iOS]

5 participants