Re-open popover on link password save failure

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-12-23 12:04:53 +01:00
parent 342fff64da
commit a826176f79
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
4 changed files with 22 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View file

@ -346,6 +346,7 @@
},
onPasswordEntered: function(event) {
var self = this;
var $element = $(event.target);
var $li = $element.closest('li[data-share-id]');
var shareId = $li.data('share-id');
@ -387,6 +388,11 @@
$loading.removeClass('inlineblock').addClass('hidden');
},
error: function(model, msg) {
// force open the menu
if (event) {
self.onToggleMenu(event)
}
// Add visual feedback to both the input and the submit button
$input.parent().find('input').addClass('error');
@ -667,8 +673,8 @@
}
}
this.$el.on('beforeHide', function() {
this.onMenuhide()
this.$el.on('beforeHide', function(e) {
this.onMenuhide(e)
}.bind(this));
this.$el.html(linkShareTemplate({
@ -709,13 +715,16 @@
}
},
onMenuhide: function() {
onMenuhide: function(event) {
if (this.hasPasswordChanged) {
var shareId = this.hasPasswordChanged
var target = this.$el.find('li[data-share-id=' + shareId + '] #linkPassText-' + shareId);
console.debug('Force saving password for share number ', shareId)
this.onPasswordEntered({ target: target })
// replace target by last opened menu
this.onPasswordEntered(_.extend(event, { target: target }))
}
// force close all opened tooltips
this.$el.find('[data-original-title]').tooltip('hide')
},
/**

View file

@ -202,14 +202,18 @@ describe('OC.Share.ShareDialogLinkShareView', function () {
});
it('shows the working icon when called', function () {
view.onPasswordEntered({target: view.$el.find('.linkPassText')});
view.onPasswordEntered(jQuery.Event('click', {
target: view.$el.find('.linkPassText')
}));
expect($workingIcon.hasClass('hidden')).toBeFalsy();
expect(shareModel.saveLinkShare.withArgs({ password: 'myPassword', cid: 123 }).calledOnce).toBeTruthy();
});
it('hides the working icon when saving the password succeeds', function () {
view.onPasswordEntered({target: view.$el.find('.linkPassText')});
view.onPasswordEntered(jQuery.Event('click', {
target: view.$el.find('.linkPassText')
}));
expect($workingIcon.hasClass('hidden')).toBeFalsy();
expect(shareModel.saveLinkShare.withArgs({ password: 'myPassword', cid: 123 }).calledOnce).toBeTruthy();
@ -220,7 +224,9 @@ describe('OC.Share.ShareDialogLinkShareView', function () {
});
it('hides the working icon when saving the password fails', function () {
view.onPasswordEntered({target: view.$el.find('.linkPassText')});
view.onPasswordEntered(jQuery.Event('click', {
target: view.$el.find('.linkPassText')
}));
expect($workingIcon.hasClass('hidden')).toBeFalsy();
expect(shareModel.saveLinkShare.withArgs({ password: 'myPassword', cid: 123 }).calledOnce).toBeTruthy();