From e402ff88c791ae578fec0f9692ad1c1d04ac7a9c Mon Sep 17 00:00:00 2001 From: oskosk Date: Mon, 26 Aug 2024 11:19:48 -0300 Subject: [PATCH 1/3] Add needsUserConnection function to check user connection status to shared extension utils package --- .../js-packages/shared-extension-utils/index.js | 1 + .../src/needs-user-connection.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 projects/js-packages/shared-extension-utils/src/needs-user-connection.js 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; From 86448b1794fb4f612efda161697ebf7493f92b55 Mon Sep 17 00:00:00 2001 From: oskosk Date: Mon, 26 Aug 2024 11:21:09 -0300 Subject: [PATCH 2/3] changelog --- .../add-needs-user-connection-shared-extension-utils | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/js-packages/shared-extension-utils/changelog/add-needs-user-connection-shared-extension-utils 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. From a9421be5c930805e96b55e30cee69d8a8145f1ad Mon Sep 17 00:00:00 2001 From: oskosk Date: Mon, 26 Aug 2024 11:34:23 -0300 Subject: [PATCH 3/3] version