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

[rnmobile] Media upload multiple prop #17397

Merged
merged 36 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
635108e
[RNMobile] Native mobile release v1.11.0 (#17181)
etoledom Aug 28, 2019
472854f
rebase to rnmobile/master
dratwas Aug 28, 2019
643c1b2
Activate Travis CI on rnmobile/master branch (#17229)
etoledom Aug 28, 2019
dc3eddd
Merge branch 'rnmobile/master' into rnmobile/media-upload-props
dratwas Aug 28, 2019
ad6c39b
fix types after merge
dratwas Aug 28, 2019
944d4e7
fix tests
dratwas Aug 28, 2019
5046a97
add multiple prop support
dratwas Aug 28, 2019
0a377e7
add check if media exists
dratwas Aug 28, 2019
49d5502
fix test
dratwas Aug 28, 2019
a78f204
Add native support for the MediaText block (#16305)
Tug Aug 29, 2019
3db95b7
MediaUpload and MediaPlaceholder unify props (#17145)
dratwas Aug 30, 2019
7aa44a2
Unify media placeholder and upload props within media-text (#17268)
lukewalczak Aug 30, 2019
f9fa455
[RNMobile] Fix dismiss keyboard button for the post title (#17260)
geriux Aug 30, 2019
a30a207
Merge branch 'rnmobile/master' into rnmobile/master
dratwas Aug 30, 2019
7b12673
Recover border colors (#17269)
etoledom Aug 30, 2019
14d482b
[RNMobile] Insure tapping at end of post inserts at end
mchowning Aug 6, 2019
89664eb
Support group block on mobile (#17251)
lukewalczak Sep 3, 2019
fc8c3da
Remove redundant bg color within button appender (#17325)
lukewalczak Sep 4, 2019
264b178
[RNMobile] DarkMode improvements (#17309)
etoledom Sep 4, 2019
b4d622c
add unit test cases
dratwas Sep 10, 2019
a2b26a5
Merge branch 'rnmobile/master' into rnmobile/media-upload-multiple
dratwas Sep 10, 2019
806c880
add multiple prop to media placeholder
dratwas Sep 16, 2019
648a1b9
[RNMobile] Add autosave to mobile apps (#17329)
daniloercoli Sep 19, 2019
2a1e2a5
Merge branch 'rnmobile/master' into rnmobile/media-upload-multiple
dratwas Sep 24, 2019
e99d365
Add isAppender functionality on mobile (#17195)
lukewalczak Sep 25, 2019
69da85e
Autosave monitor - Make the mobile editor ping the native at each key…
daniloercoli Sep 25, 2019
ae6d2ce
[RNMobile] Refactor Dark Mode HOC (#17552)
Tug Sep 25, 2019
1c9b133
Add missing heading levels to the UI (H4, H5, H6) (#17533)
SergioEstevao Sep 25, 2019
df025a6
Fix lint issue (#17598)
lukewalczak Sep 26, 2019
d8b0d83
Fix list filter on paste for RN mobile. (#17550)
SergioEstevao Sep 26, 2019
f3085c1
[RNMobile] Move MediaUploadPorgress to its own component folder (#17392)
geriux Sep 27, 2019
95acf23
Rnmobile/fix link editing on start (#17631)
SergioEstevao Sep 30, 2019
99c17b2
Merge branch 'rnmobile/master' into rnmobile/media-upload-multiple
dratwas Oct 2, 2019
febf65b
Merge branch 'master' into rnmobile/media-upload-multiple
dratwas Oct 2, 2019
00c7f35
remove redundant styles
dratwas Oct 2, 2019
37642d5
Merge branch 'master' into rnmobile/media-upload-multiple
dratwas Oct 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function MediaPlaceholder( props ) {
isAppender,
disableMediaButtons,
getStylesFromColorScheme,
multiple,
} = props;

const isOneType = allowedTypes.length === 1;
Expand Down Expand Up @@ -101,6 +102,7 @@ function MediaPlaceholder( props ) {
<MediaUpload
allowedTypes={ allowedTypes }
onSelect={ onSelect }
multiple={ multiple }
render={ ( { open, getMediaOptions } ) => {
return (
<TouchableWithoutFeedback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@
background-color: $background-dark-secondary;
}

.emptyStateContainerDark {
background-color: $background-dark-secondary;
}

.emptyStateContainerDark {
background-color: $background-dark-secondary;
}

.emptyStateContainerDark {
background-color: $background-dark-secondary;
}

.emptyStateTitle {
text-align: center;
margin-top: 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export class MediaUpload extends React.Component {
}

onPickerSelect( requestFunction ) {
const { allowedTypes = [], onSelect } = this.props;
requestFunction( allowedTypes, ( id, url ) => {
if ( id ) {
onSelect( { id, url } );
const { allowedTypes = [], onSelect, multiple = false } = this.props;
requestFunction( allowedTypes, multiple, ( media ) => {
if ( ( multiple && media ) || media.id ) {
onSelect( media );
}
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ describe( 'MediaUpload component', () => {
expectOptionForMediaType( MEDIA_TYPE_VIDEO, OPTION_TAKE_VIDEO );
} );

const expectMediaPickerForOption = ( option, requestFunction ) => {
requestFunction.mockImplementation( ( mediaTypes, callback ) => {
const expectMediaPickerForOption = ( option, allowMultiple, requestFunction ) => {
requestFunction.mockImplementation( ( mediaTypes, multiple, callback ) => {
expect( mediaTypes[ 0 ] ).toEqual( MEDIA_TYPE_VIDEO );
callback( MEDIA_ID, MEDIA_URL );
if ( multiple ) {
callback( [ { id: MEDIA_ID, url: MEDIA_URL } ] );
} else {
callback( { id: MEDIA_ID, url: MEDIA_URL } );
}
} );

const onSelect = jest.fn();
Expand All @@ -78,6 +82,7 @@ describe( 'MediaUpload component', () => {
<MediaUpload
allowedTypes={ [ MEDIA_TYPE_VIDEO ] }
onSelect={ onSelect }
multiple={ allowMultiple }
render={ ( { open, getMediaOptions } ) => {
return (
<TouchableWithoutFeedback onPress={ open }>
Expand All @@ -92,18 +97,26 @@ describe( 'MediaUpload component', () => {
expect( requestFunction ).toHaveBeenCalledTimes( 1 );

expect( onSelect ).toHaveBeenCalledTimes( 1 );
expect( onSelect ).toHaveBeenCalledWith( media );
expect( onSelect ).toHaveBeenCalledWith( allowMultiple ? [ media ] : media );
};

it( 'can select media from device library', () => {
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_CHOOSE_FROM_DEVICE, requestMediaPickFromDeviceLibrary );
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_CHOOSE_FROM_DEVICE, false, requestMediaPickFromDeviceLibrary );
} );

it( 'can select media from WP media library', () => {
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_WORD_PRESS_LIBRARY, requestMediaPickFromMediaLibrary );
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_WORD_PRESS_LIBRARY, false, requestMediaPickFromMediaLibrary );
} );

it( 'can select media by capturig', () => {
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_TAKE_MEDIA, requestMediaPickFromDeviceCamera );
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_TAKE_MEDIA, false, requestMediaPickFromDeviceCamera );
} );

it( 'can select multiple media from device library', () => {
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_CHOOSE_FROM_DEVICE, true, requestMediaPickFromDeviceLibrary );
} );

it( 'can select multiple media from WP media library', () => {
expectMediaPickerForOption( MEDIA_UPLOAD_BOTTOM_SHEET_VALUE_WORD_PRESS_LIBRARY, true, requestMediaPickFromMediaLibrary );
} );
} );