diff --git a/gutenberg b/gutenberg
index 07c5708397..7903febba8 160000
--- a/gutenberg
+++ b/gutenberg
@@ -1 +1 @@
-Subproject commit 07c570839708bb4ffb20638a8de4eb082f178831
+Subproject commit 7903febba892e39ff4dbf01cb3e739269762bc06
diff --git a/jetpack b/jetpack
index b7ccbb1d60..898c8d721c 160000
--- a/jetpack
+++ b/jetpack
@@ -1 +1 @@
-Subproject commit b7ccbb1d60d8d0a1463711836a810d1d5f012728
+Subproject commit 898c8d721c91190907603290637bdd27b9c92bd1
diff --git a/src/index.js b/src/index.js
index c7051c9c86..082bcea445 100644
--- a/src/index.js
+++ b/src/index.js
@@ -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 }
);
diff --git a/src/initial-html.js b/src/initial-html.js
index 5392f60169..edc7127836 100644
--- a/src/initial-html.js
+++ b/src/initial-html.js
@@ -12,4 +12,16 @@ export default `
+
+
+
+
+
+
+
+
+
+
+
+
`;
diff --git a/src/jetpack-editor-setup.js b/src/jetpack-editor-setup.js
index ae031d4050..898d2ec9f6 100644
--- a/src/jetpack-editor-setup.js
+++ b/src/jetpack-editor-setup.js
@@ -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 = ( {
@@ -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' );
}
diff --git a/src/test/index.js b/src/test/index.js
index bc33b11eb1..098aeb66e9 100644
--- a/src/test/index.js
+++ b/src/test/index.js
@@ -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,
};
@@ -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 } );