Make legacy automatic emails/automations notices permanently dismissable
[MAILPOET-5779]
This commit is contained in:
@@ -35,7 +35,10 @@ function Content(): JSX.Element {
|
|||||||
count > 0 ? (
|
count > 0 ? (
|
||||||
<>
|
<>
|
||||||
<AutomationListingHeader />
|
<AutomationListingHeader />
|
||||||
{legacyAutomationCount > 0 && <LegacyAutomationsNotice />}
|
{legacyAutomationCount > 0 &&
|
||||||
|
!window.mailpoet_legacy_automations_notice_dismissed && (
|
||||||
|
<LegacyAutomationsNotice />
|
||||||
|
)}
|
||||||
<AutomationListing />
|
<AutomationListing />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
@@ -1,10 +1,26 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { createInterpolateElement } from '@wordpress/element';
|
import { createInterpolateElement } from '@wordpress/element';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { Notice } from 'notices/notice';
|
import { Notice } from 'notices/notice';
|
||||||
|
import { legacyApiFetch } from './store/legacy-api';
|
||||||
|
|
||||||
export function LegacyAutomationsNotice(): JSX.Element {
|
export function LegacyAutomationsNotice(): JSX.Element {
|
||||||
|
const saveNoticeDismissed = useCallback(() => {
|
||||||
|
void legacyApiFetch({
|
||||||
|
endpoint: 'UserFlags',
|
||||||
|
method: 'set',
|
||||||
|
'data[legacy_automations_notice_dismissed]': '1',
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Notice type="info" timeout={false} closable renderInPlace>
|
<Notice
|
||||||
|
type="info"
|
||||||
|
timeout={false}
|
||||||
|
closable
|
||||||
|
renderInPlace
|
||||||
|
onClose={saveNoticeDismissed}
|
||||||
|
>
|
||||||
<p>
|
<p>
|
||||||
{createInterpolateElement(
|
{createInterpolateElement(
|
||||||
__(
|
__(
|
||||||
|
@@ -19,6 +19,7 @@ declare global {
|
|||||||
events: Record<string, Record<string, unknown>>;
|
events: Record<string, Record<string, unknown>>;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
mailpoet_legacy_automations_notice_dismissed: boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,7 +48,8 @@ const Tabs = withNpsPoll(() => {
|
|||||||
<ListingHeadingDisplay>
|
<ListingHeadingDisplay>
|
||||||
<ListingHeading />
|
<ListingHeading />
|
||||||
</ListingHeadingDisplay>
|
</ListingHeadingDisplay>
|
||||||
{window.mailpoet_legacy_automatic_emails_count > 0 && (
|
{window.mailpoet_legacy_automatic_emails_count > 0 &&
|
||||||
|
!window.mailpoet_legacy_automatic_emails_notice_dismissed && (
|
||||||
<LegacyAutomaticEmailsNotice />
|
<LegacyAutomaticEmailsNotice />
|
||||||
)}
|
)}
|
||||||
{MailPoet.corrupt_newsletters.length > 0 && (
|
{MailPoet.corrupt_newsletters.length > 0 && (
|
||||||
|
@@ -1,10 +1,26 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { createInterpolateElement } from '@wordpress/element';
|
import { createInterpolateElement } from '@wordpress/element';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { Notice } from './notice';
|
import { Notice } from './notice';
|
||||||
|
import { legacyApiFetch } from '../automation/listing/store/legacy-api';
|
||||||
|
|
||||||
export function LegacyAutomaticEmailsNotice(): JSX.Element {
|
export function LegacyAutomaticEmailsNotice(): JSX.Element {
|
||||||
|
const saveNoticeDismissed = useCallback(() => {
|
||||||
|
void legacyApiFetch({
|
||||||
|
endpoint: 'UserFlags',
|
||||||
|
method: 'set',
|
||||||
|
'data[legacy_automatic_emails_notice_dismissed]': '1',
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Notice type="info" timeout={false} closable renderInPlace>
|
<Notice
|
||||||
|
type="info"
|
||||||
|
timeout={false}
|
||||||
|
closable
|
||||||
|
renderInPlace
|
||||||
|
onClose={saveNoticeDismissed}
|
||||||
|
>
|
||||||
<p>
|
<p>
|
||||||
{createInterpolateElement(
|
{createInterpolateElement(
|
||||||
__(
|
__(
|
||||||
|
@@ -12,6 +12,7 @@ use MailPoet\Automation\Engine\Storage\AutomationStorage;
|
|||||||
use MailPoet\Entities\NewsletterEntity;
|
use MailPoet\Entities\NewsletterEntity;
|
||||||
use MailPoet\Newsletter\NewslettersRepository;
|
use MailPoet\Newsletter\NewslettersRepository;
|
||||||
use MailPoet\Segments\SegmentsSimpleListRepository;
|
use MailPoet\Segments\SegmentsSimpleListRepository;
|
||||||
|
use MailPoet\Settings\UserFlagsController;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class Automation {
|
class Automation {
|
||||||
@@ -36,6 +37,8 @@ class Automation {
|
|||||||
|
|
||||||
private SegmentsSimpleListRepository $segmentsListRepository;
|
private SegmentsSimpleListRepository $segmentsListRepository;
|
||||||
|
|
||||||
|
private UserFlagsController $userFlagsController;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AssetsController $assetsController,
|
AssetsController $assetsController,
|
||||||
AutomaticEmails $automaticEmails,
|
AutomaticEmails $automaticEmails,
|
||||||
@@ -44,7 +47,8 @@ class Automation {
|
|||||||
AutomationStorage $automationStorage,
|
AutomationStorage $automationStorage,
|
||||||
Registry $registry,
|
Registry $registry,
|
||||||
NewslettersRepository $newslettersRepository,
|
NewslettersRepository $newslettersRepository,
|
||||||
SegmentsSimpleListRepository $segmentsListRepository
|
SegmentsSimpleListRepository $segmentsListRepository,
|
||||||
|
UserFlagsController $userFlagsController
|
||||||
) {
|
) {
|
||||||
$this->assetsController = $assetsController;
|
$this->assetsController = $assetsController;
|
||||||
$this->automaticEmails = $automaticEmails;
|
$this->automaticEmails = $automaticEmails;
|
||||||
@@ -54,6 +58,7 @@ class Automation {
|
|||||||
$this->registry = $registry;
|
$this->registry = $registry;
|
||||||
$this->newslettersRepository = $newslettersRepository;
|
$this->newslettersRepository = $newslettersRepository;
|
||||||
$this->segmentsListRepository = $segmentsListRepository;
|
$this->segmentsListRepository = $segmentsListRepository;
|
||||||
|
$this->userFlagsController = $userFlagsController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
@@ -90,6 +95,7 @@ class Automation {
|
|||||||
'segments' => $this->segmentsListRepository->getListWithSubscribedSubscribersCounts(),
|
'segments' => $this->segmentsListRepository->getListWithSubscribedSubscribersCounts(),
|
||||||
'roles' => $wp_roles->get_names() + ['mailpoet_all' => __('In any WordPress role', 'mailpoet')],
|
'roles' => $wp_roles->get_names() + ['mailpoet_all' => __('In any WordPress role', 'mailpoet')],
|
||||||
'automatic_emails' => $this->automaticEmails->getAutomaticEmails(),
|
'automatic_emails' => $this->automaticEmails->getAutomaticEmails(),
|
||||||
|
'legacy_automations_notice_dismissed' => (bool)$this->userFlagsController->get('legacy_automations_notice_dismissed'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ use MailPoet\Segments\SegmentsSimpleListRepository;
|
|||||||
use MailPoet\Services\AuthorizedSenderDomainController;
|
use MailPoet\Services\AuthorizedSenderDomainController;
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
|
use MailPoet\Settings\UserFlagsController;
|
||||||
use MailPoet\Util\License\Features\Subscribers as SubscribersFeature;
|
use MailPoet\Util\License\Features\Subscribers as SubscribersFeature;
|
||||||
use MailPoet\WooCommerce\TransactionalEmails;
|
use MailPoet\WooCommerce\TransactionalEmails;
|
||||||
use MailPoet\WP\AutocompletePostListLoader as WPPostListLoader;
|
use MailPoet\WP\AutocompletePostListLoader as WPPostListLoader;
|
||||||
@@ -61,6 +62,8 @@ class Newsletters {
|
|||||||
/** @var ServicesChecker */
|
/** @var ServicesChecker */
|
||||||
private $servicesChecker;
|
private $servicesChecker;
|
||||||
|
|
||||||
|
private UserFlagsController $userFlagsController;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PageRenderer $pageRenderer,
|
PageRenderer $pageRenderer,
|
||||||
PageLimit $listingPageLimit,
|
PageLimit $listingPageLimit,
|
||||||
@@ -74,7 +77,8 @@ class Newsletters {
|
|||||||
Bridge $bridge,
|
Bridge $bridge,
|
||||||
AuthorizedSenderDomainController $senderDomainController,
|
AuthorizedSenderDomainController $senderDomainController,
|
||||||
SubscribersFeature $subscribersFeature,
|
SubscribersFeature $subscribersFeature,
|
||||||
ServicesChecker $servicesChecker
|
ServicesChecker $servicesChecker,
|
||||||
|
UserFlagsController $userFlagsController
|
||||||
) {
|
) {
|
||||||
$this->pageRenderer = $pageRenderer;
|
$this->pageRenderer = $pageRenderer;
|
||||||
$this->listingPageLimit = $listingPageLimit;
|
$this->listingPageLimit = $listingPageLimit;
|
||||||
@@ -89,6 +93,7 @@ class Newsletters {
|
|||||||
$this->senderDomainController = $senderDomainController;
|
$this->senderDomainController = $senderDomainController;
|
||||||
$this->subscribersFeature = $subscribersFeature;
|
$this->subscribersFeature = $subscribersFeature;
|
||||||
$this->servicesChecker = $servicesChecker;
|
$this->servicesChecker = $servicesChecker;
|
||||||
|
$this->userFlagsController = $userFlagsController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
@@ -161,6 +166,8 @@ class Newsletters {
|
|||||||
'type' => [NewsletterEntity::TYPE_WELCOME, NewsletterEntity::TYPE_AUTOMATIC],
|
'type' => [NewsletterEntity::TYPE_WELCOME, NewsletterEntity::TYPE_AUTOMATIC],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$data['legacy_automatic_emails_notice_dismissed'] = (bool)$this->userFlagsController->get('legacy_automatic_emails_notice_dismissed');
|
||||||
|
|
||||||
$this->pageRenderer->displayPage('newsletters.html', $data);
|
$this->pageRenderer->displayPage('newsletters.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@ class UserFlagsController {
|
|||||||
'form_editor_tutorial_seen' => false,
|
'form_editor_tutorial_seen' => false,
|
||||||
'display_new_form_editor_nps_survey' => false,
|
'display_new_form_editor_nps_survey' => false,
|
||||||
'transactional_emails_opt_in_notice_dismissed' => false,
|
'transactional_emails_opt_in_notice_dismissed' => false,
|
||||||
|
'legacy_automations_notice_dismissed' => false,
|
||||||
|
'legacy_automatic_emails_notice_dismissed' => false,
|
||||||
];
|
];
|
||||||
$this->userFlagsRepository = $userFlagsRepository;
|
$this->userFlagsRepository = $userFlagsRepository;
|
||||||
}
|
}
|
||||||
|
@@ -17,5 +17,6 @@
|
|||||||
var mailpoet_segments = <%= json_encode(segments) %>;
|
var mailpoet_segments = <%= json_encode(segments) %>;
|
||||||
var mailpoet_roles = <%= json_encode(roles) %>;
|
var mailpoet_roles = <%= json_encode(roles) %>;
|
||||||
var mailpoet_woocommerce_automatic_emails = <%= json_encode(automatic_emails) %>;
|
var mailpoet_woocommerce_automatic_emails = <%= json_encode(automatic_emails) %>;
|
||||||
|
var mailpoet_legacy_automations_notice_dismissed = <%= json_encode(legacy_automations_notice_dismissed) %>;
|
||||||
</script>
|
</script>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
@@ -55,6 +55,7 @@
|
|||||||
var mailpoet_newsletters_templates_recently_sent_count = <%= json_decode(newsletters_templates_recently_sent_count) %>;
|
var mailpoet_newsletters_templates_recently_sent_count = <%= json_decode(newsletters_templates_recently_sent_count) %>;
|
||||||
var corrupt_newsletters = <%= json_encode(corrupt_newsletters) %>;
|
var corrupt_newsletters = <%= json_encode(corrupt_newsletters) %>;
|
||||||
var mailpoet_legacy_automatic_emails_count = <%= legacy_automatic_emails_count %>;
|
var mailpoet_legacy_automatic_emails_count = <%= legacy_automatic_emails_count %>;
|
||||||
|
var mailpoet_legacy_automatic_emails_notice_dismissed = <%= json_encode(legacy_automatic_emails_notice_dismissed) %>;
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
Reference in New Issue
Block a user