Skip to content

Commit

Permalink
Merge pull request #2611 from wordpress-mobile/try/jetpack-stories-block
Browse files Browse the repository at this point in the history
Add support for Story block rendering on mobile gutenberg
  • Loading branch information
mzorz authored Nov 10, 2020
2 parents 254108c + 0d4e47c commit 3e94d94
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 61 files
+2 −0 .github/CODEOWNERS
+2 −2 .github/workflows/create-block.yml
+8 −8 .github/workflows/end2end-test.yml
+2 −2 .github/workflows/performance.yml
+2 −2 .github/workflows/static-checks.yml
+1 −1 .github/workflows/storybook-pages.yml
+6 −6 .github/workflows/unit-test.yml
+1 −1 .nvmrc
+183 −0 docs/designers-developers/developers/block-api/block-supports.md
+1 −0 package.json
+1 −0 packages/base-styles/_colors.native.scss
+18 −0 packages/base-styles/_mixins.scss
+1 −0 packages/base-styles/_variables.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
+1 −1 packages/block-library/src/gallery/gallery-image.js
+10 −7 packages/block-library/src/navigation-link/edit.js
+2 −1 packages/components/src/angle-picker-control/angle-circle.js
+6 −2 packages/components/src/date-time/date.js
+137 −157 packages/components/src/date-time/index.js
+9 −18 packages/components/src/guide/finish-button.js
+2 −2 packages/components/src/guide/test/finish-button.js
+1 −1 packages/components/src/index.js
+5 −2 packages/components/src/sandbox/index.js
+3 −2 packages/core-data/src/index.js
+4 −3 packages/core-data/src/resolvers.js
+174 −28 packages/core-data/src/test/integration.js
+1 −3 packages/data-controls/src/index.js
+149 −5 packages/e2e-tests/specs/experiments/template-part.test.js
+5 −1 packages/edit-post/src/editor.native.js
+1 −14 packages/edit-post/src/style.scss
+1 −0 packages/edit-site/src/style.scss
+19 −15 packages/edit-widgets/src/blocks/widget-area/edit/index.js
+9 −5 packages/editor/src/components/post-schedule/index.js
+1 −1 packages/editor/src/editor-styles.scss
+3 −1 packages/eslint-plugin/configs/custom.js
+6 −1 packages/eslint-plugin/rules/__tests__/no-global-active-element.js
+70 −0 packages/eslint-plugin/rules/__tests__/no-global-event-listener.js
+6 −1 packages/eslint-plugin/rules/__tests__/no-global-get-selection.js
+2 −1 packages/eslint-plugin/rules/no-global-active-element.js
+35 −0 packages/eslint-plugin/rules/no-global-event-listener.js
+2 −1 packages/eslint-plugin/rules/no-global-get-selection.js
+4 −0 packages/i18n/CHANGELOG.md
+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 −1 storybook/stories/playground/editor-styles.scss
+1 −0 test/native/setup.js
2 changes: 1 addition & 1 deletion jetpack
Submodule jetpack updated 48 files
+1 −0 .github/codeclimate-base.yml
+15 −0 .github/files/phpcompatibility-dev-phpcs.xml
+19 −0 .github/matchers/phpcs-problem-matcher.json
+62 −0 .github/workflows/phpcompatibility-dev.yml
+31 −0 .phpcs.config.xml
+5 −28 .phpcs.xml.dist
+8 −8 _inc/lib/class.core-rest-api-endpoints.php
+1 −1 _inc/lib/class.media.php
+1 −1 _inc/lib/debugger/class-jetpack-cxn-test-base.php
+5 −1 bin/prepare-commit-msg.js
+4 −0 changelog.txt
+1 −1 class.jetpack-gutenberg.php
+1 −1 class.jetpack-modules-list-table.php
+1 −1 class.jetpack-post-images.php
+1 −1 class.json-api-endpoints.php
+1 −1 composer.json
+1 −1 dangerfile.js
+1 −1 docs/coding-guidelines.md
+6 −1 extensions/blocks/contact-info/edit.native.js
+240 −0 extensions/blocks/story/edit.native.js
+97 −0 extensions/blocks/story/editor.native.scss
+10 −0 extensions/blocks/story/icon-customize.native.js
+3 −2 extensions/blocks/story/index.js
+30 −0 extensions/blocks/story/story-editing-button.native.js
+1 −0 extensions/editor.native.js
+15 −11 extensions/shared/external-media/index.js
+1 −1 extensions/shared/icons.scss
+2 −2 jetpack.php
+0 −4 json-endpoints/class.wpcom-json-api-get-site-endpoint.php
+1 −9 json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php
+40 −13 modules/contact-form/admin.php
+1 −1 modules/contact-form/grunion-contact-form.php
+20 −11 modules/contact-form/js/grunion-admin.js
+1 −1 modules/widgets/rsslinks-widget.php
+7 −7 package.json
+1 −1 packages/device-detection/src/class-device-detection.php
+13 −16 packages/status/tests/php/test-status.php
+4 −0 readme.txt
+0 −4 sal/class.json-api-site-base.php
+54 −21 tests/php/general/test_class.jetpack-xmlrpc-server.php
+67 −20 tests/php/general/test_class.jetpack.php
+2 −2 tests/php/lib/class-wp-test-jetpack-rest-testcase.php
+169 −53 tests/php/modules/sso/test_class.jetpack-sso-helpers.php
+161 −65 tests/php/sync/test_class.jetpack-sync-callables.php
+16 −6 tests/php/sync/test_class.jetpack-sync-integration.php
+28 −8 tests/php/sync/test_class.jetpack-sync-posts.php
+3 −0 tests/php/sync/test_class.jetpack-sync-sender.php
+356 −354 yarn.lock
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 -->
`;
27 changes: 27 additions & 0 deletions src/jetpack-editor-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
* 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: true,
},
story: {
available: true,
},
};

const setJetpackData = ( {
Expand Down Expand Up @@ -37,6 +44,26 @@ export default ( jetpackState ) => {

const jetpackData = setJetpackData( jetpackState );

// 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' ] );
}
} );

if ( __DEV__ ) {
require( '../jetpack/extensions/editor' );
}
Expand Down
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 3e94d94

Please sign in to comment.