diff --git a/projects/js-packages/shared-extension-utils/changelog/add-needs-user-connection-shared-extension-utils b/projects/js-packages/shared-extension-utils/changelog/add-needs-user-connection-shared-extension-utils new file mode 100644 index 0000000000000..8f76ef6dcd54d --- /dev/null +++ b/projects/js-packages/shared-extension-utils/changelog/add-needs-user-connection-shared-extension-utils @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +New utility function `needsUserConnection` to determine if a user connection is required based on the current user's connection status and site type. diff --git a/projects/js-packages/shared-extension-utils/index.js b/projects/js-packages/shared-extension-utils/index.js index 2dd8f77b42027..d2509cdab2be0 100644 --- a/projects/js-packages/shared-extension-utils/index.js +++ b/projects/js-packages/shared-extension-utils/index.js @@ -21,3 +21,4 @@ export { getBlockIconComponent, getBlockIconProp } from './src/get-block-icon-fr export { default as getJetpackBlocksVariation } from './src/get-jetpack-blocks-variation'; export * from './src/modules-state'; export { default as isMyJetpackAvailable } from './src/is-my-jetpack-available'; +export { default as needsUserConnection } from './src/needs-user-connection'; diff --git a/projects/js-packages/shared-extension-utils/src/needs-user-connection.js b/projects/js-packages/shared-extension-utils/src/needs-user-connection.js new file mode 100644 index 0000000000000..c34757e33f725 --- /dev/null +++ b/projects/js-packages/shared-extension-utils/src/needs-user-connection.js @@ -0,0 +1,13 @@ +import isCurrentUserConnected from './is-current-user-connected'; +import { isSimpleSite } from './site-type-utils'; + +/** + * Returns true if the current user is not connected to WP.com and the site is not a simple site. + * + * @return {boolean} Whether the current user is not connected to WP.com and the site is not a simple site. + */ +const needsUserConnection = () => { + return ! isCurrentUserConnected() && ! isSimpleSite(); +}; + +export default needsUserConnection;