Skip to content

Commit b150d27

Browse files
authored
Merge pull request #12531 from nextcloud/bugfix/noid/hide-download-folders
Allow to hide download option for folders shared by link
2 parents 1bf742c + 78056a3 commit b150d27

File tree

6 files changed

+66
-42
lines changed

6 files changed

+66
-42
lines changed

apps/files/js/fileactions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@
371371
}, false, context);
372372

373373
$el.addClass('permanent');
374+
374375
},
375376

376377
/**

apps/files_sharing/js/public.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ OCA.Sharing.PublicApp = {
5050
this.initialDir = $('#dir').val();
5151

5252
var token = $('#sharingToken').val();
53+
var hideDownload = $('#hideDownload').val();
54+
5355

5456
// file list mode ?
5557
if ($el.find('#filestable').length) {
@@ -92,6 +94,9 @@ OCA.Sharing.PublicApp = {
9294
]
9395
}
9496
);
97+
if (hideDownload === 'true') {
98+
this.fileList._allowSelection = false;
99+
}
95100
this.files = OCA.Files.Files;
96101
this.files.initialize();
97102
// TODO: move to PublicFileList.initialize() once
@@ -192,6 +197,27 @@ OCA.Sharing.PublicApp = {
192197
return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params);
193198
};
194199

200+
this.fileList._createRow = function(fileData) {
201+
var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments);
202+
if (hideDownload === 'true') {
203+
this.fileActions.currentFile = $tr.find('td');
204+
var mime = this.fileActions.getCurrentMimeType();
205+
var type = this.fileActions.getCurrentType();
206+
var permissions = this.fileActions.getCurrentPermissions();
207+
var action = this.fileActions.getDefault(mime, type, permissions);
208+
209+
// Remove the link. This means that files without a default action fail hard
210+
$tr.find('a.name').attr('href', '#');
211+
212+
this.fileActions.actions.all = {};
213+
}
214+
return $tr;
215+
};
216+
217+
this.fileList.isSelectedDownloadable = function () {
218+
return hideDownload !== 'true';
219+
};
220+
195221
this.fileList.getUploadUrl = function(fileName, dir) {
196222
if (_.isUndefined(dir)) {
197223
dir = this.getCurrentDirectory();
@@ -270,6 +296,11 @@ OCA.Sharing.PublicApp = {
270296
e.preventDefault();
271297
OC.redirect(FileList.getDownloadUrl());
272298
});
299+
300+
if (hideDownload === 'true') {
301+
this.fileList.$el.find('#headerSelection').remove();
302+
this.fileList.$el.find('.summary').find('td:first-child').remove();
303+
}
273304
}
274305

275306
$(document).on('click', '#directLink', function () {

core/js/share/sharedialoglinkshareview_popover_menu.handlebars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
</span>
3838
</li>
3939
{{/if}}
40-
{{#if showHideDownloadCheckbox}}
4140
<li>
4241
<span class="menuitem">
4342
<span class="icon-loading-small hidden"></span>
@@ -46,7 +45,6 @@
4645
<label for="sharingDialogHideDownload-{{cid}}">{{hideDownloadLabel}}</label>
4746
</span>
4847
</li>
49-
{{/if}}
5048
{{#if showPasswordCheckBox}}
5149
<li>
5250
<span class="menuitem">

core/js/sharedialoglinkshareview.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,6 @@
868868
var isTalkEnabled = oc_appswebroots['spreed'] !== undefined;
869869
var sendPasswordByTalk = share.sendPasswordByTalk;
870870

871-
var showHideDownloadCheckbox = !this.model.isFolder();
872871
var hideDownload = share.hideDownload;
873872

874873
var maxDate = null;
@@ -905,7 +904,6 @@
905904
shareNote: share.note,
906905
hasNote: share.note !== '',
907906
maxDate: maxDate,
908-
showHideDownloadCheckbox: showHideDownloadCheckbox,
909907
hideDownload: hideDownload,
910908
isExpirationEnforced: isExpirationEnforced,
911909
}

0 commit comments

Comments
 (0)