1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Added error context to API error alert messages

This commit is contained in:
Kevin Ansfield 2019-03-06 11:45:47 +00:00
parent 996cc166ef
commit 917c8da59c
3 changed files with 23 additions and 1 deletions

View file

@ -131,6 +131,10 @@ export default Service.extend({
msg = resp.message;
}
if (!isBlank(get(resp, 'context'))) {
msg = `${msg} ${get(resp, 'context')}`;
}
this.showAlert(msg, options);
},

View file

@ -1,4 +1,4 @@
<div class="gh-notification-content">
<div class="gh-notification-content" data-test-text="notification-content">
{{message.message}}
</div>
<button class="gh-notification-close" {{action "closeNotification"}}>{{svg-jar "close"}}<span class="hidden">Close</span></button>

View file

@ -251,6 +251,24 @@ describe('Unit: Service: notifications', function () {
expect(get(notification, 'key')).to.equal('api-error');
});
it('#showAPIError adds error context to message if available', function () {
let notifications = this.subject();
let error = new AjaxError({errors: [{
message: 'Authorization Error.',
context: 'Please sign in.'
}]});
run(() => {
notifications.showAPIError(error);
});
let alert = notifications.get('alerts.firstObject');
expect(get(alert, 'message')).to.equal('Authorization Error. Please sign in.');
expect(get(alert, 'status')).to.equal('alert');
expect(get(alert, 'type')).to.equal('error');
expect(get(alert, 'key')).to.equal('api-error');
});
it('#displayDelayed moves delayed notifications into content', function () {
let notifications = this.subject();