2019-03-28 06:09:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-12-03 21:16:04 +00:00
|
|
|
import { Component } from '@wordpress/element';
|
2019-08-01 18:09:08 +00:00
|
|
|
import { compose } from '@wordpress/compose';
|
2020-08-05 00:14:56 +00:00
|
|
|
import { withDispatch, withSelect } from '@wordpress/data';
|
2020-06-10 23:49:27 +00:00
|
|
|
import {
|
|
|
|
ONBOARDING_STORE_NAME,
|
2020-12-03 21:16:04 +00:00
|
|
|
OPTIONS_STORE_NAME,
|
|
|
|
PLUGINS_STORE_NAME,
|
2020-08-03 08:22:25 +00:00
|
|
|
SETTINGS_STORE_NAME,
|
2020-06-10 23:49:27 +00:00
|
|
|
} from '@woocommerce/data';
|
2020-08-20 04:59:52 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
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-08-13 02:05:22 +00:00
|
|
|
import CartModal from '../dashboard/components/cart-modal';
|
2020-12-03 21:16:04 +00:00
|
|
|
import { getAllTasks } from './tasks';
|
2020-08-13 02:05:22 +00:00
|
|
|
import { getCountryCode } from '../dashboard/utils';
|
2020-12-03 21:16:04 +00:00
|
|
|
import TaskList from './list';
|
2019-09-23 21:47:08 +00:00
|
|
|
|
2020-11-06 17:53:03 +00:00
|
|
|
export 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
|
|
|
};
|
|
|
|
}
|
2019-07-18 10:11:21 +00:00
|
|
|
componentDidMount() {
|
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' );
|
|
|
|
}
|
|
|
|
|
2020-07-20 06:19:01 +00:00
|
|
|
getAllTasks() {
|
2020-05-25 00:26:08 +00:00
|
|
|
const {
|
2020-07-14 01:40:56 +00:00
|
|
|
activePlugins,
|
2020-08-24 13:20:57 +00:00
|
|
|
countryCode,
|
2020-07-14 01:40:56 +00:00
|
|
|
createNotice,
|
2020-08-24 13:20:57 +00:00
|
|
|
installAndActivatePlugins,
|
|
|
|
installedPlugins,
|
2020-07-14 01:40:56 +00:00
|
|
|
isJetpackConnected,
|
2020-08-24 13:20:57 +00:00
|
|
|
onboardingStatus,
|
|
|
|
profileItems,
|
|
|
|
query,
|
2020-05-25 00:26:08 +00:00
|
|
|
} = this.props;
|
2019-12-31 08:50:45 +00:00
|
|
|
|
|
|
|
return getAllTasks( {
|
2020-08-24 13:20:57 +00:00
|
|
|
activePlugins,
|
2020-08-03 08:22:25 +00:00
|
|
|
countryCode,
|
2020-08-24 13:20:57 +00:00
|
|
|
createNotice,
|
|
|
|
installAndActivatePlugins,
|
|
|
|
installedPlugins,
|
|
|
|
isJetpackConnected,
|
|
|
|
onboardingStatus,
|
2019-12-31 08:50:45 +00:00
|
|
|
profileItems,
|
2020-02-14 02:23:21 +00:00
|
|
|
query,
|
2019-12-31 08:50:45 +00:00
|
|
|
toggleCartModal: this.toggleCartModal.bind( this ),
|
2020-07-20 06:19:01 +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-03-28 06:09:44 +00:00
|
|
|
render() {
|
2020-12-03 21:16:04 +00:00
|
|
|
const {
|
|
|
|
dismissedTasks,
|
|
|
|
isExtendedTaskListComplete,
|
|
|
|
isExtendedTaskListHidden,
|
|
|
|
isSetupTaskListHidden,
|
|
|
|
isTaskListComplete,
|
|
|
|
query,
|
|
|
|
trackedCompletedTasks,
|
|
|
|
} = this.props;
|
2020-08-05 00:14:56 +00:00
|
|
|
const { isCartModalOpen } = this.state;
|
2020-12-03 21:16:04 +00:00
|
|
|
const allTasks = this.getAllTasks();
|
2020-12-11 02:29:45 +00:00
|
|
|
const { extension: extensionTasks, setup: setupTasks } = allTasks;
|
2019-07-19 02:54:38 +00:00
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
return (
|
2020-11-04 21:48:26 +00:00
|
|
|
<>
|
2020-12-03 21:16:04 +00:00
|
|
|
{ setupTasks && ! isSetupTaskListHidden && (
|
|
|
|
<TaskList
|
|
|
|
dismissedTasks={ dismissedTasks }
|
|
|
|
isTaskListComplete={ isTaskListComplete }
|
|
|
|
isExtended={ false }
|
|
|
|
query={ query }
|
2020-12-11 02:29:45 +00:00
|
|
|
tasks={ allTasks }
|
2020-12-03 21:16:04 +00:00
|
|
|
trackedCompletedTasks={ trackedCompletedTasks }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
{ extensionTasks && ! isExtendedTaskListHidden && (
|
|
|
|
<TaskList
|
|
|
|
dismissedTasks={ dismissedTasks }
|
|
|
|
isExtendedTaskListComplete={
|
|
|
|
isExtendedTaskListComplete
|
|
|
|
}
|
|
|
|
isExtended={ true }
|
|
|
|
query={ query }
|
2020-12-11 02:29:45 +00:00
|
|
|
tasks={ allTasks }
|
2020-12-03 21:16:04 +00:00
|
|
|
trackedCompletedTasks={ trackedCompletedTasks }
|
|
|
|
/>
|
|
|
|
) }
|
2019-12-31 08:50:45 +00:00
|
|
|
{ isCartModalOpen && (
|
|
|
|
<CartModal
|
|
|
|
onClose={ () => this.toggleCartModal() }
|
|
|
|
onClickPurchaseLater={ () => this.toggleCartModal() }
|
|
|
|
/>
|
|
|
|
) }
|
2020-11-04 21:48:26 +00:00
|
|
|
</>
|
2019-03-28 06:09:44 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-01 18:09:08 +00:00
|
|
|
|
|
|
|
export default compose(
|
2020-07-20 06:19:01 +00:00
|
|
|
withSelect( ( select ) => {
|
2020-08-24 13:20:57 +00:00
|
|
|
const { getProfileItems, getTasksStatus } = select(
|
|
|
|
ONBOARDING_STORE_NAME
|
|
|
|
);
|
2020-08-03 08:22:25 +00:00
|
|
|
const { getSettings } = select( SETTINGS_STORE_NAME );
|
2020-12-03 21:16:04 +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();
|
2020-08-03 08:22:25 +00:00
|
|
|
const { general: generalSettings = {} } = getSettings( 'general' );
|
|
|
|
const countryCode = getCountryCode(
|
|
|
|
generalSettings.woocommerce_default_country
|
|
|
|
);
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
const activePlugins = getActivePlugins();
|
2020-05-25 00:26:08 +00:00
|
|
|
const installedPlugins = getInstalledPlugins();
|
2020-08-24 13:20:57 +00:00
|
|
|
const onboardingStatus = getTasksStatus();
|
2019-10-11 12:55:35 +00:00
|
|
|
|
|
|
|
return {
|
2020-07-20 06:19:01 +00:00
|
|
|
activePlugins,
|
2020-08-03 08:22:25 +00:00
|
|
|
countryCode,
|
2020-12-03 21:16:04 +00:00
|
|
|
dismissedTasks:
|
|
|
|
getOption( 'woocommerce_task_list_dismissed_tasks' ) || [],
|
|
|
|
isExtendedTaskListComplete:
|
|
|
|
getOption( 'woocommerce_extended_task_list_complete' ) ===
|
|
|
|
'yes',
|
|
|
|
isExtendedTaskListHidden:
|
|
|
|
getOption( 'woocommerce_extended_task_list_hidden' ) === 'yes',
|
2020-07-20 06:19:01 +00:00
|
|
|
isJetpackConnected: isJetpackConnected(),
|
2020-12-03 21:16:04 +00:00
|
|
|
isSetupTaskListHidden:
|
|
|
|
getOption( 'woocommerce_task_list_hidden' ) === 'yes',
|
|
|
|
isTaskListComplete:
|
|
|
|
getOption( 'woocommerce_task_list_complete' ) === 'yes',
|
2020-07-20 06:19:01 +00:00
|
|
|
installedPlugins,
|
2020-08-24 13:20:57 +00:00
|
|
|
onboardingStatus,
|
2019-10-11 12:55:35 +00:00
|
|
|
profileItems,
|
2020-12-03 21:16:04 +00:00
|
|
|
trackedCompletedTasks:
|
|
|
|
getOption( 'woocommerce_task_list_tracked_completed_tasks' ) ||
|
|
|
|
[],
|
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-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,
|
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 );
|