-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
mzorz
merged 17 commits into
try/jetpack-stories-block-mobile
from
try/jetpack-stories-block-mobile-on-done
Oct 14, 2020
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
12483fa
added mobile StoryUpdateProgress component and bridge code to send/re…
mzorz 2c17055
updated WPAndroid bridge DeferredEventEmitter to handle Story save ev…
mzorz 78455a8
changed all Save event interface methods to use String ids instead of…
mzorz da1a900
redefined upload/save state constants
mzorz 9613c56
added onStorySaveResult handling to bridge, and renamed STORY_SAVE_ST…
mzorz b305a9d
checking for matches of mediaId in mediaFiles while saving to send s…
mzorz 407b2d1
added mediaModelCreated() method to the bridge, so a new ID can be as…
mzorz 269cc91
mediaId should always be a string in mediaFiles so, converting to avo…
mzorz 5ce5e5c
removed commented code
mzorz e83c8c8
updated documentation
mzorz 42288a5
added missing implementation of method storySaveSync() in demo app
mzorz 0213a1f
Merge branch 'try/jetpack-stories-block-mobile' into try/jetpack-stor…
mzorz 5d385b5
fixed prettier warning
mzorz 1934b2d
Merge branch 'try/jetpack-stories-block-mobile' into try/jetpack-stor…
mzorz 876ef24
Update packages/block-editor/src/components/story-update-progress/REA…
mzorz 5b74fa0
Update packages/block-editor/src/components/story-update-progress/REA…
mzorz e288930
Mobile Stories block (part3: refactor / rename) (#26005)
mzorz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/block-editor/src/components/story-update-progress/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
## 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 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 ajetpack
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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