aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js/share.js
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2016-10-10 10:15:42 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-07 14:58:45 +0100
commit9e5e120ef9869b7c52d90e85782ec83a9217275d (patch)
tree139a9c041b3436573550115856720252099601c0 /apps/files_sharing/js/share.js
parentbc1cb8a6d09d97df93b7914e020759eb7df73df1 (diff)
downloadnextcloud-server-9e5e120ef9869b7c52d90e85782ec83a9217275d.tar.gz
nextcloud-server-9e5e120ef9869b7c52d90e85782ec83a9217275d.zip
refactor share permission logic into own method to reuse it for the share tab
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/files_sharing/js/share.js')
-rw-r--r--apps/files_sharing/js/share.js35
1 files changed, 22 insertions, 13 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 7629124ec44..2119db0b71e 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -36,19 +36,7 @@
var oldCreateRow = fileList._createRow;
fileList._createRow = function(fileData) {
var tr = oldCreateRow.apply(this, arguments);
- var sharePermissions = fileData.permissions;
- if (fileData.mountType && fileData.mountType === "external-root"){
- // for external storages we can't use the permissions of the mountpoint
- // instead we show all permissions and only use the share permissions from the mountpoint to handle resharing
- sharePermissions = sharePermissions | (OC.PERMISSION_ALL & ~OC.PERMISSION_SHARE);
- }
- if (fileData.type === 'file') {
- // files can't be shared with delete permissions
- sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE;
-
- // create permissions don't mean anything for files
- sharePermissions = sharePermissions & ~OC.PERMISSION_CREATE;
- }
+ var sharePermissions = OCA.Sharing.Util.getSharePermissions(fileData);
tr.attr('data-share-permissions', sharePermissions);
if (fileData.shareOwner) {
tr.attr('data-share-owner', fileData.shareOwner);
@@ -251,6 +239,27 @@
text += ', +' + (count - maxRecipients);
}
return text;
+ },
+
+ /**
+ * @param {Array} fileData
+ * @returns {String}
+ */
+ getSharePermissions: function(fileData) {
+ var sharePermissions = fileData.permissions;
+ if (fileData.mountType && fileData.mountType === "external-root"){
+ // for external storages we can't use the permissions of the mountpoint
+ // instead we show all permissions and only use the share permissions from the mountpoint to handle resharing
+ sharePermissions = sharePermissions | (OC.PERMISSION_ALL & ~OC.PERMISSION_SHARE);
+ }
+ if (fileData.type === 'file') {
+ // files can't be shared with delete permissions
+ sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE;
+
+ // create permissions don't mean anything for files
+ sharePermissions = sharePermissions & ~OC.PERMISSION_CREATE;
+ }
+ return sharePermissions;
}
};
})();