diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/index.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/index.js index c2d7272dbbf..e13f07180ad 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/index.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/index.js @@ -87,6 +87,7 @@ class InboxPanel extends Component { render() { const { isError, + isPanelEmpty, isRequesting, isUndoRequesting, isDismissAllUndoRequesting, @@ -119,9 +120,16 @@ class InboxPanel extends Component { const hasNotes = hasValidNotes( notes ); + const isActivityHeaderVisible = + hasNotes || isRequesting || isUndoRequesting; + + if ( isPanelEmpty ) { + isPanelEmpty( ! hasNotes && ! isActivityHeaderVisible ); + } + return ( - { ( hasNotes || isRequesting || isUndoRequesting ) && ( + { isActivityHeaderVisible && ( ) } - { ( isRequesting || isDismissAllUndoRequesting ) && ( +
+ { ( isRequesting || isDismissAllUndoRequesting ) && ( +
+ +
+ ) }
- + { ! isRequesting && + ! isDismissAllUndoRequesting && + this.renderNotes( hasNotes ) }
- ) } -
- { ! isRequesting && - ! isDismissAllUndoRequesting && - this.renderNotes( hasNotes ) } -
+
); } diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/style.scss b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/style.scss index 70f7d822f03..f847827678f 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/style.scss +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox/style.scss @@ -6,6 +6,29 @@ background: $core-grey-light-200; border-radius: 2px; @include font-size( 13 ); + margin: 20px; + -ms-box-orient: horizontal; + &.banner { + -webkit-flex-direction: column; + flex-direction: column; + img { + width: 100%; + height: 120px; + } + } + &.thumbnail { + display: flex; + -webkit-flex-direction: row-reverse; + flex-direction: row-reverse; + img { + width: 128px; + height: 100%; + } + } + + .woocommerce-homepage-column & { + margin: 20px 0; + } &:not(.is-placeholder) { border: 1px solid $light-gray-secondary; @@ -152,34 +175,6 @@ } } - -.woocommerce-inbox-message { - margin: 20px; - -ms-box-orient: horizontal; - display: -webkit-box; - display: -moz-box; - display: -ms-flexbox; - &.banner { - -webkit-flex-direction: column; - flex-direction: column; - img { - width: 100%; - height: 120px; - } - } - &.thumbnail { - display: -moz-flex; - display: -webkit-flex; - display: flex; - -webkit-flex-direction: row-reverse; - flex-direction: row-reverse; - img { - width: 128px; - height: 100%; - } - } -} - .woocommerce-inbox-message__wrapper > div { padding: $gap $gap-large; .is-placeholder & { @@ -197,3 +192,18 @@ } } } + +.woocommerce-layout__inbox-panel-header { + .woocommerce-homepage-column & { + padding: 0 24px; + } +} + +.woocommerce-homepage-notes-wrapper { + .is-inbox & { + height: calc(100% - 30px); + & > div { + overflow: auto; + } + } +} diff --git a/plugins/woocommerce-admin/client/homepage/layout.js b/plugins/woocommerce-admin/client/homepage/layout.js index 25a25b29234..830b648e808 100644 --- a/plugins/woocommerce-admin/client/homepage/layout.js +++ b/plugins/woocommerce-admin/client/homepage/layout.js @@ -9,7 +9,6 @@ import { useRef, useEffect, } from '@wordpress/element'; -import { Button } from '@wordpress/components'; import { compose } from '@wordpress/compose'; import classnames from 'classnames'; import { get } from 'lodash'; @@ -24,6 +23,7 @@ import './style.scss'; import { isOnboardingEnabled } from 'dashboard/utils'; import withSelect from 'wc-api/with-select'; import TaskListPlaceholder from '../task-list/placeholder'; +import InboxPanel from '../header/activity-panel/panels/inbox'; const TaskList = lazy( () => import( /* webpackChunkName: "task-list" */ '../task-list' ) @@ -52,31 +52,30 @@ export const Layout = ( props ) => { }; }, [] ); - const { query, requestingTaskList, taskListComplete, taskListHidden } = props; + const { + isUndoRequesting, + query, + requestingTaskList, + taskListComplete, + taskListHidden, + } = props; const isTaskListEnabled = taskListHidden === false && ! taskListComplete; const isDashboardShown = ! isTaskListEnabled || ! query.task; + const isInboxPanelEmpty = ( isEmpty ) => { + setShowInbox( ! isEmpty ); + }; + + if ( isUndoRequesting && ! showInbox ) { + setShowInbox( true ); + } + const renderColumns = () => { return ( { showInbox && (
-
- -
-
-
-
-
-
-
+
) }
{ > { isDashboardShown ? renderColumns() - : isTaskListEnabled && renderTaskList() - } + : isTaskListEnabled && renderTaskList() }
); }; @@ -143,6 +141,7 @@ export default compose( withSelect( ( select ) => { const { getOptions, + getUndoDismissRequesting, isGetOptionsRequesting, } = select( 'wc-api' ); @@ -151,14 +150,19 @@ export default compose( 'woocommerce_task_list_complete', 'woocommerce_task_list_hidden', ] ); - + const { isUndoRequesting } = getUndoDismissRequesting(); return { + isUndoRequesting, requestingTaskList: isGetOptionsRequesting( [ 'woocommerce_task_list_complete', 'woocommerce_task_list_hidden', ] ), - taskListComplete: get( options, [ 'woocommerce_task_list_complete' ] ), - taskListHidden: get( options, [ 'woocommerce_task_list_hidden' ] ) === 'yes', + taskListComplete: get( options, [ + 'woocommerce_task_list_complete', + ] ), + taskListHidden: + get( options, [ 'woocommerce_task_list_hidden' ] ) === + 'yes', }; } diff --git a/plugins/woocommerce-admin/client/homepage/test/index.js b/plugins/woocommerce-admin/client/homepage/test/index.js index 1cbe7e2e380..2ebff901dda 100644 --- a/plugins/woocommerce-admin/client/homepage/test/index.js +++ b/plugins/woocommerce-admin/client/homepage/test/index.js @@ -10,6 +10,9 @@ jest.mock( 'homepage/stats-overview', () => jest.fn().mockReturnValue( null ) ); // We aren't testing the component here. jest.mock( 'task-list', () => jest.fn().mockReturnValue( '[TaskList]' ) ); +// We aren't testing the component here. +jest.mock( 'header/activity-panel/panels/inbox', () => jest.fn().mockReturnValue( '[InboxPanel]' ) ); + describe( 'Homepage Layout', () => { it( 'should show TaskList placeholder when loading', () => { const { container } = render(