diff options
author | Roeland Douma <rullzer@users.noreply.github.com> | 2015-10-05 21:40:37 +0200 |
---|---|---|
committer | Roeland Douma <rullzer@users.noreply.github.com> | 2015-10-05 21:40:37 +0200 |
commit | 97bade91080136e797bd1c805da5132beb6254f7 (patch) | |
tree | 3e37a78836ed2dbae7e2e12e24fc908e78adddb5 | |
parent | cf9fb034c436825cee2e90dc8ec3b30b3c93d222 (diff) | |
parent | 8c459a895d3338aa1565a4077add175c7020898d (diff) | |
download | nextcloud-server-97bade91080136e797bd1c805da5132beb6254f7.tar.gz nextcloud-server-97bade91080136e797bd1c805da5132beb6254f7.zip |
Merge pull request #19558 from owncloud/sharing_sidebar_toggle_enforcedpass
Do not remove linkshare if there is none
-rw-r--r-- | core/js/sharedialoglinkshareview.js | 6 | ||||
-rw-r--r-- | core/js/tests/specs/sharedialogviewSpec.js | 37 |
2 files changed, 42 insertions, 1 deletions
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 3d8fb461461..792062f0e16 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -124,7 +124,11 @@ this.$el.find('#linkPassText').focus(); } } else { - this.model.removeLinkShare(); + if (this.model.get('linkShare').isLinkShare) { + this.model.removeLinkShare(); + } else { + this.$el.find('#linkPass').slideToggle(OC.menuSpeed); + } } }, diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js index de6f9944094..b01a3d2cae6 100644 --- a/core/js/tests/specs/sharedialogviewSpec.js +++ b/core/js/tests/specs/sharedialogviewSpec.js @@ -231,6 +231,43 @@ describe('OC.Share.ShareDialogView', function() { expect(dialog.$el.find('#linkCheckbox').prop('checked')).toEqual(true); expect(dialog.$el.find('#linkText').val()).toEqual(link); }); + describe('password', function() { + var slideToggleStub; + + beforeEach(function() { + $('#allowShareWithLink').val('yes'); + configModel.set({ + enforcePasswordForPublicLink: false + }); + + slideToggleStub = sinon.stub($.fn, 'slideToggle'); + }); + afterEach(function() { + slideToggleStub.restore(); + }); + + it('enforced but toggled does not fire request', function() { + configModel.set('enforcePasswordForPublicLink', true); + dialog.render(); + + dialog.$el.find('[name=linkCheckbox]').click(); + + // The password linkPass field is shown (slideToggle is called). + // No request is made yet + expect(slideToggleStub.callCount).toEqual(1); + expect(slideToggleStub.getCall(0).thisValue.eq(0).attr('id')).toEqual('linkPass'); + expect(fakeServer.requests.length).toEqual(0); + + // Now untoggle share by link + dialog.$el.find('[name=linkCheckbox]').click(); + dialog.render(); + + // Password field disappears and no ajax requests have been made + expect(fakeServer.requests.length).toEqual(0); + expect(slideToggleStub.callCount).toEqual(2); + expect(slideToggleStub.getCall(1).thisValue.eq(0).attr('id')).toEqual('linkPass'); + }); + }); describe('expiration date', function() { var shareData; var shareItem; |