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