Skip to content

[RNMobile] Add "Set as Featured Image" Button to Image Block (Android Only)#31705

Merged
SiobhyB merged 38 commits intotrunkfrom
update/image-block-with-featured-image-setting
Jun 3, 2021
Merged

[RNMobile] Add "Set as Featured Image" Button to Image Block (Android Only)#31705
SiobhyB merged 38 commits intotrunkfrom
update/image-block-with-featured-image-setting

Conversation

@SiobhyB
Copy link
Copy Markdown
Contributor

@SiobhyB SiobhyB commented May 11, 2021

Partial fix for: wordpress-mobile/gutenberg-mobile#1011

gutenberg-mobile: wordpress-mobile/gutenberg-mobile#3116
WordPress-Android: wordpress-mobile/WordPress-Android#14503

Description

Building on the work done in #30806, this PR will add a Set as Featured button to the image block's settings, with the purpose being to make it simpler for users to set a featured image within the post's editor. Users will also be able to Remove as Featured directly from the block's settings.

Note: This PR introduces the Set as Featured button to Android devices only, support for iOS will follow in future iterations, too.

How has this been tested?

Test Case 1: General Flow

To start with, the general flow for setting a featured image via the image block on a post without an existing image is as follows.
  • In the app, navigate to HomeBlog Posts to create a new blog post, one which doesn't already have a featured image set.
  • Add a new image block, and upload an image to it.
  • Tap the image block's cog/gear icon to access its settings.
  • Observe the new Set as Featured button at the bottom of the settings and tap it.
  • Verify that you see a confirmation message about the newly set featured image and that the block now has a Featured banner overlaying it.

Test Case 2: "Replace Existing" Flow

It's also possible for users to replace an existing featured image via the following flow.
  • Add a new image block to the post and upload a second image to it.
  • Again, tap the image block's cog/gear icon to access its settings.
  • Tap the Set as Featured button at the bottom of the settings and tap it.
  • A dialog should appear to inform you that the post already has a featured image, with an option to Cancel or confirm your wish to Replace.
  • Tap Cancel to confirm it works as expected, to dismiss the action.
  • Go through steps two through four again and this time tap Replace.
  • Verify that you see a confirmation message about the newly set featured image and that the block now has a Featured banner overlaying it. The banner should no longer overlay the previous featured image.

Test Case 3: "Editor Loads" Flow

Next, we should verify that a **Remove as Featured** option appears when a post with a featured image is first loaded. To test this, follow these steps.
  • Verify that a featured image has been set on the post and tap the back button.
  • Return to the post's editor by tapping on it from the post list screen.
  • Verify that the post's featured image has a Featured banner overlaying it. Tap the cog/gear icon to then confirm the option to Remove as Featured appears.

Test Case 4: "Post Settings" Flow

The image block should be updated to reflect whether its image is featured or not even when the featured image is set via the general Post Settings flow.
  • Tap the three icons to the upper right of the post editor to access Post Settings.
  • Tap existing featured image and then Remove.
  • Tap the back button to confirm that the Featured banner has been removed from the featured image, as expected. Tap the cog/gear icon to then confirm the option to Set as Featured appears.
  • Return to the Post Settings screen and set a new featured image.
  • Tap the back button. If the new featured image hasn't already been added to the editor via an image block, add it.
  • Confirm that the Featured banner displays overlays the correct image and that Remove as Featured appears in its settings.

Test Case 5: "Replace in Image Block" Flow

Finally, it's possible to replace an image directly within the image block's settings. We need to verify that the featured settings update as expected depending on the image that's chosen for an image block.
  • Select any image block that is flagged with the Featured banner.
  • Tap the edit icon to the upper right and then Replace.
  • Replace with any image that isn't the post's featured image.
  • Verify that the Featured banner is removed from the block when the new image uploads and that the Set as Featured button appears in the block's settings.
  • Go through the steps to replace the block's image again, this time pick the post's featured image.
  • Verify that the Featured banner appears again and that the Remove as Featured button appears in the block's settings.

Screenshots

Set as Featured Image Remove as Featured Image
Replace Dialog Confirmation Dialog

Types of changes

This PR introduces a new feature (non-breaking change which adds functionality). The feature it introduces is a Set as Featured button in the image block's setting, which enables a user to either set an image as featured or remove it as featured.

A high-level overview of the code changes involved is as follows:

  • A new component is defined with getSetFeaturedButton. This component outputs a button with either a Set as Featured or a Remove as Featured label, depending on whether isFeaturedImage is true or not.
  • onSetFeatured will be called when the button is tapped, this function utilizes another function named setFeaturedImage to send an image's media ID over the bridge when a request is made to either set a new featured image (in which case the media ID is that of the selected image) or to remove an existing featured image (in which case the media ID is zero). A call to close the settings screen is also made within onSetFeatured.
  • Building on the logic for grabbing the ID of a post's featured image, which was set out in [RNMobile] Add Featured Banner to Image Block (Android Only) #30806, featuredImageId is updated after confirmation of the change on the native side, as native is our main source of truth when it comes to confirming the change to the post's featured image ID. The changes to packages/edit-post/src/editor.native.js in the linked PR can be referenced for further details around how this is handled using the getEditedPostAttribute() function.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@SiobhyB SiobhyB added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label May 11, 2021
@github-actions
Copy link
Copy Markdown

github-actions bot commented May 11, 2021

Size Change: 0 B

Total Size: 1.03 MB

ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.12 kB 0 B
build/annotations/index.js 2.93 kB 0 B
build/api-fetch/index.js 2.42 kB 0 B
build/autop/index.js 2.28 kB 0 B
build/blob/index.js 672 B 0 B
build/block-directory/index.js 6.61 kB 0 B
build/block-directory/style-rtl.css 989 B 0 B
build/block-directory/style.css 990 B 0 B
build/block-editor/index.js 118 kB 0 B
build/block-editor/style-rtl.css 12.9 kB 0 B
build/block-editor/style.css 12.9 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/archives/style-rtl.css 65 B 0 B
build/block-library/blocks/archives/style.css 65 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 112 B 0 B
build/block-library/blocks/audio/style.css 112 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 603 B 0 B
build/block-library/blocks/button/style.css 602 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 315 B 0 B
build/block-library/blocks/buttons/editor.css 315 B 0 B
build/block-library/blocks/buttons/style-rtl.css 375 B 0 B
build/block-library/blocks/buttons/style.css 375 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 422 B 0 B
build/block-library/blocks/columns/style.css 422 B 0 B
build/block-library/blocks/cover/editor-rtl.css 644 B 0 B
build/block-library/blocks/cover/editor.css 646 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.22 kB 0 B
build/block-library/blocks/cover/style.css 1.23 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 401 B 0 B
build/block-library/blocks/embed/style.css 400 B 0 B
build/block-library/blocks/file/editor-rtl.css 301 B 0 B
build/block-library/blocks/file/editor.css 300 B 0 B
build/block-library/blocks/file/frontend.js 773 B 0 B
build/block-library/blocks/file/style-rtl.css 255 B 0 B
build/block-library/blocks/file/style.css 255 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB 0 B
build/block-library/blocks/freeform/editor.css 2.44 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 704 B 0 B
build/block-library/blocks/gallery/editor.css 705 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.06 kB 0 B
build/block-library/blocks/gallery/style.css 1.06 kB 0 B
build/block-library/blocks/group/editor-rtl.css 160 B 0 B
build/block-library/blocks/group/editor.css 160 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/heading/editor-rtl.css 129 B 0 B
build/block-library/blocks/heading/editor.css 129 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/home-link/style-rtl.css 259 B 0 B
build/block-library/blocks/home-link/style.css 259 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 729 B 0 B
build/block-library/blocks/image/editor.css 727 B 0 B
build/block-library/blocks/image/style-rtl.css 481 B 0 B
build/block-library/blocks/image/style.css 485 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 281 B 0 B
build/block-library/blocks/latest-comments/style.css 282 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 529 B 0 B
build/block-library/blocks/latest-posts/style.css 529 B 0 B
build/block-library/blocks/legacy-widget/editor-rtl.css 582 B 0 B
build/block-library/blocks/legacy-widget/editor.css 583 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 176 B 0 B
build/block-library/blocks/media-text/editor.css 176 B 0 B
build/block-library/blocks/media-text/style-rtl.css 492 B 0 B
build/block-library/blocks/media-text/style.css 489 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 633 B 0 B
build/block-library/blocks/navigation-link/editor.css 634 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B 0 B
build/block-library/blocks/navigation-link/style.css 94 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.55 kB 0 B
build/block-library/blocks/navigation/editor.css 1.55 kB 0 B
build/block-library/blocks/navigation/frontend.js 2.86 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 1.63 kB 0 B
build/block-library/blocks/navigation/style.css 1.63 kB 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 310 B 0 B
build/block-library/blocks/page-list/editor.css 311 B 0 B
build/block-library/blocks/page-list/style-rtl.css 240 B 0 B
build/block-library/blocks/page-list/style.css 240 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B 0 B
build/block-library/blocks/paragraph/editor.css 157 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 247 B 0 B
build/block-library/blocks/paragraph/style.css 248 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 140 B 0 B
build/block-library/blocks/post-comments-form/style.css 140 B 0 B
build/block-library/blocks/post-comments/style-rtl.css 360 B 0 B
build/block-library/blocks/post-comments/style.css 359 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B 0 B
build/block-library/blocks/post-excerpt/style.css 69 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 141 B 0 B
build/block-library/blocks/post-featured-image/style.css 141 B 0 B
build/block-library/blocks/post-title/style-rtl.css 60 B 0 B
build/block-library/blocks/post-title/style.css 60 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 103 B 0 B
build/block-library/blocks/preformatted/style.css 103 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 318 B 0 B
build/block-library/blocks/pullquote/style.css 318 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 98 B 0 B
build/block-library/blocks/query-loop/editor.css 97 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 315 B 0 B
build/block-library/blocks/query-loop/style.css 317 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query-title/editor-rtl.css 86 B 0 B
build/block-library/blocks/query-title/editor.css 86 B 0 B
build/block-library/blocks/query/editor-rtl.css 131 B 0 B
build/block-library/blocks/query/editor.css 132 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 211 B 0 B
build/block-library/blocks/search/editor.css 211 B 0 B
build/block-library/blocks/search/style-rtl.css 359 B 0 B
build/block-library/blocks/search/style.css 362 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 251 B 0 B
build/block-library/blocks/separator/style.css 251 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 512 B 0 B
build/block-library/blocks/shortcode/editor.css 512 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 440 B 0 B
build/block-library/blocks/site-logo/editor.css 441 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 154 B 0 B
build/block-library/blocks/site-logo/style.css 154 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 800 B 0 B
build/block-library/blocks/social-links/editor.css 799 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB 0 B
build/block-library/blocks/social-links/style.css 1.33 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 308 B 0 B
build/block-library/blocks/spacer/editor.css 308 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/table/style-rtl.css 480 B 0 B
build/block-library/blocks/table/style.css 480 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 551 B 0 B
build/block-library/blocks/template-part/editor.css 550 B 0 B
build/block-library/blocks/term-description/editor-rtl.css 90 B 0 B
build/block-library/blocks/term-description/editor.css 90 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 569 B 0 B
build/block-library/blocks/video/editor.css 570 B 0 B
build/block-library/blocks/video/style-rtl.css 173 B 0 B
build/block-library/blocks/video/style.css 173 B 0 B
build/block-library/common-rtl.css 1.26 kB 0 B
build/block-library/common.css 1.26 kB 0 B
build/block-library/editor-rtl.css 9.96 kB 0 B
build/block-library/editor.css 9.96 kB 0 B
build/block-library/index.js 147 kB 0 B
build/block-library/reset-rtl.css 506 B 0 B
build/block-library/reset.css 507 B 0 B
build/block-library/style-rtl.css 10.1 kB 0 B
build/block-library/style.css 10.1 kB 0 B
build/block-library/theme-rtl.css 692 B 0 B
build/block-library/theme.css 693 B 0 B
build/block-serialization-default-parser/index.js 1.3 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/blocks/index.js 47.2 kB 0 B
build/components/index.js 179 kB 0 B
build/components/style-rtl.css 16.2 kB 0 B
build/components/style.css 16.1 kB 0 B
build/compose/index.js 10 kB 0 B
build/core-data/index.js 12.1 kB 0 B
build/customize-widgets/index.js 9.96 kB 0 B
build/customize-widgets/style-rtl.css 1.45 kB 0 B
build/customize-widgets/style.css 1.44 kB 0 B
build/data-controls/index.js 830 B 0 B
build/data/index.js 7.22 kB 0 B
build/date/index.js 31.8 kB 0 B
build/deprecated/index.js 738 B 0 B
build/dom-ready/index.js 576 B 0 B
build/dom/index.js 4.62 kB 0 B
build/edit-navigation/index.js 13.9 kB 0 B
build/edit-navigation/style-rtl.css 3.08 kB 0 B
build/edit-navigation/style.css 3.08 kB 0 B
build/edit-post/classic-rtl.css 454 B 0 B
build/edit-post/classic.css 454 B 0 B
build/edit-post/index.js 58.4 kB 0 B
build/edit-post/style-rtl.css 6.92 kB 0 B
build/edit-post/style.css 6.91 kB 0 B
build/edit-site/index.js 25.9 kB 0 B
build/edit-site/style-rtl.css 4.75 kB 0 B
build/edit-site/style.css 4.75 kB 0 B
build/edit-widgets/index.js 15.7 kB 0 B
build/edit-widgets/style-rtl.css 3.42 kB 0 B
build/edit-widgets/style.css 3.42 kB 0 B
build/editor/index.js 38.2 kB 0 B
build/editor/style-rtl.css 3.91 kB 0 B
build/editor/style.css 3.9 kB 0 B
build/element/index.js 3.44 kB 0 B
build/escape-html/index.js 739 B 0 B
build/format-library/index.js 5.66 kB 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.js 1.76 kB 0 B
build/html-entities/index.js 628 B 0 B
build/i18n/index.js 3.73 kB 0 B
build/is-shallow-equal/index.js 709 B 0 B
build/keyboard-shortcuts/index.js 1.74 kB 0 B
build/keycodes/index.js 1.43 kB 0 B
build/list-reusable-blocks/index.js 2.07 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/media-utils/index.js 3.08 kB 0 B
build/notices/index.js 1.07 kB 0 B
build/nux/index.js 2.31 kB 0 B
build/nux/style-rtl.css 718 B 0 B
build/nux/style.css 716 B 0 B
build/plugins/index.js 1.99 kB 0 B
build/primitives/index.js 1.03 kB 0 B
build/priority-queue/index.js 791 B 0 B
build/react-i18n/index.js 924 B 0 B
build/redux-routine/index.js 2.82 kB 0 B
build/reusable-blocks/index.js 2.56 kB 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/rich-text/index.js 10.6 kB 0 B
build/server-side-render/index.js 1.63 kB 0 B
build/shortcode/index.js 1.68 kB 0 B
build/token-list/index.js 847 B 0 B
build/url/index.js 1.95 kB 0 B
build/viewport/index.js 1.28 kB 0 B
build/warning/index.js 1.13 kB 0 B
build/widgets/index.js 1.67 kB 0 B
build/wordcount/index.js 1.24 kB 0 B

compressed-size-action

SiobhyB added 13 commits May 11, 2021 13:54
…red| button

The function returns a button (in the form of a BottomSheet.Cell component) based on whether "isFeaturedImage" is true or false. The function called within the image block's settings.

In its current form, the button is unresponsive and only includes a label to "Set as Featured Image" or "Remove as Featured Image", depending on whether the current image is already featured or not.
For now, the button will only work on Android devices, so an "androidOnly" conditional is necessary to avoid bugs/complications on iOS.
The getStylesFromColorScheme hook is used to define CSS selectors for the button, depending on whether the device uses dark or light mode. The hook's "featuredButtonStyle" variable is then called via BottomSheet's labelStyle attribute.
This commit uses the "getStylesFromColorScheme" hook to set up CSS selectors for the "Set as Featured Image" button, as its style will vary slightly from the base button.
This includes CSS for both the light mode and dark mode versions of the button.
This function will fire when the "Set/Remove as Featured Image" button is pressed and its functionality will be fleshed out in future commits.
setFeaturedImage is imported from '@wordpress/react-native-bridge' and called via the onSetFeatured, as it'll be utilised when the button is pressed.
…edImage()

When a featured image is being removed, the mediaId will be zero, and when it's being set it'll be the "attributes.id" of the image in the block.
@SiobhyB SiobhyB self-assigned this May 11, 2021
@SiobhyB SiobhyB added the [Type] Enhancement A suggestion for improvement. label May 12, 2021
@SiobhyB SiobhyB requested a review from hypest May 12, 2021 10:21
@hypest
Copy link
Copy Markdown
Contributor

hypest commented May 12, 2021

SiobhyB requested a review from hypest 31 minutes ago

👋 @SiobhyB , happy to review! Can you share some info about what's not "finished" yet keeping the PR in Draft mode? Anything in particular you'd like me to offer feedback on? Thanks!

@SiobhyB
Copy link
Copy Markdown
Contributor Author

SiobhyB commented May 12, 2021

@hypest, thanks for taking a look! The gutenberg-mobile PR still has a couple of failing tests that I'm looking into, but the overall code is functioning.

I'm keeping the PR as a draft as there will likely be some commits coming as part of the efforts to resolve the failing tests, but I believe that these will mainly be merges and updates to references. I don't currently have any other major changes to the code in mind, so seeking feedback on the overall PRs, aside from the failing tests on gutenberg-mobile (unless you notice something in the code that's causing them to fail, of course!). Looking forward to hearing what you think and thanks again!

@SiobhyB
Copy link
Copy Markdown
Contributor Author

SiobhyB commented May 12, 2021

@hypest, just an FYI that I'm taking this out of draft now as all tests have now passed. :D 🎉

@SiobhyB SiobhyB marked this pull request as ready for review May 12, 2021 16:37
@SiobhyB
Copy link
Copy Markdown
Contributor Author

SiobhyB commented May 21, 2021

@hypest, just an FYI that the bug I mentioned in the above comment has been fixed now. :)

SiobhyB added 2 commits May 26, 2021 15:27
…functions

These functions had accidentally been given the oppositive names (that is, the function that removes a featured image was named "setFeaturedButton" and vice versa). This commit corrects that mistake.
@SiobhyB SiobhyB requested a review from ajitbohra as a code owner May 26, 2021 14:36
@SiobhyB
Copy link
Copy Markdown
Contributor Author

SiobhyB commented May 27, 2021

👋 @ajitbohra, it seems like you were added as a reviewer to this PR following a change to the image/constants.js file. Would you be able to let me know whether this was an automatic assignment? I don't recall manually requesting your review, so wanted to double-check.

Most of the changes in the PR itself are on the native side and are already under review by two developers from the mobile team. Would you still need to review the changes in this instance or is it okay to proceed with the current reviewers? I'm not that familiar with the way reviews are assigned in the project, so any insight you can offer around the correct processes would be appreciated. Thanks!

@hypest
Copy link
Copy Markdown
Contributor

hypest commented May 27, 2021

Tested all the flows via WPAndroid and works perfect! 🎉

✅ Test Case 1: General Flow
✅ Test Case 2: "Replace Existing" Flow
✅ Test Case 3: "Editor Loads" Flow
✅ Test Case 4: "Post Settings" Flow
✅ Test Case 5: "Replace in Image Block" Flow

@hypest
Copy link
Copy Markdown
Contributor

hypest commented May 27, 2021

✅ Also verified via WPiOS that the feature is not available there as expected (Android only for the time being, iOS is worked on a different set of PRs).

Copy link
Copy Markdown
Contributor

@hypest hypest left a comment

Choose a reason for hiding this comment

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

Looks good to me! Awesome work here @SiobhyB , thanks for persevering and addressing all feedback!

Seems like there are some web E2E test job failing but don't look relevant to the changes here. Perhaps you can update from trunk and see if that fixes them (trunk seems green at the time of writing this).

I'll leave it to the other reviewers of this PR to conclude their rounds and I guess we can start merging the domino! 👏

Copy link
Copy Markdown
Member

@ajitbohra ajitbohra left a comment

Choose a reason for hiding this comment

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

@SiobhyB

LGTM 👍

  • That's an automatic assignment
  • As we already have a code review and 1 approval its good to merge

Copy link
Copy Markdown
Contributor

@jd-alexander jd-alexander left a comment

Choose a reason for hiding this comment

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

Hi @SiobhyB I ran tests after merging in the refactor and all flows work as expected! 🎉

WP Android

✅ Test Case 1: General Flow
✅ Test Case 2: "Replace Existing" Flow
✅ Test Case 3: "Editor Loads" Flow
✅ Test Case 4: "Post Settings" Flow
✅ Test Case 5: "Replace in Image Block" Flow

WP iOS
✅ Verified that the functionality does not work on iOS and that setting the featured image in Post Settings does not cause the editor to crash.

@SiobhyB SiobhyB force-pushed the update/image-block-with-featured-image-setting branch 2 times, most recently from bc00de7 to 4e24d0a Compare June 2, 2021 16:57
@SiobhyB SiobhyB merged commit f2472ed into trunk Jun 3, 2021
@SiobhyB SiobhyB deleted the update/image-block-with-featured-image-setting branch June 3, 2021 09:51
@github-actions github-actions bot added this to the Gutenberg 10.9 milestone Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants