mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03:00
aaabf4b103
fixes https://github.com/TryGhost/Team/issues/2009 - When an email is sent, but it failed there was no way to retry once you left the retry screen - There was no indication that the email failed to send in the post list and editor
95 lines
2.5 KiB
JavaScript
95 lines
2.5 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class PublishModalComponent extends Component {
|
|
static modalOptions = {
|
|
className: 'fullscreen-modal-total-overlay publish-modal',
|
|
omitBackdrop: true,
|
|
ignoreBackdropClick: true
|
|
};
|
|
|
|
@service store;
|
|
|
|
@tracked emailErrorMessage = this.args.data.publishOptions.post.didEmailFail ? this.args.data.publishOptions.post.email.error : undefined;
|
|
@tracked isConfirming = false;
|
|
@tracked isComplete = false;
|
|
@tracked postCount = null;
|
|
|
|
get recipientType() {
|
|
const filter = this.args.data.publishOptions.recipientFilter;
|
|
|
|
if (!filter) {
|
|
return 'none';
|
|
}
|
|
|
|
if (filter === 'status:free') {
|
|
return 'free';
|
|
}
|
|
|
|
if (filter === 'status:-free') {
|
|
return 'paid';
|
|
}
|
|
|
|
if (filter.includes('status:free') && filter.includes('status:-free')) {
|
|
return 'all';
|
|
}
|
|
|
|
return 'specific';
|
|
}
|
|
|
|
@action
|
|
toggleConfirm() {
|
|
this.isConfirming = !this.isConfirming;
|
|
|
|
if (this.isConfirming) {
|
|
this.fetchPostCountTask.perform();
|
|
}
|
|
}
|
|
|
|
@action
|
|
setCompleted() {
|
|
this.emailErrorMessage = undefined;
|
|
this.isConfirming = false;
|
|
this.isComplete = true;
|
|
}
|
|
|
|
@task
|
|
*saveTask() {
|
|
try {
|
|
yield this.args.data.saveTask.perform();
|
|
|
|
this.isConfirming = false;
|
|
this.isComplete = true;
|
|
} catch (e) {
|
|
if (e?.name === 'EmailFailedError') {
|
|
return this.emailErrorMessage = e.message;
|
|
}
|
|
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
// we fetch the new post count in advance when reaching the confirm step
|
|
// to avoid a copy flash when reaching the complete step
|
|
@task
|
|
*fetchPostCountTask() {
|
|
const publishOptions = this.args.data.publishOptions;
|
|
|
|
// no count is shown for pages, scheduled posts, or email-only posts
|
|
if (publishOptions.post.isPage || publishOptions.isScheduled || !publishOptions.willPublish) {
|
|
this.postCount = null;
|
|
return;
|
|
}
|
|
|
|
const result = yield this.store.query('post', {filter: 'status:published', limit: 1});
|
|
let count = result.meta.pagination.total;
|
|
|
|
count += 1; // account for the new post
|
|
|
|
this.postCount = count;
|
|
}
|
|
}
|