Skip to content

Commit

Permalink
Merge pull request #4977 from google/followup/4908-gathering-data-fix
Browse files Browse the repository at this point in the history
Update WP dashboard popular pages widget to skip rendering table if no rows
  • Loading branch information
felixarntz authored Mar 25, 2022
2 parents baeffe7 + 73274d9 commit cb9539e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions assets/js/components/wp-dashboard/WPDashboardPopularPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
import { CORE_USER } from '../../googlesitekit/datastore/user/constants';
import PreviewTable from '../../components/PreviewTable';
import TableOverflowContainer from '../../components/TableOverflowContainer';
import { isZeroReport } from '../../modules/analytics/util/is-zero-report';
import ReportTable from '../ReportTable';
import DetailsPermaLinks from '../DetailsPermaLinks';
import { numFmt } from '../../util';
Expand Down Expand Up @@ -110,10 +109,15 @@ export default function WPDashboardPopularPages( props ) {
return <WidgetReportError moduleSlug="analytics" error={ error } />;
}

if ( isZeroReport( report ) && ! zeroDataStatesEnabled ) {
if ( isGatheringData && ! zeroDataStatesEnabled ) {
return <WidgetReportZero moduleSlug="analytics" />;
}

// Skip rendering the table if there are no rows.
if ( ! report[ 0 ].data?.rows?.length ) {
return null;
}

const rows = cloneDeep( report[ 0 ].data.rows );
// Combine the titles from the pageTitles with the rows from the metrics report.
rows.forEach( ( row ) => {
Expand Down

0 comments on commit cb9539e

Please sign in to comment.