Ask for permissions step
[MAILPOET-1856]
This commit is contained in:
@@ -34,6 +34,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mailpoet_welcome_wizard_step_revenue_tracking {
|
||||||
|
input[type="submit"] {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.mailpoet_welcome_wizard_step {
|
.mailpoet_welcome_wizard_step {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
padding: 60px 60px 40px 40px;
|
padding: 60px 60px 40px 40px;
|
||||||
|
@@ -1,12 +1,46 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
import RevenueTrackingPermissionStep from './steps/revenue_tracking_permission_step.jsx';
|
||||||
|
|
||||||
function RevenueTrackingPermission() {
|
function RevenueTrackingPermission() {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleApiError = (response) => {
|
||||||
|
setLoading(false);
|
||||||
|
let errorMessage = MailPoet.I18n.t('unknownError');
|
||||||
|
if (response && response.errors && response.errors.length > 0) {
|
||||||
|
errorMessage = response.errors.map(error => error.message);
|
||||||
|
}
|
||||||
|
MailPoet.Notice.error(errorMessage, { scroll: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateSettings = (data) => {
|
||||||
|
return 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 = {
|
||||||
|
accept_cookie_revenue_tracking: allowed ? 1 : 0,
|
||||||
|
};
|
||||||
|
updateSettings(settings).then(finishWizard);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mailpoet_welcome_wizard_steps mailpoet_welcome_wizard_centered_column">
|
<div className="mailpoet_welcome_wizard_steps mailpoet_welcome_wizard_centered_column">
|
||||||
<div className="mailpoet_welcome_wizard_header">
|
<div className="mailpoet_welcome_wizard_header">
|
||||||
<img src={window.mailpoet_logo_url} width="200" height="87" alt="MailPoet logo"/>
|
<img src={window.mailpoet_logo_url} width="200" height="87" alt="MailPoet logo" />
|
||||||
</div>
|
</div>
|
||||||
<h1>This is the page</h1>
|
<RevenueTrackingPermissionStep loading={loading} submitForm={submit} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,64 @@
|
|||||||
|
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;
|
||||||
|
@@ -17,10 +17,10 @@ if (container) {
|
|||||||
ReactDOM.render((
|
ReactDOM.render((
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<div>
|
<div>
|
||||||
<Route exact path="/" render={() => <Redirect to={basePath} />} />
|
|
||||||
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
|
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
|
||||||
<Route path="/import" component={WooCommerceImportController} />
|
<Route path="/import" component={WooCommerceImportController} />
|
||||||
<Route path="/revenue-tracking-permission" component={RevenueTrackingPermissionController} />
|
<Route path="/revenue-tracking-permission" component={RevenueTrackingPermissionController} />
|
||||||
|
<Route render={() => <Redirect to={basePath} />} />
|
||||||
</div>
|
</div>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
), container);
|
), container);
|
||||||
|
@@ -114,7 +114,7 @@ class Changelog {
|
|||||||
private function checkRevenueTrackingPermissionPage() {
|
private function checkRevenueTrackingPermissionPage() {
|
||||||
if (
|
if (
|
||||||
!in_array($_GET['page'], ['mailpoet-revenue-tracking-permission', 'mailpoet-welcome-wizard', 'mailpoet-migration'])
|
!in_array($_GET['page'], ['mailpoet-revenue-tracking-permission', 'mailpoet-welcome-wizard', 'mailpoet-migration'])
|
||||||
&& ($this->settings->get('woocommerce.accept_cookie_revenue_tracking ') !== null)
|
&& ($this->settings->get('accept_cookie_revenue_tracking') === null)
|
||||||
&& $this->settings->get('tracking.enabled')
|
&& $this->settings->get('tracking.enabled')
|
||||||
&& $this->wooCommerceHelper->isWooCommerceActive()
|
&& $this->wooCommerceHelper->isWooCommerceActive()
|
||||||
&& $this->wp->currentUserCan('administrator')
|
&& $this->wp->currentUserCan('administrator')
|
||||||
|
@@ -12,6 +12,11 @@
|
|||||||
|
|
||||||
<% block translations %>
|
<% block translations %>
|
||||||
<%= localize({
|
<%= localize({
|
||||||
|
'revenueTrackingInfo1': 'MailPoet can use browser cookies for more precise WooCommerce tracking.',
|
||||||
|
'revenueTrackingInfo2': 'This is practical for abandoned cart emails and when a customer uses several email addresses.',
|
||||||
|
'revenueTrackingAllow': 'Allow MailPoet cookies. My visitors are made aware that cookies are used on my website',
|
||||||
|
'revenueTrackingDontAllow': 'Don’t allow MailPoet cookies and rely on basic revenue tracking',
|
||||||
|
'revenueTrackingSubmit': _x('Save', 'Submit button caption'),
|
||||||
|
'unknownError': __('Unknown error')
|
||||||
}) %>
|
}) %>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
Reference in New Issue
Block a user