2018-06-28 13:52:45 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2018-06-29 15:20:08 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2023-04-25 22:17:33 +00:00
|
|
|
import { lazy, useState, useEffect } from '@wordpress/element';
|
2022-12-15 22:31:47 +00:00
|
|
|
import { useSelect, useDispatch } from '@wordpress/data';
|
2020-08-05 22:02:24 +00:00
|
|
|
import { uniqueId, find } from 'lodash';
|
2021-11-17 05:56:25 +00:00
|
|
|
import { Icon, help as helpIcon, external } from '@wordpress/icons';
|
2023-03-16 14:22:33 +00:00
|
|
|
import { STORE_KEY as CES_STORE_KEY } from '@woocommerce/customer-effort-score';
|
2021-02-16 20:01:11 +00:00
|
|
|
import { H, Section } from '@woocommerce/components';
|
2021-03-30 18:44:17 +00:00
|
|
|
import {
|
2021-06-09 13:56:45 +00:00
|
|
|
ONBOARDING_STORE_NAME,
|
2021-03-30 18:44:17 +00:00
|
|
|
OPTIONS_STORE_NAME,
|
|
|
|
useUser,
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences,
|
2022-06-14 18:31:50 +00:00
|
|
|
getVisibleTasks,
|
2021-03-30 18:44:17 +00:00
|
|
|
} from '@woocommerce/data';
|
2022-07-05 17:02:46 +00:00
|
|
|
import { getHistory, addHistoryListener } from '@woocommerce/navigation';
|
2020-12-18 13:17:07 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2021-06-11 13:37:21 +00:00
|
|
|
import { useSlot } from '@woocommerce/experimental';
|
2023-04-25 22:17:33 +00:00
|
|
|
import {
|
|
|
|
LayoutContextProvider,
|
|
|
|
useExtendLayout,
|
|
|
|
} from '@woocommerce/admin-layout';
|
2021-12-14 16:56:42 +00:00
|
|
|
|
2018-06-28 13:52:45 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-06-29 15:20:08 +00:00
|
|
|
import './style.scss';
|
2021-12-14 16:56:42 +00:00
|
|
|
import { IconFlag } from './icon-flag';
|
2023-05-11 19:07:13 +00:00
|
|
|
import { hasUnreadNotes as checkIfHasUnreadNotes } from './unread-indicators';
|
2020-08-13 02:05:22 +00:00
|
|
|
import { Tabs } from './tabs';
|
|
|
|
import { SetupProgress } from './setup-progress';
|
2020-11-16 13:48:50 +00:00
|
|
|
import { DisplayOptions } from './display-options';
|
2020-12-18 13:17:07 +00:00
|
|
|
import { HighlightTooltip } from './highlight-tooltip';
|
2021-02-16 20:01:11 +00:00
|
|
|
import { Panel } from './panel';
|
2021-06-09 13:56:45 +00:00
|
|
|
import {
|
|
|
|
getLowStockCount as getLowStockProducts,
|
|
|
|
getOrderStatuses,
|
|
|
|
getUnreadOrders,
|
2021-12-14 16:56:42 +00:00
|
|
|
} from '../homescreen/activity-panel/orders/utils';
|
|
|
|
import { getUnapprovedReviews } from '../homescreen/activity-panel/reviews/utils';
|
2021-06-11 13:37:21 +00:00
|
|
|
import { ABBREVIATED_NOTIFICATION_SLOT_NAME } from './panels/inbox/abbreviated-notifications-panel';
|
2022-04-26 20:17:45 +00:00
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
2022-12-15 22:31:47 +00:00
|
|
|
import { getUrlParams } from '~/utils';
|
2023-05-17 01:54:31 +00:00
|
|
|
import { useActiveSetupTasklist } from '~/task-lists';
|
2022-10-20 20:15:44 +00:00
|
|
|
import { getSegmentsFromPath } from '~/utils/url-helpers';
|
2022-12-15 22:31:47 +00:00
|
|
|
import { FeedbackIcon } from '~/products/images/feedback-icon';
|
2020-07-14 12:20:51 +00:00
|
|
|
|
|
|
|
const HelpPanel = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "activity-panels-help" */ './panels/help' )
|
|
|
|
);
|
|
|
|
|
2020-04-29 18:01:27 +00:00
|
|
|
const InboxPanel = lazy( () =>
|
2020-10-06 13:13:32 +00:00
|
|
|
import(
|
2021-06-09 13:56:45 +00:00
|
|
|
/* webpackChunkName: "activity-panels-inbox" */ './panels/inbox/inbox-panel'
|
2020-10-06 13:13:32 +00:00
|
|
|
)
|
2020-04-29 18:01:27 +00:00
|
|
|
);
|
2020-11-25 18:51:15 +00:00
|
|
|
|
2022-06-01 17:10:20 +00:00
|
|
|
const SetupTasksPanel = lazy( () =>
|
|
|
|
import(
|
|
|
|
/* webpackChunkName: "activity-panels-setup" */ './panels/setup-tasks/setup-tasks-panel.tsx'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-12-14 16:56:42 +00:00
|
|
|
export const ActivityPanel = ( { isEmbedded, query } ) => {
|
2021-02-19 13:57:17 +00:00
|
|
|
const [ currentTab, setCurrentTab ] = useState( '' );
|
2021-03-25 23:42:01 +00:00
|
|
|
const [ isPanelClosing, setIsPanelClosing ] = useState( false );
|
2021-02-19 13:57:17 +00:00
|
|
|
const [ isPanelOpen, setIsPanelOpen ] = useState( false );
|
|
|
|
const [ isPanelSwitching, setIsPanelSwitching ] = useState( false );
|
2021-06-11 13:37:21 +00:00
|
|
|
const { fills } = useSlot( ABBREVIATED_NOTIFICATION_SLOT_NAME );
|
|
|
|
const hasExtendedNotifications = Boolean( fills?.length );
|
2021-12-14 16:56:42 +00:00
|
|
|
const { updateUserPreferences, ...userData } = useUserPreferences();
|
2022-06-14 18:31:50 +00:00
|
|
|
const activeSetupList = useActiveSetupTasklist();
|
2021-02-19 13:57:17 +00:00
|
|
|
|
2022-07-05 17:02:46 +00:00
|
|
|
useEffect( () => {
|
|
|
|
return addHistoryListener( () => {
|
|
|
|
closePanel();
|
|
|
|
clearPanel();
|
|
|
|
} );
|
|
|
|
}, [] );
|
|
|
|
|
2023-04-25 22:17:33 +00:00
|
|
|
const updatedLayoutContext = useExtendLayout( 'activity-panel' );
|
|
|
|
|
2021-03-30 18:44:17 +00:00
|
|
|
const getPreviewSiteBtnTrackData = ( select, getOption ) => {
|
|
|
|
let trackData = {};
|
|
|
|
if ( query.page === 'wc-admin' && query.task === 'appearance' ) {
|
2021-11-09 12:42:33 +00:00
|
|
|
const { getTaskLists } = select( ONBOARDING_STORE_NAME );
|
|
|
|
const taskLists = getTaskLists();
|
|
|
|
const tasks = taskLists.reduce(
|
|
|
|
( acc, taskList ) => [ ...acc, ...taskList.tasks ],
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
const task = tasks.find( ( t ) => t.id === 'appearance' );
|
|
|
|
|
2021-03-30 18:44:17 +00:00
|
|
|
const demoNotice = getOption( 'woocommerce_demo_store_notice' );
|
|
|
|
trackData = {
|
|
|
|
set_notice: demoNotice ? 'Y' : 'N',
|
2021-11-09 12:42:33 +00:00
|
|
|
create_homepage:
|
|
|
|
task?.additionalData?.hasHomepage === true ? 'Y' : 'N',
|
|
|
|
upload_logo: task?.additionalData?.themeMods?.custom_logo
|
|
|
|
? 'Y'
|
|
|
|
: 'N',
|
2021-03-30 18:44:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return trackData;
|
|
|
|
};
|
|
|
|
|
2021-11-15 20:57:13 +00:00
|
|
|
function getThingsToDoNextCount( extendedTaskList ) {
|
|
|
|
if (
|
|
|
|
! extendedTaskList ||
|
|
|
|
! extendedTaskList.tasks.length ||
|
|
|
|
extendedTaskList.isHidden
|
|
|
|
) {
|
2021-06-09 13:56:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2021-11-15 20:57:13 +00:00
|
|
|
return extendedTaskList.tasks.filter(
|
|
|
|
( task ) => task.canView && ! task.isComplete && ! task.isDismissed
|
2021-06-09 13:56:45 +00:00
|
|
|
).length;
|
|
|
|
}
|
|
|
|
|
2023-05-11 19:07:13 +00:00
|
|
|
function checkIfHasAbbreviatedNotifications(
|
2021-06-09 13:56:45 +00:00
|
|
|
select,
|
|
|
|
setupTaskListHidden,
|
|
|
|
thingsToDoNextCount
|
|
|
|
) {
|
|
|
|
const orderStatuses = getOrderStatuses( select );
|
|
|
|
|
2023-05-11 19:07:13 +00:00
|
|
|
const isOrdersCardVisible = setupTaskListHidden
|
|
|
|
? getUnreadOrders( select, orderStatuses ) > 0
|
|
|
|
: false;
|
|
|
|
const isReviewsCardVisible = setupTaskListHidden
|
|
|
|
? getUnapprovedReviews( select )
|
|
|
|
: false;
|
|
|
|
const isLowStockCardVisible = setupTaskListHidden
|
|
|
|
? getLowStockProducts( select )
|
|
|
|
: false;
|
2021-06-09 13:56:45 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
thingsToDoNextCount > 0 ||
|
|
|
|
isOrdersCardVisible ||
|
|
|
|
isReviewsCardVisible ||
|
2021-06-11 13:37:21 +00:00
|
|
|
isLowStockCardVisible ||
|
|
|
|
hasExtendedNotifications
|
2021-06-09 13:56:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const {
|
|
|
|
hasUnreadNotes,
|
2021-06-09 13:56:45 +00:00
|
|
|
hasAbbreviatedNotifications,
|
2021-11-15 20:57:13 +00:00
|
|
|
isCompletedTask,
|
2021-06-09 13:56:45 +00:00
|
|
|
thingsToDoNextCount,
|
2021-02-19 13:57:17 +00:00
|
|
|
requestingTaskListOptions,
|
|
|
|
setupTaskListComplete,
|
|
|
|
setupTaskListHidden,
|
2022-06-14 18:31:50 +00:00
|
|
|
setupTasksCompleteCount,
|
|
|
|
setupTasksCount,
|
2021-03-30 18:44:17 +00:00
|
|
|
previewSiteBtnTrackData,
|
2021-02-19 13:57:17 +00:00
|
|
|
} = useSelect( ( select ) => {
|
2021-11-15 20:57:13 +00:00
|
|
|
const { getOption } = select( OPTIONS_STORE_NAME );
|
|
|
|
const { getTask, getTaskList, hasFinishedResolution } = select(
|
|
|
|
ONBOARDING_STORE_NAME
|
2021-06-09 13:56:45 +00:00
|
|
|
);
|
2020-08-05 22:02:24 +00:00
|
|
|
|
2023-09-21 22:35:45 +00:00
|
|
|
const setupList = activeSetupList && getTaskList( activeSetupList );
|
2022-06-14 18:31:50 +00:00
|
|
|
|
2023-09-21 22:35:45 +00:00
|
|
|
const isSetupTaskListHidden = setupList?.isHidden ?? false;
|
2022-06-14 18:31:50 +00:00
|
|
|
const setupVisibleTasks = getVisibleTasks( setupList?.tasks || [] );
|
2021-11-15 20:57:13 +00:00
|
|
|
const extendedTaskList = getTaskList( 'extended' );
|
|
|
|
|
|
|
|
const thingsToDoCount = getThingsToDoNextCount( extendedTaskList );
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
return {
|
2023-05-11 19:07:13 +00:00
|
|
|
hasUnreadNotes: checkIfHasUnreadNotes( select ),
|
|
|
|
hasAbbreviatedNotifications: checkIfHasAbbreviatedNotifications(
|
2021-06-09 13:56:45 +00:00
|
|
|
select,
|
|
|
|
isSetupTaskListHidden,
|
|
|
|
thingsToDoCount
|
|
|
|
),
|
|
|
|
thingsToDoNextCount: thingsToDoCount,
|
2022-06-21 08:37:34 +00:00
|
|
|
requestingTaskListOptions:
|
|
|
|
! hasFinishedResolution( 'getTaskLists' ),
|
2022-06-14 18:31:50 +00:00
|
|
|
setupTaskListComplete: setupList?.isComplete,
|
2021-06-09 13:56:45 +00:00
|
|
|
setupTaskListHidden: isSetupTaskListHidden,
|
2022-06-14 18:31:50 +00:00
|
|
|
setupTasksCount: setupVisibleTasks.length,
|
|
|
|
setupTasksCompleteCount: setupVisibleTasks.filter(
|
|
|
|
( task ) => task.isComplete
|
|
|
|
).length,
|
2021-11-15 20:57:13 +00:00
|
|
|
isCompletedTask: Boolean(
|
|
|
|
query.task && getTask( query.task )?.isComplete
|
|
|
|
),
|
2021-03-30 18:44:17 +00:00
|
|
|
previewSiteBtnTrackData: getPreviewSiteBtnTrackData(
|
|
|
|
select,
|
|
|
|
getOption
|
|
|
|
),
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
|
|
|
} );
|
2022-12-15 22:31:47 +00:00
|
|
|
|
|
|
|
const { showCesModal } = useDispatch( CES_STORE_KEY );
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const { currentUserCan } = useUser();
|
|
|
|
|
|
|
|
const togglePanel = ( { name: tabName }, isTabOpen ) => {
|
|
|
|
const panelSwitching =
|
|
|
|
tabName !== currentTab &&
|
|
|
|
currentTab !== '' &&
|
|
|
|
isTabOpen &&
|
|
|
|
isPanelOpen;
|
|
|
|
|
2021-03-25 23:42:01 +00:00
|
|
|
if ( isPanelClosing ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
setCurrentTab( tabName );
|
|
|
|
setIsPanelOpen( isTabOpen );
|
|
|
|
setIsPanelSwitching( panelSwitching );
|
|
|
|
};
|
|
|
|
|
|
|
|
const closePanel = () => {
|
2021-03-25 23:42:01 +00:00
|
|
|
setIsPanelClosing( true );
|
2021-02-19 13:57:17 +00:00
|
|
|
setIsPanelOpen( false );
|
|
|
|
};
|
|
|
|
|
|
|
|
const clearPanel = () => {
|
2021-02-25 12:56:00 +00:00
|
|
|
if ( ! isPanelOpen ) {
|
2021-03-25 23:42:01 +00:00
|
|
|
setIsPanelClosing( false );
|
2021-02-25 12:56:00 +00:00
|
|
|
setIsPanelSwitching( false );
|
|
|
|
setCurrentTab( '' );
|
|
|
|
}
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2019-07-25 01:33:41 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const isHomescreen = () => {
|
|
|
|
return query.page === 'wc-admin' && ! query.path;
|
|
|
|
};
|
|
|
|
|
2022-12-15 22:31:47 +00:00
|
|
|
const isProductScreen = () => {
|
2022-10-20 20:15:44 +00:00
|
|
|
const [ firstPathSegment ] = getSegmentsFromPath( query.path );
|
|
|
|
return (
|
|
|
|
firstPathSegment === 'add-product' || firstPathSegment === 'product'
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-12-16 00:09:21 +00:00
|
|
|
const isAddProductPage = () => {
|
|
|
|
const urlParams = getUrlParams( window.location.search );
|
|
|
|
|
|
|
|
return (
|
|
|
|
isEmbedded &&
|
|
|
|
/post-new\.php$/.test( window.location.pathname ) &&
|
|
|
|
urlParams?.post_type === 'product'
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const isPerformingSetupTask = () => {
|
|
|
|
return (
|
2020-07-14 12:20:51 +00:00
|
|
|
query.task &&
|
|
|
|
! query.path &&
|
|
|
|
( requestingTaskListOptions === true ||
|
2021-01-27 18:40:02 +00:00
|
|
|
( setupTaskListHidden === false &&
|
2021-02-19 13:57:17 +00:00
|
|
|
setupTaskListComplete === false ) )
|
|
|
|
);
|
|
|
|
};
|
2020-10-22 22:13:14 +00:00
|
|
|
|
|
|
|
// @todo Pull in dynamic unread status/count
|
2021-02-19 13:57:17 +00:00
|
|
|
const getTabs = () => {
|
2021-11-17 05:56:25 +00:00
|
|
|
const activity = {
|
|
|
|
name: 'activity',
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Activity', 'woocommerce' ),
|
2021-11-17 05:56:25 +00:00
|
|
|
icon: <IconFlag />,
|
2021-06-09 13:56:45 +00:00
|
|
|
unread: hasUnreadNotes || hasAbbreviatedNotifications,
|
2021-02-19 13:57:17 +00:00
|
|
|
visible:
|
2022-10-20 20:15:44 +00:00
|
|
|
( isEmbedded || ! isHomescreen() ) &&
|
|
|
|
! isPerformingSetupTask() &&
|
2022-12-15 22:31:47 +00:00
|
|
|
! isProductScreen(),
|
|
|
|
};
|
|
|
|
|
|
|
|
const feedback = {
|
|
|
|
name: 'feedback',
|
|
|
|
title: __( 'Feedback', 'woocommerce' ),
|
|
|
|
icon: <FeedbackIcon />,
|
|
|
|
onClick: () => {
|
|
|
|
setCurrentTab( 'feedback' );
|
|
|
|
setIsPanelOpen( true );
|
|
|
|
showCesModal(
|
|
|
|
{
|
|
|
|
action: 'product_feedback',
|
|
|
|
title: __(
|
|
|
|
"How's your experience with the product editor?",
|
|
|
|
'woocommerce'
|
|
|
|
),
|
|
|
|
firstQuestion: __(
|
|
|
|
'The product editing screen is easy to use',
|
|
|
|
'woocommerce'
|
|
|
|
),
|
|
|
|
secondQuestion: __(
|
|
|
|
"The product editing screen's functionality meets my needs",
|
|
|
|
'woocommerce'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
onRecordScore: () => {
|
|
|
|
setCurrentTab( '' );
|
|
|
|
setIsPanelOpen( false );
|
|
|
|
},
|
|
|
|
onCloseModal: () => {
|
|
|
|
setCurrentTab( '' );
|
|
|
|
setIsPanelOpen( false );
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'snackbar',
|
|
|
|
icon: <span>🌟</span>,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
2022-12-16 00:09:21 +00:00
|
|
|
visible: isAddProductPage(),
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2021-02-16 20:01:11 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const setup = {
|
|
|
|
name: 'setup',
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Finish setup', 'woocommerce' ),
|
2022-06-14 18:31:50 +00:00
|
|
|
icon: (
|
|
|
|
<SetupProgress
|
|
|
|
setupTasksComplete={ setupTasksCompleteCount }
|
|
|
|
setupCompletePercent={ Math.ceil(
|
|
|
|
( setupTasksCompleteCount / setupTasksCount ) * 100
|
|
|
|
) }
|
|
|
|
/>
|
|
|
|
),
|
2021-02-19 13:57:17 +00:00
|
|
|
visible:
|
|
|
|
currentUserCan( 'manage_woocommerce' ) &&
|
2021-11-15 20:57:13 +00:00
|
|
|
! requestingTaskListOptions &&
|
2021-02-19 13:57:17 +00:00
|
|
|
! setupTaskListComplete &&
|
|
|
|
! setupTaskListHidden &&
|
2022-10-20 20:15:44 +00:00
|
|
|
! isHomescreen() &&
|
2022-12-15 22:31:47 +00:00
|
|
|
! isProductScreen(),
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2020-10-15 19:49:46 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const help = {
|
|
|
|
name: 'help',
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Help', 'woocommerce' ),
|
2021-02-19 13:57:17 +00:00
|
|
|
icon: <Icon icon={ helpIcon } />,
|
|
|
|
visible:
|
2021-10-14 14:04:17 +00:00
|
|
|
currentUserCan( 'manage_woocommerce' ) &&
|
|
|
|
( ( isHomescreen() && ! isEmbedded ) ||
|
|
|
|
isPerformingSetupTask() ),
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2020-09-24 21:23:27 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const displayOptions = {
|
|
|
|
component: DisplayOptions,
|
|
|
|
visible:
|
2021-10-14 14:04:17 +00:00
|
|
|
currentUserCan( 'manage_woocommerce' ) &&
|
|
|
|
! isEmbedded &&
|
|
|
|
isHomescreen() &&
|
|
|
|
! isPerformingSetupTask(),
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2020-11-16 13:48:50 +00:00
|
|
|
|
2021-03-05 02:37:18 +00:00
|
|
|
const previewSite = {
|
|
|
|
name: 'previewSite',
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Preview site', 'woocommerce' ),
|
2021-03-05 02:37:18 +00:00
|
|
|
icon: <Icon icon={ external } />,
|
2022-04-26 20:17:45 +00:00
|
|
|
visible: isHomescreen() && query.task === 'appearance',
|
2021-03-05 02:37:18 +00:00
|
|
|
onClick: () => {
|
2022-04-26 20:17:45 +00:00
|
|
|
window.open( getAdminSetting( 'siteUrl' ) );
|
2021-03-30 18:44:17 +00:00
|
|
|
recordEvent(
|
|
|
|
'wcadmin_tasklist_previewsite',
|
|
|
|
previewSiteBtnTrackData
|
|
|
|
);
|
|
|
|
|
2021-03-05 02:37:18 +00:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-04-22 13:08:35 +00:00
|
|
|
const previewStore = {
|
|
|
|
name: 'previewStore',
|
|
|
|
title: __( 'Preview store', 'woocommerce' ),
|
|
|
|
icon: <Icon icon={ external } />,
|
2022-04-26 20:17:45 +00:00
|
|
|
visible: isHomescreen() && query.task !== 'appearance',
|
2022-04-22 13:08:35 +00:00
|
|
|
onClick: () => {
|
2022-04-26 20:17:45 +00:00
|
|
|
window.open( getAdminSetting( 'shopUrl' ) );
|
2022-04-22 13:08:35 +00:00
|
|
|
recordEvent( 'wcadmin_previewstore_click' );
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
activity,
|
2022-12-15 22:31:47 +00:00
|
|
|
feedback,
|
2022-04-22 13:08:35 +00:00
|
|
|
setup,
|
|
|
|
previewSite,
|
|
|
|
previewStore,
|
|
|
|
displayOptions,
|
|
|
|
help,
|
|
|
|
].filter( ( tab ) => tab.visible );
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2018-06-28 13:52:45 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const getPanelContent = ( tab ) => {
|
2020-08-05 22:02:24 +00:00
|
|
|
const { task } = query;
|
|
|
|
|
2018-07-06 12:40:05 +00:00
|
|
|
switch ( tab ) {
|
2021-11-17 05:56:25 +00:00
|
|
|
case 'activity':
|
2021-06-09 13:56:45 +00:00
|
|
|
return (
|
|
|
|
<InboxPanel
|
|
|
|
hasAbbreviatedNotifications={
|
|
|
|
hasAbbreviatedNotifications
|
|
|
|
}
|
|
|
|
thingsToDoNextCount={ thingsToDoNextCount }
|
|
|
|
/>
|
|
|
|
);
|
2020-07-14 12:20:51 +00:00
|
|
|
case 'help':
|
|
|
|
return <HelpPanel taskName={ task } />;
|
2022-06-01 17:10:20 +00:00
|
|
|
case 'setup':
|
|
|
|
return <SetupTasksPanel query={ query } />;
|
2018-06-28 13:52:45 +00:00
|
|
|
default:
|
2018-07-09 15:46:31 +00:00
|
|
|
return null;
|
2018-06-28 13:52:45 +00:00
|
|
|
}
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2018-07-06 12:40:05 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const closedHelpPanelHighlight = () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
recordEvent( 'help_tooltip_click' );
|
2021-12-14 16:56:42 +00:00
|
|
|
if ( userData && updateUserPreferences ) {
|
|
|
|
updateUserPreferences( {
|
2020-12-18 13:17:07 +00:00
|
|
|
help_panel_highlight_shown: 'yes',
|
|
|
|
} );
|
|
|
|
}
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
2020-12-18 13:17:07 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
const shouldShowHelpTooltip = () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
const { task } = query;
|
|
|
|
const startedTasks =
|
2021-12-14 16:56:42 +00:00
|
|
|
userData && userData.task_list_tracked_started_tasks;
|
|
|
|
const highlightShown = userData && userData.help_panel_highlight_shown;
|
2020-12-18 13:17:07 +00:00
|
|
|
if (
|
|
|
|
task &&
|
|
|
|
highlightShown !== 'yes' &&
|
|
|
|
( startedTasks || {} )[ task ] > 1 &&
|
2021-11-15 20:57:13 +00:00
|
|
|
! isCompletedTask
|
2020-12-18 13:17:07 +00:00
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2021-02-19 13:57:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const tabs = getTabs();
|
|
|
|
const headerId = uniqueId( 'activity-panel-header_' );
|
|
|
|
const showHelpHighlightTooltip = shouldShowHelpTooltip();
|
|
|
|
|
|
|
|
return (
|
2023-04-25 22:17:33 +00:00
|
|
|
<LayoutContextProvider value={ updatedLayoutContext }>
|
2022-06-14 18:31:50 +00:00
|
|
|
<div>
|
|
|
|
<H id={ headerId } className="screen-reader-text">
|
|
|
|
{ __( 'Store Activity', 'woocommerce' ) }
|
|
|
|
</H>
|
|
|
|
<Section
|
|
|
|
component="aside"
|
|
|
|
id="woocommerce-activity-panel"
|
|
|
|
className="woocommerce-layout__activity-panel"
|
|
|
|
aria-labelledby={ headerId }
|
|
|
|
>
|
|
|
|
<Tabs
|
|
|
|
tabs={ tabs }
|
|
|
|
tabOpen={ isPanelOpen }
|
|
|
|
selectedTab={ currentTab }
|
|
|
|
onTabClick={ ( tab, tabOpen ) => {
|
|
|
|
if ( tab.onClick ) {
|
|
|
|
tab.onClick();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
togglePanel( tab, tabOpen );
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
<Panel
|
|
|
|
currentTab
|
|
|
|
isPanelOpen={ isPanelOpen }
|
|
|
|
isPanelSwitching={ isPanelSwitching }
|
|
|
|
tab={ find( getTabs(), { name: currentTab } ) }
|
|
|
|
content={ getPanelContent( currentTab ) }
|
|
|
|
closePanel={ () => closePanel() }
|
|
|
|
clearPanel={ () => clearPanel() }
|
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
{ showHelpHighlightTooltip ? (
|
|
|
|
<HighlightTooltip
|
|
|
|
delay={ 1000 }
|
|
|
|
useAnchor={ true }
|
|
|
|
title={ __( "We're here for help", 'woocommerce' ) }
|
|
|
|
content={ __(
|
|
|
|
'If you have any questions, feel free to explore the WooCommerce docs listed here.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
closeButtonText={ __( 'Got it', 'woocommerce' ) }
|
|
|
|
id="activity-panel-tab-help"
|
|
|
|
onClose={ () => closedHelpPanelHighlight() }
|
|
|
|
onShow={ () => recordEvent( 'help_tooltip_view' ) }
|
|
|
|
/>
|
|
|
|
) : null }
|
|
|
|
</div>
|
2023-04-25 22:17:33 +00:00
|
|
|
</LayoutContextProvider>
|
2021-02-19 13:57:17 +00:00
|
|
|
);
|
|
|
|
};
|
2018-06-28 13:52:45 +00:00
|
|
|
|
2020-07-14 12:20:51 +00:00
|
|
|
ActivityPanel.defaultProps = {
|
|
|
|
getHistory,
|
|
|
|
};
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
export default ActivityPanel;
|