diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx
index fe3cd534da..746708b128 100644
--- a/assets/js/src/listing/listing.jsx
+++ b/assets/js/src/listing/listing.jsx
@@ -12,6 +12,7 @@ import ListingSearch from 'listing/search.jsx';
import ListingGroups from 'listing/groups.jsx';
import ListingFilters from 'listing/filters.jsx';
import ListingItems from 'listing/listing_items.jsx';
+import MailerError from 'listing/notices.jsx';
import { withRouter } from 'react-router-dom';
const Listing = createReactClass({ // eslint-disable-line react/prefer-es6-class
@@ -636,97 +637,100 @@ const Listing = createReactClass({ // eslint-disable-line react/prefer-es6-class
}
return (
-
- { groups }
- { search }
-
-
-
- {extraActions}
-
-
-
-
-
+ { this.state.meta.mta_method && }
+
+ { groups }
+ { search }
+
+
+
+ {extraActions}
+
+
+
+
+ 0}
+ />
+
+
+ 0}
- />
-
-
- 0}
- onSelectItem={this.handleSelectItem}
- onSelectAll={this.handleSelectAll}
- selection={this.state.selection}
- selected_ids={this.state.selected_ids}
- loading={this.state.loading}
- group={this.state.group}
- count={this.state.count}
- limit={this.state.limit}
- item_actions={itemActions}
- messages={messages}
- items={items}
- />
-
-
- 0}
+ selected_ids={this.state.selected_ids}
+ loading={this.state.loading}
+ group={this.state.group}
+ count={this.state.count}
+ limit={this.state.limit}
+ item_actions={itemActions}
+ messages={messages}
+ items={items}
/>
-
-
-
-
-
+
+ 0}
+ />
+
+
+
+
+
+
+
-
+ >
);
},
});
diff --git a/assets/js/src/listing/notices.jsx b/assets/js/src/listing/notices.jsx
new file mode 100644
index 0000000000..f7688b8d7f
--- /dev/null
+++ b/assets/js/src/listing/notices.jsx
@@ -0,0 +1,111 @@
+import MailPoet from 'mailpoet';
+import PropTypes from 'prop-types';
+import React, { Fragment } from 'react';
+import ReactStringReplace from 'react-string-replace';
+
+const resumeMailerSending = () => {
+ MailPoet.Ajax.post({
+ api_version: window.mailpoet_api_version,
+ endpoint: 'mailer',
+ action: 'resumeSending',
+ }).done(() => {
+ MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice'));
+ window.mailpoet_listing.forceUpdate();
+ }).fail((response) => {
+ if (response.errors.length > 0) {
+ MailPoet.Notice.error(
+ response.errors.map(error => error.message),
+ { scroll: true }
+ );
+ }
+ });
+};
+
+function MailerError(props) {
+ if (props.mta_log.error && props.mta_log.status === 'paused' && props.mta_log.error.operation !== 'authorization') {
+ if (props.mta_log.error.operation === 'migration') {
+ return (
+
+
{ props.mta_log.error.error_message }
+
+ );
+ }
+
+ let message = props.mta_log.error.error_message;
+ const code = props.mta_log.error.error_code;
+ if (code) {
+ message += message ? ', ' : '';
+ message += MailPoet.I18n.t('mailerErrorCode').replace('%$1s', code);
+ }
+ return (
+
+
+ {
+ props.mta_log.error.operation === 'send'
+ ? MailPoet.I18n.t('mailerSendErrorNotice').replace('%$1s', props.mta_method)
+ : MailPoet.I18n.t('mailerConnectionErrorNotice')
+ }
+ :
+ {' '}
+ { message }
+
+ { props.mta_method === 'PHPMail' ?
:
}
+
+
+ { MailPoet.I18n.t('mailerResumeSendingButton') }
+
+
+
+ );
+ }
+ return null;
+}
+
+MailerError.propTypes = {
+ mta_method: PropTypes.string.isRequired,
+ mta_log: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
+};
+
+const PHPMailerCheckSettingsNotice = () => (
+
+ { MailPoet.I18n.t('mailerSendErrorCheckConfiguration') }
+
+
+ {
+ ReactStringReplace(
+ MailPoet.I18n.t('mailerSendErrorUseSendingService'),
+ /(.*?)<\/b>/g,
+ (match, key) => { match }
+ )
+ }
+
+
+
+ { MailPoet.I18n.t('mailerSendErrorSignUpForSendingService') }
+
+
+
+
+);
+
+const MailerCheckSettingsNotice = () => (
+
+ {
+ ReactStringReplace(
+ MailPoet.I18n.t('mailerCheckSettingsNotice'),
+ /\[link\](.*?)\[\/link\]/g,
+ match => { match }
+ )
+ }
+
+);
+
+export default MailerError;
diff --git a/assets/js/src/newsletters/listings/mixins.jsx b/assets/js/src/newsletters/listings/mixins.jsx
index 12157a6377..3aecc77d53 100644
--- a/assets/js/src/newsletters/listings/mixins.jsx
+++ b/assets/js/src/newsletters/listings/mixins.jsx
@@ -407,134 +407,6 @@ const MailerMixin = {
jQuery('[data-id="mailpoet_authorization_error"]').slideUp();
});
}
- if (
- state.meta.mta_log.error
- && state.meta.mta_log.status === 'paused'
- && state.meta.mta_log.error.operation !== 'authorization'
- ) {
- const errorType = MailerMixin.getMailerErrorType(state);
- let container = jQuery('[data-id="mailpoet_mailer_error"]')[0];
- if (!container) {
- MailPoet.Notice[errorType](
- '',
- { static: true, id: 'mailpoet_mailer_error' }
- );
- container = jQuery('[data-id="mailpoet_mailer_error"]')[0];
- }
- ReactDOM.render(
- MailerMixin.getMailerError(state),
- container
- );
- } else {
- MailPoet.Notice.hide('mailpoet_mailer_error');
- }
- },
- getMailerError(state) {
- if (state.meta.mta_log.error.operation === 'migration') {
- return (
-
-
{ state.meta.mta_log.error.error_message }
-
- );
- }
-
- // offer MSS when PHPMail is failing
- let mailerErrorCheckSettings;
- if (state.meta.mta_method === 'PHPMail') {
- mailerErrorCheckSettings = (
- <>
- { MailPoet.I18n.t('mailerSendErrorCheckConfiguration') }
-
-
- {
- ReactStringReplace(
- MailPoet.I18n.t('mailerSendErrorUseSendingService'),
- /(.*?)<\/b>/g,
- (match, key) => { match }
- )
- }
-
-
-
- { MailPoet.I18n.t('mailerSendErrorSignUpForSendingService') }
-
-
-
- >
- );
- } else {
- mailerErrorCheckSettings = (
-
- {
- ReactStringReplace(
- MailPoet.I18n.t('mailerCheckSettingsNotice'),
- /\[link\](.*?)\[\/link\]/g,
- match => { match }
- )
- }
-
- );
- }
-
- // append error code if available
- let mailerErrorMessage = state.meta.mta_log.error.error_message;
- if (state.meta.mta_log.error.error_code) {
- mailerErrorMessage += mailerErrorMessage ? ', ' : '';
- mailerErrorMessage += MailPoet.I18n.t('mailerErrorCode').replace('%$1s', state.meta.mta_log.error.error_code);
- }
-
- return (
-
-
- {
- state.meta.mta_log.error.operation === 'send'
- ? MailPoet.I18n.t('mailerSendErrorNotice').replace('%$1s', state.meta.mta_method)
- : MailPoet.I18n.t('mailerConnectionErrorNotice')
- }
- :
- {' '}
- { mailerErrorMessage }
-
- { mailerErrorCheckSettings }
-
-
- { MailPoet.I18n.t('mailerResumeSendingButton') }
-
-
-
- );
- },
- getMailerErrorType(state) {
- if (state.meta.mta_log.error.operation === 'migration') {
- return 'system';
- }
- return 'error';
- },
- resumeMailerSending() {
- MailPoet.Ajax.post({
- api_version: window.mailpoet_api_version,
- endpoint: 'mailer',
- action: 'resumeSending',
- }).done(() => {
- MailPoet.Notice.hide('mailpoet_mailer_error');
- MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice'));
- window.mailpoet_listing.forceUpdate();
- }).fail((response) => {
- if (response.errors.length > 0) {
- MailPoet.Notice.error(
- response.errors.map(error => error.message),
- { scroll: true }
- );
- }
- });
},
};
diff --git a/tests/acceptance/NewsletterSendingErrorCest.php b/tests/acceptance/NewsletterSendingErrorCest.php
index f38fc0a618..ddf0bc0a53 100644
--- a/tests/acceptance/NewsletterSendingErrorCest.php
+++ b/tests/acceptance/NewsletterSendingErrorCest.php
@@ -18,7 +18,7 @@ class NewsletterSendingErrorCest {
$settings->withSendingError($errorMessage);
$I->amOnMailpoetPage('Emails');
- $I->waitForElement('.mailpoet_notice.notice-error div');
+ $I->waitForElement('div.mailpoet_notice.notice-error');
$I->see('Sending has been paused due to a technical issue with SMTP: ' . $errorMessage, '.notice-error p');
$I->see('Check your sending method settings.', '.notice-error p');
$I->see('Resume sending', '.notice-error p');
@@ -40,7 +40,7 @@ class NewsletterSendingErrorCest {
$settings->withSendingError($errorMessage);
$I->amOnMailpoetPage('Emails');
- $I->waitForElement('.mailpoet_notice.notice-error div');
+ $I->waitForElement('div.mailpoet_notice.notice-error');
$I->see('Sending has been paused due to a technical issue with PHPMail: ' . $errorMessage, '.notice-error p');
$I->see('Please check your sending method configuration, you may need to consult with your hosting company.', '.notice-error p');
$I->see('The easy alternative is to send emails with MailPoet Sending Service instead, like thousands of other users do.', '.notice-error p');