Add page for permissions asking
[MAILPOET-1856]
This commit is contained in:
14
assets/js/src/wizard/revenue_tracking_permission.jsx
Normal file
14
assets/js/src/wizard/revenue_tracking_permission.jsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
function RevenueTrackingPermission() {
|
||||||
|
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>
|
||||||
|
<h1>This is the page</h1>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RevenueTrackingPermission;
|
@ -3,17 +3,24 @@ 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';
|
import WooCommerceImportController from './woocommerce_import_controller.jsx';
|
||||||
|
import RevenueTrackingPermissionController from './revenue_tracking_permission.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';
|
let basePath = '/steps/1';
|
||||||
|
if (window.location.search.includes('revenue-tracking-permission')) {
|
||||||
|
basePath = '/revenue-tracking-permission';
|
||||||
|
} else if (window.location.search.includes('woocommerce-list-import')) {
|
||||||
|
basePath = '/import';
|
||||||
|
}
|
||||||
ReactDOM.render((
|
ReactDOM.render((
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<div>
|
<div>
|
||||||
<Route exact path="/" render={() => <Redirect to={basePath} />} />
|
<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} />
|
||||||
</div>
|
</div>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
), container);
|
), container);
|
||||||
|
@ -63,6 +63,9 @@ class Changelog {
|
|||||||
$this->checkWelcomeWizard();
|
$this->checkWelcomeWizard();
|
||||||
}
|
}
|
||||||
$this->checkWooCommerceListImportPage();
|
$this->checkWooCommerceListImportPage();
|
||||||
|
if ($this->settings->get('display_revenues')) {
|
||||||
|
$this->checkRevenueTrackingPermissionPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkMp2Migration($version) {
|
private function checkMp2Migration($version) {
|
||||||
@ -108,6 +111,18 @@ class Changelog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkRevenueTrackingPermissionPage() {
|
||||||
|
if (
|
||||||
|
!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('tracking.enabled')
|
||||||
|
&& $this->wooCommerceHelper->isWooCommerceActive()
|
||||||
|
&& $this->wp->currentUserCan('administrator')
|
||||||
|
) {
|
||||||
|
$this->url_helper->redirectTo($this->wp->adminUrl('admin.php?page=mailpoet-revenue-tracking-permission'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function terminateWithRedirect($redirect_url) {
|
private function terminateWithRedirect($redirect_url) {
|
||||||
// save version number
|
// save version number
|
||||||
$this->settings->set('version', Env::$version);
|
$this->settings->set('version', Env::$version);
|
||||||
|
@ -360,6 +360,19 @@ class Menu {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// WooCommerce List Import
|
||||||
|
$this->wp->addSubmenuPage(
|
||||||
|
true,
|
||||||
|
$this->setPageTitle($this->wp->__('Track WooCommerce revenues with cookies', 'mailpoet')),
|
||||||
|
$this->wp->__('Track WooCommerce revenues with cookies', 'mailpoet'),
|
||||||
|
AccessControl::PERMISSION_ACCESS_PLUGIN_ADMIN,
|
||||||
|
'mailpoet-revenue-tracking-permission',
|
||||||
|
array(
|
||||||
|
$this,
|
||||||
|
'revenueTrackingPermission'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Update page
|
// Update page
|
||||||
$this->wp->addSubmenuPage(
|
$this->wp->addSubmenuPage(
|
||||||
true,
|
true,
|
||||||
@ -432,6 +445,17 @@ class Menu {
|
|||||||
$this->displayPage('woocommerce_list_import.html', $data);
|
$this->displayPage('woocommerce_list_import.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function revenueTrackingPermission() {
|
||||||
|
if (!$this->settings->get('display_revenues')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((bool)(defined('DOING_AJAX') && DOING_AJAX)) return;
|
||||||
|
$data = [
|
||||||
|
'finish_wizard_url' => $this->wp->adminUrl('admin.php?page=' . self::MAIN_PAGE_SLUG),
|
||||||
|
];
|
||||||
|
$this->displayPage('revenue_tracking_permission.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/revenue_tracking_permission.html
Normal file
17
views/revenue_tracking_permission.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({
|
||||||
|
|
||||||
|
}) %>
|
||||||
|
<% endblock %>
|
Reference in New Issue
Block a user