Skip to content

Commit 3282acc

Browse files
committed
stats-authors: toggle the "authors" module when there is only one to be displayed
Resolves #80534
1 parent ebcd294 commit 3282acc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

client/my-sites/stats/features/modules/stats-authors/stats-authors.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
isRequestingSiteStatsForQuery,
1313
getSiteStatsNormalizedData,
1414
} from 'calypso/state/stats/lists/selectors';
15+
import { getModuleToggles } from 'calypso/state/stats/module-toggles/selectors';
1516
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
1617
import EmptyModuleCard from '../../../components/empty-module-card/empty-module-card';
1718
import { SUPPORT_URL, JETPACK_SUPPORT_URL_TRAFFIC } from '../../../const';
@@ -45,6 +46,14 @@ const StatAuthors: React.FC< StatsDefaultModuleProps > = ( {
4546
getSiteStatsNormalizedData( state, siteId, statType, query )
4647
) as [ id: number, label: string ];
4748

49+
// toggle the module if it's going to show just a single author
50+
const isSingleAuthor = data?.length === 1;
51+
52+
useSelector( ( state ) => {
53+
const pageModuleToggles = getModuleToggles( state, siteId, [ 'traffic' ] );
54+
pageModuleToggles.authors = ! isSingleAuthor;
55+
} );
56+
4857
return (
4958
<>
5059
{ ! shouldGateStatsModule && siteId && statType && (

0 commit comments

Comments
 (0)