diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-11-19 14:19:42 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-11-20 19:46:35 +0100 |
commit | fb8aa31dbf961d23f508eecf1cb44c7dbbac1d70 (patch) | |
tree | 02b4da201381895dba656b9b61cf65f6a3a5cdf7 /apps/files_sharing/js | |
parent | 1bf742c462b238f441d1a6f115a3f489c98f8bb4 (diff) | |
download | nextcloud-server-fb8aa31dbf961d23f508eecf1cb44c7dbbac1d70.tar.gz nextcloud-server-fb8aa31dbf961d23f508eecf1cb44c7dbbac1d70.zip |
Allow to hide download option for folders shared by link
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/public.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index c7169b3ce12..812da7ca5cb 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -50,6 +50,8 @@ OCA.Sharing.PublicApp = { this.initialDir = $('#dir').val(); var token = $('#sharingToken').val(); + var hideDownload = $('#hideDownload').val(); + // file list mode ? if ($el.find('#filestable').length) { @@ -92,6 +94,9 @@ OCA.Sharing.PublicApp = { ] } ); + if (hideDownload === 'true') { + this.fileList._allowSelection = false; + } this.files = OCA.Files.Files; this.files.initialize(); // TODO: move to PublicFileList.initialize() once @@ -192,6 +197,27 @@ OCA.Sharing.PublicApp = { return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params); }; + this.fileList._createRow = function(fileData) { + var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments); + if (hideDownload === 'true') { + this.fileActions.currentFile = $tr.find('td'); + var mime = this.fileActions.getCurrentMimeType(); + var type = this.fileActions.getCurrentType(); + var permissions = this.fileActions.getCurrentPermissions(); + var action = this.fileActions.getDefault(mime, type, permissions); + if (action) { + // remove link href if there is a default action configured (disables downloading when trying to open in a new tab) + $tr.find('a.name').attr('href', '#'); + } + delete this.fileActions.actions.all.Download; + } + return $tr; + }; + + this.fileList.isSelectedDownloadable = function () { + return hideDownload !== 'true'; + }; + this.fileList.getUploadUrl = function(fileName, dir) { if (_.isUndefined(dir)) { dir = this.getCurrentDirectory(); @@ -270,6 +296,10 @@ OCA.Sharing.PublicApp = { e.preventDefault(); OC.redirect(FileList.getDownloadUrl()); }); + + if (hideDownload === 'true') { + this.fileList.$el.find('#headerSelection').remove(); + } } $(document).on('click', '#directLink', function () { |