Reuse the new notice for a similar forgotten MSS notice
[MAILPOET-3830]
This commit is contained in:
@@ -38,13 +38,13 @@ export const addStatsCTAAction = (actions) => {
|
||||
export const checkMailerStatus = (state) => {
|
||||
if (state.meta.mta_log.error && state.meta.mta_log.error.operation === 'authorization') {
|
||||
MailPoet.Notice.hide('mailpoet_notice_being_sent');
|
||||
if (state.meta.mta_log.error.error_message.indexOf('mailpoet-js-button-resume-sending') >= 0) {
|
||||
jQuery('.mailpoet-js-error-unauthorized-emails-notice').hide(); // prevent duplicate notices
|
||||
}
|
||||
MailPoet.Notice.error(
|
||||
state.meta.mta_log.error.error_message,
|
||||
{ static: true, id: 'mailpoet_authorization_error' }
|
||||
);
|
||||
jQuery('.js-button-resume-sending').on('click', () => {
|
||||
jQuery('[data-id="mailpoet_authorization_error"]').slideUp();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -8,6 +8,7 @@ use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\Services\Bridge\API;
|
||||
use MailPoet\Util\Helpers;
|
||||
use MailPoet\Util\Notices\UnauthorizedEmailNotice;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class MailPoetMapper {
|
||||
@@ -93,21 +94,10 @@ class MailPoetMapper {
|
||||
}
|
||||
|
||||
private function getUnauthorizedEmailMessage($sender) {
|
||||
$email = $sender ? $sender['from_email'] : null;
|
||||
$message = '<p>';
|
||||
$message .= sprintf(WPFunctions::get()->__('The MailPoet Sending Service did not send your latest email because the address %s is not yet authorized.', 'mailpoet'), '<i>' . ( $email ?: WPFunctions::get()->__('Unknown address') ) . '</i>' );
|
||||
$message .= '</p><p>';
|
||||
$message .= Helpers::replaceLinkTags(
|
||||
WPFunctions::get()->__('[link]Authorize your email in your account now.[/link]', 'mailpoet'),
|
||||
'https://account.mailpoet.com/authorization',
|
||||
[
|
||||
'class' => 'button button-primary',
|
||||
'target' => '_blank',
|
||||
'rel' => 'noopener noreferrer',
|
||||
]
|
||||
);
|
||||
$message .= ' <button class="button mailpoet-js-button-resume-sending">' . WPFunctions::get()->__('Resume sending', 'mailpoet') . '</button>';
|
||||
$message .= '</p>';
|
||||
$email = $sender ? $sender['from_email'] : WPFunctions::get()->__('Unknown address');
|
||||
$validationError = ['invalid_sender_address' => $email];
|
||||
$notice = new UnauthorizedEmailNotice(WPFunctions::get(), null);
|
||||
$message = $notice->getMessage($validationError);
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,7 @@ class PermanentNotices {
|
||||
$this->wp = $wp;
|
||||
$this->phpVersionWarnings = new PHPVersionWarnings();
|
||||
$this->afterMigrationNotice = new AfterMigrationNotice();
|
||||
$this->unauthorizedEmailsNotice = new UnauthorizedEmailNotice(SettingsController::getInstance(), $wp);
|
||||
$this->unauthorizedEmailsNotice = new UnauthorizedEmailNotice($wp, SettingsController::getInstance());
|
||||
$this->unauthorizedEmailsInNewslettersNotice = new UnauthorizedEmailInNewslettersNotice(SettingsController::getInstance(), $wp);
|
||||
$this->inactiveSubscribersNotice = new InactiveSubscribersNotice(SettingsController::getInstance(), $wp);
|
||||
$this->blackFridayNotice = new BlackFridayNotice();
|
||||
|
@@ -12,21 +12,24 @@ class UnauthorizedEmailNotice {
|
||||
|
||||
const OPTION_NAME = 'unauthorized-email-addresses-notice';
|
||||
|
||||
/** @var SettingsController */
|
||||
/** @var SettingsController|null */
|
||||
private $settings;
|
||||
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(
|
||||
SettingsController $settings,
|
||||
WPFunctions $wp
|
||||
WPFunctions $wp,
|
||||
SettingsController $settings = null
|
||||
) {
|
||||
$this->settings = $settings;
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
public function init($shouldDisplay) {
|
||||
if (!$this->settings instanceof SettingsController) {
|
||||
throw new \Exception('This method can only be called if SettingsController is provided');
|
||||
}
|
||||
$validationError = $this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING);
|
||||
if ($shouldDisplay && isset($validationError['invalid_sender_address'])) {
|
||||
return $this->display($validationError);
|
||||
@@ -34,6 +37,12 @@ class UnauthorizedEmailNotice {
|
||||
}
|
||||
|
||||
public function display($validationError) {
|
||||
$message = $this->getMessage($validationError);
|
||||
$extraClasses = 'mailpoet-js-error-unauthorized-emails-notice';
|
||||
Notice::displayError($message, $extraClasses, self::OPTION_NAME, false, false);
|
||||
}
|
||||
|
||||
public function getMessage($validationError) {
|
||||
$message = $this->getMessageText($validationError);
|
||||
$message .= sprintf(
|
||||
'<p>%s %s %s</p>',
|
||||
@@ -41,8 +50,7 @@ class UnauthorizedEmailNotice {
|
||||
$this->getDifferentEmailButton(),
|
||||
$this->getResumeSendingButton($validationError)
|
||||
);
|
||||
$extraClasses = 'mailpoet-js-error-unauthorized-emails-notice';
|
||||
Notice::displayError($message, $extraClasses, self::OPTION_NAME, false, false);
|
||||
return $message;
|
||||
}
|
||||
|
||||
private function getMessageText($validationError) {
|
||||
|
Reference in New Issue
Block a user