Added display of server-side error message when bookmark request fails

closes https://github.com/TryGhost/Ghost/issues/11212

- store error message that is received from the server and remove the url from the context string for cleaner display
This commit is contained in:
Kevin Ansfield 2020-06-08 17:38:49 +01:00
parent a40706ed28
commit c8839bb0a2
2 changed files with 10 additions and 1 deletions

View File

@ -60,7 +60,7 @@
</div>
{{else if this.hasError}}
<div class="miw-100 flex flex-row pa2 pl3 ba br2 b--red-l3 red bg-error-red f7 fw4 lh-title h10 items-center">
<span class="mr3">There was an error when parsing the URL.</span>
<span class="mr3">{{or this.errorMessage "There was an error when parsing the URL."}}</span>
<button type="button" class="red-d2 mr3 fw6 hover-red" {{action "retry"}}><span class="underline">Retry</span></button>
<button type="button" class="red-d2 mr-auto fw6 underline hover-red" {{action "insertAsLink"}}><span class="underline">Paste URL as link</span></button>
<button type="button" {{action this.deleteCard}} class="nudge-right--2">

View File

@ -93,6 +93,7 @@ export default Component.extend({
},
retry() {
this.set('errorMessage', null);
this.set('hasError', false);
},
@ -152,6 +153,14 @@ export default Component.extend({
this.send('insertAsLink', {linkOnError: true});
return;
}
if (err.payload.errors && err.payload.errors[0]) {
let [firstError] = err.payload.errors;
let errorMessage = firstError.context || firstError.message;
errorMessage = errorMessage.replace(url, '').trim();
this.set('errorMessage', errorMessage);
}
this.set('hasError', true);
}
}),