Skip to content

Commit

Permalink
Subscribe block: Hide social followers toggle when showSubscribersTot…
Browse files Browse the repository at this point in the history
…al is not on or isPublicizeEnabled is false (#28944)

* Don't show "Include social followers in count" when showSubscribersTotal is not toggled or isPublicizeEnabled is false
  • Loading branch information
TimBroddin authored Mar 9, 2023
1 parent cb3eb70 commit 51c65fe
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
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 }

<ToggleControl
label={ __( 'Place button on new line', 'jetpack' ) }
checked={ buttonOnNewLine }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jest.mock( '@wordpress/block-editor/build/components/use-setting', () => {
};
} );

jest.mock( '@wordpress/notices', () => {}, { virtual: true } );

const setButtonBackgroundColor = jest.fn();
const setGradient = jest.fn();
const setTextColor = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jest.mock( '@wordpress/block-editor', () => ( {
} ),
} ) );

jest.mock( '@wordpress/notices', () => {}, { virtual: true } );

describe( 'SubscriptionEdit', () => {
test( 'adds correct classes to container', async () => {
const { container } = render( <SubscriptionEdit { ...defaultProps } /> );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import runBlockFixtureTests from '../../../shared/test/block-fixtures';
// The main block should be the first in the array.
const blocks = [ { name: `jetpack/${ name }`, settings } ];

jest.mock( '@wordpress/notices', () => {}, { virtual: true } );

runBlockFixtureTests( `jetpack/${ name }`, blocks, __dirname );
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/tests/jest.config.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ module.exports = {
...baseConfig.testPathIgnorePatterns,
'extensions/shared/test/block-fixtures.js',
],
moduleNameMapper: {
...baseConfig.moduleNameMapper,
'\\.(css|less|sass|scss)$': '<rootDir>/tests/styles-mock.js',
},
};
1 change: 1 addition & 0 deletions projects/plugins/jetpack/tests/styles-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};

0 comments on commit 51c65fe

Please sign in to comment.