Remove old WooCommerce steps [MAILPOET-1928]

This commit is contained in:
wxa
2020-07-22 16:58:50 +03:00
committed by Veljko V
parent 79314bc2c7
commit bf6ad55e3d
8 changed files with 0 additions and 362 deletions

View File

@@ -1,43 +0,0 @@
import React, { useState } from 'react';
import MailPoet from 'mailpoet';
import RevenueTrackingPermissionStep from './steps/revenue_tracking_permission_step.jsx';
function RevenueTrackingPermission() {
const [loading, setLoading] = useState(false);
const handleApiError = (response) => {
setLoading(false);
MailPoet.Notice.showApiErrorNotice(response, { scroll: true });
};
const updateSettings = (data) => MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'settings',
action: 'set',
data,
}).fail(handleApiError);
const finishWizard = () => {
window.location = window.finish_wizard_url;
};
const submit = (allowed) => {
setLoading(true);
const settings = {
'woocommerce.accept_cookie_revenue_tracking.enabled': allowed ? 1 : 0,
'woocommerce.accept_cookie_revenue_tracking.set': 1,
};
updateSettings(settings).then(finishWizard);
};
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>
<RevenueTrackingPermissionStep loading={loading} submitForm={submit} />
</div>
);
}
export default RevenueTrackingPermission;

View File

@@ -1,64 +0,0 @@
import React, { useState } from 'react';
import MailPoet from 'mailpoet';
import PropTypes from 'prop-types';
function RevenueTrackingPermissionStep({ submitForm, loading }) {
const [allowed, setAllowed] = useState('true');
const submit = (event) => {
event.preventDefault();
if (allowed === undefined) return false;
submitForm(allowed === 'true');
return false;
};
return (
<div
className="
mailpoet_welcome_wizard_step_content
mailpoet_welcome_wizard_step_revenue_tracking
mailpoet_welcome_wizard_centered_column
"
>
<p>{MailPoet.I18n.t('revenueTrackingInfo1')}</p>
<p>{MailPoet.I18n.t('revenueTrackingInfo2')}</p>
<form onSubmit={submit} className="mailpoet_wizard_woocommerce_list">
<label htmlFor="tracking_allowed">
<input
id="tracking_allowed"
type="radio"
name="import_type"
checked={allowed === 'true'}
onChange={(e) => setAllowed(e.target.value)}
value="true"
/>
{MailPoet.I18n.t('revenueTrackingAllow')}
</label>
<label htmlFor="tracking_not_allowed">
<input
id="tracking_not_allowed"
type="radio"
name="import_type"
checked={allowed === 'false'}
onChange={(e) => setAllowed(e.target.value)}
value="false"
/>
{MailPoet.I18n.t('revenueTrackingDontAllow')}
</label>
<input
className="button button-primary"
type="submit"
value={MailPoet.I18n.t('revenueTrackingSubmit')}
disabled={loading}
/>
</form>
</div>
);
}
RevenueTrackingPermissionStep.propTypes = {
submitForm: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
};
export default RevenueTrackingPermissionStep;

View File

@@ -1,83 +0,0 @@
import PropTypes from 'prop-types';
import React from 'react';
import MailPoet from 'mailpoet';
import ReactHtmlParser from 'react-html-parser';
class WizardWooCommerceImportListStep extends React.Component {
constructor(props) {
super(props);
this.state = {
importType: null,
};
this.handleOptionChange = this.handleOptionChange.bind(this);
this.submit = this.submit.bind(this);
}
handleOptionChange(event) {
this.setState({
importType: event.target.value,
});
}
submit(event) {
event.preventDefault();
if (!this.state.importType) return false;
this.props.submitForm(this.state.importType);
return false;
}
render() {
return (
<div className="mailpoet_welcome_wizard_step_content mailpoet_welcome_wizard_centered_column">
<h1>{MailPoet.I18n.t('wooCommerceListImportTitle')}</h1>
<p>{MailPoet.I18n.t('wooCommerceListImportInfo1')}</p>
<p>{MailPoet.I18n.t('wooCommerceListImportInfo2')}</p>
<p><b>{MailPoet.I18n.t('wooCommerceListImportInfo3')}</b></p>
<form onSubmit={this.submit} className="mailpoet_wizard_woocommerce_list">
<label htmlFor="import_type_subscribed">
<input
id="import_type_subscribed"
type="radio"
name="import_type"
checked={this.state.importType === 'subscribed'}
onChange={this.handleOptionChange}
value="subscribed"
data-automation-id="import_as_subscribed"
/>
{ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxSubscribed'))}
</label>
<label htmlFor="import_type_unsubscribed">
<input
id="import_type_unsubscribed"
type="radio"
name="import_type"
checked={this.state.importType === 'unsubscribed'}
onChange={this.handleOptionChange}
value="unsubscribed"
data-automation-id="import_as_unsubscribed"
/>
{ReactHtmlParser(MailPoet.I18n.t('wooCommerceListImportCheckboxUnsubscribed'))}
</label>
<p>{MailPoet.I18n.t('wooCommerceListImportInfo4')}</p>
<input
className="button button-primary"
type="submit"
value={MailPoet.I18n.t('wooCommerceListImportSubmit')}
disabled={!this.state.importType || this.props.loading}
data-automation-id="submit_woo_commerce_list_import"
/>
</form>
</div>
);
}
}
WizardWooCommerceImportListStep.propTypes = {
submitForm: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
};
export default WizardWooCommerceImportListStep;

View File

@@ -1,67 +0,0 @@
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);
this.scheduleImport = this.scheduleImport.bind(this);
this.finishWizard = this.finishWizard.bind(this);
this.submit = this.submit.bind(this);
}
finishWizard() {
this.setState({ loading: true });
window.location = window.finish_wizard_url;
}
updateSettings(data) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'settings',
action: 'set',
data,
}).fail(this.handleApiError);
}
scheduleImport() {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'importExport',
action: 'setupWooCommerceInitialImport',
}).then(() => this.setState({ loading: false })).fail(this.handleApiError);
}
handleApiError(response) {
this.setState({ loading: false });
MailPoet.Notice.showApiErrorNotice(response, { scroll: true });
}
submit(importType) {
this.setState({ loading: true });
const settings = {
woocommerce_import_screen_displayed: 1,
'mailpoet_subscribe_old_woocommerce_customers.enabled': importType === 'subscribed' ? 1 : 0,
};
this.updateSettings(settings).then(this.scheduleImport).then(this.finishWizard);
}
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} submitForm={this.submit} />
</div>
);
}
}
WooCommerceImportController.propTypes = {};
export default WooCommerceImportController;

View File

@@ -1,31 +0,0 @@
<?php
namespace MailPoet\AdminPages\Pages;
use MailPoet\AdminPages\PageRenderer;
use MailPoet\Config\Menu;
use MailPoet\WP\Functions as WPFunctions;
class RevenueTrackingPermission {
/** @var PageRenderer */
private $pageRenderer;
/** @var WPFunctions */
private $wp;
public function __construct(
PageRenderer $pageRenderer,
WPFunctions $wp
) {
$this->pageRenderer = $pageRenderer;
$this->wp = $wp;
}
public function render() {
if ((bool)(defined('DOING_AJAX') && DOING_AJAX)) return;
$data = [
'finish_wizard_url' => $this->wp->adminUrl('admin.php?page=' . Menu::MAIN_PAGE_SLUG),
];
$this->pageRenderer->displayPage('revenue_tracking_permission.html', $data);
}
}

View File

@@ -1,28 +0,0 @@
<?php
namespace MailPoet\AdminPages\Pages;
use MailPoet\AdminPages\PageRenderer;
use MailPoet\Config\Menu;
use MailPoet\WP\Functions as WPFunctions;
class WooCommerceListImport {
/** @var PageRenderer */
private $pageRenderer;
/** @var WPFunctions */
private $wp;
public function __construct(PageRenderer $pageRenderer, WPFunctions $wp) {
$this->pageRenderer = $pageRenderer;
$this->wp = $wp;
}
public function render() {
if ((bool)(defined('DOING_AJAX') && DOING_AJAX)) return;
$data = [
'finish_wizard_url' => $this->wp->adminUrl('admin.php?page=' . Menu::MAIN_PAGE_SLUG),
];
$this->pageRenderer->displayPage('woocommerce_list_import.html', $data);
}
}

View File

@@ -1,21 +0,0 @@
<% 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({
'revenueTrackingInfo1': _x('MailPoet can use browser cookies for more precise WooCommerce tracking.', 'Browser cookies are data created by websites and stored in visitors web browser'),
'revenueTrackingInfo2': _x('This is practical for abandoned cart emails and when a customer uses several email addresses.', '“abandoned cart emails“ are emails which are sent automatically from e-commerce websites when a customer add a product to the cart and then leave the website'),
'revenueTrackingAllow': _x('Allow MailPoet cookies. My visitors are made aware that cookies are used on my website.', '“MailPoet cookies” and “cookies” are browser cookies created by MailPoet'),
'revenueTrackingDontAllow': _x('Dont allow MailPoet cookies and rely on basic revenue tracking.', '“MailPoet cookies” are browser cookies created by MailPoet'),
'revenueTrackingSubmit': _x('Save', 'Submit button caption')
}) %>
<% endblock %>

View File

@@ -1,25 +0,0 @@
<% 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': _x('WooCommerce customers now have their own list', 'Title on the customers import page'),
'wooCommerceListImportInfo1': __('MailPoet will create a list of your WooCommerce customers, even those who dont have an account, known as "Guests".'),
'wooCommerceListImportInfo2': __('New customers will be able to join this list during checkout. You can manage this new checkout feature in your MailPoet Settings.'),
'wooCommerceListImportInfo3': __('To begin, please choose how you want to populate your list:'),
'wooCommerceListImportCheckboxSubscribed': __('<b>add and subscribe</b> all my customers to this list because they agreed to receive marketing emails from me'),
'wooCommerceListImportCheckboxUnsubscribed': __('<b>add</b> all my customers to the list, but <b>as unsubscribed</b>. They can join this list next time they check out'),
'wooCommerceListImportInfo4': __('Their subscription preference on other lists wont be changed.'),
'wooCommerceListImportSubmit': _x('Create my WooCommerce Customers list now!', 'Submit button caption'),
'unknownError': __('Unknown error'),
}) %>
<% endblock %>