2020-11-06 01:21:05 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2024-06-17 05:05:11 +00:00
|
|
|
import { __experimentalErrorBoundary as ErrorBoundary } from '@woocommerce/components';
|
2020-11-06 01:21:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import OrdersPanel from './orders';
|
2020-11-25 18:51:15 +00:00
|
|
|
import StockPanel from './stock';
|
2020-12-02 13:30:39 +00:00
|
|
|
import ReviewsPanel from './reviews';
|
2020-11-06 01:21:05 +00:00
|
|
|
|
2020-11-23 15:06:55 +00:00
|
|
|
export function getAllPanels( {
|
2022-01-19 16:45:17 +00:00
|
|
|
lowStockProductsCount,
|
|
|
|
unapprovedReviewsCount,
|
|
|
|
unreadOrdersCount,
|
2020-11-25 18:51:15 +00:00
|
|
|
manageStock,
|
2021-10-04 17:02:01 +00:00
|
|
|
isTaskListHidden,
|
2020-11-23 15:06:55 +00:00
|
|
|
orderStatuses,
|
2020-12-29 16:19:13 +00:00
|
|
|
publishedProductCount,
|
2020-12-02 13:30:39 +00:00
|
|
|
reviewsEnabled,
|
2020-12-29 16:19:13 +00:00
|
|
|
totalOrderCount,
|
2020-11-23 15:06:55 +00:00
|
|
|
} ) {
|
2021-10-04 17:02:01 +00:00
|
|
|
if ( ! isTaskListHidden ) {
|
2021-01-29 14:23:02 +00:00
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-11-06 01:21:05 +00:00
|
|
|
return [
|
2020-11-23 15:06:55 +00:00
|
|
|
totalOrderCount > 0 && {
|
2020-11-06 01:21:05 +00:00
|
|
|
className: 'woocommerce-homescreen-card',
|
2022-01-19 16:45:17 +00:00
|
|
|
count: unreadOrdersCount,
|
2020-12-09 20:57:41 +00:00
|
|
|
collapsible: true,
|
2020-11-06 01:21:05 +00:00
|
|
|
id: 'orders-panel',
|
2021-03-16 00:34:20 +00:00
|
|
|
initialOpen: false,
|
2020-11-06 16:50:24 +00:00
|
|
|
panel: (
|
2024-06-17 05:05:11 +00:00
|
|
|
<ErrorBoundary
|
|
|
|
errorMessage={
|
|
|
|
<>
|
|
|
|
{ __(
|
|
|
|
'There was an error getting your orders.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
<br />
|
|
|
|
{ __( 'Please try again.', 'woocommerce' ) }
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<OrdersPanel
|
|
|
|
unreadOrdersCount={ unreadOrdersCount }
|
|
|
|
orderStatuses={ orderStatuses }
|
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
2020-11-06 16:50:24 +00:00
|
|
|
),
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Orders', 'woocommerce' ),
|
2020-11-06 01:21:05 +00:00
|
|
|
},
|
2020-12-29 16:19:13 +00:00
|
|
|
totalOrderCount > 0 &&
|
|
|
|
publishedProductCount > 0 &&
|
|
|
|
manageStock === 'yes' && {
|
|
|
|
className: 'woocommerce-homescreen-card',
|
2022-01-19 16:45:17 +00:00
|
|
|
count: lowStockProductsCount,
|
2020-12-29 16:19:13 +00:00
|
|
|
id: 'stock-panel',
|
|
|
|
initialOpen: false,
|
2022-01-19 16:45:17 +00:00
|
|
|
collapsible: lowStockProductsCount !== 0,
|
2020-12-29 16:19:13 +00:00
|
|
|
panel: (
|
2024-06-17 05:05:11 +00:00
|
|
|
<ErrorBoundary
|
|
|
|
errorMessage={
|
|
|
|
<>
|
|
|
|
{ __(
|
|
|
|
'There was an error getting your low stock products.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
<br />
|
|
|
|
{ __( 'Please try again.', 'woocommerce' ) }
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<StockPanel
|
|
|
|
lowStockProductsCount={ lowStockProductsCount }
|
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
2020-12-29 16:19:13 +00:00
|
|
|
),
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Stock', 'woocommerce' ),
|
2020-12-29 16:19:13 +00:00
|
|
|
},
|
|
|
|
publishedProductCount > 0 &&
|
2022-01-19 16:45:17 +00:00
|
|
|
unapprovedReviewsCount > 0 &&
|
2020-12-29 16:19:13 +00:00
|
|
|
reviewsEnabled === 'yes' && {
|
|
|
|
className: 'woocommerce-homescreen-card',
|
|
|
|
id: 'reviews-panel',
|
2022-01-19 16:45:17 +00:00
|
|
|
count: unapprovedReviewsCount,
|
2020-12-29 16:19:13 +00:00
|
|
|
initialOpen: false,
|
2022-01-19 16:45:17 +00:00
|
|
|
collapsible: unapprovedReviewsCount !== 0,
|
2020-12-29 16:19:13 +00:00
|
|
|
panel: (
|
2024-06-17 05:05:11 +00:00
|
|
|
<ErrorBoundary
|
|
|
|
errorMessage={
|
|
|
|
<>
|
|
|
|
{ __(
|
|
|
|
'There was an error getting your reviews.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
<br />
|
|
|
|
{ __( 'Please try again.', 'woocommerce' ) }
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<ReviewsPanel
|
|
|
|
hasUnapprovedReviews={ unapprovedReviewsCount > 0 }
|
|
|
|
/>
|
|
|
|
</ErrorBoundary>
|
2020-12-29 16:19:13 +00:00
|
|
|
),
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Reviews', 'woocommerce' ),
|
2020-12-29 16:19:13 +00:00
|
|
|
},
|
2020-11-06 01:21:05 +00:00
|
|
|
// Add another panel row here
|
2020-11-23 15:06:55 +00:00
|
|
|
].filter( Boolean );
|
2020-11-06 01:21:05 +00:00
|
|
|
}
|