diff --git a/core/js/share/sharedialoglinkshareview_popover_menu.handlebars b/core/js/share/sharedialoglinkshareview_popover_menu.handlebars
index 412ed8efca..baee3aa663 100644
--- a/core/js/share/sharedialoglinkshareview_popover_menu.handlebars
+++ b/core/js/share/sharedialoglinkshareview_popover_menu.handlebars
@@ -11,6 +11,16 @@
+ {{#if showHideDownloadCheckbox}}
+
+
+
+ {{/if}}
{{#if publicUpload}}
\n \n"
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publicUpload : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publicEditing : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPasswordCheckBox : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showHideDownloadCheckbox : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publicUpload : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publicEditing : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPasswordCheckBox : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " \n \n \n \n \n \n \n \n \n \n \n \n \n "
+ alias4(((helper = (helper = helpers.addNoteLabel || (depth0 != null ? depth0.addNoteLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"addNoteLabel","hash":{},"data":data}) : helper)))
+ "\n \n \n \n \n \n \n"
- + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.social : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.social : depth0),{"name":"each","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " \n\n";
},"useData":true});
templates['sharedialoglinkshareview_popover_menu_pending'] = template({"1":function(container,depth0,helpers,partials,data) {
diff --git a/core/js/tests/specs/sharedialoglinkshareview.js b/core/js/tests/specs/sharedialoglinkshareview.js
index 9d07dcb479..d8dec3968e 100644
--- a/core/js/tests/specs/sharedialoglinkshareview.js
+++ b/core/js/tests/specs/sharedialoglinkshareview.js
@@ -72,6 +72,100 @@ describe('OC.Share.ShareDialogLinkShareView', function () {
configModel.isShareWithLinkAllowed.restore();
});
+ describe('hide download', function () {
+
+ var $hideDownloadCheckbox;
+ var $workingIcon;
+
+ beforeEach(function () {
+ // Needed to render the view
+ configModel.isShareWithLinkAllowed.returns(true);
+
+ // Setting the share also triggers the rendering
+ shareModel.set({
+ linkShare: {
+ isLinkShare: true,
+ }
+ });
+
+ $hideDownloadCheckbox = view.$el.find('.hideDownloadCheckbox');
+ $workingIcon = $hideDownloadCheckbox.prev('.icon-loading-small');
+
+ sinon.stub(shareModel, 'saveLinkShare');
+
+ expect($workingIcon.hasClass('hidden')).toBeTruthy();
+ });
+
+ afterEach(function () {
+ shareModel.saveLinkShare.restore();
+ });
+
+ it('is shown if the share is a file', function() {
+ expect($hideDownloadCheckbox.length).toBeTruthy();
+ });
+
+ it('is not shown if the share is a folder', function() {
+ shareModel.fileInfoModel.set('mimetype', 'httpd/unix-directory');
+
+ // Setting the item type also triggers the rendering
+ shareModel.set({
+ itemType: 'folder'
+ });
+
+ $hideDownloadCheckbox = view.$el.find('.hideDownloadCheckbox');
+
+ expect($hideDownloadCheckbox.length).toBeFalsy();
+ });
+
+ it('checkbox is checked when the setting is enabled', function () {
+ shareModel.set({
+ linkShare: {
+ isLinkShare: true,
+ hideDownload: true
+ }
+ });
+
+ $hideDownloadCheckbox = view.$el.find('.hideDownloadCheckbox');
+
+ expect($hideDownloadCheckbox.is(':checked')).toEqual(true);
+ });
+
+ it('checkbox is not checked when the setting is disabled', function () {
+ expect($hideDownloadCheckbox.is(':checked')).toEqual(false);
+ });
+
+ it('enables the setting if clicked when unchecked', function () {
+ // Simulate the click by checking the checkbox and then triggering
+ // the "change" event.
+ $hideDownloadCheckbox.prop('checked', true);
+ $hideDownloadCheckbox.change();
+
+ expect($workingIcon.hasClass('hidden')).toBeFalsy();
+ expect(shareModel.saveLinkShare.withArgs({ hideDownload: true }).calledOnce).toBeTruthy();
+ });
+
+ it('disables the setting if clicked when checked', function () {
+ shareModel.set({
+ linkShare: {
+ isLinkShare: true,
+ hideDownload: true
+ }
+ });
+
+ $hideDownloadCheckbox = view.$el.find('.hideDownloadCheckbox');
+ $workingIcon = $hideDownloadCheckbox.prev('.icon-loading-small');
+
+ // Simulate the click by unchecking the checkbox and then triggering
+ // the "change" event.
+ $hideDownloadCheckbox.prop('checked', false);
+ $hideDownloadCheckbox.change();
+
+ expect($workingIcon.hasClass('hidden')).toBeFalsy();
+ expect(shareModel.saveLinkShare.withArgs({ hideDownload: false }).calledOnce).toBeTruthy();
+ });
+
+ });
+
describe('onPasswordEntered', function () {
var $passwordText;
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js
index 2e89b2e3cd..a2eabbf4ae 100644
--- a/core/js/tests/specs/shareitemmodelSpec.js
+++ b/core/js/tests/specs/shareitemmodelSpec.js
@@ -168,7 +168,8 @@ describe('OC.Share.ShareItemModel', function() {
stime: 1403884258,
storage: 1,
token: 'tehtoken',
- uid_owner: 'root'
+ uid_owner: 'root',
+ hide_download: 1
}
]));
@@ -186,6 +187,7 @@ describe('OC.Share.ShareItemModel', function() {
var linkShare = model.get('linkShare');
expect(linkShare.isLinkShare).toEqual(true);
+ expect(linkShare.hideDownload).toEqual(true);
// TODO: check more attributes
});
@@ -289,7 +291,8 @@ describe('OC.Share.ShareItemModel', function() {
stime: 1403884258,
storage: 1,
token: 'tehtoken',
- uid_owner: 'root'
+ uid_owner: 'root',
+ hide_download: 0
}, {
displayname_owner: 'root',
expiration: '2015-10-15 00:00:00',
@@ -307,7 +310,8 @@ describe('OC.Share.ShareItemModel', function() {
stime: 1403884509,
storage: 1,
token: 'anothertoken',
- uid_owner: 'root'
+ uid_owner: 'root',
+ hide_download: 1
}]
));
OC.currentUser = 'root';
@@ -320,6 +324,7 @@ describe('OC.Share.ShareItemModel', function() {
var linkShare = model.get('linkShare');
expect(linkShare.isLinkShare).toEqual(true);
expect(linkShare.token).toEqual('tehtoken');
+ expect(linkShare.hideDownload).toEqual(false);
// TODO: check child too
});
@@ -579,6 +584,7 @@ describe('OC.Share.ShareItemModel', function() {
expect(addShareStub.calledOnce).toEqual(true);
expect(addShareStub.firstCall.args[0]).toEqual({
+ hideDownload: false,
password: '',
passwordChanged: false,
permissions: OC.PERMISSION_READ,
@@ -603,6 +609,7 @@ describe('OC.Share.ShareItemModel', function() {
expect(addShareStub.calledOnce).toEqual(true);
expect(addShareStub.firstCall.args[0]).toEqual({
+ hideDownload: false,
password: '',
passwordChanged: false,
permissions: OC.PERMISSION_READ,