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

Subscribe block: Hide social followers toggle when showSubscribersTotal is not on or isPublicizeEnabled is false #28944

Merged
merged 10 commits into from
Mar 9, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Don't show "Include social followers in count" when showSubscribersTotal is not toggled or isPublicizeEnabled is false
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { numberFormat } from '@automattic/jetpack-components';
import { usePublicizeConfig } from '@automattic/jetpack-publicize-components';
import { isSimpleSite } from '@automattic/jetpack-shared-extension-utils';
import {
ContrastChecker,
Expand Down Expand Up @@ -54,6 +55,8 @@ export default function SubscriptionControls( {
buttonWidth,
successMessage,
} ) {
const { isPublicizeEnabled } = usePublicizeConfig();

return (
<>
{ isNewsletterFeatureEnabled() && <PaidPlanPanel /> }
Expand Down Expand Up @@ -240,14 +243,17 @@ export default function SubscriptionControls( {
}
} }
/>
<ToggleControl
disabled={ ! showSubscribersTotal }
label={ __( 'Include social followers in count', 'jetpack' ) }
checked={ includeSocialFollowers }
onChange={ () => {
setAttributes( { includeSocialFollowers: ! includeSocialFollowers } );
} }
/>
{ showSubscribersTotal && isPublicizeEnabled ? (
<ToggleControl
disabled={ ! showSubscribersTotal }
label={ __( 'Include social followers in count', 'jetpack' ) }
checked={ includeSocialFollowers }
onChange={ () => {
setAttributes( { includeSocialFollowers: ! includeSocialFollowers } );
} }
/>
) : null }
Comment on lines +246 to +255
Copy link
Member

@manzoorwanijk manzoorwanijk Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work for published posts on simple sites with a free plan because isPublicizeEnabled is more like a local state whether sharing is enabled for the post or not. For published posts, this flag is false if re-sharing is not enabled. For simple sites, resharing is not enabled with free plan.

You can check its source in usePublicizeConfig.

The correct solution here might to check if publicize module is active.

CC: @jeherve

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct solution here might to check if publicize module is active.

This may indeed be a better solution, and we now have useModuleStatus to help with that. @Automattic/zap Is that something you could look into?

Thank you!


<ToggleControl
label={ __( 'Place button on new line', 'jetpack' ) }
checked={ buttonOnNewLine }
Expand Down