1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/modal-confirm-email-send.js
Kevin Ansfield 76c357a66f Added polling when confirming email to show immediate error
no issue

- when confirming email send, after initial save in, poll every second for a maximum of 10 seconds and check the status of the email
  - if it's `'success'` close the modal immediately
  - if it's `'failure'` switch the confirm modal to an error state
  - if the save fails for some other reason (validation, server error) close the modal immediately and let the normal editor error handling do it's thing
- fixed confirm modal not appearing when retrying a save after a post validation failed
- show email status in post status area
    - `"and sending to x members"` when email is pending or submitting
    - `"and sent to x members"` once email is fully submitted
2019-11-20 23:27:09 +00:00

31 lines
819 B
JavaScript

import ModalComponent from 'ghost-admin/components/modal-base';
import {task} from 'ember-concurrency';
export default ModalComponent.extend({
errorMessage: null,
// Allowed actions
confirm: () => {},
confirmAndCheckError: task(function* () {
try {
yield this.confirm();
this.closeModal();
return true;
} catch (e) {
// switch to "failed" state if email fails
if (e && e.name === 'EmailFailedError') {
this.set('errorMessage', e.message);
return;
}
// close modal and continue with normal error handling if it was
// a non-email-related error
this.closeModal();
if (e) {
throw e;
}
}
})
});