Add empty woo commerce import list page
[MAILPOET-1732]
This commit is contained in:
committed by
M. Shull
parent
4f64b29458
commit
02c74db0ed
13
assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx
Normal file
13
assets/js/src/wizard/steps/woo_commerce_import_list_step.jsx
Normal 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;
|
@@ -2,15 +2,18 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Route, HashRouter, Redirect } from 'react-router-dom';
|
import { Route, HashRouter, Redirect } from 'react-router-dom';
|
||||||
import WelcomeWizardStepsController from './welcome_wizard_controller.jsx';
|
import WelcomeWizardStepsController from './welcome_wizard_controller.jsx';
|
||||||
|
import WooCommerceImportController from './woocommerce_import_controller.jsx';
|
||||||
|
|
||||||
const container = document.getElementById('mailpoet_wizard_container');
|
const container = document.getElementById('mailpoet_wizard_container');
|
||||||
|
|
||||||
if (container) {
|
if (container) {
|
||||||
|
const basePath = window.location.search.includes('woocommerce-list-import') ? '/import' : '/steps/1';
|
||||||
ReactDOM.render((
|
ReactDOM.render((
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<div>
|
<div>
|
||||||
<Route exact path="/" render={() => <Redirect to="/steps/1" />} />
|
<Route exact path="/" render={() => <Redirect to={basePath} />} />
|
||||||
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
|
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
|
||||||
|
<Route path="/import" component={WooCommerceImportController} />
|
||||||
</div>
|
</div>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
), container);
|
), container);
|
||||||
|
54
assets/js/src/wizard/woocommerce_import_controller.jsx
Normal file
54
assets/js/src/wizard/woocommerce_import_controller.jsx
Normal 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;
|
@@ -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
|
// Update page
|
||||||
$this->wp->addSubmenuPage(
|
$this->wp->addSubmenuPage(
|
||||||
true,
|
true,
|
||||||
@@ -394,6 +407,14 @@ class Menu {
|
|||||||
$this->displayPage('welcome_wizard.html', $data);
|
$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() {
|
function update() {
|
||||||
global $wp;
|
global $wp;
|
||||||
$current_url = $this->wp->homeUrl(add_query_arg($wp->query_string, $wp->request));
|
$current_url = $this->wp->homeUrl(add_query_arg($wp->query_string, $wp->request));
|
||||||
|
17
views/woocommerce_list_import.html
Normal file
17
views/woocommerce_list_import.html
Normal 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 %>
|
Reference in New Issue
Block a user