Skip to content

Commit

Permalink
Merge pull request #2807 from wordpress-mobile/jetpack-stories-block-…
Browse files Browse the repository at this point in the history
…base-1.41.1

Re-implement #2611 Support for story block rendering on 1.41.1
  • Loading branch information
mzorz authored Nov 14, 2020
2 parents bcc7bb3 + e80e0b9 commit b9feb99
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ workflows:
branches:
ignore:
- develop
- /^dependabot/submodules/.*/
- ios-device-checks:
name: Test iOS on Device - Full
requires: [ "Optional UI Tests" ]
Expand All @@ -274,6 +275,18 @@ workflows:
requires: [ "Optional UI Tests" ]
- android-native-unit-tests:
name: Android Native Unit Tests
- ios-device-checks:
name: Test iOS on Device - Full (Submodule Update)
post-to-slack: true
filters:
branches:
only: /^dependabot/submodules/.*/
- android-device-checks:
name: Test Android on Device - Full (Submodule Update)
post-to-slack: true
filters:
branches:
only: /^dependabot/submodules/.*/

ui-tests-full-scheduled:
jobs:
Expand Down
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 21 files
+1 −0 packages/base-styles/_colors.native.scss
+104 −0 packages/block-editor/src/components/block-media-update-progress/README.md
+299 −0 packages/block-editor/src/components/block-media-update-progress/index.native.js
+9 −0 packages/block-editor/src/components/block-media-update-progress/styles.native.scss
+500 −0 packages/block-editor/src/components/block-media-update-progress/test/index.native.js
+1 −0 packages/block-editor/src/components/index.native.js
+5 −1 packages/edit-post/src/editor.native.js
+1 −1 packages/react-native-bridge/android/build.gradle
+26 −0 ...-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java
+29 −0 ...droid/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
+86 −8 ...ages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/DeferredEventEmitter.java
+3 −0 packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/GutenbergProps.kt
+93 −5 packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java
+115 −5 packages/react-native-bridge/index.js
+42 −4 packages/react-native-bridge/ios/Gutenberg.swift
+28 −5 packages/react-native-bridge/ios/GutenbergBridgeDelegate.swift
+6 −0 packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.m
+38 −0 packages/react-native-bridge/ios/RNReactNativeGutenbergBridge.swift
+30 −1 packages/react-native-editor/android/app/src/main/java/com/gutenberg/MainApplication.java
+21 −1 packages/react-native-editor/ios/GutenbergDemo/GutenbergViewController.swift
+1 −0 test/native/setup.js
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import correctTextFontWeight from './text-font-weight-correct';
import setupJetpackEditor from './jetpack-editor-setup';
import initialHtml from './initial-html';

addAction( 'native.pre-render', 'gutenberg-mobile', ( props ) => {
addAction( 'native.pre-render', 'gutenberg-mobile', () => {
require( './strings-overrides' );
correctTextFontWeight();
} );

addAction( 'native.render', 'gutenberg-mobile', ( props ) => {
setupJetpackEditor(
props.jetpackState || { blogId: 1, isJetpackActive: true }
);
Expand Down
12 changes: 12 additions & 0 deletions src/initial-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ export default `
<div class="wp-block-jetpack-address"><div class="jetpack-address__address jetpack-address__address1">Random Street</div></div>
<!-- /wp:jetpack/address --></div>
<!-- /wp:jetpack/contact-info -->
<!-- wp:jetpack/story {"mediaFiles":[{"alt":"","caption":"","id":320,"link":"https://cldup.com/n48GTQmw7s.jpg","mime":"image/jpeg","type":"image","url":"https://cldup.com/n48GTQmw7s.jpg"},{"alt":"","caption":"","id":321,"link":"https://cldup.com/u2kdydrlQv.jpg","mime":"image/jpeg","type":"image","url":"https://cldup.com/u2kdydrlQv.jpg"},{"alt":"","caption":"","id":319,"link":"https://cldup.com/fi7gqyUrbL.jpg","mime":"image/jpeg","type":"image","url":"https://cldup.com/fi7gqyUrbL.jpg"}]} -->
<div class="wp-block-jetpack-story wp-story"></div>
<!-- /wp:jetpack/story -->
<!-- wp:jetpack/story -->
<div class="wp-block-jetpack-story wp-story"></div>
<!-- /wp:jetpack/story -->
<!-- wp:jetpack/story {"mediaFiles":[]}} -->
<div class="wp-block-jetpack-story wp-story"></div>
<!-- /wp:jetpack/story -->
`;
31 changes: 28 additions & 3 deletions src/jetpack-editor-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
* Internal dependencies
*/
import { JETPACK_DATA_PATH } from '../jetpack/extensions/shared/get-jetpack-data';
/**
* WordPress dependencies
*/
import { dispatch, select } from '@wordpress/data';

// When adding new blocks to this list please also consider updating ./block-support/supported-blocks.json
const supportedJetpackBlocks = {
'contact-info': {
available: __DEV__,
},
story: {
available: true,
},
};
Expand Down Expand Up @@ -37,9 +44,27 @@ export default ( jetpackState ) => {

const jetpackData = setJetpackData( jetpackState );

if ( __DEV__ ) {
require( '../jetpack/extensions/editor' );
}
// Note on the use of setTimeout() here:
// We observed the settings may not be ready exactly when the native.render hooks get run but rather
// right after that execution cycle (because state hasn't changed yet). Hence, we're only checking for
// the actual settings to be loaded by using setTimeout without a delay parameter. This ensures the
// settings are loaded onto the store and we can use the core/block-editor selector by the time we do
// the actual check.

// eslint-disable-next-line @wordpress/react-no-unsafe-timeout
setTimeout( () => {
const mediaFilesCollectionBlock = select(
'core/block-editor'
).getSettings( 'capabilities' ).mediaFilesCollectionBlock;

if ( mediaFilesCollectionBlock !== true ) {
dispatch( 'core/edit-post' ).hideBlockTypes( [ 'jetpack/story' ] );
} else {
dispatch( 'core/edit-post' ).showBlockTypes( [ 'jetpack/story' ] );
}
} );

require( '../jetpack/extensions/editor' );

return jetpackData;
};
5 changes: 4 additions & 1 deletion src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe( 'Test Jetpack blocks', () => {
const mockRegisterBlockCollection = jest.fn();
jest.mock( '@wordpress/blocks', () => {
return {
getCategories: () => [],
getCategories: () => [ { slug: 'media' } ],
setCategories: jest.fn(),
registerBlockCollection: mockRegisterBlockCollection,
};
Expand All @@ -12,6 +12,9 @@ describe( 'Test Jetpack blocks', () => {
'../../jetpack/extensions/blocks/contact-info/editor.js',
() => jest.fn()
);
jest.mock( '../../jetpack/extensions/blocks/story/editor.js', () =>
jest.fn()
);

const setupJetpackEditor = require( '../jetpack-editor-setup' ).default;
setupJetpackEditor( { blogId: 1, isJetpackActive: true } );
Expand Down

0 comments on commit b9feb99

Please sign in to comment.