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] Add "Set as Featured Image" Button to Image Block (Android Only) #28854

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a4a52fe
Add "set as featured image" button to image block
SiobhyB Feb 8, 2021
4040201
Add "setFeaturedImage" function in bridge code
Feb 11, 2021
6bcfbd9
Add setFeaturedImage function to MainApplication
Feb 12, 2021
0cff0d7
Add "OnSetFeaturedImageListener" listener
Feb 12, 2021
dbec57d
Update edit.native.js with small syntax correction
Feb 12, 2021
d66bd01
Set up "OnSetFeaturedImageListener" in WPAndroidGlue.java
Feb 12, 2021
d1ed155
Passing featured image ID from native (Android) to Gutenberg
Mar 3, 2021
6a57885
Merge branch 'trunk' into update/featured-image-button-in-image-block…
SiobhyB Mar 3, 2021
444f3e3
Restore missing curly brace
Mar 3, 2021
2cbe570
Updates to featured-banner.native.js
Mar 5, 2021
073fa92
Attempts to select featured image using getEditedPostAttribute()
Mar 15, 2021
64359b1
Update featured-banner.native.js
Mar 15, 2021
48f8ea1
Add featured banner to image/index.native.js
Mar 15, 2021
f114ade
Update featured image banner and button styles
Mar 15, 2021
46ba7e8
Create getFeaturedImageId function and cleanup
Mar 16, 2021
b8f05f4
Tidy up edit.native.js
Mar 16, 2021
c7d00f3
Update AndroidGlueCode
Mar 18, 2021
84a8850
retrigger checks
Mar 22, 2021
eb78dc4
Update setup.js
Mar 22, 2021
bed517e
retrigger checks
Mar 22, 2021
64b1c8b
Update function name from "featuredImageIdChange" to "featuredImageId…
Mar 23, 2021
d8c0824
Rename "featuredImageIdNotifier" to "onRequestFeaturedImageId"
Mar 23, 2021
32f134d
Create OnSetFeaturedImageListener
Mar 23, 2021
75de59f
Dismiss bottomsheet when "setFeaturedImage" is called
Mar 23, 2021
67369d3
Introduce "onRemoveFeatured" button and tidying up names
Mar 29, 2021
c9aba0a
Updates to function names
Mar 29, 2021
a9d051f
Convert FeaturedBanner to Badge component
Mar 30, 2021
a92525b
Update edit.native.js to correct merge conflict
Mar 30, 2021
54a5f14
Correct merge conflict with GutenbergBridgeJS2Parent.java
Mar 30, 2021
e99999c
retrigger checks
Mar 30, 2021
be31d63
retrigger checks
Mar 30, 2021
9795874
retrigger checks
Mar 30, 2021
2284524
retrigger checks
Mar 30, 2021
2736f33
Update edit.native.js to fix merge conflict
Mar 31, 2021
e9ebc69
Update edit.native.js to check if an image is featured uppn changes
Mar 31, 2021
2eb1979
Update styles.native.scss to add border to the top of featured button
Apr 1, 2021
a33b8b9
Update edit.native.js
Apr 1, 2021
0cdeadb
Introduce "featuredMedia" prop for use when editor loads
Apr 6, 2021
737627d
Fetch ID of post's initial featured image
Apr 7, 2021
9e524ea
Merge branch 'trunk' into update/featured-image-button-in-image-block…
SiobhyB Apr 8, 2021
6d53341
Updated featured state when image is replaced within block
Apr 8, 2021
cc00dc2
Remove checkIfFeaturedImage function
Apr 8, 2021
4dc6cef
Fix merge conflict
Apr 8, 2021
b335086
Fix merge conflict
Apr 8, 2021
3cbe30a
Add "setFeaturedImage" and "featuredImageIdCurrent" functions to Swif…
Apr 10, 2021
39303e4
Simplify this.state.isFeaturedImage by converting to a boolean inside…
Apr 10, 2021
0c69a62
Comment out iOS-specific changes to the bridge
Apr 12, 2021
cc4aa8d
Add iOS functions to bridge
Apr 12, 2021
d71d067
Flag featured image when editor mounts and comment out iOS methods fr…
Apr 12, 2021
28f19af
Comment out a bridge function for iOS (missing from previous commit).
Apr 12, 2021
262291f
Add set featured image functionality behind dev flag
Apr 13, 2021
a17e6e9
Move "set as featured" button behind devOnly and androidOnly flag
Apr 13, 2021
1c4b2ca
Calling "__DEV__" directly instead of defining a separate variable
Apr 13, 2021
ba7c283
Update changelog.md
Apr 13, 2021
206fede
Merge branch 'trunk' into update/featured-image-button-in-image-block…
SiobhyB Apr 13, 2021
1f844b6
Merge branch 'trunk' into update/featured-image-button-in-image-block…
SiobhyB Apr 20, 2021
9761c04
Merge branch 'trunk' into update/featured-image-button-in-image-block…
SiobhyB Apr 20, 2021
85844e4
Remove "subscribeFeaturedImageIdCurrent" functionality
Apr 20, 2021
1f61eb8
Remove featuredImageId check in componentDidMount()
Apr 20, 2021
35fa071
Remove isFeaturedImage functionality from image/index.native.js
Apr 20, 2021
590040b
Remove iOS functions from bridge
Apr 20, 2021
619f4f7
Remove android.util.Log import
Apr 20, 2021
dd6a63f
Remove redundant space
Apr 20, 2021
35f7023
Update CHANGELOG.md
Apr 20, 2021
2ed72bf
Tweak androidOnly const
Apr 20, 2021
c74e737
Merge branch 'trunk' into update/featured-image-button-in-image-block…
Apr 23, 2021
68ef75e
Refactor 'set as featured' button into its own function
Apr 27, 2021
fbe83c2
Merge branch 'update/featured-image-button-in-image-block-settings' o…
Apr 27, 2021
e3ba262
Merge branch 'trunk' into update/featured-image-button-in-image-block…
SiobhyB Apr 27, 2021
9caa86a
Fix syntax issue with onSetFeatured function
Apr 27, 2021
fe2c108
Merge remote-tracking branch 'upstream/trunk' into update/featured-im…
Apr 27, 2021
89a8c6c
Merge branch 'WordPress:trunk' into update/featured-image-button-in-i…
SiobhyB May 9, 2021
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
10 changes: 10 additions & 0 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
Image,
WIDE_ALIGNMENTS,
LinkSettingsNavigation,
BottomSheet,
} from '@wordpress/components';
import {
BlockCaption,
Expand Down Expand Up @@ -245,6 +246,8 @@ export class ImageEdit extends Component {
} );
}

onSetFeatured() {}

onSetLinkDestination( href ) {
this.props.setAttributes( {
linkDestination: LINK_DESTINATION_CUSTOM,
Expand Down Expand Up @@ -444,6 +447,13 @@ export class ImageEdit extends Component {
<PanelBody title={ __( 'Link Settings' ) }>
{ this.getLinkSettings( true ) }
</PanelBody>
<PanelBody>
<BottomSheet.Cell
label={ __( 'Set as Featured Image' ) }
labelStyle={ styles.setFeaturedButton }
onPress={ this.onSetFeatured }
/>
</PanelBody>
</InspectorControls>
);

Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/image/styles.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@
padding-right: 0;
padding-bottom: $grid-unit;
}

.setFeaturedButton {
text-align: center;
color: $blue-medium;
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public static GutenbergUserEvent getEnum(String eventName) {

void requestImageUploadCancel(int mediaId);

void setFeaturedImage(int mediaId);

void editorDidEmitLog(String message, LogLevel logLevel);

void editorDidAutosave();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ public void requestImageUploadCancel(final int mediaId) {
mGutenbergBridgeJS2Parent.requestImageUploadCancel(mediaId);
}

@ReactMethod
public void setFeaturedImage(final int mediaId) {
mGutenbergBridgeJS2Parent.setFeaturedImage(mediaId);
}

@ReactMethod
public void requestImageFullscreenPreview(String mediaUrl) {
mGutenbergBridgeJS2Parent.requestImageFullscreenPreview(mediaUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ public void requestImageUploadCancel(int mediaId) {
mOnMediaLibraryButtonListener.onCancelUploadForMediaDueToDeletedBlock(mediaId);
}

@Override
SiobhyB marked this conversation as resolved.
Show resolved Hide resolved
public void setFeaturedImage(int mediaId) {
mOnMediaLibraryButtonListener.onSetFeaturedImageButtonClicked(mediaId);
}

@Override
public void editorDidMount(ReadableArray unsupportedBlockNames) {
mOnEditorMountListener.onEditorDidMount(unsupportedBlockNames.toArrayList());
Expand Down
6 changes: 6 additions & 0 deletions packages/react-native-bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ export function requestImageUploadCancel( mediaId ) {
return RNReactNativeGutenbergBridge.requestImageUploadCancel( mediaId );
}

export function setFeaturedImage( mediaId ) {
return RNReactNativeGutenbergBridge.setFeaturedImage(
mediaId
);
}

export function getOtherMediaOptions( filter, callback ) {
return RNReactNativeGutenbergBridge.getOtherMediaOptions(
filter,
Expand Down