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

Mobile Stories block (part2: on done) #25771

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export {
MEDIA_TYPE_VIDEO,
} from './media-upload';
export { default as MediaUploadProgress } from './media-upload-progress';
export { default as StoryUpdateProgress } from './story-update-progress';
export { default as URLInput } from './url-input';
export { default as BlockInvalidWarning } from './block-list/block-invalid-warning';
export { default as BlockCaption } from './block-caption';
Expand Down
105 changes: 105 additions & 0 deletions packages/block-editor/src/components/story-update-progress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
StoryUpdateProgress
===================

`StoryUpdateProgress` shows a progress bar while the media files associated with a Story block are being saved and uploaded
Copy link
Contributor

Choose a reason for hiding this comment

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

Same than what I mentioned here.

It's possible that this component could give us troubles, since it's defined on the gutenberg repo but used only on a jetpack block and referring to a jetpack/wpcom feature (Stories).

What I would recommend in this case is to make all required bridge methods generic, and move this component to Jetpack.

Pinging @hypest and @maxme to get their opinion, since this would be a bigger refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed elsewhere with @etoledom - I'll make this component generic given it may be used on other blocks containing a collection of media in the future, and that will solve this situation 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in the set of PRs mentioned / starting with this #26005


## Usage

Usage example

```jsx
import { ImageBackground, Text, View } from 'react-native';
import {
StoryUpdateProgress,
} from '@wordpress/block-editor';

function StoryProgress( { url, id } ) {
return (
<StoryUpdateProgress
mediaId={ id }
renderContent={ ( { isSaveFailed, retryMessage } ) => {
return (
<ImageBackground
resizeMethod="scale"
source={ { uri: url } }
>
{ isSaveFailed &&
<View>
<Text>{ retryMessage }</Text>
</View>
}
</ImageBackground>
);
} }
/>
);
}
```

## Props

### mediaFiles

A collection of media ID that identifies the current story upload.
mzorz marked this conversation as resolved.
Show resolved Hide resolved

- Type: `Array`
- Required: Yes
- Platform: Mobile

### renderContent

Content to be rendered along with the progress bar, usually the thumbnail of the media being uploaded.

- Type: `React components`
- Required: Yes
- Platform: Mobile

It passes an object containing the following properties:

`{ isUploadInProgress, isUploadFailed, isSaveInProgress, isSaveFailed, retryMessage }`

### onUpdateMediaProgress

Callback called when the progress of the upload is updated.

- Type: `Function`
- Required: No
- Platform: Mobile

The argument of the callback is an object containing the following properties:

`{ mediaId, mediaUrl, progress, state }`

### onFinishMediaUploadWithSuccess

Callback called when the media file has been uploaded successfully.

- Type: `Function`
- Required: No
- Platform: Mobile

The argument of the callback is an object containing the following properties:

`{ mediaId, mediaServerId, mediaUrl, progress, state }`

### onFinishMediaUploadWithFailure

Callback called when the media file couldn't be uploaded.

- Type: `Function`
- Required: No
- Platform: Mobile

The argument of the callback is an object containing the following properties:

`{ mediaId, progress, state }`
jd-alexander marked this conversation as resolved.
Show resolved Hide resolved


### onMediaUploadStateReset

Callback called when the media upload is reset
mzorz marked this conversation as resolved.
Show resolved Hide resolved

- Type: `Function`
- Required: No
- Platform: Mobile

Loading