Add empty woo commerce import list page

[MAILPOET-1732]
This commit is contained in:
Rostislav Wolny
2019-03-14 15:44:36 +01:00
committed by M. Shull
parent 4f64b29458
commit 02c74db0ed
5 changed files with 109 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
import PropTypes from 'prop-types';
import React from 'react';
import MailPoet from 'mailpoet';
const WizardWooCommerceImportListStep = props => (
<div className="mailpoet_welcome_wizard_step_content mailpoet_welcome_wizard_centered_column">
<h1>{MailPoet.I18n.t('wooCommerceListImportTitle')}</h1>
</div>
);
WizardWooCommerceImportListStep.propTypes = {};
export default WizardWooCommerceImportListStep;

View File

@@ -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((
<HashRouter>
<div>
<Route exact path="/" render={() => <Redirect to="/steps/1" />} />
<Route exact path="/" render={() => <Redirect to={basePath} />} />
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
<Route path="/import" component={WooCommerceImportController} />
</div>
</HashRouter>
), container);

View File

@@ -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 (
<div className="mailpoet_welcome_wizard_steps mailpoet_welcome_wizard_centered_column">
<div className="mailpoet_welcome_wizard_header">
<img src={window.mailpoet_logo_url} width="200" height="87" alt="MailPoet logo" />
</div>
<WooCommerceImportListStep loading={this.state.loading} />
</div>
);
}
}
WooCommerceImportController.propTypes = {};
export default WooCommerceImportController;

View File

@@ -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));

View File

@@ -0,0 +1,17 @@
<% extends 'layout.html' %>
<% block content %>
<script>
var mailpoet_logo_url = '<%= cdn_url('welcome-wizard/mailpoet-logo.20190109-1400.png') %>';
var finish_wizard_url = '<%= finish_wizard_url %>';
</script>
<div id="mailpoet_wizard_container"></div>
<% endblock %>
<% block translations %>
<%= localize({
'wooCommerceListImportTitle': __('WooCommerce customers now have their own list'),
}) %>
<% endblock %>