From 4d445350eae9a7b581ac367c73cdfe6f2ce8d0dc Mon Sep 17 00:00:00 2001 From: Joshua T Flowers Date: Mon, 15 Mar 2021 20:34:20 -0400 Subject: [PATCH] Close activity panel tabs by default and track (https://github.com/woocommerce/woocommerce-admin/pull/6566) * Close activity panels by default and track shown * Add task list shown data to tracks * Add changelog and testing instructions * Fire the panel tracks again when the task list is hidden --- .../woocommerce-admin/TESTING-INSTRUCTIONS.md | 9 ++++++++ .../client/homescreen/activity-panel/index.js | 22 +++++++++++++++++++ .../homescreen/activity-panel/panels.js | 2 +- plugins/woocommerce-admin/readme.txt | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md b/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md index 1e84fe63392..9b277859022 100644 --- a/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md +++ b/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md @@ -2,6 +2,15 @@ ## Unreleased +### Close activity panel tabs by default and track #6566 + +1. Open your browser console and enter `localStorage.setItem( 'debug', 'wc-admin:tracks' );`. Make sure the "Verbose" is selected under the levels shown. +2. With the task list enabled, navigate to the homescreen. +3. Check that the `wcadmin_activity_panel_visible_panels` event is shown with `taskList: true` in its data. +4. Hide the task list. +5. Note that `wcadmin_activity_panel_visible_panels` event is shown with visible activity panels. +6. After refreshing, make sure that the "Orders" activity panel is closed by default. + ### Update undefined task name properties for help panel tracks #6565 1. Enter `localStorage.setItem( 'debug', 'wc-admin:*' );` into your console. Leave your console open. diff --git a/plugins/woocommerce-admin/client/homescreen/activity-panel/index.js b/plugins/woocommerce-admin/client/homescreen/activity-panel/index.js index 83085129af8..f9382c9758b 100644 --- a/plugins/woocommerce-admin/client/homescreen/activity-panel/index.js +++ b/plugins/woocommerce-admin/client/homescreen/activity-panel/index.js @@ -12,6 +12,8 @@ import { } from '@wordpress/components'; import { getSetting } from '@woocommerce/wc-admin-settings'; import { OPTIONS_STORE_NAME } from '@woocommerce/data'; +import { recordEvent } from '@woocommerce/tracks'; +import { useEffect } from '@wordpress/element'; /** * Internal dependencies @@ -52,6 +54,17 @@ export const ActivityPanel = () => { const panels = getAllPanels( panelsData ); + useEffect( () => { + const visiblePanels = panels.reduce( + ( acc, panel ) => { + acc[ panel.id ] = true; + return acc; + }, + { taskList: panelsData.isTaskListHidden !== 'yes' } + ); + recordEvent( 'activity_panel_visible_panels', visiblePanels ); + }, [ panelsData.isTaskListHidden ] ); + if ( panels.length === 0 ) { return null; } @@ -86,6 +99,15 @@ export const ActivityPanel = () => { initialOpen={ initialOpen } collapsible={ collapsible } disabled={ ! collapsible } + onToggle={ ( isOpen ) => { + if ( ! isOpen ) { + return; + } + + recordEvent( 'activity_panel_open', { + tab: id, + } ); + } } > { panel } diff --git a/plugins/woocommerce-admin/client/homescreen/activity-panel/panels.js b/plugins/woocommerce-admin/client/homescreen/activity-panel/panels.js index 2ca77779535..b0cdbe35b43 100644 --- a/plugins/woocommerce-admin/client/homescreen/activity-panel/panels.js +++ b/plugins/woocommerce-admin/client/homescreen/activity-panel/panels.js @@ -31,7 +31,7 @@ export function getAllPanels( { count: countUnreadOrders, collapsible: true, id: 'orders-panel', - initialOpen: true, + initialOpen: false, panel: (