Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-open popover on link password save failure #18551

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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