aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/share.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/src/share.js')
-rw-r--r--apps/files_sharing/src/share.js76
1 files changed, 44 insertions, 32 deletions
diff --git a/apps/files_sharing/src/share.js b/apps/files_sharing/src/share.js
index abcb444cb48..cdc3c917dfa 100644
--- a/apps/files_sharing/src/share.js
+++ b/apps/files_sharing/src/share.js
@@ -1,16 +1,15 @@
-/* eslint-disable */
-/*
- * Copyright (c) 2014
- *
- * This file is licensed under the Affero General Public License version 3
- * or later.
- *
- * See the COPYING-README file.
- *
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2011-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
+/* eslint-disable */
import escapeHTML from 'escape-html'
+import { ShareType } from '@nextcloud/sharing'
+import { getCapabilities } from '@nextcloud/capabilities'
+
(function() {
_.extend(OC.Files.Client, {
@@ -46,7 +45,7 @@ import escapeHTML from 'escape-html'
*/
attach: function(fileList) {
// core sharing is disabled/not loaded
- if (!OC.Share) {
+ if (!getCapabilities().files_sharing?.api_enabled) {
return
}
if (fileList.id === 'trashbin' || fileList.id === 'files.public') {
@@ -65,7 +64,15 @@ import escapeHTML from 'escape-html'
delete fileActions.actions.all.Details
delete fileActions.actions.all.Goto
}
+ if (_.isFunction(fileData.canDownload) && !fileData.canDownload()) {
+ delete fileActions.actions.all.Download
+ if ((fileData.permissions & OC.PERMISSION_UPDATE) === 0) {
+ // neither move nor copy is allowed, remove the action completely
+ delete fileActions.actions.all.MoveCopy
+ }
+ }
tr.attr('data-share-permissions', sharePermissions)
+ tr.attr('data-share-attributes', JSON.stringify(fileData.shareAttributes))
if (fileData.shareOwner) {
tr.attr('data-share-owner', fileData.shareOwner)
tr.attr('data-share-owner-id', fileData.shareOwnerId)
@@ -86,6 +93,7 @@ import escapeHTML from 'escape-html'
var oldElementToFile = fileList.elementToFile
fileList.elementToFile = function($el) {
var fileInfo = oldElementToFile.apply(this, arguments)
+ fileInfo.shareAttributes = JSON.parse($el.attr('data-share-attributes') || '[]')
fileInfo.sharePermissions = $el.attr('data-share-permissions') || undefined
fileInfo.shareOwner = $el.attr('data-share-owner') || undefined
fileInfo.shareOwnerId = $el.attr('data-share-owner-id') || undefined
@@ -140,28 +148,30 @@ import escapeHTML from 'escape-html'
_.each($files, function(file) {
var $tr = $(file)
- var shareTypes = $tr.attr('data-share-types') || ''
+ var shareTypesStr = $tr.attr('data-share-types') || ''
var shareOwner = $tr.attr('data-share-owner')
- if (shareTypes || shareOwner) {
+ if (shareTypesStr || shareOwner) {
var hasLink = false
var hasShares = false
- _.each(shareTypes.split(',') || [], function(shareType) {
- shareType = parseInt(shareType, 10)
- if (shareType === OC.Share.SHARE_TYPE_LINK) {
+ _.each(shareTypesStr.split(',') || [], function(shareTypeStr) {
+ let shareType = parseInt(shareTypeStr, 10)
+ if (shareType === ShareType.Link) {
hasLink = true
- } else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
+ } else if (shareType === ShareType.Email) {
hasLink = true
- } else if (shareType === OC.Share.SHARE_TYPE_USER) {
+ } else if (shareType === ShareType.User) {
+ hasShares = true
+ } else if (shareType === ShareType.Group) {
hasShares = true
- } else if (shareType === OC.Share.SHARE_TYPE_GROUP) {
+ } else if (shareType === ShareType.Remote) {
hasShares = true
- } else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
+ } else if (shareType === ShareType.RemoteGroup) {
hasShares = true
- } else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
+ } else if (shareType === ShareType.Team) {
hasShares = true
- } else if (shareType === OC.Share.SHARE_TYPE_ROOM) {
+ } else if (shareType === ShareType.Room) {
hasShares = true
- } else if (shareType === OC.Share.SHARE_TYPE_DECK) {
+ } else if (shareType === ShareType.Deck) {
hasShares = true
}
})
@@ -192,8 +202,8 @@ import escapeHTML from 'escape-html'
permissions: OC.PERMISSION_ALL,
iconClass: function(fileName, context) {
var shareType = parseInt(context.$file.data('share-types'), 10)
- if (shareType === OC.Share.SHARE_TYPE_EMAIL
- || shareType === OC.Share.SHARE_TYPE_LINK) {
+ if (shareType === ShareType.Email
+ || shareType === ShareType.Link) {
return 'icon-public'
}
return 'icon-shared'
@@ -206,6 +216,10 @@ import escapeHTML from 'escape-html'
},
type: OCA.Files.FileActions.TYPE_INLINE,
actionHandler: function(fileName, context) {
+ // details view disabled in some share lists
+ if (!fileList._detailsView) {
+ return
+ }
// do not open sidebar if permission is set and equal to 0
var permissions = parseInt(context.$file.data('share-permissions'), 10)
if (isNaN(permissions) || permissions > 0) {
@@ -288,7 +302,11 @@ import escapeHTML from 'escape-html'
var iconClass = 'icon-shared'
action.removeClass('shared-style')
// update folder icon
- if (type === 'dir' && (hasShares || hasLink || ownerId)) {
+ var isEncrypted = $tr.attr('data-e2eencrypted')
+ if (type === 'dir' && isEncrypted === 'true') {
+ shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted')
+ $tr.attr('data-icon', shareFolderIcon)
+ } else if (type === 'dir' && (hasShares || hasLink || ownerId)) {
if (typeof mountType !== 'undefined' && mountType !== 'shared-root' && mountType !== 'shared') {
shareFolderIcon = OC.MimeType.getIconUrl('dir-' + mountType)
} else if (hasLink) {
@@ -299,13 +317,9 @@ import escapeHTML from 'escape-html'
$tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')')
$tr.attr('data-icon', shareFolderIcon)
} else if (type === 'dir') {
- var isEncrypted = $tr.attr('data-e2eencrypted')
// FIXME: duplicate of FileList._createRow logic for external folder,
// need to refactor the icon logic into a single code path eventually
- if (isEncrypted === 'true') {
- shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted')
- $tr.attr('data-icon', shareFolderIcon)
- } else if (mountType && mountType.indexOf('external') === 0) {
+ if (mountType && mountType.indexOf('external') === 0) {
shareFolderIcon = OC.MimeType.getIconUrl('dir-external')
$tr.attr('data-icon', shareFolderIcon)
} else {
@@ -335,7 +349,6 @@ import escapeHTML from 'escape-html'
avatarElement.each(function() {
$(this).avatar($(this).data('username'), 32)
})
- action.find('span[title]').tooltip({ placement: 'top' })
}
} else {
action.html('<span class="hidden-visually">' + t('files_sharing', 'Shared') + '</span>').prepend(icon)
@@ -469,7 +482,6 @@ import escapeHTML from 'escape-html'
avatarElement.each(function() {
$(this).avatar($(this).data('username'), 32)
})
- action.find('span[title]').tooltip({ placement: 'top' })
}
} else {
action.html('<span class="hidden-visually">' + t('files_sharing', 'Shared') + '</span>').prepend(icon)