Create default responseerror notice
[MAILPOET-1856]
This commit is contained in:
@@ -218,4 +218,14 @@ MailPoet.Notice = {
|
|||||||
message: message,
|
message: message,
|
||||||
}, options));
|
}, options));
|
||||||
},
|
},
|
||||||
|
showApiErrorNotice: function showApiErrorNotice(response, options) {
|
||||||
|
var errorMessage = MailPoet.I18n.t('ajaxFailedErrorMessage');
|
||||||
|
if (response && response.errors && response.errors.length > 0) {
|
||||||
|
errorMessage = response.errors.map(error => error.message);
|
||||||
|
}
|
||||||
|
this.show(jQuery.extend({}, {
|
||||||
|
type: 'error',
|
||||||
|
message: errorMessage,
|
||||||
|
}, options));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@@ -7,11 +7,7 @@ function RevenueTrackingPermission() {
|
|||||||
|
|
||||||
const handleApiError = (response) => {
|
const handleApiError = (response) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
let errorMessage = MailPoet.I18n.t('unknownError');
|
MailPoet.Notice.showApiErrorNotice(response, { scroll: true });
|
||||||
if (response && response.errors && response.errors.length > 0) {
|
|
||||||
errorMessage = response.errors.map(error => error.message);
|
|
||||||
}
|
|
||||||
MailPoet.Notice.error(errorMessage, { scroll: true });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateSettings = data => MailPoet.Ajax.post({
|
const updateSettings = data => MailPoet.Ajax.post({
|
||||||
|
@@ -38,11 +38,7 @@ class WooCommerceImportController extends React.Component {
|
|||||||
|
|
||||||
handleApiError(response) {
|
handleApiError(response) {
|
||||||
this.setState({ loading: false });
|
this.setState({ loading: false });
|
||||||
let errorMessage = MailPoet.I18n.t('unknownError');
|
MailPoet.Notice.showApiErrorNotice(response, { scroll: true });
|
||||||
if (response && response.errors && response.errors.length > 0) {
|
|
||||||
errorMessage = response.errors.map(error => error.message);
|
|
||||||
}
|
|
||||||
MailPoet.Notice.error(errorMessage, { scroll: true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit(importType) {
|
submit(importType) {
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
'revenueTrackingInfo2': _x('This is practical for abandoned cart emails and when a customer uses several email addresses.', '“abandoned cart emails“ are emails which are sent automatically from e-commerce websites when a customer add a product to the cart and then leave the website'),
|
'revenueTrackingInfo2': _x('This is practical for abandoned cart emails and when a customer uses several email addresses.', '“abandoned cart emails“ are emails which are sent automatically from e-commerce websites when a customer add a product to the cart and then leave the website'),
|
||||||
'revenueTrackingAllow': _x('Allow MailPoet cookies. My visitors are made aware that cookies are used on my website', '“MailPoet cookies” and “cookies” are browser cookies created by MailPoet'),
|
'revenueTrackingAllow': _x('Allow MailPoet cookies. My visitors are made aware that cookies are used on my website', '“MailPoet cookies” and “cookies” are browser cookies created by MailPoet'),
|
||||||
'revenueTrackingDontAllow': _x('Don’t allow MailPoet cookies and rely on basic revenue tracking', '“MailPoet cookies” are browser cookies created by MailPoet'),
|
'revenueTrackingDontAllow': _x('Don’t allow MailPoet cookies and rely on basic revenue tracking', '“MailPoet cookies” are browser cookies created by MailPoet'),
|
||||||
'revenueTrackingSubmit': _x('Save', 'Submit button caption'),
|
'revenueTrackingSubmit': _x('Save', 'Submit button caption')
|
||||||
'unknownError': __('Unknown error')
|
|
||||||
}) %>
|
}) %>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
Reference in New Issue
Block a user