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

Shared Extension Utils: Add needsUserConnection function #39077

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions projects/js-packages/shared-extension-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
@@ -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;
Loading