-
Notifications
You must be signed in to change notification settings - Fork 144
Update TaskList design #4434
Update TaskList design #4434
Changes from 18 commits
d9a59b9
ea20f8a
f29053e
ae59bd8
c566e6f
2dc3a7c
b1621ef
c01ac84
e5d8ecf
40474a6
7059c6d
3a4e7ff
78deea4
f062ae9
ad9a439
73a9ace
bf2c6f8
98b3d2b
db9fb2a
d584d1a
98b8aa9
4f30b28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,7 +302,10 @@ class CustomizableDashboard extends Component { | |
render() { | ||
const { query, taskListHidden, taskListComplete } = this.props; | ||
|
||
const isTaskListEnabled = isOnboardingEnabled() && ! taskListHidden; | ||
const isTaskListEnabled = | ||
isOnboardingEnabled() && | ||
! taskListHidden && | ||
! window.wcAdminFeatures.homepage; | ||
|
||
const isDashboardShown = | ||
! isTaskListEnabled || ( ! query.task && taskListComplete ); | ||
|
@@ -311,7 +314,7 @@ class CustomizableDashboard extends Component { | |
<Fragment> | ||
{ isTaskListEnabled && ( | ||
<Suspense fallback={ <Spinner /> }> | ||
<TaskList query={ query } inline={ isDashboardShown } /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrelated nit: Maybe rename |
||
<TaskList query={ query } /> | ||
</Suspense> | ||
) } | ||
{ isDashboardShown && this.renderDashboardReports() } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,8 @@ export const Layout = ( props ) => { | |
}; | ||
}, [] ); | ||
|
||
const { query, requestingTaskList, taskListHidden } = props; | ||
const isTaskListEnabled = taskListHidden === false; | ||
const { query, requestingTaskList, taskListComplete, taskListHidden } = props; | ||
const isTaskListEnabled = taskListHidden === false && ! taskListComplete; | ||
const isDashboardShown = ! isTaskListEnabled || ! query.task; | ||
|
||
const renderColumns = () => { | ||
|
@@ -101,15 +101,12 @@ export const Layout = ( props ) => { | |
|
||
const renderTaskList = () => { | ||
if ( requestingTaskList ) { | ||
return <TaskListPlaceholder />; | ||
return; | ||
} | ||
|
||
return ( | ||
<Suspense fallback={ <Spinner /> }> | ||
<TaskList | ||
query={ query } | ||
inline | ||
/> | ||
<Suspense fallback={ <TaskListPlaceholder /> }> | ||
<TaskList query={ query } /> | ||
</Suspense> | ||
); | ||
}; | ||
|
@@ -133,6 +130,10 @@ Layout.propTypes = { | |
* If the task list option is being fetched. | ||
*/ | ||
requestingTaskList: PropTypes.bool.isRequired, | ||
/** | ||
* If the task list has been completed. | ||
*/ | ||
taskListComplete: PropTypes.bool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theres a proptype violation here, "Invalid prop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unable to reproduce this - can you provide steps? |
||
/** | ||
* If the task list is hidden. | ||
*/ | ||
|
@@ -152,13 +153,16 @@ export default compose( | |
|
||
if ( isOnboardingEnabled() ) { | ||
const options = getOptions( [ | ||
'woocommerce_task_list_complete', | ||
'woocommerce_task_list_hidden', | ||
] ); | ||
|
||
return { | ||
requestingTaskList: isGetOptionsRequesting( [ | ||
'woocommerce_task_list_complete', | ||
'woocommerce_task_list_hidden', | ||
] ), | ||
taskListComplete: Boolean( get( options, [ 'woocommerce_task_list_complete' ] ) ), | ||
taskListHidden: get( options, [ 'woocommerce_task_list_hidden' ] ) === 'yes', | ||
}; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,24 @@ import { Component, cloneElement, Fragment } from '@wordpress/element'; | |
import { get, isEqual } from 'lodash'; | ||
import { compose } from '@wordpress/compose'; | ||
import classNames from 'classnames'; | ||
import { Snackbar, Icon, Button, Modal } from '@wordpress/components'; | ||
import { | ||
Button, | ||
Card, | ||
CardBody, | ||
CardHeader, | ||
Modal, | ||
} from '@wordpress/components'; | ||
import { withDispatch } from '@wordpress/data'; | ||
import { | ||
Icon, | ||
check, | ||
chevronRight, | ||
} from '@wordpress/icons'; | ||
|
||
/** | ||
* WooCommerce dependencies | ||
*/ | ||
import { Card, List, MenuItem, EllipsisMenu } from '@woocommerce/components'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
import { H, List, EllipsisMenu } from '@woocommerce/components'; | ||
import { updateQueryString } from '@woocommerce/navigation'; | ||
import { PLUGINS_STORE_NAME } from '@woocommerce/data'; | ||
|
||
|
@@ -187,56 +198,20 @@ class TaskDashboard extends Component { | |
return currentTask; | ||
} | ||
|
||
renderPrompt() { | ||
if ( this.props.promptShown ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Snackbar className="woocommerce-task-card__prompt"> | ||
<div className="woocommerce-task-card__prompt-pointer" /> | ||
<div className="woocommerce-task-card__prompt-content"> | ||
<span> | ||
{ __( 'Is this card useful?', 'woocommerce-admin' ) } | ||
</span> | ||
<div className="woocommerce-task-card__prompt-actions"> | ||
<Button | ||
isLink | ||
onClick={ () => this.hideTaskCard( 'hide_card' ) } | ||
> | ||
{ __( 'No, hide it', 'woocommerce-admin' ) } | ||
</Button> | ||
|
||
<Button isLink onClick={ () => this.keepTaskCard() }> | ||
{ __( 'Yes, keep it', 'woocommerce-admin' ) } | ||
</Button> | ||
</div> | ||
</div> | ||
</Snackbar> | ||
); | ||
} | ||
|
||
renderMenu() { | ||
return ( | ||
<EllipsisMenu | ||
label={ __( 'Task List Options', 'woocommerce-admin' ) } | ||
renderContent={ () => ( | ||
<div className="woocommerce-task-card__section-controls"> | ||
<MenuItem | ||
isClickable | ||
onInvoke={ () => | ||
this.hideTaskCard( 'remove_card' ) | ||
} | ||
> | ||
<Icon | ||
icon={ 'trash' } | ||
label={ __( 'Remove block' ) } | ||
/> | ||
{ __( 'Remove this card', 'woocommerce-admin' ) } | ||
</MenuItem> | ||
</div> | ||
) } | ||
/> | ||
<div className="woocommerce-card__menu woocommerce-card__header-item"> | ||
<EllipsisMenu | ||
label={ __( 'Task List Options', 'woocommerce-admin' ) } | ||
renderContent={ () => ( | ||
<div className="woocommerce-task-card__section-controls"> | ||
<Button onClick={ () => this.hideTaskCard( 'remove_card' ) }> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another unrelated comment: It always bugged me that clicking this didn't cause the task list to disappear immediately or at least show a spinner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK to handle this in a follow up? |
||
{ __( 'Hide this', 'woocommerce-admin' ) } | ||
</Button> | ||
</div> | ||
) } | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
|
@@ -313,52 +288,23 @@ class TaskDashboard extends Component { | |
); | ||
} | ||
|
||
onSkipStoreSetup = () => { | ||
const completedTaskKeys = this.getTasks() | ||
.filter( ( x ) => x.completed ) | ||
.map( ( x ) => x.key ); | ||
|
||
recordEvent( 'tasklist_skip', { | ||
completed_tasks_count: completedTaskKeys.length, | ||
completed_tasks: completedTaskKeys, | ||
reason: 'skip', | ||
} ); | ||
|
||
this.props.updateOptions( { | ||
woocommerce_task_list_hidden: 'yes', | ||
} ); | ||
}; | ||
|
||
renderSkipActions() { | ||
return ( | ||
<div className="skip-actions"> | ||
<Button | ||
isLink | ||
className="is-secondary" | ||
onClick={ this.onSkipStoreSetup } | ||
> | ||
{ __( 'Skip store setup', 'woocommerce-admin' ) } | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
const { inline, query } = this.props; | ||
const { query } = this.props; | ||
const { isCartModalOpen, isWelcomeModalOpen } = this.state; | ||
const currentTask = this.getCurrentTask(); | ||
const listTasks = this.getTasks().map( ( task ) => { | ||
task.className = classNames( | ||
task.completed ? 'is-complete' : null, | ||
task.className | ||
); | ||
task.before = task.completed ? ( | ||
<i className="material-icons-outlined">check_circle</i> | ||
) : ( | ||
<i className="material-icons-outlined">{ task.icon }</i> | ||
task.before = ( | ||
<div className="woocommerce-task__icon"> | ||
{ task.completed && <Icon icon={ check } /> } | ||
</div> | ||
); | ||
task.after = ( | ||
<i className="material-icons-outlined">chevron_right</i> | ||
task.after = ( task.time | ||
? <span className="woocommerce-task-estimated-time">{ task.time }</span> | ||
: <Icon icon={ chevronRight } /> | ||
); | ||
|
||
if ( ! task.onClick ) { | ||
|
@@ -367,6 +313,13 @@ class TaskDashboard extends Component { | |
|
||
return task; | ||
} ); | ||
const numCompleteTasks = listTasks.filter( task => task.completed ).length; | ||
const progressBarClass = classNames( | ||
'woocommerce-task-card__progress-bar', | ||
{ | ||
'completed': listTasks.length === numCompleteTasks, | ||
} | ||
); | ||
|
||
return ( | ||
<Fragment> | ||
|
@@ -377,23 +330,21 @@ class TaskDashboard extends Component { | |
} ) | ||
) : ( | ||
<Fragment> | ||
<Card | ||
className="woocommerce-task-card" | ||
title={ __( | ||
'Set up your store and start selling', | ||
'woocommerce-admin' | ||
) } | ||
description={ __( | ||
'Below you’ll find a list of the most important steps to get your store up and running.', | ||
'woocommerce-admin' | ||
) } | ||
menu={ inline && this.renderMenu() } | ||
> | ||
<List items={ listTasks } /> | ||
<Card size="large" className="woocommerce-task-card"> | ||
<progress | ||
className={ progressBarClass } | ||
max={ listTasks.length } | ||
value={ numCompleteTasks } | ||
/> | ||
<CardHeader> | ||
<H>{ __( 'Store setup', 'woocommerce-admin' ) }</H> | ||
{ this.renderMenu() } | ||
</CardHeader> | ||
<CardBody> | ||
<List items={ listTasks } /> | ||
</CardBody> | ||
</Card> | ||
{ inline && this.renderPrompt() } | ||
{ isWelcomeModalOpen && this.renderWelcomeModal() } | ||
{ this.renderSkipActions() } | ||
</Fragment> | ||
) } | ||
</div> | ||
|
@@ -419,16 +370,10 @@ export default compose( | |
const profileItems = getProfileItems(); | ||
|
||
const options = getOptions( [ | ||
'woocommerce_task_list_prompt_shown', | ||
'woocommerce_task_list_welcome_modal_dismissed', | ||
'woocommerce_task_list_hidden', | ||
'woocommerce_task_list_tracked_completed_tasks', | ||
] ); | ||
const promptShown = get( | ||
options, | ||
[ 'woocommerce_task_list_prompt_shown' ], | ||
false | ||
); | ||
const modalDismissed = get( | ||
options, | ||
[ 'woocommerce_task_list_welcome_modal_dismissed' ], | ||
|
@@ -459,7 +404,6 @@ export default compose( | |
return { | ||
modalDismissed, | ||
profileItems, | ||
promptShown, | ||
taskListPayments, | ||
isJetpackConnected: isJetpackConnected(), | ||
incompleteTasks, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeffstieler if #4418 is merged first this should be updated to
! getFeatureFlag( 'homepage' );