Skip to content

Commit

Permalink
Re-open popover on link password save failure
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jan 2, 2020
1 parent 342fff6 commit a826176
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/js/dist/share_backend.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/share_backend.js.map

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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')
},

/**
Expand Down
12 changes: 9 additions & 3 deletions core/js/tests/specs/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit a826176

Please sign in to comment.