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

Allow to hide download option for folders shared by link #12531

Merged
merged 4 commits into from
Nov 20, 2018
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
1 change: 1 addition & 0 deletions apps/files/js/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
}, false, context);

$el.addClass('permanent');

},

/**
Expand Down
31 changes: 31 additions & 0 deletions apps/files_sharing/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

// Remove the link. This means that files without a default action fail hard
$tr.find('a.name').attr('href', '#');

this.fileActions.actions.all = {};
}
return $tr;
};

this.fileList.isSelectedDownloadable = function () {
return hideDownload !== 'true';
};

this.fileList.getUploadUrl = function(fileName, dir) {
if (_.isUndefined(dir)) {
dir = this.getCurrentDirectory();
Expand Down Expand Up @@ -270,6 +296,11 @@ OCA.Sharing.PublicApp = {
e.preventDefault();
OC.redirect(FileList.getDownloadUrl());
});

if (hideDownload === 'true') {
this.fileList.$el.find('#headerSelection').remove();
this.fileList.$el.find('.summary').find('td:first-child').remove();
}
}

$(document).on('click', '#directLink', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
</span>
</li>
{{/if}}
{{#if showHideDownloadCheckbox}}
<li>
<span class="menuitem">
<span class="icon-loading-small hidden"></span>
Expand All @@ -46,7 +45,6 @@
<label for="sharingDialogHideDownload-{{cid}}">{{hideDownloadLabel}}</label>
</span>
</li>
{{/if}}
{{#if showPasswordCheckBox}}
<li>
<span class="menuitem">
Expand Down
2 changes: 0 additions & 2 deletions core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@
var isTalkEnabled = oc_appswebroots['spreed'] !== undefined;
var sendPasswordByTalk = share.sendPasswordByTalk;

var showHideDownloadCheckbox = !this.model.isFolder();
var hideDownload = share.hideDownload;

var maxDate = null;
Expand Down Expand Up @@ -905,7 +904,6 @@
shareNote: share.note,
hasNote: share.note !== '',
maxDate: maxDate,
showHideDownloadCheckbox: showHideDownloadCheckbox,
hideDownload: hideDownload,
isExpirationEnforced: isExpirationEnforced,
}
Expand Down
Loading