Remove automation hiding logic
This was introduced in: https://github.com/mailpoet/mailpoet/pull/4917 https://github.com/mailpoet/mailpoet/pull/5171 [MAILPOET-5779]
This commit is contained in:
1
mailpoet/assets/js/src/global.d.ts
vendored
1
mailpoet/assets/js/src/global.d.ts
vendored
@@ -134,7 +134,6 @@ interface Window {
|
||||
mailpoet_premium_plugin_download_url: string;
|
||||
mailpoet_premium_plugin_activation_url: string;
|
||||
mailpoet_plugin_partial_key: string;
|
||||
mailpoet_hide_automations: boolean;
|
||||
mailpoet_email_volume_limit: string;
|
||||
mailpoet_email_volume_limit_reached: boolean;
|
||||
mailpoet_current_wp_user_email: string;
|
||||
|
@@ -66,7 +66,6 @@ export const MailPoet = {
|
||||
premiumPluginDownloadUrl: window.mailpoet_premium_plugin_download_url,
|
||||
premiumPluginActivationUrl: window.mailpoet_premium_plugin_activation_url,
|
||||
pluginPartialKey: window.mailpoet_plugin_partial_key,
|
||||
hideAutomations: window.mailpoet_hide_automations,
|
||||
emailVolumeLimit: window.mailpoet_email_volume_limit,
|
||||
emailVolumeLimitReached: window.mailpoet_email_volume_limit_reached,
|
||||
currentWpUserEmail: window.mailpoet_current_wp_user_email,
|
||||
|
@@ -84,50 +84,6 @@ function NewsletterTypesComponent({
|
||||
);
|
||||
};
|
||||
|
||||
const getRedirectToAutomateWooType = () => {
|
||||
const redirectToAutomateWoo = (): void => {
|
||||
MailPoet.trackEvent(
|
||||
'Emails > Type selected',
|
||||
{
|
||||
'Email type': 'woocommerce_automatewoo',
|
||||
},
|
||||
{ send_immediately: true }, // This tell Mixpanel client to send events from buffer immediately
|
||||
() => {
|
||||
// Anonymous callback which does the redirect
|
||||
window.location.href = `edit.php?post_type=aw_workflow#presets`;
|
||||
},
|
||||
);
|
||||
};
|
||||
return {
|
||||
slug: 'woocommerce_automatewoo',
|
||||
title: __('Automations', 'mailpoet'),
|
||||
description: __(
|
||||
'Convert and retain customers with automated marketing that does the hard work for you. AutomateWoo has the tools you need to grow your store and make more money.',
|
||||
'mailpoet',
|
||||
),
|
||||
kbLink:
|
||||
'https://kb.mailpoet.com/article/408-integration-with-automatewoo',
|
||||
action: (
|
||||
<Button
|
||||
automationId="woocommerce_automatewoo"
|
||||
onClick={redirectToAutomateWoo}
|
||||
tabIndex={0}
|
||||
onKeyDown={(event): void => {
|
||||
if (
|
||||
['keydown', 'keypress'].includes(event.type) &&
|
||||
['Enter', ' '].includes(event.key)
|
||||
) {
|
||||
event.preventDefault();
|
||||
redirectToAutomateWoo();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{__('Set up', 'mailpoet')}
|
||||
</Button>
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
const createNewsletter = (type): void => {
|
||||
setIsCreating(true);
|
||||
MailPoet.trackEvent('Emails > Type selected', {
|
||||
@@ -241,45 +197,43 @@ function NewsletterTypesComponent({
|
||||
),
|
||||
action: standardAction,
|
||||
},
|
||||
MailPoet.hideAutomations
|
||||
? getRedirectToAutomateWooType()
|
||||
: {
|
||||
slug: 'automations',
|
||||
title: (
|
||||
<>
|
||||
{__('Automations', 'mailpoet')}{' '}
|
||||
<Info>
|
||||
{__(
|
||||
'Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</Info>
|
||||
</>
|
||||
),
|
||||
description: __(
|
||||
'Set up automated emails like welcome emails, abandoned cart reminders or one of our many automation templates to inform, engage and reward your audience.',
|
||||
'mailpoet',
|
||||
),
|
||||
action: (
|
||||
<Button
|
||||
onClick={createAutomation}
|
||||
automationId="create_automation"
|
||||
withSpinner={isCreating}
|
||||
onKeyDown={(event): void => {
|
||||
if (
|
||||
['keydown', 'keypress'].includes(event.type) &&
|
||||
['Enter', ' '].includes(event.key)
|
||||
) {
|
||||
event.preventDefault();
|
||||
createAutomation();
|
||||
}
|
||||
}}
|
||||
tabIndex={0}
|
||||
>
|
||||
{__('Set up', 'mailpoet')}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
slug: 'automations',
|
||||
title: (
|
||||
<>
|
||||
{__('Automations', 'mailpoet')}{' '}
|
||||
<Info>
|
||||
{__(
|
||||
'Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.',
|
||||
'mailpoet',
|
||||
)}
|
||||
</Info>
|
||||
</>
|
||||
),
|
||||
description: __(
|
||||
'Set up automated emails like welcome emails, abandoned cart reminders or one of our many automation templates to inform, engage and reward your audience.',
|
||||
'mailpoet',
|
||||
),
|
||||
action: (
|
||||
<Button
|
||||
onClick={createAutomation}
|
||||
automationId="create_automation"
|
||||
withSpinner={isCreating}
|
||||
onKeyDown={(event): void => {
|
||||
if (
|
||||
['keydown', 'keypress'].includes(event.type) &&
|
||||
['Enter', ' '].includes(event.key)
|
||||
) {
|
||||
event.preventDefault();
|
||||
createAutomation();
|
||||
}
|
||||
}}
|
||||
tabIndex={0}
|
||||
>
|
||||
{__('Set up', 'mailpoet')}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
slug: 'notification',
|
||||
title: __('Latest Post Notifications', 'mailpoet'),
|
||||
|
@@ -3,8 +3,6 @@ import { MailPoet } from 'mailpoet';
|
||||
import { Notice } from 'notices/notice';
|
||||
|
||||
function AutomationsInfoNotice() {
|
||||
if (!MailPoet.hideAutomations) return null;
|
||||
|
||||
const automationsInfo = createInterpolateElement(
|
||||
MailPoet.I18n.t('automationsInfoNotice'),
|
||||
{
|
||||
|
@@ -140,10 +140,7 @@ class PageRenderer {
|
||||
if ($this->subscribersFeature->isSubscribersCountEnoughForCache($subscriberCount)) {
|
||||
$subscribersCacheCreatedAt = $this->transientCache->getOldestCreatedAt(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY) ?: Carbon::now();
|
||||
}
|
||||
// Automations are hidden when the subscription is part of a bundle and AutomateWoo is active
|
||||
$showAutomations = !($this->wp->isPluginActive('automatewoo/automatewoo.php') &&
|
||||
$this->servicesChecker->isBundledSubscription());
|
||||
$hideAutomations = !$this->wp->applyFilters('mailpoet_show_automations', $showAutomations);
|
||||
|
||||
$defaults = [
|
||||
'current_page' => sanitize_text_field(wp_unslash($_GET['page'] ?? '')),
|
||||
'site_name' => $this->wp->wpSpecialcharsDecode($this->wp->getOption('blogname'), ENT_QUOTES),
|
||||
@@ -185,7 +182,6 @@ class PageRenderer {
|
||||
'mss_key_pending_approval' => $this->servicesChecker->isMailPoetAPIKeyPendingApproval(),
|
||||
'mss_active' => $this->bridge->isMailpoetSendingServiceEnabled(),
|
||||
'plugin_partial_key' => $this->servicesChecker->generatePartialApiKey(),
|
||||
'mailpoet_hide_automations' => $hideAutomations,
|
||||
'subscriber_count' => $subscriberCount,
|
||||
'subscribers_counts_cache_created_at' => $subscribersCacheCreatedAt->format('Y-m-d\TH:i:sO'),
|
||||
'subscribers_limit' => $this->subscribersFeature->getSubscribersLimit(),
|
||||
|
@@ -521,18 +521,8 @@ class Menu {
|
||||
}
|
||||
|
||||
private function registerAutomationMenu() {
|
||||
$parentSlug = self::MAIN_PAGE_SLUG;
|
||||
// Automations menu is hidden when the subscription is part of a bundle and AutomateWoo is active but pages can be accessed directly
|
||||
$showAutomations = !($this->wp->isPluginActive('automatewoo/automatewoo.php') &&
|
||||
$this->servicesChecker->isBundledSubscription());
|
||||
if (
|
||||
!$this->wp->applyFilters('mailpoet_show_automations', $showAutomations)
|
||||
) {
|
||||
$parentSlug = self::NO_PARENT_PAGE_SLUG;
|
||||
}
|
||||
|
||||
$automationPage = $this->wp->addSubmenuPage(
|
||||
$parentSlug,
|
||||
self::MAIN_PAGE_SLUG,
|
||||
$this->setPageTitle(__('Automations', 'mailpoet')),
|
||||
// @ToDo Remove Beta once Automation is no longer beta.
|
||||
'<span>' . esc_html__('Automations', 'mailpoet') . '</span><span class="mailpoet-beta-badge">Beta</span>',
|
||||
@@ -562,7 +552,6 @@ class Menu {
|
||||
);
|
||||
|
||||
// Automation templates
|
||||
|
||||
$this->wp->addSubmenuPage(
|
||||
self::AUTOMATIONS_PAGE_SLUG,
|
||||
$this->setPageTitle(__('Automation Templates', 'mailpoet')),
|
||||
|
@@ -1,51 +0,0 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Test\DataFactories\Newsletter;
|
||||
use MailPoet\Test\DataFactories\Settings;
|
||||
|
||||
class HideAutomationsForBundlesAndAutomateWooCest {
|
||||
public function dontSeeWooCommerceTabForBundleAndAutomateWoo(\AcceptanceTester $i) {
|
||||
$i->wantTo('do not see WooCommerce Tab for bundles when AutomateWoo and WooCommerce are active');
|
||||
$newsletterFactory = new Newsletter();
|
||||
$newsletterFactory
|
||||
->withSubject('Testing AutomateWoo Automations for bundles')
|
||||
->create();
|
||||
$i->activateWooCommerce();
|
||||
$i->activateAutomateWoo();
|
||||
$settings = new Settings();
|
||||
$settings->withValidMssKey('apiKey');
|
||||
$settings->withSubscriptionType(Bridge::WPCOM_BUNDLE_SUBSCRIPTION_TYPE);
|
||||
$i->login();
|
||||
$i->amOnMailpoetPage('Emails');
|
||||
$i->dontSeeElement('[data-automation-id="tab-WooCommerce"]');
|
||||
}
|
||||
|
||||
public function seeAutomateWooAutomationsForBundleAndAutomateWoo(\AcceptanceTester $i) {
|
||||
$i->wantTo('see AutomateWoo Automations for bundles when AutomateWoo is active');
|
||||
$i->activateWooCommerce();
|
||||
$i->activateAutomateWoo();
|
||||
$settings = new Settings();
|
||||
$settings->withValidMssKey('apiKey');
|
||||
$settings->withSubscriptionType(Bridge::WPCOM_BUNDLE_SUBSCRIPTION_TYPE);
|
||||
$i->login();
|
||||
$i->amOnMailpoetPage('Emails');
|
||||
$i->wantTo('Not see WooCommerce Automatic emails');
|
||||
$i->dontSeeElement('[data-automation-id="create_woocommerce_product_purchased_in_category"]');
|
||||
$i->wantTo('See WooCommerce Email Customizer');
|
||||
$i->seeElement('[data-automation-id="customize_woocommerce"]');
|
||||
$i->wantTo('See AutomateWoo Automations');
|
||||
$i->seeElement('[data-automation-id="woocommerce_automatewoo"]');
|
||||
$i->click('[data-automation-id="woocommerce_automatewoo"]');
|
||||
$i->seeElement('#automatewoo-workflow-tabs-root');
|
||||
$i->deactivateAutomateWoo();
|
||||
$i->login();
|
||||
$i->amOnMailpoetPage('Emails');
|
||||
$i->wantTo('See WooCommerce Automatic emails');
|
||||
$i->seeElement('[data-automation-id="create_woocommerce_product_purchased_in_category"]');
|
||||
$i->wantTo('Not see AutomateWoo Automations');
|
||||
$i->dontSeeElement('[data-automation-id="woocommerce_automatewoo"]');
|
||||
}
|
||||
}
|
@@ -3,12 +3,8 @@
|
||||
namespace MailPoet\Test\Config;
|
||||
|
||||
use Codeception\Util\Stub;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Config\Menu;
|
||||
use MailPoet\Config\Router;
|
||||
use MailPoet\Config\ServicesChecker;
|
||||
use MailPoet\Form\Util\CustomFonts;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class MenuTest extends \MailPoetTest {
|
||||
public function testItReturnsTrueIfCurrentPageBelongsToMailpoet() {
|
||||
@@ -60,83 +56,4 @@ class MenuTest extends \MailPoetTest {
|
||||
$menu->checkPremiumKey($checker);
|
||||
verify($menu->premiumKeyValid)->false();
|
||||
}
|
||||
|
||||
public function testItHidesAutomationIfBundledSubscriptionAndAutomateWooActive() {
|
||||
$checker = Stub::make(
|
||||
new ServicesChecker(),
|
||||
[
|
||||
'isPremiumKeyValid' => true,
|
||||
'isBundledSubscription' => true,
|
||||
],
|
||||
$this
|
||||
);
|
||||
|
||||
$wpMock = $this->createMock(WPFunctions::class);
|
||||
$wpMock->method('isPluginActive')->willReturn(true);
|
||||
|
||||
$accessControlMock = $this->createMock(AccessControl::class);
|
||||
$accessControlMock->method('validatePermission')->willReturn(true);
|
||||
|
||||
$wpMock->expects($this->any())->method('addSubmenuPage')->withConsecutive(
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[Menu::NO_PARENT_PAGE_SLUG, $this->anything(), $this->anything(), $this->anything(), Menu::AUTOMATIONS_PAGE_SLUG, $this->anything()]
|
||||
)->willReturn(true);
|
||||
|
||||
$menu = new Menu(
|
||||
$accessControlMock,
|
||||
$wpMock,
|
||||
$checker,
|
||||
$this->diContainer,
|
||||
$this->diContainer->get(Router::class),
|
||||
$this->diContainer->get(CustomFonts::class)
|
||||
);
|
||||
|
||||
$menu->setup();
|
||||
|
||||
}
|
||||
|
||||
public function testItShowsAutomationIfFilterIsTrue() {
|
||||
$checker = Stub::make(
|
||||
new ServicesChecker(),
|
||||
[
|
||||
'isPremiumKeyValid' => true,
|
||||
'isBundledSubscription' => true,
|
||||
],
|
||||
$this
|
||||
);
|
||||
|
||||
$wpMock = $this->createMock(WPFunctions::class);
|
||||
$wpMock->method('isPluginActive')->willReturn(true);
|
||||
$wpMock->method('applyFilters')->willReturn(true);
|
||||
|
||||
$accessControlMock = $this->createMock(AccessControl::class);
|
||||
$accessControlMock->method('validatePermission')->willReturn(true);
|
||||
|
||||
$wpMock->expects($this->any())->method('addSubmenuPage')->withConsecutive(
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[Menu::MAIN_PAGE_SLUG, $this->anything(), $this->anything(), $this->anything(), Menu::AUTOMATIONS_PAGE_SLUG, $this->anything()]
|
||||
)->willReturn(true);
|
||||
|
||||
$menu = new Menu(
|
||||
$accessControlMock,
|
||||
$wpMock,
|
||||
$checker,
|
||||
$this->diContainer,
|
||||
$this->diContainer->get(Router::class),
|
||||
$this->diContainer->get(CustomFonts::class)
|
||||
);
|
||||
|
||||
$menu->setup();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -91,7 +91,6 @@
|
||||
var mailpoet_mss_key_pending_approval = '<%= mss_key_pending_approval %>';
|
||||
var mailpoet_mss_active = <%= json_encode(mss_active) %>;
|
||||
var mailpoet_plugin_partial_key = '<%= plugin_partial_key %>';
|
||||
var mailpoet_hide_automations = <%= json_encode(mailpoet_hide_automations) %>;
|
||||
var mailpoet_subscribers_count = <%= subscriber_count %>;
|
||||
var mailpoet_subscribers_counts_cache_created_at = <%= json_encode(subscribers_counts_cache_created_at) %>;
|
||||
var mailpoet_subscribers_limit = <%= subscribers_limit ? subscribers_limit : 'false' %>;
|
||||
|
Reference in New Issue
Block a user