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 #17140

Merged
merged 30 commits into from
Nov 10, 2020
Merged

Mobile stories block #17140

merged 30 commits into from
Nov 10, 2020

Conversation

mzorz
Copy link
Contributor

@mzorz mzorz commented Sep 11, 2020

Changes proposed in this Pull Request:

This PR adds .native.* files to support the Story block rendering on the gutenberg-mobile editor used by the WordPress Android and iOS apps.

Related Gutenberg PR: WordPress/gutenberg#26721
Related Gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#2611
Related WPAndroid PR: wordpress-mobile/WordPress-Android#12939 and wordpress-mobile/WordPress-Android#13130
Related WPiOS PR: WordPress/gutenberg#26704

NOTE: the code has already been reviewed and merged in several other PRs feeding this feature branch. Omiting climate issues in this PR for now given they're not really relevant.

Jetpack product discussion

See pbD5rk-m7 and other links from there.

Test instructions:

@brbrr had a few interesting questions to complete the description of the PR that I'll try to address here:

  • Do I need android device to test it?

You can also use an emulator. This will come with Android Studio (see below for instructions to download and install Android Studio)

  • Can I use my iPhone instead?

Technically yes, but for the goals of this set of PRs the short answer is no.

  • Do I need to build app manually, or should I use beta/production version?

We have CI build APKs for testing if you'd prefer to skip the native steps. You can download the CI-built APK corresponding to the WPAndroid PR here.

  • Any way I can test it without mobile device?

Yes, with an emulator. Do all of the following. YMMV but this is basically what you'll need to get it running.

Setup (SKIP to "Actual testing..." below if you don't intend to do any sort of debugging)

  1. Clone the WordPress for Android repository locally. Use the branch at this PR Mobile stories block wordpress-mobile/WordPress-Android#13130. For cloning please bear in mind you'll need to also clone the submodules so, use this:
    git clone --recurse-submodules git@github.com:wordpress-mobile/WordPress-Android.git
  2. Download and Install Android Studio
  3. Open it and create an android virtual device you'll use as an emulator. Read managing avds for instructions.

React native part

  1. open a terminal in the WordPress-Android folder you just cloned. Do cd libs/gutenberg-mobile
  2. run nvm install --latest-npm.
  3. npm install
  4. once it's finished, if you intend only to smoke test that's enough, but if you want to make changes to code you can run the metro server with npm run start:reset. You will have to make a change in the WAndroid project's gradle.properties file as well.

WordPress for Android part

  1. if you want to be able to edit gutenberg / jetpack code for reasons, include the following line in your gradle.properties file:
wp.BUILD_GUTENBERG_FROM_SOURCE = true
  1. To build the project, follow the build instructions at https://github.com/wordpress-mobile/WordPress-Android#wordpress-for-android (or just open it on Android Studio and hit the Run button)
  2. Once you have a running build, you should be able to follow the steps provided in Mobile Stories block wordpress-mobile/WordPress-Android#12939 for smoke testing the functionality, but a shorter version of the steps to try the functionality are given below as well.

Actual Stories functionality testing:

a. tap on the main screen's "+" floating action button, then choose Story.
b. Take a picture or select from the media picker to create some story slides.
c. Then, tap on the "->" icon on the top-right of the screen in the visual story composer, and give your Story a name, then hit the big PUBLISH button at the bottom.
d. Wait for it to upload.
e. Now go to your Posts list, and look for the post you just created
f. open it by tapping on it
g. the Gutenberg editor should load and the Story block should render.
h. tap on it and your story should be loaded in the Story creator again for editing.

Here's a GIF file showing all of these steps and a few more.

testStory

Proposed changelog entry for your changes:

no changes visible to the web side of things, this PR only affects the WordPress mobile apps

@jetpackbot
Copy link
Collaborator

jetpackbot commented Sep 11, 2020

Scheduled Jetpack release: November 10, 2020.
Scheduled code freeze: October 26, 2020

E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17140

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Generated by 🚫 dangerJS against 74d2fd6

@mzorz mzorz requested review from cameronvoell, Tug and etoledom October 2, 2020 02:45
@mzorz mzorz marked this pull request as ready for review October 2, 2020 02:45
@mzorz mzorz requested a review from guarani October 2, 2020 02:46
mzorz added 4 commits October 8, 2020 20:58
* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* Mobile Stories block (part 3): rename using BlockMediaUpdateProgress (#17456)

* using BlockMediaUpdateProgress

* method rename
@jeherve jeherve added [Status] Needs Team Review Obsolete. Use Needs Review instead. and removed [Status] Needs Review This PR is ready for review. labels Nov 5, 2020
@jeherve jeherve added this to the 9.2 milestone Nov 5, 2020
@mzorz
Copy link
Contributor Author

mzorz commented Nov 5, 2020

This is now ready for final review and merge. As noted in the description, the code has already been reviewed and merged in several other PRs feeding this feature branch. Climate issues observed in this PR can be omitted given they're not really relevant.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Nice job! 🎉

@kraftbj kraftbj added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Nov 6, 2020
@mzorz mzorz removed request for Tug and cameronvoell November 9, 2020 12:23
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello mzorz! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D52449-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

LGTM! 🚢

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Nov 10, 2020
@mzorz
Copy link
Contributor Author

mzorz commented Nov 10, 2020

LGTM! 🚢

Thank you @jeherve ! :D 🎉

@mzorz mzorz merged commit 898c8d7 into master Nov 10, 2020
@mzorz mzorz deleted the try/jetpack-stories-block-mobile branch November 10, 2020 17:43
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Nov 10, 2020
@jeherve
Copy link
Member

jeherve commented Nov 11, 2020

r216657-wpcom

@cameronvoell cameronvoell restored the try/jetpack-stories-block-mobile branch November 14, 2020 02:46
@cameronvoell cameronvoell deleted the try/jetpack-stories-block-mobile branch November 14, 2020 02:46
@cameronvoell cameronvoell restored the try/jetpack-stories-block-mobile branch November 14, 2020 02:46
cameronvoell pushed a commit that referenced this pull request Nov 14, 2020
* basic scaffolding for the Story block on mobile editor

* added flex alignment and actual mediaFiles attribute rendering

* applying styles to stories block view

* removed unused alignment

* added StoryEditingButton and showing it when the story block is selected

* connecting StoryEditingButton with bridge's requestStoryCreatorLoad

* updated requestStoryCreatorLoad call to pass block's mediaFiles and clientId over the bridge

* added new component StoryUpdateProgress

* Revert "added new component StoryUpdateProgress", not belonging to this branch

This reverts commit 86fb956.

* fixed lint warnings

* changed the no longer existing color dark-gray-500 removed in WordPress/gutenberg@162bc50 with gray-700

* added package-lock.json

* Mobile Stories block (part 2): introduce StoryUpdateProgress (#17222)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* Mobile Stories block (part 3): rename using BlockMediaUpdateProgress (#17456)

* using BlockMediaUpdateProgress

* method rename

* updated (automatically modified) package-lock.json

* removed package-lock.json

* moved condition check for http or https to helper method isUrlRemote()

* calling mediaUploadSync and mediaSaveSync regardless of ids, we always will want to receive updates on all 3 stages

* fixed spelling

* Mobile Stories block (part 4): error handling (#17458)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* using BlockMediaUpdateProgress

* method rename

* updated story block to represent error state

* added cancel and retry bridge methods specific for mediaFiles collection based blocks

* using a deep copy of mediaFiles when replacing ids and mediaUrl, given mediaFiles attribute needs to be replaced again and cannot be modified in place as per React conventions

* added requestMediaFilesSaveCancelDialog bridge method

* changed props name onMediaModelCreated to more generic onMediaIdChanged

* removed commented code

* replaced for loops with map

* Mobile Stories block (part 5): add empty placeholder (#17539)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* using BlockMediaUpdateProgress

* method rename

* updated story block to represent error state

* added cancel and retry bridge methods specific for mediaFiles collection based blocks

* using a deep copy of mediaFiles when replacing ids and mediaUrl, given mediaFiles attribute needs to be replaced again and cannot be modified in place as per React conventions

* added requestMediaFilesSaveCancelDialog bridge method

* changed props name onMediaModelCreated to more generic onMediaIdChanged

* removed commented code

* added MediaPlaceholder, wrapped in a pointerEvents=none View so we can handle media picking from the StoryComposer

* replaced for loops with map

* importing defined const MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO instead of re-defining

* made placeholder container look as per any other media placeholder, reservign the Story style container for populated Story blocks

* Mobile Stories block (part 6): rewrote StoryEdit class as a function (#17549)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* using BlockMediaUpdateProgress

* method rename

* updated story block to represent error state

* added cancel and retry bridge methods specific for mediaFiles collection based blocks

* using a deep copy of mediaFiles when replacing ids and mediaUrl, given mediaFiles attribute needs to be replaced again and cannot be modified in place as per React conventions

* added requestMediaFilesSaveCancelDialog bridge method

* changed props name onMediaModelCreated to more generic onMediaIdChanged

* removed commented code

* added MediaPlaceholder, wrapped in a pointerEvents=none View so we can handle media picking from the StoryComposer

* replaced for loops with map

* rewrote StoryEdit class as a function

* removed unused imports

* removed unused function

* story block: set inserter support to false for web, but keep it for mobile (#17690)

* renamed params to avoid name shadowing
mzorz added a commit that referenced this pull request Nov 14, 2020
* basic scaffolding for the Story block on mobile editor

* added flex alignment and actual mediaFiles attribute rendering

* applying styles to stories block view

* removed unused alignment

* added StoryEditingButton and showing it when the story block is selected

* connecting StoryEditingButton with bridge's requestStoryCreatorLoad

* updated requestStoryCreatorLoad call to pass block's mediaFiles and clientId over the bridge

* added new component StoryUpdateProgress

* Revert "added new component StoryUpdateProgress", not belonging to this branch

This reverts commit 86fb956.

* fixed lint warnings

* changed the no longer existing color dark-gray-500 removed in WordPress/gutenberg@162bc50 with gray-700

* added package-lock.json

* Mobile Stories block (part 2): introduce StoryUpdateProgress (#17222)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* Mobile Stories block (part 3): rename using BlockMediaUpdateProgress (#17456)

* using BlockMediaUpdateProgress

* method rename

* updated (automatically modified) package-lock.json

* removed package-lock.json

* moved condition check for http or https to helper method isUrlRemote()

* calling mediaUploadSync and mediaSaveSync regardless of ids, we always will want to receive updates on all 3 stages

* fixed spelling

* Mobile Stories block (part 4): error handling (#17458)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* using BlockMediaUpdateProgress

* method rename

* updated story block to represent error state

* added cancel and retry bridge methods specific for mediaFiles collection based blocks

* using a deep copy of mediaFiles when replacing ids and mediaUrl, given mediaFiles attribute needs to be replaced again and cannot be modified in place as per React conventions

* added requestMediaFilesSaveCancelDialog bridge method

* changed props name onMediaModelCreated to more generic onMediaIdChanged

* removed commented code

* replaced for loops with map

* Mobile Stories block (part 5): add empty placeholder (#17539)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* using BlockMediaUpdateProgress

* method rename

* updated story block to represent error state

* added cancel and retry bridge methods specific for mediaFiles collection based blocks

* using a deep copy of mediaFiles when replacing ids and mediaUrl, given mediaFiles attribute needs to be replaced again and cannot be modified in place as per React conventions

* added requestMediaFilesSaveCancelDialog bridge method

* changed props name onMediaModelCreated to more generic onMediaIdChanged

* removed commented code

* added MediaPlaceholder, wrapped in a pointerEvents=none View so we can handle media picking from the StoryComposer

* replaced for loops with map

* importing defined const MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO instead of re-defining

* made placeholder container look as per any other media placeholder, reservign the Story style container for populated Story blocks

* Mobile Stories block (part 6): rewrote StoryEdit class as a function (#17549)

* Revert "Revert "added new component StoryUpdateProgress", not belonging to this branch"

This reverts commit 34349b1.

* added mediaSave statuses listeners definitions

* moved StoryEdit to a React.Component class and implemented StoryUpdateProgress overlay

* added onStorySaveResult handling to Story block

* edit mode: replacing urls by id for saving process

* added onMediaModelCreated() callback so we can re-assign the mediaID to the mediaFiles attribute of a Story block once such a mediaModel is created

* update the mediaFile id and URL of a given story frame when finished uploading succesfully

* removed commented imports

* added explicit TODO comments to make sure to follow up on them for error handling

* make sure to call mediaUploadSync and storySaveSync if any of the mediaFiles contained in this block is not a remote url - also call onRemoveBlockCheckUpload() action under the same conditions in componentWillUnmount()

* using BlockMediaUpdateProgress

* method rename

* updated story block to represent error state

* added cancel and retry bridge methods specific for mediaFiles collection based blocks

* using a deep copy of mediaFiles when replacing ids and mediaUrl, given mediaFiles attribute needs to be replaced again and cannot be modified in place as per React conventions

* added requestMediaFilesSaveCancelDialog bridge method

* changed props name onMediaModelCreated to more generic onMediaIdChanged

* removed commented code

* added MediaPlaceholder, wrapped in a pointerEvents=none View so we can handle media picking from the StoryComposer

* replaced for loops with map

* rewrote StoryEdit class as a function

* removed unused imports

* removed unused function

* story block: set inserter support to false for web, but keep it for mobile (#17690)

* renamed params to avoid name shadowing

Co-authored-by: mzorz <mariozorz@gmail.com>
@kraftbj kraftbj deleted the try/jetpack-stories-block-mobile branch November 17, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Story Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants