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] Block Inserter: Limit Jetpack block collection to the WordPress app #25155

Merged
merged 8 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@automattic/jetpack-components": "workspace:* || ^0.17",
"@automattic/jetpack-shared-extension-utils": "workspace:* || ^0.4",
"@automattic/jetpack-shared-extension-utils": "workspace:* || ^0.5",
"@wordpress/annotations": "2.12.0",
"@wordpress/components": "19.14.0",
"@wordpress/compose": "5.10.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add a new utility function for native use. The function returns the namespace of the host app e.g. Jetpack or WordPress.
3 changes: 3 additions & 0 deletions projects/js-packages/shared-extension-utils/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './index.js';

export { default as getHostAppNamespace } from './src/get-host-app-namespace';
2 changes: 1 addition & 1 deletion projects/js-packages/shared-extension-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-shared-extension-utils",
"version": "0.4.14-alpha",
"version": "0.5.0-alpha",
"description": "Utility functions used by the block editor extensions",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/shared-extension-utils/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* WordPress dependencies
*/
import { store as blockEditorStore } from '@wordpress/block-editor';
import { select } from '@wordpress/data';

/**
* Retrieves host app's namespace e.g. "WordPress" or "Jetpack".
*
* @returns {string} hostAppNamespace The host app's namespace.
*/
export default function getHostAppNamespace() {
return select( blockEditorStore ).getSettings().hostAppNamespace;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Native block inserter: Only display blocks under a Jetpack heading if the host app is WordPress
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Updated package dependencies.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { getHostAppNamespace } from '@automattic/jetpack-shared-extension-utils';
import { getCategories, setCategories, registerBlockCollection } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { JetpackLogo } from './icons';

registerBlockCollection( 'jetpack', {
title: __( 'Jetpack powered', 'jetpack' ),
icon: <JetpackLogo />,
} );
const hostApp = getHostAppNamespace();
if ( hostApp === 'WordPress' ) {
registerBlockCollection( 'jetpack', {
title: __( 'Jetpack powered', 'jetpack' ),
icon: <JetpackLogo />,
} );
}

setCategories( [
...getCategories().filter( ( { slug } ) => slug !== 'earn' ),
Expand Down
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@automattic/jetpack-licensing": "workspace:* || ^0.5",
"@automattic/jetpack-partner-coupon": "workspace:* || ^0.2",
"@automattic/jetpack-publicize-components": "workspace:* || ^0.3",
"@automattic/jetpack-shared-extension-utils": "workspace:* || ^0.4",
"@automattic/jetpack-shared-extension-utils": "workspace:* || ^0.5",
"@automattic/popup-monitor": "1.0.1",
"@automattic/request-external-access": "1.0.0",
"@automattic/social-previews": "1.1.4",
Expand Down