When the `or Cancel` button is clicked, the action `SET_SETTING` is not
triggered and thus `hasUnsavedChanges` was not updated resulting in
problems like the one described here:
https://github.com/mailpoet/mailpoet/pull/4315#issuecomment-1273013496.
This commit fixes this problem by updating `hasUnsavedChanges` also when
the action `SET_SETTINGS` (not the `s` at the end) is triggered.
[MAILPOET-4499]
This commit improves the code that decides whether or not to display a
confirmation message when the user tries to leave the settings pages
with unsaved changes. Before this commit, the confirmation message would
be displayed even if the user changed the settings a few times and then
back to the original value. Now, this won't happen anymore.
When the page is loaded, we save the original state of data in a
different property called `originalData` and use it to compare against
the current data when deciding whether or not the page has unsaved
changes.
I considered storing just a hash of the original data and using that for
the comparison, but I couldn't find an easy way to generate a hash of an
object in JS.
[MAILPOET-4499]
This commit updates a few acceptance tests to make sure they work with
the new modal that was added when the user tries to leave the settings
page before waiting for the save process to finish.
[MAILPOET-4499]
This is necessary to set state.save.hasUnsavedChanges to false when the
user clicks on the Verify button as this call triggers a call to
SET_SETTING that sets state.save.hasUnsavedChanges to true.
[MAILPOET-4499]
This commit display a confirmation modal when the user tries to leave
the settings page and there are unsaved changes or saving is current in
progress. It uses the same React component that is used for form editor.
[MAILPOET-4499]
The previous logic could not reliably redirect to the template selection
and was showing the 'Edit newsletter' buttons to early in the process. The
logic which decides on what buttons to show have now been bundled in a
single EditNewsletter component
[MAILPOET-4520]
getNewsletterFromQueue() has too many conditions under which it returns null. Therefore we can not rely on that method when we wont to delete running tasks with no associated newsletter.
[MAILPOET-4708]
WooCommerce Subscriptions doesn't support WooCommerce Custom Orders
Tables, so we should skip the WooCommerce Subscriptions related tests
when Woo COT is enabled.
[MAILPOET-4695]