Merge pull request #10692 from nextcloud/deleted-share-remove-actions
Do not show action menu if no actions are available
This commit is contained in:
commit
2b5ec3755e
|
@ -558,7 +558,27 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this._renderMenuTrigger($tr, context);
|
function objectValues(obj) {
|
||||||
|
var res = [];
|
||||||
|
for (var i in obj) {
|
||||||
|
if (obj.hasOwnProperty(i)) {
|
||||||
|
res.push(obj[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// polyfill
|
||||||
|
if (!Object.values) {
|
||||||
|
Object.values = objectValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
var menuActions = Object.values(this.actions.all).filter(function (action) {
|
||||||
|
return action.type !== OCA.Files.FileActions.TYPE_INLINE;
|
||||||
|
});
|
||||||
|
// do not render the menu if nothing is in it
|
||||||
|
if (menuActions.length > 0) {
|
||||||
|
this._renderMenuTrigger($tr, context);
|
||||||
|
}
|
||||||
|
|
||||||
if (triggerEvent){
|
if (triggerEvent){
|
||||||
fileList.$fileList.trigger(jQuery.Event("fileActionsReady", {fileList: fileList, $files: $tr}));
|
fileList.$fileList.trigger(jQuery.Event("fileActionsReady", {fileList: fileList, $files: $tr}));
|
||||||
|
|
|
@ -42,14 +42,16 @@
|
||||||
var fileActions = fileList.fileActions;
|
var fileActions = fileList.fileActions;
|
||||||
var oldCreateRow = fileList._createRow;
|
var oldCreateRow = fileList._createRow;
|
||||||
fileList._createRow = function(fileData) {
|
fileList._createRow = function(fileData) {
|
||||||
|
|
||||||
if (fileData.permissions === 0) {
|
|
||||||
// no permission, disabling sidebar
|
|
||||||
delete fileActions.actions.all.Details;
|
|
||||||
}
|
|
||||||
|
|
||||||
var tr = oldCreateRow.apply(this, arguments);
|
var tr = oldCreateRow.apply(this, arguments);
|
||||||
var sharePermissions = OCA.Sharing.Util.getSharePermissions(fileData);
|
var sharePermissions = OCA.Sharing.Util.getSharePermissions(fileData);
|
||||||
|
|
||||||
|
if (fileData.permissions === 0) {
|
||||||
|
// no permission, disabling sidebar
|
||||||
|
delete fileActions.actions.all.Comment;
|
||||||
|
delete fileActions.actions.all.Details;
|
||||||
|
delete fileActions.actions.all.Goto;
|
||||||
|
}
|
||||||
tr.attr('data-share-permissions', sharePermissions);
|
tr.attr('data-share-permissions', sharePermissions);
|
||||||
if (fileData.shareOwner) {
|
if (fileData.shareOwner) {
|
||||||
tr.attr('data-share-owner', fileData.shareOwner);
|
tr.attr('data-share-owner', fileData.shareOwner);
|
||||||
|
|
Loading…
Reference in New Issue