Merge pull request #4605 from manwithtwowatches/feature/4509-image-upload-response-errors
Feature/4509 image upload response errors
This commit is contained in:
commit
1ce027eb2c
4 changed files with 47 additions and 10 deletions
|
|
@ -40,6 +40,7 @@
|
||||||
* Fix avatar display on mobile profile [#4591](https://github.com/diaspora/diaspora/pull/4591)
|
* Fix avatar display on mobile profile [#4591](https://github.com/diaspora/diaspora/pull/4591)
|
||||||
* Add lightbox to unauthenticated header, fix [#4432](https://github.com/diaspora/diaspora/issues/4432)
|
* Add lightbox to unauthenticated header, fix [#4432](https://github.com/diaspora/diaspora/issues/4432)
|
||||||
* Fix "more picture" indication (+n) on mobile by adding a link on the indication [#4592](https://github.com/diaspora/diaspora/pull/4592)
|
* Fix "more picture" indication (+n) on mobile by adding a link on the indication [#4592](https://github.com/diaspora/diaspora/pull/4592)
|
||||||
|
* Display errors when photo upload fails [#4509](https://github.com/diaspora/diaspora/issues/4509)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)
|
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ app.views.PublisherUploader = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadCompleteHandler: function(id, fileName, response) {
|
uploadCompleteHandler: function(id, fileName, response) {
|
||||||
|
if (response.success){
|
||||||
this.el_info.text(Diaspora.I18n.t('photo_uploader.completed', {file: fileName})).fadeTo(2000, 0);
|
this.el_info.text(Diaspora.I18n.t('photo_uploader.completed', {file: fileName})).fadeTo(2000, 0);
|
||||||
|
|
||||||
var id = response.data.photo.id,
|
var id = response.data.photo.id,
|
||||||
|
|
@ -67,6 +68,11 @@ app.views.PublisherUploader = Backbone.View.extend({
|
||||||
|
|
||||||
this._addFinishedPhoto(id, url);
|
this._addFinishedPhoto(id, url);
|
||||||
this.trigger('change');
|
this.trigger('change');
|
||||||
|
} else {
|
||||||
|
this._cancelPhotoUpload();
|
||||||
|
this.trigger('change');
|
||||||
|
this.el_info.text(Diaspora.I18n.t('photo_uploader.error', {file: fileName}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// replace the first photo placeholder with the finished uploaded image and
|
// replace the first photo placeholder with the finished uploaded image and
|
||||||
|
|
@ -96,6 +102,14 @@ app.views.PublisherUploader = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_cancelPhotoUpload: function() {
|
||||||
|
var publisher = this.options.publisher;
|
||||||
|
var placeholder = publisher.el_photozone.find('li.loading').first();
|
||||||
|
placeholder
|
||||||
|
.removeClass('loading')
|
||||||
|
.find('img').remove();
|
||||||
|
},
|
||||||
|
|
||||||
// remove an already uploaded photo
|
// remove an already uploaded photo
|
||||||
_removePhoto: function(evt) {
|
_removePhoto: function(evt) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ en:
|
||||||
photo_uploader:
|
photo_uploader:
|
||||||
looking_good: "OMG, you look awesome!"
|
looking_good: "OMG, you look awesome!"
|
||||||
completed: "<%= file %> completed"
|
completed: "<%= file %> completed"
|
||||||
|
error: "A problem occurred while uploading file <%= file %>"
|
||||||
invalid_ext: "{file} has invalid extension. Only {extensions} are allowed."
|
invalid_ext: "{file} has invalid extension. Only {extensions} are allowed."
|
||||||
size_error: "{file} is too large, maximum file size is {sizeLimit}."
|
size_error: "{file} is too large, maximum file size is {sizeLimit}."
|
||||||
empty: "{file} is empty, please select files again without it."
|
empty: "{file} is empty, please select files again without it."
|
||||||
|
|
|
||||||
|
|
@ -382,15 +382,17 @@ describe("app.views.Publisher", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('completion', function() {
|
context('successful completion', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
Diaspora.I18n.loadLocale({ photo_uploader: { completed: '<%= file %> completed' }});
|
Diaspora.I18n.loadLocale({ photo_uploader: { completed: '<%= file %> completed' }});
|
||||||
$('#photodropzone').html('<li class="publisher_photo loading"><img src="" /></li>');
|
$('#photodropzone').html('<li class="publisher_photo loading"><img src="" /></li>');
|
||||||
|
|
||||||
this.uploader.onComplete(null, 'test.jpg', { data: { photo: {
|
this.uploader.onComplete(null, 'test.jpg', {
|
||||||
|
data: { photo: {
|
||||||
id: '987',
|
id: '987',
|
||||||
unprocessed_image: { url: 'test.jpg' }
|
unprocessed_image: { url: 'test.jpg' }
|
||||||
}}});
|
}},
|
||||||
|
success: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows it in text form', function() {
|
it('shows it in text form', function() {
|
||||||
|
|
@ -417,6 +419,25 @@ describe("app.views.Publisher", function() {
|
||||||
expect(this.view.el_preview.prop('disabled')).toBeFalsy();
|
expect(this.view.el_preview.prop('disabled')).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('unsuccessful completion', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
Diaspora.I18n.loadLocale({ photo_uploader: { completed: '<%= file %> completed' }});
|
||||||
|
$('#photodropzone').html('<li class="publisher_photo loading"><img src="" /></li>');
|
||||||
|
|
||||||
|
this.uploader.onComplete(null, 'test.jpg', {
|
||||||
|
data: { photo: {
|
||||||
|
id: '987',
|
||||||
|
unprocessed_image: { url: 'test.jpg' }
|
||||||
|
}},
|
||||||
|
success: false });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows error message', function() {
|
||||||
|
var info = this.view.view_uploader.el_info;
|
||||||
|
expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.error', {file: 'test.jpg'}))
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('photo removal', function() {
|
context('photo removal', function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue