diff --git a/projects/packages/premium-analytics/changelog/wooa7s-1786-default-insights-widgets b/projects/packages/premium-analytics/changelog/wooa7s-1786-default-insights-widgets new file mode 100644 index 000000000000..e670d789c0b7 --- /dev/null +++ b/projects/packages/premium-analytics/changelog/wooa7s-1786-default-insights-widgets @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Insights: Reorder and resize the default widgets so each row fills the grid, and add Popular post, Total views, and Total visitors to the defaults. diff --git a/projects/packages/premium-analytics/src/dashboard-layout.php b/projects/packages/premium-analytics/src/dashboard-layout.php index 830b1697f2ed..9b73904601a0 100644 --- a/projects/packages/premium-analytics/src/dashboard-layout.php +++ b/projects/packages/premium-analytics/src/dashboard-layout.php @@ -298,70 +298,75 @@ function get_dashboard_default_section_layouts() { ), ), DASHBOARD_INSIGHTS_SECTION_ID => array( - // Mirrors the legacy Calypso Stats Insights page (WOOA7S-1616). - // Emails is not an Insights module (it lives on the Subscribers - // tab). Two canonical modules are not ported yet — All-time total - // views (WOOA7S-1512) and Most popular post (part of WOOA7S-1510). - // Row 1: annual highlights + all-time stats. + // Follows the prototype's rows (WOOA7S-1786). Emails lives on the + // Subscribers tab, and the site-wide views heatmap has no widget + // yet (WOOA7S-1787), so that row is absent. + // Row 1: highlights banner. get_dashboard_default_widget_instance( 'default-annual-highlights-widget-instance', 'jpa/annual-highlights', 0, - 2, - 2 + 4, + 1 ), + // Row 2: posting-activity heatmap. get_dashboard_default_widget_instance( - 'default-all-time-stats-widget-instance', - 'jpa/all-time-stats', + 'default-posting-activity-widget-instance', + 'jpa/posting-activity', 1, - 2, - 2 + 4, + 1 ), - // Row 2: latest post + the two most-popular cards + tags. + // Row 3: the two post spotlights. get_dashboard_default_widget_instance( 'default-latest-post-widget-instance', 'jpa/latest-post', 2, - 1, + 2, 2 ), get_dashboard_default_widget_instance( - 'default-most-popular-time-widget-instance', - 'jpa/most-popular-time', + 'default-popular-post-widget-instance', + 'jpa/popular-post', 3, - 1, + 2, 2 ), + // Row 4: the period totals + the two most-popular cards. The + // most-popular cards still crop at this height (WOOA7S-1846). get_dashboard_default_widget_instance( - 'default-most-popular-day-widget-instance', - 'jpa/most-popular-day', + 'default-total-views-widget-instance', + 'jpa/total-views', 4, 1, - 2 + 1 ), get_dashboard_default_widget_instance( - 'default-tags-widget-instance', - 'jpa/tags', + 'default-total-visitors-widget-instance', + 'jpa/total-visitors', 5, 1, - 2, - array( - 'max' => 10, - ) + 1 ), - // Row 3: posting-activity heatmap + the two comment leaderboards. get_dashboard_default_widget_instance( - 'default-posting-activity-widget-instance', - 'jpa/posting-activity', + 'default-most-popular-time-widget-instance', + 'jpa/most-popular-time', 6, - 2, - 2 + 1, + 1 ), - // Posts before authors, matching the design's Insights bottom row. + get_dashboard_default_widget_instance( + 'default-most-popular-day-widget-instance', + 'jpa/most-popular-day', + 7, + 1, + 1 + ), + // Row 5: the comment leaderboards, shares, and tags. get_dashboard_default_widget_instance( 'default-most-commented-posts-widget-instance', 'jpa/most-commented-posts', - 7, + 8, 1, 2, array( @@ -371,18 +376,27 @@ function get_dashboard_default_section_layouts() { get_dashboard_default_widget_instance( 'default-most-commented-authors-widget-instance', 'jpa/most-commented-authors', - 8, + 9, 1, 2, array( 'max' => 10, ) ), - // Row 4: shares, joined by the two unported modules noted above. get_dashboard_default_widget_instance( 'default-shares-widget-instance', 'jpa/shares', - 9, + 10, + 1, + 2, + array( + 'max' => 10, + ) + ), + get_dashboard_default_widget_instance( + 'default-tags-widget-instance', + 'jpa/tags', + 11, 1, 2, array( diff --git a/projects/packages/premium-analytics/tests/php/Dashboard_Layout_Test.php b/projects/packages/premium-analytics/tests/php/Dashboard_Layout_Test.php index 84903a0ae3e7..930ca72b9132 100644 --- a/projects/packages/premium-analytics/tests/php/Dashboard_Layout_Test.php +++ b/projects/packages/premium-analytics/tests/php/Dashboard_Layout_Test.php @@ -281,49 +281,54 @@ public function test_seed_default_dashboard_layout_adds_insights_widgets() { $layout_by_uuid = array_column( $layout, null, 'uuid' ); $layout_types = array_column( $layout, 'type' ); - $this->assertContains( 'jpa/annual-highlights', $layout_types ); - $this->assertContains( 'jpa/all-time-stats', $layout_types ); - $this->assertContains( 'jpa/latest-post', $layout_types ); - $this->assertContains( 'jpa/posting-activity', $layout_types ); + // uuid => [ type, width, height, order ]; each row fills the four-column grid. + $expected = array( + 'default-annual-highlights-widget-instance' => array( 'jpa/annual-highlights', 4, 1, 0 ), + 'default-posting-activity-widget-instance' => array( 'jpa/posting-activity', 4, 1, 1 ), + 'default-latest-post-widget-instance' => array( 'jpa/latest-post', 2, 2, 2 ), + 'default-popular-post-widget-instance' => array( 'jpa/popular-post', 2, 2, 3 ), + 'default-total-views-widget-instance' => array( 'jpa/total-views', 1, 1, 4 ), + 'default-total-visitors-widget-instance' => array( 'jpa/total-visitors', 1, 1, 5 ), + 'default-most-popular-time-widget-instance' => array( 'jpa/most-popular-time', 1, 1, 6 ), + 'default-most-popular-day-widget-instance' => array( 'jpa/most-popular-day', 1, 1, 7 ), + 'default-most-commented-posts-widget-instance' => array( 'jpa/most-commented-posts', 1, 2, 8 ), + 'default-most-commented-authors-widget-instance' => array( 'jpa/most-commented-authors', 1, 2, 9 ), + 'default-shares-widget-instance' => array( 'jpa/shares', 1, 2, 10 ), + 'default-tags-widget-instance' => array( 'jpa/tags', 1, 2, 11 ), + ); + + $this->assertSame( array_keys( $expected ), array_column( $layout, 'uuid' ) ); + + foreach ( $expected as $uuid => $instance ) { + list( $type, $width, $height, $order ) = $instance; + + $this->assertSame( $type, $layout_by_uuid[ $uuid ]['type'], $uuid ); + $this->assertSame( + array( + 'width' => $width, + 'height' => $height, + 'order' => $order, + ), + $layout_by_uuid[ $uuid ]['placement'], + $uuid + ); + } + $this->assertNotContains( 'jpa/authors', $layout_types ); $this->assertNotContains( 'jpa/videopress', $layout_types ); // Emails is not an Insights module — it lives on the Subscribers tab. $this->assertNotContains( 'jpa/stats-emails', $layout_types ); // The Comments module ships as two focused widgets, not one toggled widget. - $this->assertContains( 'jpa/most-commented-authors', $layout_types ); - $this->assertContains( 'jpa/most-commented-posts', $layout_types ); $this->assertNotContains( 'jpa/comments', $layout_types ); - $this->assertContains( 'jpa/shares', $layout_types ); - $this->assertSame( - array( - 'uuid' => 'default-most-commented-posts-widget-instance', - 'type' => 'jpa/most-commented-posts', - 'attributes' => array( - 'max' => 10, - ), - 'placement' => array( - 'width' => 1, - 'height' => 2, - 'order' => 7, - ), - ), - $layout_by_uuid['default-most-commented-posts-widget-instance'] - ); - $this->assertSame( - array( - 'uuid' => 'default-shares-widget-instance', - 'type' => 'jpa/shares', - 'attributes' => array( - 'max' => 10, - ), - 'placement' => array( - 'width' => 1, - 'height' => 2, - 'order' => 9, - ), - ), - $layout_by_uuid['default-shares-widget-instance'] + // Total views and Total visitors carry the totals row instead. + $this->assertNotContains( 'jpa/all-time-stats', $layout_types ); + + // Highlights falls back to the widget's own default metric list. + $this->assertArrayNotHasKey( + 'attributes', + $layout_by_uuid['default-annual-highlights-widget-instance'] ); + $this->assertSame( get_dashboard_default_layout_for( DASHBOARD_INSIGHTS_SECTION_ID ), get_dashboard_default_layout_for( 'analytics/insights' )