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:
parent
996cc166ef
commit
917c8da59c
|
@ -131,6 +131,10 @@ export default Service.extend({
|
||||||
msg = resp.message;
|
msg = resp.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isBlank(get(resp, 'context'))) {
|
||||||
|
msg = `${msg} ${get(resp, 'context')}`;
|
||||||
|
}
|
||||||
|
|
||||||
this.showAlert(msg, options);
|
this.showAlert(msg, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="gh-notification-content">
|
<div class="gh-notification-content" data-test-text="notification-content">
|
||||||
{{message.message}}
|
{{message.message}}
|
||||||
</div>
|
</div>
|
||||||
<button class="gh-notification-close" {{action "closeNotification"}}>{{svg-jar "close"}}<span class="hidden">Close</span></button>
|
<button class="gh-notification-close" {{action "closeNotification"}}>{{svg-jar "close"}}<span class="hidden">Close</span></button>
|
||||||
|
|
|
@ -251,6 +251,24 @@ describe('Unit: Service: notifications', function () {
|
||||||
expect(get(notification, 'key')).to.equal('api-error');
|
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 () {
|
it('#displayDelayed moves delayed notifications into content', function () {
|
||||||
let notifications = this.subject();
|
let notifications = this.subject();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue