Skip to content

Commit

Permalink
Tooltip for page template selection buttons (#2216)
Browse files Browse the repository at this point in the history
* Starter Page Templates - Tooltip

* Update Release Notes

* Update Gutenberg ref
  • Loading branch information
Gerardo Pacheco authored May 26, 2020
1 parent cd2fadd commit 59220b0
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [***] Trash icon that is used to remove blocks is moved to the new menu reachable via ellipsis button in the block toolbar
* [**] Block toolbar can now collapse when the block width is smaller than the toolbar content
* [**] Creating undo levels less frequently
* [**] Tooltip for page template selection buttons

1.28.0
------
Expand Down
8 changes: 8 additions & 0 deletions android/app/src/main/java/com/gutenberg/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ public void requestMediaEditor(MediaUploadCallback mediaUploadCallback, String m
public void logUserEvent(GutenbergUserEvent gutenbergUserEvent, ReadableMap eventProperties) {
}

@Override
public void setStarterPageTemplatesTooltipShown(boolean tooltipShown) {
}

@Override
public void requestStarterPageTemplatesTooltipShown(StarterPageTemplatesTooltipShownCallback starterPageTemplatesTooltipShownCallback) {
}

@Override
public void editorDidEmitLog(String message, LogLevel logLevel) {
switch (logLevel) {
Expand Down
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 76 files
+4 −1 bin/check-latest-npm.js
+5 −0 changelog.txt
+0 −9 docs/designers-developers/developers/data/data-core-block-editor.md
+1 −1 gutenberg.php
+1 −1 lib/class-wp-rest-block-directory-controller.php
+2 −1 package-lock.json
+1 −1 package.json
+1 −0 packages/block-directory/package.json
+59 −0 packages/block-directory/src/components/downloadable-block-list-item/test/__snapshots__/index.js.snap
+19 −0 packages/block-directory/src/components/downloadable-block-list-item/test/fixtures/index.js
+34 −0 packages/block-directory/src/components/downloadable-block-list-item/test/index.js
+12 −24 packages/block-directory/src/components/downloadable-block-notice/index.js
+2 −2 packages/block-directory/src/components/downloadable-block-notice/style.scss
+22 −0 packages/block-directory/src/components/downloadable-block-notice/test/__snapshots__/index.js.snap
+25 −26 packages/block-directory/src/components/downloadable-block-notice/test/index.js
+10 −82 packages/block-directory/src/components/downloadable-blocks-list/index.js
+57 −0 packages/block-directory/src/components/downloadable-blocks-list/test/__snapshots__/index.js.snap
+21 −44 packages/block-directory/src/components/downloadable-blocks-list/test/index.js
+47 −91 packages/block-directory/src/store/actions.js
+0 −13 packages/block-directory/src/store/constants.js
+40 −122 packages/block-directory/src/store/controls.js
+2 −1 packages/block-directory/src/store/index.js
+3 −12 packages/block-directory/src/store/reducer.js
+5 −1 packages/block-directory/src/store/resolvers.js
+14 −2 packages/block-directory/src/store/selectors.js
+112 −133 packages/block-directory/src/store/test/actions.js
+45 −0 packages/block-directory/src/store/test/controls.js
+78 −10 packages/block-directory/src/store/test/reducer.js
+67 −1 packages/block-directory/src/store/test/selectors.js
+1 −0 packages/block-editor/CHANGELOG.md
+2 −4 packages/block-editor/src/components/inserter/block-list.js
+0 −14 packages/block-editor/src/components/inserter/test/block-list.js
+5 −5 packages/block-editor/src/components/inserter/test/fixtures/index.js
+36 −1 packages/block-editor/src/components/page-template-picker/picker.native.js
+100 −0 packages/block-editor/src/components/page-template-picker/tooltip/index.native.js
+34 −0 packages/block-editor/src/components/page-template-picker/tooltip/style.native.scss
+5 −1 packages/block-editor/src/hooks/color.js
+3 −50 packages/block-editor/src/store/selectors.js
+8 −69 packages/block-editor/src/store/test/selectors.js
+11 −0 packages/block-library/src/columns/block.json
+1 −7 packages/block-library/src/columns/index.js
+12 −0 packages/block-library/src/group/block.json
+0 −9 packages/block-library/src/group/index.js
+9 −0 packages/block-library/src/heading/block.json
+0 −10 packages/block-library/src/heading/index.js
+10 −0 packages/block-library/src/media-text/block.json
+0 −6 packages/block-library/src/media-text/index.js
+1 −3 packages/block-library/src/nextpage/block.json
+8 −0 packages/block-library/src/paragraph/block.json
+0 −9 packages/block-library/src/paragraph/index.js
+0 −1 packages/components/src/custom-select-control/style.scss
+13 −0 packages/compose/README.md
+36 −0 packages/compose/src/hooks/use-previous/README.md
+31 −0 packages/compose/src/hooks/use-previous/index.js
+1 −0 packages/compose/src/index.js
+1 −1 packages/e2e-tests/specs/experiments/block-directory-add.test.js
+7 −1 packages/env/lib/wordpress.js
+3 −3 packages/project-management-automation/README.md
+3 −3 packages/project-management-automation/lib/index.js
+12 −0 packages/project-management-automation/lib/tasks/add-milestone/README.md
+2 −2 packages/project-management-automation/lib/tasks/add-milestone/index.js
+1 −1 packages/project-management-automation/lib/tasks/add-milestone/test/index.js
+10 −0 packages/project-management-automation/lib/tasks/assign-fixed-issues/README.md
+1 −1 packages/project-management-automation/lib/tasks/assign-fixed-issues/index.js
+1 −1 packages/project-management-automation/lib/tasks/assign-fixed-issues/test/index.js
+12 −0 packages/project-management-automation/lib/tasks/first-time-contributor/README.md
+4 −4 packages/project-management-automation/lib/tasks/first-time-contributor/index.js
+3 −3 packages/project-management-automation/lib/tasks/first-time-contributor/test/index.js
+1 −0 packages/scripts/CHANGELOG.md
+12 −0 packages/scripts/README.md
+5 −6 packages/scripts/scripts/test-e2e.js
+5 −8 packages/scripts/scripts/test-unit-jest.js
+30 −3 packages/scripts/utils/config.js
+2 −0 packages/scripts/utils/index.js
+99 −2 packages/scripts/utils/test/index.js
+1 −1 readme.txt
8 changes: 8 additions & 0 deletions ios/gutenberg/GutenbergViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
func gutenbergDidRequestMention(callback: @escaping (Result<String, NSError>) -> Void) {
callback(.success("matt"))
}

func gutenbergDidRequestStarterPageTemplatesTooltipShown() -> Bool {
return false;
}

func gutenbergDidRequestSetStarterPageTemplatesTooltipShown(_ tooltipShown: Bool) {
print("Gutenberg requested setting tooltip flag")
}
}

extension GutenbergViewController: GutenbergBridgeDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ interface MediaUploadCallback {
void onMediaFileUploadFailed(int mediaId);
}

interface StarterPageTemplatesTooltipShownCallback {
void onRequestStarterPageTemplatesTooltipShown(boolean tooltipShown);
}

// Ref: https://github.com/facebook/react-native/blob/master/Libraries/polyfills/console.js#L376
enum LogLevel {
TRACE(0),
Expand Down Expand Up @@ -140,4 +144,8 @@ public static GutenbergUserEvent getEnum(String eventName) {
void logUserEvent(GutenbergUserEvent gutenbergUserEvent, ReadableMap eventProperties);

void onAddMention(Consumer<String> onSuccess);

void setStarterPageTemplatesTooltipShown(boolean tooltipShown);

void requestStarterPageTemplatesTooltipShown(StarterPageTemplatesTooltipShownCallback starterPageTemplatesTooltipShownCallback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.GutenbergUserEvent;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.MediaType;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.OtherMediaOptionsReceivedCallback;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.StarterPageTemplatesTooltipShownCallback;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.RNMedia;
import org.wordpress.mobile.WPAndroidGlue.MediaOption;

Expand Down Expand Up @@ -256,6 +257,25 @@ public void addMention(Promise promise) {
mGutenbergBridgeJS2Parent.onAddMention(promise::resolve);
}

@ReactMethod
public void setStarterPageTemplatesTooltipShown(boolean tooltipShown) {
mGutenbergBridgeJS2Parent.setStarterPageTemplatesTooltipShown(tooltipShown);
}

@ReactMethod
public void requestStarterPageTemplatesTooltipShown(final Callback jsCallback) {
StarterPageTemplatesTooltipShownCallback starterPageTemplatesTooltipShownCallback = requestStarterPageTemplatesTooltipShownCallback(jsCallback);
mGutenbergBridgeJS2Parent.requestStarterPageTemplatesTooltipShown(starterPageTemplatesTooltipShownCallback);
}

private StarterPageTemplatesTooltipShownCallback requestStarterPageTemplatesTooltipShownCallback(final Callback jsCallback) {
return new StarterPageTemplatesTooltipShownCallback() {
@Override public void onRequestStarterPageTemplatesTooltipShown(boolean tooltipShown) {
jsCallback.invoke(tooltipShown);
}
};
}

private GutenbergBridgeJS2Parent.MediaUploadCallback getNewUploadMediaCallback(final Boolean allowMultipleSelection, final Callback jsCallback) {
return new GutenbergBridgeJS2Parent.MediaUploadCallback() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class WPAndroidGlueCode {
private OnImageFullscreenPreviewListener mOnImageFullscreenPreviewListener;
private OnMediaEditorListener mOnMediaEditorListener;
private OnLogGutenbergUserEventListener mOnLogGutenbergUserEventListener;
private OnStarterPageTemplatesTooltipShownEventListener mOnStarterPageTemplatesTooltipShownListener;
private boolean mIsEditorMounted;

private String mContentHtml = "";
Expand Down Expand Up @@ -166,6 +167,11 @@ public interface OnLogGutenbergUserEventListener {
void onGutenbergUserEvent(GutenbergUserEvent event, Map<String, Object> properties);
}

public interface OnStarterPageTemplatesTooltipShownEventListener {
void onSetStarterPageTemplatesTooltipShown(boolean tooltipShown);
boolean onRequestStarterPageTemplatesTooltipShown();
}

public void mediaSelectionCancelled() {
mAppendsMultipleSelectedToSiblingBlocks = false;
}
Expand Down Expand Up @@ -338,6 +344,17 @@ public void logUserEvent(GutenbergUserEvent event, ReadableMap eventProperties)
@Override public void onAddMention(Consumer<String> onSuccess) {
mAddMentionUtil.getMention(onSuccess);
}

@Override
public void setStarterPageTemplatesTooltipShown(boolean showTooltip) {
mOnStarterPageTemplatesTooltipShownListener.onSetStarterPageTemplatesTooltipShown(showTooltip);
}

@Override
public void requestStarterPageTemplatesTooltipShown(StarterPageTemplatesTooltipShownCallback starterPageTemplatesTooltipShownCallback) {
boolean tooltipShown = mOnStarterPageTemplatesTooltipShownListener.onRequestStarterPageTemplatesTooltipShown();
starterPageTemplatesTooltipShownCallback.onRequestStarterPageTemplatesTooltipShown(tooltipShown);
}
}, mIsDarkMode);

return Arrays.asList(
Expand Down Expand Up @@ -448,6 +465,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
OnMediaEditorListener onMediaEditorListener,
OnLogGutenbergUserEventListener onLogGutenbergUserEventListener,
AddMentionUtil addMentionUtil,
OnStarterPageTemplatesTooltipShownEventListener onStarterPageTemplatesTooltipListener,
boolean isDarkMode) {

MutableContextWrapper contextWrapper = (MutableContextWrapper) mReactRootView.getContext();
Expand All @@ -462,6 +480,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
mOnMediaEditorListener = onMediaEditorListener;
mOnLogGutenbergUserEventListener = onLogGutenbergUserEventListener;
mAddMentionUtil = addMentionUtil;
mOnStarterPageTemplatesTooltipShownListener = onStarterPageTemplatesTooltipListener;

sAddCookiesInterceptor.setOnAuthHeaderRequestedListener(onAuthHeaderRequestedListener);

Expand Down
8 changes: 8 additions & 0 deletions react-native-gutenberg-bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,12 @@ export function addMention() {
return RNReactNativeGutenbergBridge.addMention();
}

export function requestStarterPageTemplatesTooltipShown( callback ) {
return RNReactNativeGutenbergBridge.requestStarterPageTemplatesTooltipShown( callback );
}

export function setStarterPageTemplatesTooltipShown( tooltipShown ) {
return RNReactNativeGutenbergBridge.setStarterPageTemplatesTooltipShown( tooltipShown );
}

export default RNReactNativeGutenbergBridge;
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,20 @@ public protocol GutenbergBridgeDelegate: class {
///
func gutenbergDidRequestMediaEditor(with mediaUrl: URL, callback: @escaping MediaPickerDidPickMediaCallback)


/// Tells the delegate that the editor needs to log a custom event
/// - Parameter event: The event key to be logged
func gutenbergDidLogUserEvent(_ event: GutenbergUserEvent)

/// Tells the delegate that the editor requested a mention
/// - Parameter callback: Completion handler to be called with an user mention or an error
func gutenbergDidRequestMention(callback: @escaping (Swift.Result<String, NSError>) -> Void)

/// Tells the delegate that the editor requested to show the tooltip
func gutenbergDidRequestStarterPageTemplatesTooltipShown() -> Bool

/// Tells the delegate that the editor requested to set the tooltip's visibility
/// - Parameter tooltipShown: Tooltip's visibility value
func gutenbergDidRequestSetStarterPageTemplatesTooltipShown(_ tooltipShown: Bool)
}

// MARK: - Optional GutenbergBridgeDelegate methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject)
RCT_EXTERN_METHOD(requestMediaEditor:(NSString *)mediaUrl callback:(RCTResponseSenderBlock)callback)
RCT_EXTERN_METHOD(logUserEvent:(NSString *)event properties:(NSDictionary *)properties)
RCT_EXTERN_METHOD(addMention:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)rejecter)
RCT_EXTERN_METHOD(requestStarterPageTemplatesTooltipShown:(RCTResponseSenderBlock)callback)
RCT_EXTERN_METHOD(setStarterPageTemplatesTooltipShown:(BOOL)tooltipShown)

@end
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter {
}
})
}

@objc
func requestStarterPageTemplatesTooltipShown(_ callback: @escaping RCTResponseSenderBlock) {
callback([self.delegate?.gutenbergDidRequestStarterPageTemplatesTooltipShown() ?? false])
}

@objc
func setStarterPageTemplatesTooltipShown(_ tooltipShown: Bool) {
self.delegate?.gutenbergDidRequestSetStarterPageTemplatesTooltipShown(tooltipShown)
}

}

// MARK: - RCTBridgeModule delegate
Expand Down

0 comments on commit 59220b0

Please sign in to comment.