2019-03-28 06:09:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-03-15 21:45:19 +00:00
|
|
|
|
import { Component, cloneElement, Fragment } from '@wordpress/element';
|
2020-06-10 23:49:27 +00:00
|
|
|
|
import { isEqual } from 'lodash';
|
2019-08-01 18:09:08 +00:00
|
|
|
|
import { compose } from '@wordpress/compose';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import classNames from 'classnames';
|
2020-05-27 16:08:39 +00:00
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
CardBody,
|
|
|
|
|
CardHeader,
|
|
|
|
|
Modal,
|
2020-06-18 23:44:00 +00:00
|
|
|
|
__experimentalText as Text,
|
2020-05-27 16:08:39 +00:00
|
|
|
|
} from '@wordpress/components';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import { withDispatch } from '@wordpress/data';
|
2020-05-27 16:08:39 +00:00
|
|
|
|
import { Icon, check, chevronRight } from '@wordpress/icons';
|
2019-07-18 10:11:21 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WooCommerce dependencies
|
|
|
|
|
*/
|
2020-06-18 23:44:00 +00:00
|
|
|
|
import { List, EllipsisMenu } from '@woocommerce/components';
|
2019-07-19 02:54:38 +00:00
|
|
|
|
import { updateQueryString } from '@woocommerce/navigation';
|
2020-06-10 23:49:27 +00:00
|
|
|
|
import {
|
|
|
|
|
PLUGINS_STORE_NAME,
|
|
|
|
|
OPTIONS_STORE_NAME,
|
|
|
|
|
ONBOARDING_STORE_NAME,
|
|
|
|
|
} from '@woocommerce/data';
|
2019-03-28 06:09:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2019-11-14 14:35:55 +00:00
|
|
|
|
* Internal dependencies
|
2019-03-28 06:09:44 +00:00
|
|
|
|
*/
|
|
|
|
|
import './style.scss';
|
2020-05-21 17:15:08 +00:00
|
|
|
|
import CartModal from 'dashboard/components/cart-modal';
|
2020-07-14 01:40:56 +00:00
|
|
|
|
import { getAllTasks, recordTaskViewEvent } from './tasks';
|
2019-10-07 20:27:34 +00:00
|
|
|
|
import { recordEvent } from 'lib/tracks';
|
2019-12-31 08:50:45 +00:00
|
|
|
|
import withSelect from 'wc-api/with-select';
|
2019-09-23 21:47:08 +00:00
|
|
|
|
|
2019-08-01 18:09:08 +00:00
|
|
|
|
class TaskDashboard extends Component {
|
2019-11-01 04:00:57 +00:00
|
|
|
|
constructor( props ) {
|
|
|
|
|
super( props );
|
|
|
|
|
this.state = {
|
2019-12-31 08:50:45 +00:00
|
|
|
|
isCartModalOpen: false,
|
2019-11-01 04:00:57 +00:00
|
|
|
|
isWelcomeModalOpen: ! props.modalDismissed,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 10:11:21 +00:00
|
|
|
|
componentDidMount() {
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const { incompleteTasks, updateOptions } = this.props;
|
2019-08-21 05:58:47 +00:00
|
|
|
|
document.body.classList.add( 'woocommerce-onboarding' );
|
2019-07-18 10:11:21 +00:00
|
|
|
|
document.body.classList.add( 'woocommerce-task-dashboard__body' );
|
2019-10-07 20:27:34 +00:00
|
|
|
|
|
2019-10-29 02:08:39 +00:00
|
|
|
|
this.recordTaskView();
|
|
|
|
|
this.recordTaskListView();
|
2019-10-21 00:33:46 +00:00
|
|
|
|
|
2020-03-23 20:47:12 +00:00
|
|
|
|
if ( ! incompleteTasks.length ) {
|
|
|
|
|
updateOptions( {
|
2020-06-10 13:33:30 +00:00
|
|
|
|
woocommerce_task_list_complete: 'yes',
|
2019-10-21 00:33:46 +00:00
|
|
|
|
} );
|
|
|
|
|
}
|
2020-03-23 20:47:12 +00:00
|
|
|
|
|
|
|
|
|
this.possiblyTrackCompletedTasks();
|
2019-07-18 10:11:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 02:08:39 +00:00
|
|
|
|
componentDidUpdate( prevProps ) {
|
2020-04-08 21:27:24 +00:00
|
|
|
|
const {
|
|
|
|
|
completedTaskKeys,
|
|
|
|
|
incompleteTasks,
|
|
|
|
|
query,
|
|
|
|
|
updateOptions,
|
|
|
|
|
} = this.props;
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const {
|
|
|
|
|
completedTaskKeys: prevCompletedTaskKeys,
|
|
|
|
|
incompleteTasks: prevIncompleteTasks,
|
|
|
|
|
query: prevQuery,
|
|
|
|
|
} = prevProps;
|
|
|
|
|
const { task: prevTask } = prevQuery;
|
|
|
|
|
const { task } = query;
|
2019-10-29 02:08:39 +00:00
|
|
|
|
|
|
|
|
|
if ( prevTask !== task ) {
|
2019-10-29 18:24:24 +00:00
|
|
|
|
window.document.documentElement.scrollTop = 0;
|
2019-10-29 02:08:39 +00:00
|
|
|
|
this.recordTaskView();
|
|
|
|
|
}
|
2020-03-23 20:47:12 +00:00
|
|
|
|
|
|
|
|
|
if ( ! incompleteTasks.length && prevIncompleteTasks.length ) {
|
|
|
|
|
updateOptions( {
|
2020-06-10 13:33:30 +00:00
|
|
|
|
woocommerce_task_list_complete: 'yes',
|
2020-03-23 20:47:12 +00:00
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ! isEqual( prevCompletedTaskKeys, completedTaskKeys ) ) {
|
|
|
|
|
this.possiblyTrackCompletedTasks();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
possiblyTrackCompletedTasks() {
|
2020-04-08 21:27:24 +00:00
|
|
|
|
const {
|
|
|
|
|
completedTaskKeys,
|
|
|
|
|
trackedCompletedTasks,
|
|
|
|
|
updateOptions,
|
|
|
|
|
} = this.props;
|
2020-03-23 20:47:12 +00:00
|
|
|
|
|
|
|
|
|
if ( ! isEqual( trackedCompletedTasks, completedTaskKeys ) ) {
|
|
|
|
|
updateOptions( {
|
|
|
|
|
woocommerce_task_list_tracked_completed_tasks: completedTaskKeys,
|
|
|
|
|
} );
|
|
|
|
|
}
|
2019-10-29 02:08:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 10:46:25 +00:00
|
|
|
|
dismissTask( key ) {
|
|
|
|
|
const { createNotice, dismissedTasks, updateOptions } = this.props;
|
|
|
|
|
|
|
|
|
|
createNotice( 'success', __( 'Task dismissed' ), {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
label: __( 'Undo', 'woocommerce-admin' ),
|
|
|
|
|
onClick: () => this.undoDismissTask( key ),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
recordEvent( 'tasklist_dismiss_task', { task_name: key } );
|
|
|
|
|
|
|
|
|
|
updateOptions( {
|
|
|
|
|
woocommerce_task_list_dismissed_tasks: [ ...dismissedTasks, key ],
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
undoDismissTask( key ) {
|
|
|
|
|
const { dismissedTasks, updateOptions } = this.props;
|
|
|
|
|
|
|
|
|
|
const updatedDismissedTasks = dismissedTasks.filter(
|
|
|
|
|
( task ) => task !== key
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
updateOptions( {
|
|
|
|
|
woocommerce_task_list_dismissed_tasks: updatedDismissedTasks,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 10:11:21 +00:00
|
|
|
|
componentWillUnmount() {
|
2019-08-21 05:58:47 +00:00
|
|
|
|
document.body.classList.remove( 'woocommerce-onboarding' );
|
2019-07-18 10:11:21 +00:00
|
|
|
|
document.body.classList.remove( 'woocommerce-task-dashboard__body' );
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 08:50:45 +00:00
|
|
|
|
getTasks() {
|
2020-05-25 00:26:08 +00:00
|
|
|
|
const {
|
2020-07-14 10:46:25 +00:00
|
|
|
|
dismissedTasks,
|
2020-05-25 00:26:08 +00:00
|
|
|
|
profileItems,
|
|
|
|
|
query,
|
|
|
|
|
taskListPayments,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
activePlugins,
|
2020-05-25 00:26:08 +00:00
|
|
|
|
installedPlugins,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
installAndActivatePlugins,
|
|
|
|
|
createNotice,
|
|
|
|
|
isJetpackConnected,
|
2020-05-25 00:26:08 +00:00
|
|
|
|
} = this.props;
|
2019-12-31 08:50:45 +00:00
|
|
|
|
|
|
|
|
|
return getAllTasks( {
|
|
|
|
|
profileItems,
|
2020-06-10 23:49:27 +00:00
|
|
|
|
taskListPayments,
|
2020-02-14 02:23:21 +00:00
|
|
|
|
query,
|
2019-12-31 08:50:45 +00:00
|
|
|
|
toggleCartModal: this.toggleCartModal.bind( this ),
|
2020-07-14 01:40:56 +00:00
|
|
|
|
activePlugins,
|
2020-05-25 00:26:08 +00:00
|
|
|
|
installedPlugins,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
installAndActivatePlugins,
|
|
|
|
|
createNotice,
|
|
|
|
|
isJetpackConnected,
|
2020-07-14 10:46:25 +00:00
|
|
|
|
} ).filter(
|
|
|
|
|
( task ) => task.visible && ! dismissedTasks.includes( task.key )
|
|
|
|
|
);
|
2019-12-31 08:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
|
recordTaskView() {
|
2020-04-16 23:58:36 +00:00
|
|
|
|
const {
|
|
|
|
|
isJetpackConnected,
|
|
|
|
|
activePlugins,
|
|
|
|
|
installedPlugins,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
query,
|
2020-04-16 23:58:36 +00:00
|
|
|
|
} = this.props;
|
2020-07-14 01:40:56 +00:00
|
|
|
|
const { task: taskName } = query;
|
2020-03-02 22:22:32 +00:00
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
|
if ( ! taskName ) {
|
2019-10-29 02:08:39 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
|
recordTaskViewEvent(
|
|
|
|
|
taskName,
|
|
|
|
|
isJetpackConnected,
|
|
|
|
|
activePlugins,
|
|
|
|
|
installedPlugins
|
|
|
|
|
);
|
2019-10-29 02:08:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recordTaskListView() {
|
2019-10-07 20:27:34 +00:00
|
|
|
|
if ( this.getCurrentTask() ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-02 02:36:25 +00:00
|
|
|
|
|
2019-10-07 20:27:34 +00:00
|
|
|
|
const { profileItems } = this.props;
|
2019-12-31 08:50:45 +00:00
|
|
|
|
const tasks = this.getTasks();
|
2020-01-02 02:36:25 +00:00
|
|
|
|
|
2019-10-07 20:27:34 +00:00
|
|
|
|
recordEvent( 'tasklist_view', {
|
|
|
|
|
number_tasks: tasks.length,
|
|
|
|
|
store_connected: profileItems.wccom_connected,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
keepTaskCard() {
|
|
|
|
|
recordEvent( 'tasklist_completed', {
|
|
|
|
|
action: 'keep_card',
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_prompt_shown: true,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hideTaskCard( action ) {
|
|
|
|
|
recordEvent( 'tasklist_completed', {
|
|
|
|
|
action,
|
|
|
|
|
} );
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_hidden: 'yes',
|
|
|
|
|
woocommerce_task_list_prompt_shown: true,
|
|
|
|
|
} );
|
2019-08-01 18:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 02:54:38 +00:00
|
|
|
|
getCurrentTask() {
|
2020-07-15 02:09:49 +00:00
|
|
|
|
const {
|
|
|
|
|
query,
|
|
|
|
|
profileItems,
|
|
|
|
|
payments,
|
|
|
|
|
activePlugins,
|
|
|
|
|
installedPlugins,
|
|
|
|
|
createNotice,
|
|
|
|
|
isJetpackConnected,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const allTasks = getAllTasks( {
|
|
|
|
|
profileItems,
|
|
|
|
|
options: payments,
|
|
|
|
|
query,
|
|
|
|
|
activePlugins,
|
|
|
|
|
installedPlugins,
|
|
|
|
|
createNotice,
|
|
|
|
|
isJetpackConnected,
|
|
|
|
|
} );
|
|
|
|
|
const { task } = query;
|
|
|
|
|
|
|
|
|
|
const currentTask = allTasks.find( ( s ) => s.key === task );
|
2019-07-19 02:54:38 +00:00
|
|
|
|
|
|
|
|
|
if ( ! currentTask ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currentTask;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
renderMenu() {
|
|
|
|
|
return (
|
2020-05-27 16:08:39 +00:00
|
|
|
|
<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' )
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{ __( 'Hide this', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
) }
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2019-10-11 12:55:35 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 08:50:45 +00:00
|
|
|
|
toggleCartModal() {
|
2020-01-02 02:36:25 +00:00
|
|
|
|
const { isCartModalOpen } = this.state;
|
|
|
|
|
|
|
|
|
|
if ( ! isCartModalOpen ) {
|
|
|
|
|
recordEvent( 'tasklist_purchase_extensions' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState( { isCartModalOpen: ! isCartModalOpen } );
|
2019-12-31 08:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-01 04:00:57 +00:00
|
|
|
|
closeWelcomeModal() {
|
|
|
|
|
// Prevent firing this event before the modal is seen.
|
2020-02-14 02:23:21 +00:00
|
|
|
|
if (
|
|
|
|
|
document.body.classList.contains( 'woocommerce-admin-is-loading' )
|
|
|
|
|
) {
|
2019-11-01 04:00:57 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState( { isWelcomeModalOpen: false } );
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_welcome_modal_dismissed: true,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderWelcomeModal() {
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
title={
|
|
|
|
|
<Fragment>
|
|
|
|
|
<span
|
|
|
|
|
role="img"
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
focusable="false"
|
|
|
|
|
className="woocommerce-task-dashboard__welcome-modal-icon"
|
|
|
|
|
>
|
|
|
|
|
🚀
|
|
|
|
|
</span>
|
2020-02-14 02:23:21 +00:00
|
|
|
|
{ __(
|
|
|
|
|
"Woo hoo - you're almost there!",
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
2019-11-01 04:00:57 +00:00
|
|
|
|
</Fragment>
|
|
|
|
|
}
|
|
|
|
|
onRequestClose={ () => this.closeWelcomeModal() }
|
|
|
|
|
className="woocommerce-task-dashboard__welcome-modal"
|
|
|
|
|
>
|
|
|
|
|
<div className="woocommerce-task-dashboard__welcome-modal-wrapper">
|
|
|
|
|
<div className="woocommerce-task-dashboard__welcome-modal-message">
|
|
|
|
|
<p>
|
|
|
|
|
{ __(
|
|
|
|
|
'Based on the information you provided we’ve prepared some final set up tasks for you to perform.',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
{ __(
|
|
|
|
|
'Once complete your store will be ready for launch - exciting!',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2020-02-14 02:23:21 +00:00
|
|
|
|
<Button
|
|
|
|
|
isPrimary
|
|
|
|
|
onClick={ () => this.closeWelcomeModal() }
|
|
|
|
|
>
|
2019-11-01 04:00:57 +00:00
|
|
|
|
{ __( 'Continue', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
|
render() {
|
2020-05-27 16:08:39 +00:00
|
|
|
|
const { query } = this.props;
|
2019-12-31 08:50:45 +00:00
|
|
|
|
const { isCartModalOpen, isWelcomeModalOpen } = this.state;
|
2019-07-19 02:54:38 +00:00
|
|
|
|
const currentTask = this.getCurrentTask();
|
2020-02-14 02:23:21 +00:00
|
|
|
|
const listTasks = this.getTasks().map( ( task ) => {
|
|
|
|
|
task.className = classNames(
|
|
|
|
|
task.completed ? 'is-complete' : null,
|
|
|
|
|
task.className
|
|
|
|
|
);
|
2020-05-27 16:08:39 +00:00
|
|
|
|
task.before = (
|
|
|
|
|
<div className="woocommerce-task__icon">
|
|
|
|
|
{ task.completed && <Icon icon={ check } /> }
|
|
|
|
|
</div>
|
2020-02-14 02:23:21 +00:00
|
|
|
|
);
|
2019-10-29 18:03:07 +00:00
|
|
|
|
|
2020-06-19 00:13:41 +00:00
|
|
|
|
task.title = (
|
2020-06-24 22:14:44 +00:00
|
|
|
|
<Text
|
|
|
|
|
as="div"
|
|
|
|
|
variant={ task.completed ? 'body.small' : 'button' }
|
|
|
|
|
>
|
|
|
|
|
{ task.title }
|
2020-07-14 10:46:25 +00:00
|
|
|
|
{ task.time && ! task.completed && (
|
|
|
|
|
<span className="woocommerce-task__estimated-time">
|
|
|
|
|
{ task.time }
|
|
|
|
|
</span>
|
|
|
|
|
) }
|
2020-06-24 22:14:44 +00:00
|
|
|
|
</Text>
|
2020-06-19 00:13:41 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-05-27 16:08:39 +00:00
|
|
|
|
if ( ! task.completed ) {
|
2020-07-14 10:46:25 +00:00
|
|
|
|
task.after = task.isDismissable ? (
|
|
|
|
|
<Button
|
|
|
|
|
isTertiary
|
|
|
|
|
onClick={ ( event ) => {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
this.dismissTask( task.key );
|
|
|
|
|
} }
|
|
|
|
|
>
|
|
|
|
|
{ __( 'Dismiss', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
2020-05-27 16:08:39 +00:00
|
|
|
|
) : (
|
|
|
|
|
<Icon icon={ chevronRight } />
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 18:03:07 +00:00
|
|
|
|
if ( ! task.onClick ) {
|
|
|
|
|
task.onClick = () => updateQueryString( { task: task.key } );
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
return task;
|
|
|
|
|
} );
|
2020-05-27 16:08:39 +00:00
|
|
|
|
const numCompleteTasks = listTasks.filter( ( task ) => task.completed )
|
|
|
|
|
.length;
|
|
|
|
|
const progressBarClass = classNames(
|
|
|
|
|
'woocommerce-task-card__progress-bar',
|
|
|
|
|
{
|
|
|
|
|
completed: listTasks.length === numCompleteTasks,
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-07-19 02:54:38 +00:00
|
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
|
return (
|
2019-07-18 10:11:21 +00:00
|
|
|
|
<Fragment>
|
|
|
|
|
<div className="woocommerce-task-dashboard__container">
|
2019-07-19 02:54:38 +00:00
|
|
|
|
{ currentTask ? (
|
2020-03-15 21:45:19 +00:00
|
|
|
|
cloneElement( currentTask.container, {
|
|
|
|
|
query,
|
|
|
|
|
} )
|
2019-07-19 02:54:38 +00:00
|
|
|
|
) : (
|
2019-10-11 12:55:35 +00:00
|
|
|
|
<Fragment>
|
|
|
|
|
<Card
|
2020-05-27 16:08:39 +00:00
|
|
|
|
size="large"
|
2020-06-24 22:14:44 +00:00
|
|
|
|
className="woocommerce-task-card woocommerce-dashboard-card"
|
2019-10-11 12:55:35 +00:00
|
|
|
|
>
|
2020-05-27 16:08:39 +00:00
|
|
|
|
<progress
|
|
|
|
|
className={ progressBarClass }
|
|
|
|
|
max={ listTasks.length }
|
|
|
|
|
value={ numCompleteTasks }
|
|
|
|
|
/>
|
2020-06-18 23:44:00 +00:00
|
|
|
|
<CardHeader size="medium">
|
|
|
|
|
<Text variant="title.small">
|
2020-05-27 16:08:39 +00:00
|
|
|
|
{ __(
|
2020-06-09 02:06:35 +00:00
|
|
|
|
'Finish setup',
|
2020-05-27 16:08:39 +00:00
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
2020-06-18 23:44:00 +00:00
|
|
|
|
</Text>
|
2020-05-27 16:08:39 +00:00
|
|
|
|
{ this.renderMenu() }
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardBody>
|
|
|
|
|
<List items={ listTasks } />
|
|
|
|
|
</CardBody>
|
2019-10-11 12:55:35 +00:00
|
|
|
|
</Card>
|
2019-11-01 04:00:57 +00:00
|
|
|
|
{ isWelcomeModalOpen && this.renderWelcomeModal() }
|
2019-10-11 12:55:35 +00:00
|
|
|
|
</Fragment>
|
2019-07-19 02:54:38 +00:00
|
|
|
|
) }
|
2019-03-28 06:09:44 +00:00
|
|
|
|
</div>
|
2019-12-31 08:50:45 +00:00
|
|
|
|
{ isCartModalOpen && (
|
|
|
|
|
<CartModal
|
|
|
|
|
onClose={ () => this.toggleCartModal() }
|
|
|
|
|
onClickPurchaseLater={ () => this.toggleCartModal() }
|
|
|
|
|
/>
|
|
|
|
|
) }
|
2019-07-18 10:11:21 +00:00
|
|
|
|
</Fragment>
|
2019-03-28 06:09:44 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-01 18:09:08 +00:00
|
|
|
|
|
|
|
|
|
export default compose(
|
2020-03-23 20:47:12 +00:00
|
|
|
|
withSelect( ( select, props ) => {
|
2020-05-28 08:51:40 +00:00
|
|
|
|
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const { getOption } = select( OPTIONS_STORE_NAME );
|
2020-05-21 17:15:08 +00:00
|
|
|
|
const {
|
|
|
|
|
getActivePlugins,
|
|
|
|
|
getInstalledPlugins,
|
|
|
|
|
isJetpackConnected,
|
|
|
|
|
} = select( PLUGINS_STORE_NAME );
|
2019-08-01 18:09:08 +00:00
|
|
|
|
const profileItems = getProfileItems();
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const modalDismissed =
|
|
|
|
|
getOption( 'woocommerce_task_list_welcome_modal_dismissed' ) ||
|
|
|
|
|
false;
|
|
|
|
|
const taskListPayments = getOption( 'woocommerce_task_list_payments' );
|
|
|
|
|
const trackedCompletedTasks =
|
|
|
|
|
getOption( 'woocommerce_task_list_tracked_completed_tasks' ) || [];
|
|
|
|
|
const payments = getOption( 'woocommerce_task_list_payments' );
|
2020-07-14 10:46:25 +00:00
|
|
|
|
const dismissedTasks =
|
|
|
|
|
getOption( 'woocommerce_task_list_dismissed_tasks' ) || [];
|
2020-06-10 23:49:27 +00:00
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
|
const activePlugins = getActivePlugins();
|
2020-05-25 00:26:08 +00:00
|
|
|
|
const installedPlugins = getInstalledPlugins();
|
2020-07-14 01:40:56 +00:00
|
|
|
|
const { createNotice } = props;
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const tasks = getAllTasks( {
|
|
|
|
|
profileItems,
|
2020-06-10 23:49:27 +00:00
|
|
|
|
options: payments,
|
2020-03-23 20:47:12 +00:00
|
|
|
|
query: props.query,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
activePlugins,
|
2020-05-25 00:26:08 +00:00
|
|
|
|
installedPlugins,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
createNotice,
|
|
|
|
|
isJetpackConnected: isJetpackConnected(),
|
2020-03-23 20:47:12 +00:00
|
|
|
|
} );
|
2020-04-08 21:27:24 +00:00
|
|
|
|
const completedTaskKeys = tasks
|
|
|
|
|
.filter( ( task ) => task.completed )
|
|
|
|
|
.map( ( task ) => task.key );
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const incompleteTasks = tasks.filter(
|
|
|
|
|
( task ) => task.visible && ! task.completed
|
|
|
|
|
);
|
2019-10-11 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
return {
|
2020-07-14 10:46:25 +00:00
|
|
|
|
dismissedTasks,
|
2019-11-01 04:00:57 +00:00
|
|
|
|
modalDismissed,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
profileItems,
|
2019-12-31 08:50:45 +00:00
|
|
|
|
taskListPayments,
|
2020-03-02 22:22:32 +00:00
|
|
|
|
isJetpackConnected: isJetpackConnected(),
|
2020-03-23 20:47:12 +00:00
|
|
|
|
incompleteTasks,
|
|
|
|
|
trackedCompletedTasks,
|
|
|
|
|
completedTaskKeys,
|
2020-04-16 23:58:36 +00:00
|
|
|
|
activePlugins,
|
|
|
|
|
installedPlugins,
|
2020-07-15 02:09:49 +00:00
|
|
|
|
payments,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
};
|
|
|
|
|
} ),
|
2020-02-14 02:23:21 +00:00
|
|
|
|
withDispatch( ( dispatch ) => {
|
2020-07-14 10:46:25 +00:00
|
|
|
|
const { createNotice } = dispatch( 'core/notices' );
|
2020-06-10 23:49:27 +00:00
|
|
|
|
const { updateOptions } = dispatch( OPTIONS_STORE_NAME );
|
2020-07-14 01:40:56 +00:00
|
|
|
|
const { installAndActivatePlugins } = dispatch( PLUGINS_STORE_NAME );
|
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
return {
|
2020-07-14 10:46:25 +00:00
|
|
|
|
createNotice,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
updateOptions,
|
2020-07-14 01:40:56 +00:00
|
|
|
|
installAndActivatePlugins,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
};
|
2019-08-01 18:09:08 +00:00
|
|
|
|
} )
|
|
|
|
|
)( TaskDashboard );
|