0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Refined email debug screen error handling

refs https://github.com/TryGhost/Team/issues/2327
This commit is contained in:
Rishabh 2022-12-02 21:28:12 +05:30
parent 6ae9b49e73
commit e74ba81276
2 changed files with 23 additions and 10 deletions

View file

@ -44,8 +44,8 @@
<div class="gh-box gh-box-error gh-box-tip gh-email-debug-error">
{{svg-jar "warning"}}
<div class="gh-email-debug-errortext">
<h4>Something went wrong!</h4>
<p class="mb0">{{this.emailError.message}}</p>
<h4>{{this.emailError.message}}</h4>
<p class="mb0">{{this.emailError.details}}</p>
</div>
<LinkTo @route="editor.edit" @models={{array this.post.displayName this.post.id}} class="gh-btn gh-btn-primary gh-btn-icon gh-btn-red ember-view self-center">
<span>Retry</span>
@ -58,7 +58,7 @@
<Tabs::Tabs class="gh-tabs-analytics" @forceRender={{true}} as |tabs|>
<tabs.tab>
<h3>{{svg-jar "analytics-tab-sent-large"}} {{this.tabTotals.permanentFailures}}</h3>
<p><span class="analytics-tab-label">Permanent failures</span></p>
<p><span class="analytics-tab-label">Permanent {{gh-pluralize this.tabTotals.permanentFailures "failure" without-count=true}}</span></p>
</tabs.tab>
<tabs.tabPanel>
@ -107,7 +107,7 @@
<tabs.tab>
<h3>{{svg-jar "analytics-tab-opened-large"}}{{this.tabTotals.temporaryFailures}}</h3>
<p><span class="analytics-tab-label">Temporary failures</span></p>
<p><span class="analytics-tab-label">Temporary {{gh-pluralize this.tabTotals.temporaryFailures "failure" without-count=true}}</span></p>
</tabs.tab>
<tabs.tabPanel>
@ -161,7 +161,7 @@
<tabs.tab>
<h3>{{svg-jar "analytics-tab-clicked-large"}}{{this.tabTotals.erroredBatches}}</h3>
<p><span class="analytics-tab-label">Batches errored</span></p>
<p><span class="analytics-tab-label">{{gh-pluralize this.tabTotals.erroredBatches "batch" without-count=true}} errored</span></p>
</tabs.tab>
<tabs.tabPanel>

View file

@ -2,6 +2,8 @@ import Component from '@glimmer/component';
import moment from 'moment-timezone';
import {action} from '@ember/object';
import {didCancel, task} from 'ember-concurrency';
import {formatNumber} from 'ghost-admin/helpers/format-number';
import {ghPluralize} from 'ghost-admin/helpers/gh-pluralize';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';
export default class Debug extends Component {
@ -14,14 +16,24 @@ export default class Debug extends Component {
@tracked emailBatches = null;
@tracked recipientFailures = null;
@tracked loading = true;
get post() {
return this.args.post;
}
get emailError() {
// get failed batches count
let failedBatches = this.emailBatchesData?.filter((batch) => {
return batch.statusClass === 'failed';
}).length || 0;
// get total batch count
let totalBatches = this.emailBatchesData?.length || 0;
let details = (this.loading || !totalBatches) ? '' : `${failedBatches} of ${ghPluralize(totalBatches, 'batch')} failed to send, check below for more details.`;
return {
message: this.post.email?.error || 'Failed to send email!'
message: this.post.email?.error || 'Failed to send email.',
details
};
}
@ -43,11 +55,11 @@ export default class Debug extends Component {
get tabTotals() {
return {
temporaryFailures: this.temporaryFailureData?.length || 0,
permanentFailures: this.permanentFailureData?.length || 0,
erroredBatches: this.emailBatchesData?.filter((batch) => {
temporaryFailures: formatNumber(this.temporaryFailureData?.length || 0),
permanentFailures: formatNumber(this.permanentFailureData?.length || 0),
erroredBatches: formatNumber(this.emailBatchesData?.filter((batch) => {
return batch.statusClass === 'failed';
}).length || 0
}).length || 0)
};
}
@ -171,6 +183,7 @@ export default class Debug extends Component {
let statsUrl = this.ghostPaths.url.api(`emails/${this.post.email.id}/batches`);
let result = yield this.ajax.request(statsUrl, {data});
this.emailBatches = result.batches;
this.loading = false;
}
async fetchRecipientFailures() {