diff --git a/src/client.js b/src/client.js index ff4c49e65..dc7d8a8a7 100644 --- a/src/client.js +++ b/src/client.js @@ -137,53 +137,52 @@ const parseAclList = (acls) => { return list } -/** @type OC.Plugin */ -const FilesPlugin = { - attach(fileList) { - client = fileList.filesClient - client.addFileInfoParser((response) => { - const data = {} - const props = response.propStat[0].properties - const groupFolderId = props[ACL_PROPERTIES.GROUP_FOLDER_ID] - if (typeof groupFolderId !== 'undefined') { - data.groupFolderId = groupFolderId - } - const aclEnabled = props[ACL_PROPERTIES.PROPERTY_ACL_ENABLED] - if (typeof aclEnabled !== 'undefined') { - data.aclEnabled = !!aclEnabled - } +export function initFilesClient(filesClient) { + client = filesClient; + patchFilesClient(filesClient); +} - const aclCanManage = props[ACL_PROPERTIES.PROPERTY_ACL_CAN_MANAGE] - if (typeof aclCanManage !== 'undefined') { - data.aclCanManage = !!aclCanManage - } +function patchFilesClient(client) { + client.addFileInfoParser((response) => { + const data = {} + const props = response.propStat[0].properties + const groupFolderId = props[ACL_PROPERTIES.GROUP_FOLDER_ID] + if (typeof groupFolderId !== 'undefined') { + data.groupFolderId = groupFolderId + } + const aclEnabled = props[ACL_PROPERTIES.PROPERTY_ACL_ENABLED] + if (typeof aclEnabled !== 'undefined') { + data.aclEnabled = !!aclEnabled + } - const acls = props[ACL_PROPERTIES.PROPERTY_ACL_LIST] || [] - const inheritedAcls = props[ACL_PROPERTIES.PROPERTY_INHERITED_ACL_LIST] || [] + const aclCanManage = props[ACL_PROPERTIES.PROPERTY_ACL_CAN_MANAGE] + if (typeof aclCanManage !== 'undefined') { + data.aclCanManage = !!aclCanManage + } - data.acl = parseAclList(acls) - data.inheritedAcls = parseAclList(inheritedAcls) + const acls = props[ACL_PROPERTIES.PROPERTY_ACL_LIST] || [] + const inheritedAcls = props[ACL_PROPERTIES.PROPERTY_INHERITED_ACL_LIST] || [] - data.acl.map((acl) => { - const inheritedAcl = data.inheritedAcls.find((inheritedAclRule) => inheritedAclRule.mappingType === acl.mappingType && inheritedAclRule.mappingId === acl.mappingId) - if (inheritedAcl) { - acl.permissions = (acl.permissions & acl.mask) | (inheritedAcl.permissions & ~acl.mask) - } - return acl - }) - return data + data.acl = parseAclList(acls) + data.inheritedAcls = parseAclList(inheritedAcls) + + data.acl.map((acl) => { + const inheritedAcl = data.inheritedAcls.find((inheritedAclRule) => inheritedAclRule.mappingType === acl.mappingType && inheritedAclRule.mappingId === acl.mappingId) + if (inheritedAcl) { + acl.permissions = (acl.permissions & acl.mask) | (inheritedAcl.permissions & ~acl.mask) + } + return acl }) + return data + }) - patchClientForNestedPropPatch(client) - }, -}; + patchClientForNestedPropPatch(client) +} (function(OC) { Object.assign(OC.Files.Client, ACL_PROPERTIES) })(window.OC) -OC.Plugins.register('OCA.Files.FileList', FilesPlugin) - class AclDavService { propFind(model) { diff --git a/src/files.js b/src/files.js index 368a3a39f..b191cbf16 100644 --- a/src/files.js +++ b/src/files.js @@ -21,6 +21,7 @@ */ import { generateUrl, imagePath } from '@nextcloud/router' import './client.js' +import {initFilesClient} from "./client"; // eslint-disable-next-line __webpack_nonce__ = btoa(OC.requestToken) @@ -38,6 +39,7 @@ window.addEventListener('DOMContentLoaded', () => { return } import(/* webpackChunkName: "sharing" */'./SharingSidebarApp.js').then((Module) => { + initFilesClient(OC.Files.getClient()); OCA.Sharing.ShareTabSections.registerSection((el, fileInfo) => { if (fileInfo.mountType !== 'group') { return