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

Media: Refactor MediaUpload, MediaPlaceholder and mediaUpload to support arrays with multiple supported types. #9707

Merged
merged 2 commits into from Sep 28, 2018

Conversation

Projects
None yet
3 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Sep 7, 2018

mediaUpload util only allowed the uploads of a single type or all types. That makes impossible for a block to accept just the upload of images and videos.

This PR enhances the mediaUpload util and related components ( MediaUpload, MediaPlaceholder) to accept an allowedTypes prop with an array of all the supported types.

Testing

I tried to upload to each media block and verified no error occurred.
I used the Test Media Upload block available in https://gist.github.com/jorgefilipecosta/7a925ac31448832f00fceb0b0caed423, and checked I can correctly upload images and videos using the button and drag&drop. I checked that on the media library only images and videos are listed and that we can correctly select items of this types. The type string passed by MediaPlaceholder is the same for the media library and the mediaUpload function.

Required for: #9416

@jorgefilipecosta jorgefilipecosta self-assigned this Sep 7, 2018

@jorgefilipecosta jorgefilipecosta changed the title from WIP utils: mediaUpload: Support multiple type string in mediaUpload allowedType to utils: mediaUpload: Support multiple type string in mediaUpload allowedType Sep 7, 2018

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Sep 14, 2018

@jorgefilipecosta jorgefilipecosta added this to the 4.0 milestone Sep 14, 2018

@aduth

This comment has been minimized.

Show comment
Hide comment
@aduth

aduth Sep 14, 2018

Member

cc @antpb re: #9169 (similar / identical change proposed there)

Member

aduth commented Sep 14, 2018

cc @antpb re: #9169 (similar / identical change proposed there)

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Sep 27, 2018

@talldan

Hey @jorgefilipecosta. This is working really well in my tests, and it's great to have consistency with the name of the prop.

I spotted a couple of issues with the wrong prop being deprecated in a couple of places, which is important to fix.

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Sep 27, 2018

Member

Thank you for the review @talldan, I think all the feedback was applied.

Member

jorgefilipecosta commented Sep 27, 2018

Thank you for the review @talldan, I think all the feedback was applied.

@talldan

This comment has been minimized.

Show comment
Hide comment
@talldan

talldan Sep 28, 2018

Contributor

Looks good, I gave it a test and everything worked. 👍

I've added a commit to fix a couple of typos and a whitespace issue I just noticed.

Contributor

talldan commented Sep 28, 2018

Looks good, I gave it a test and everything worked. 👍

I've added a commit to fix a couple of typos and a whitespace issue I just noticed.

jorgefilipecosta and others added some commits Sep 7, 2018

[04044ed09] Added deprecations. (+2 squashed commits)
Squashed commits:
[99427d9] Changed representation to use an array.
[e2bc0ab] utils: mediaUpload: Support multiple type string in mediaUpload allowedType

@jorgefilipecosta jorgefilipecosta changed the title from utils: mediaUpload: Support multiple type string in mediaUpload allowedType to Media: Refactor MediaUpload, MediaPlaceholder and mediaUpload to support arrays with multiple supported types. Sep 28, 2018

@jorgefilipecosta jorgefilipecosta merged commit 007f15c into master Sep 28, 2018

2 checks passed

codecov/project 48.56% (+0.02%) compared to 3a210ab
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the update/mediaupload-support-allowedType-support-multiple-type-string branch Sep 28, 2018

@aduth

This comment has been minimized.

Show comment
Hide comment
@aduth

aduth Sep 28, 2018

Member

We should have included deprecations in the docs/deprecated.md and packages/editor/CHANGELOG.md documents.

Member

aduth commented Sep 28, 2018

We should have included deprecations in the docs/deprecated.md and packages/editor/CHANGELOG.md documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment