mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Improve importer error messaging
closes #3274 - Ensure that validation errors are always handled by moving them into the importer - Ensure that db errors are handled consistently across sqlite and mysql - Change the errors to be output in a table, with a short failure notification - Add tests for 003 importing bad files
This commit is contained in:
parent
b6d7afe9ad
commit
05afe8afb2
4 changed files with 16 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
var DebugController = Ember.Controller.extend(Ember.Evented, {
|
||||
uploadButtonText: 'Import',
|
||||
importErrors: '',
|
||||
|
||||
actions: {
|
||||
onUpload: function (file) {
|
||||
|
@ -7,6 +8,7 @@ var DebugController = Ember.Controller.extend(Ember.Evented, {
|
|||
formData = new FormData();
|
||||
|
||||
this.set('uploadButtonText', 'Importing');
|
||||
this.notifications.closePassive();
|
||||
|
||||
formData.append('importfile', file);
|
||||
|
||||
|
@ -20,7 +22,10 @@ var DebugController = Ember.Controller.extend(Ember.Evented, {
|
|||
}).then(function () {
|
||||
self.notifications.showSuccess('Import successful.');
|
||||
}).catch(function (response) {
|
||||
self.notifications.showAPIError(response);
|
||||
if (response && response.jqXHR && response.jqXHR.responseJSON && response.jqXHR.responseJSON.errors) {
|
||||
self.set('importErrors', response.jqXHR.responseJSON.errors);
|
||||
}
|
||||
self.notifications.showError('Import Failed');
|
||||
}).finally(function () {
|
||||
self.set('uploadButtonText', 'Import');
|
||||
self.trigger('reset');
|
||||
|
|
7
ghost/admin/templates/-import-errors.hbs
Normal file
7
ghost/admin/templates/-import-errors.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{#if importErrors}}
|
||||
<table class="table">
|
||||
{{#each importErrors}}
|
||||
<tr><td>{{message}}</td></tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
|
@ -28,6 +28,7 @@
|
|||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label>Import</label>
|
||||
{{partial "import-errors"}}
|
||||
{{gh-file-upload id="importfile" uploadButtonText=uploadButtonText}}
|
||||
<p>Import from another Ghost installation. If you import a user, this will replace the current user & log you out.</p>
|
||||
</div>
|
||||
|
|
|
@ -52,6 +52,8 @@ var Notifications = Ember.ArrayProxy.extend({
|
|||
|
||||
if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.error) {
|
||||
this.showError(resp.jqXHR.responseJSON.error, delayed);
|
||||
} else if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.errors) {
|
||||
this.showErrors(resp.jqXHR.responseJSON.errors, delayed);
|
||||
} else {
|
||||
this.showError(defaultErrorText, delayed);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue