From 02c74db0ed9f89fb2216b4e6c6cb1cd3290c241e Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Thu, 14 Mar 2019 15:44:36 +0100 Subject: [PATCH] Add empty woo commerce import list page [MAILPOET-1732] --- .../steps/woo_commerce_import_list_step.jsx | 13 +++++ assets/js/src/wizard/wizard.jsx | 5 +- .../wizard/woocommerce_import_controller.jsx | 54 +++++++++++++++++++ lib/Config/Menu.php | 21 ++++++++ views/woocommerce_list_import.html | 17 ++++++ 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx create mode 100644 assets/js/src/wizard/woocommerce_import_controller.jsx create mode 100644 views/woocommerce_list_import.html diff --git a/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx b/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx new file mode 100644 index 0000000000..4d429da4ae --- /dev/null +++ b/assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx @@ -0,0 +1,13 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import MailPoet from 'mailpoet'; + +const WizardWooCommerceImportListStep = props => ( +
+

{MailPoet.I18n.t('wooCommerceListImportTitle')}

+
+); + +WizardWooCommerceImportListStep.propTypes = {}; + +export default WizardWooCommerceImportListStep; diff --git a/assets/js/src/wizard/wizard.jsx b/assets/js/src/wizard/wizard.jsx index 987db90185..465db2f97a 100644 --- a/assets/js/src/wizard/wizard.jsx +++ b/assets/js/src/wizard/wizard.jsx @@ -2,15 +2,18 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Route, HashRouter, Redirect } from 'react-router-dom'; import WelcomeWizardStepsController from './welcome_wizard_controller.jsx'; +import WooCommerceImportController from './woocommerce_import_controller.jsx'; const container = document.getElementById('mailpoet_wizard_container'); if (container) { + const basePath = window.location.search.includes('woocommerce-list-import') ? '/import' : '/steps/1'; ReactDOM.render((
- } /> + } /> +
), container); diff --git a/assets/js/src/wizard/woocommerce_import_controller.jsx b/assets/js/src/wizard/woocommerce_import_controller.jsx new file mode 100644 index 0000000000..cadbffdefc --- /dev/null +++ b/assets/js/src/wizard/woocommerce_import_controller.jsx @@ -0,0 +1,54 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import MailPoet from 'mailpoet'; +import WooCommerceImportListStep from './steps/woo_commerce_import_list_step.jsx'; + +class WooCommerceImportController extends React.Component { + constructor(props) { + super(props); + + this.state = { + loading: false, + }; + this.updateSettings = this.updateSettings.bind(this); + } + + + finishWizard() { + this.setState({ loading: true }); + window.location = window.finish_wizard_url; + } + + updateSettings(data) { + this.setState({ loading: true }); + return MailPoet.Ajax.post({ + api_version: window.mailpoet_api_version, + endpoint: 'settings', + action: 'set', + data, + }).then(() => this.setState({ loading: false })).fail((response) => { + this.setState({ loading: false }); + if (response.errors.length > 0) { + MailPoet.Notice.error( + response.errors.map(error => error.message), + { scroll: true } + ); + } + }); + } + + render() { + return ( +
+
+ MailPoet logo +
+ +
+ ); + } +} + +WooCommerceImportController.propTypes = {}; + +export default WooCommerceImportController; diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index bc2176430e..bdecacbcd0 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -340,6 +340,19 @@ class Menu { ) ); + // WooCommerce List Import + $this->wp->addSubmenuPage( + true, + $this->setPageTitle($this->wp->__('WooCommerce List Import', 'mailpoet')), + $this->wp->__('WooCommerce List Import', 'mailpoet'), + AccessControl::PERMISSION_ACCESS_PLUGIN_ADMIN, + 'mailpoet-woocommerce-list-import', + array( + $this, + 'wooCommerceListImport' + ) + ); + // Update page $this->wp->addSubmenuPage( true, @@ -394,6 +407,14 @@ class Menu { $this->displayPage('welcome_wizard.html', $data); } + function wooCommerceListImport() { + if ((bool)(defined('DOING_AJAX') && DOING_AJAX)) return; + $data = [ + + ]; + $this->displayPage('woocommerce_list_import.html', $data); + } + function update() { global $wp; $current_url = $this->wp->homeUrl(add_query_arg($wp->query_string, $wp->request)); diff --git a/views/woocommerce_list_import.html b/views/woocommerce_list_import.html new file mode 100644 index 0000000000..656b6ede0b --- /dev/null +++ b/views/woocommerce_list_import.html @@ -0,0 +1,17 @@ +<% extends 'layout.html' %> + +<% block content %> + + +
+ +<% endblock %> + +<% block translations %> +<%= localize({ +'wooCommerceListImportTitle': __('WooCommerce customers now have their own list'), +}) %> +<% endblock %>