diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e44b5d2be3c6..74bb9ed5ef1ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -430,7 +430,7 @@ importers: '@automattic/color-studio': 2.5.0 '@automattic/jetpack-base-styles': workspace:* || ^0.3 '@automattic/jetpack-components': workspace:* || ^0.17 - '@automattic/jetpack-shared-extension-utils': workspace:* || ^0.4 + '@automattic/jetpack-shared-extension-utils': workspace:* || ^0.5 '@automattic/jetpack-webpack-config': workspace:* || ^1.3 '@babel/core': 7.18.6 '@babel/plugin-transform-react-jsx': 7.18.6 @@ -1295,7 +1295,7 @@ importers: '@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/jetpack-webpack-config': workspace:* || ^1.3 '@automattic/popup-monitor': 1.0.1 '@automattic/remove-asset-webpack-plugin': workspace:* || ^1.0 diff --git a/projects/js-packages/publicize-components/changelog/rnmobile-limit-block-collection-to-wordpress-app b/projects/js-packages/publicize-components/changelog/rnmobile-limit-block-collection-to-wordpress-app new file mode 100644 index 0000000000000..c47cb18e82997 --- /dev/null +++ b/projects/js-packages/publicize-components/changelog/rnmobile-limit-block-collection-to-wordpress-app @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Updated package dependencies. diff --git a/projects/js-packages/publicize-components/package.json b/projects/js-packages/publicize-components/package.json index 9197315272d95..0465f23f386a0 100644 --- a/projects/js-packages/publicize-components/package.json +++ b/projects/js-packages/publicize-components/package.json @@ -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", diff --git a/projects/js-packages/shared-extension-utils/changelog/rnmobile-limit-block-collection-to-wordpress-app b/projects/js-packages/shared-extension-utils/changelog/rnmobile-limit-block-collection-to-wordpress-app new file mode 100644 index 0000000000000..812930b3d1bed --- /dev/null +++ b/projects/js-packages/shared-extension-utils/changelog/rnmobile-limit-block-collection-to-wordpress-app @@ -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. diff --git a/projects/js-packages/shared-extension-utils/index.native.js b/projects/js-packages/shared-extension-utils/index.native.js new file mode 100644 index 0000000000000..1262187ec20da --- /dev/null +++ b/projects/js-packages/shared-extension-utils/index.native.js @@ -0,0 +1,3 @@ +export * from './index.js'; + +export { default as getHostAppNamespace } from './src/get-host-app-namespace'; diff --git a/projects/js-packages/shared-extension-utils/package.json b/projects/js-packages/shared-extension-utils/package.json index 48fab58db3154..633e260b89f9c 100644 --- a/projects/js-packages/shared-extension-utils/package.json +++ b/projects/js-packages/shared-extension-utils/package.json @@ -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": { diff --git a/projects/js-packages/shared-extension-utils/src/get-host-app-namespace.native.js b/projects/js-packages/shared-extension-utils/src/get-host-app-namespace.native.js new file mode 100644 index 0000000000000..fa43fb8603590 --- /dev/null +++ b/projects/js-packages/shared-extension-utils/src/get-host-app-namespace.native.js @@ -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; +} diff --git a/projects/plugins/jetpack/changelog/rnmobile-limit-block-collection-to-wordpress-app b/projects/plugins/jetpack/changelog/rnmobile-limit-block-collection-to-wordpress-app new file mode 100644 index 0000000000000..dd90eade4db88 --- /dev/null +++ b/projects/plugins/jetpack/changelog/rnmobile-limit-block-collection-to-wordpress-app @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Native block inserter: Only display blocks under a Jetpack heading if the host app is WordPress diff --git a/projects/plugins/jetpack/changelog/rnmobile-limit-block-collection-to-wordpress-app#2 b/projects/plugins/jetpack/changelog/rnmobile-limit-block-collection-to-wordpress-app#2 new file mode 100644 index 0000000000000..1eaea6a769e84 --- /dev/null +++ b/projects/plugins/jetpack/changelog/rnmobile-limit-block-collection-to-wordpress-app#2 @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Updated package dependencies. diff --git a/projects/plugins/jetpack/extensions/shared/block-category.native.js b/projects/plugins/jetpack/extensions/shared/block-category.native.js index c4b5fa680d22b..98c340032fc5e 100644 --- a/projects/plugins/jetpack/extensions/shared/block-category.native.js +++ b/projects/plugins/jetpack/extensions/shared/block-category.native.js @@ -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: , -} ); +const hostApp = getHostAppNamespace(); +if ( hostApp === 'WordPress' ) { + registerBlockCollection( 'jetpack', { + title: __( 'Jetpack powered', 'jetpack' ), + icon: , + } ); +} setCategories( [ ...getCategories().filter( ( { slug } ) => slug !== 'earn' ), diff --git a/projects/plugins/jetpack/package.json b/projects/plugins/jetpack/package.json index e2975e6cf1de3..b885f0f47e522 100644 --- a/projects/plugins/jetpack/package.json +++ b/projects/plugins/jetpack/package.json @@ -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",