diff --git a/mailpoet/assets/js/src/automation/listing/automation-listing-notices.tsx b/mailpoet/assets/js/src/automation/listing/automation-listing-notices.tsx index 752ab0d2a9..2875bfb9d2 100644 --- a/mailpoet/assets/js/src/automation/listing/automation-listing-notices.tsx +++ b/mailpoet/assets/js/src/automation/listing/automation-listing-notices.tsx @@ -5,6 +5,8 @@ import { __ } from '@wordpress/i18n'; import { getQueryArg, removeQueryArgs } from '@wordpress/url'; export const LISTING_NOTICES = { + automationActivated: 'activated', + automationSaved: 'saved', automationDeleted: 'deleted', automationHadBeenDeleted: 'had-been-deleted', } as const; @@ -14,8 +16,14 @@ export function useAutomationListingNotices(): void { useEffect(() => { const notice = getQueryArg(window.location.href, 'notice'); - - if (notice === LISTING_NOTICES.automationDeleted) { + if (notice === LISTING_NOTICES.automationActivated) { + createNotice('success', __('Your automation is now active.', 'mailpoet')); + } else if (notice === LISTING_NOTICES.automationSaved) { + createNotice( + 'success', + __('Your automation has been saved.', 'mailpoet'), + ); + } else if (notice === LISTING_NOTICES.automationDeleted) { createNotice( 'success', __('1 automation moved to the Trash.', 'mailpoet'), diff --git a/mailpoet/assets/js/src/newsletters/send.tsx b/mailpoet/assets/js/src/newsletters/send.tsx index f6b8dffcaa..fb896f5442 100644 --- a/mailpoet/assets/js/src/newsletters/send.tsx +++ b/mailpoet/assets/js/src/newsletters/send.tsx @@ -445,7 +445,7 @@ class NewsletterSendComponent extends Component< this.props.history.push(`/send/congratulate/${this.state.item.id}`); return; } - this.redirectToListing(); + this.redirectToListing('activated'); // prepare segments let filters = []; @@ -504,7 +504,7 @@ class NewsletterSendComponent extends Component< this.props.history.push(`/send/congratulate/${this.state.item.id}`); return; } - this.redirectToListing(); + this.redirectToListing('activated'); // display success message depending on newsletter type const opts = this.state.item.options; @@ -579,7 +579,7 @@ class NewsletterSendComponent extends Component< }, }) .done(() => { - this.redirectToListing(); + this.redirectToListing('activated'); this.context.notices.success(
{__('The newsletter sending has been resumed.', 'mailpoet')} @@ -610,17 +610,17 @@ class NewsletterSendComponent extends Component< ); }) .done(() => { - this.redirectToListing(); + this.redirectToListing('saved'); }) .fail((err) => { this.showError(err); }); }; - redirectToListing = () => { + redirectToListing = (action: 'activated' | 'saved') => { // redirect to listing based on newsletter type if (['automatic', 'welcome'].includes(this.state.item.type)) { - window.location.href = 'admin.php?page=mailpoet-automation'; + window.location.href = `admin.php?page=mailpoet-automation¬ice=${action}`; } else { this.props.history.push(`/${this.state.item.type}`); }