From b082278f0404efc65b72d7cf0516d2de52f1393b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 15 Aug 2018 09:39:12 +0200 Subject: [PATCH 1/2] Do not show action menu if no actions are available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/fileactions.js | 8 +++++++- apps/files_sharing/js/share.js | 12 +++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 3623663ed6..ac3afba038 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -558,7 +558,13 @@ } }); - this._renderMenuTrigger($tr, context); + 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){ fileList.$fileList.trigger(jQuery.Event("fileActionsReady", {fileList: fileList, $files: $tr})); diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 0f8dc58a85..68529fd882 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -42,14 +42,16 @@ var fileActions = fileList.fileActions; var oldCreateRow = fileList._createRow; fileList._createRow = function(fileData) { - - if (fileData.permissions === 0) { - // no permission, disabling sidebar - delete fileActions.actions.all.Details; - } var tr = oldCreateRow.apply(this, arguments); 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); if (fileData.shareOwner) { tr.attr('data-share-owner', fileData.shareOwner); From 5647f85a3cc88e8b650164d56839448abb5e0229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 16 Aug 2018 07:43:57 +0200 Subject: [PATCH 2/2] Object.values polyfill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/fileactions.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index ac3afba038..8ce8eddb0b 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -558,6 +558,20 @@ } }); + 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; });