From 4c7c49b6ba0a682d799b57738f2b6e5ce67eb64a Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Wed, 12 Feb 2020 13:04:29 +0100 Subject: [PATCH 1/3] Show inherited acls Signed-off-by: Miloslav Nenadal --- src/client.js | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/client.js b/src/client.js index 52225ed5a..42dcd99a7 100644 --- a/src/client.js +++ b/src/client.js @@ -140,21 +140,20 @@ client.addFileInfoParser(function(response) { data.aclCanManage = !!aclCanManage; } - var acls = props[ACL_PROPERTIES.PROPERTY_ACL_LIST]; - var inheritedAcls = props[ACL_PROPERTIES.PROPERTY_INHERITED_ACL_LIST]; + var acls = props[ACL_PROPERTIES.PROPERTY_ACL_LIST] || []; + var inheritedAcls = props[ACL_PROPERTIES.PROPERTY_INHERITED_ACL_LIST] || []; - if (!_.isUndefined(acls)) { - data.acl = parseAclList(acls); - data.inheritedAcls = parseAclList(inheritedAcls); + data.acl = parseAclList(acls); + data.inheritedAcls = parseAclList(inheritedAcls); + + data.acl.map((acl) => { + let 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; + }) - data.acl.map((acl) => { - let 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); @@ -167,8 +166,9 @@ class AclDavService { } ).then((status, fileInfo) => { if (fileInfo) { let acls = [] + let existingMappings = {}; for ( let i in fileInfo.acl ) { - let acl = new Rule() + let acl = new Rule(); acl.fromValues( fileInfo.acl[i].mappingType, fileInfo.acl[i].mappingId, @@ -177,6 +177,26 @@ class AclDavService { fileInfo.acl[i].permissions, ) acls.push(acl); + + if (existingMappings[fileInfo.acl[i].mappingType] == null) { + existingMappings[fileInfo.acl[i].mappingType] = new Set(); + } + existingMappings[fileInfo.acl[i].mappingType].add(fileInfo.acl[i].mappingId); + } + for ( let i in fileInfo.inheritedAcls ) { + if (existingMappings[fileInfo.inheritedAcls[i].mappingType] != null && existingMappings[fileInfo.inheritedAcls[i].mappingType].has(fileInfo.inheritedAcls[i].mappingId)) { + continue; + } + + let acl = new Rule(); + acl.fromValues( + fileInfo.inheritedAcls[i].mappingType, + fileInfo.inheritedAcls[i].mappingId, + fileInfo.inheritedAcls[i].mappingDisplayName, + fileInfo.inheritedAcls[i].mask, + fileInfo.inheritedAcls[i].permissions, + ) + acls.push(acl); } return { acls, From 6ad20ae475f48cd3354f9adba1c6e9ae0182bdff Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Tue, 18 Feb 2020 09:35:53 +0100 Subject: [PATCH 2/3] Improve inherited acls ui - inherited acls cannot be removed - if non inherited acl is removed, inherited acl takes it's place if any Signed-off-by: Miloslav Nenadal --- src/client.js | 27 ++++++++++++--------------- src/components/SharingSidebarView.vue | 9 ++++++++- src/model/Rule.js | 12 +++++++++++- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/client.js b/src/client.js index 42dcd99a7..f9ef13a18 100644 --- a/src/client.js +++ b/src/client.js @@ -165,8 +165,8 @@ class AclDavService { properties: [ACL_PROPERTIES.PROPERTY_ACL_LIST, ACL_PROPERTIES.PROPERTY_INHERITED_ACL_LIST, ACL_PROPERTIES.GROUP_FOLDER_ID, ACL_PROPERTIES.PROPERTY_ACL_ENABLED, ACL_PROPERTIES.PROPERTY_ACL_CAN_MANAGE] } ).then((status, fileInfo) => { if (fileInfo) { - let acls = [] - let existingMappings = {}; + let aclsById = {}; + let inheritedAclsById = {}; for ( let i in fileInfo.acl ) { let acl = new Rule(); acl.fromValues( @@ -176,18 +176,9 @@ class AclDavService { fileInfo.acl[i].mask, fileInfo.acl[i].permissions, ) - acls.push(acl); - - if (existingMappings[fileInfo.acl[i].mappingType] == null) { - existingMappings[fileInfo.acl[i].mappingType] = new Set(); - } - existingMappings[fileInfo.acl[i].mappingType].add(fileInfo.acl[i].mappingId); + aclsById[acl.getUniqueMappingIdentifier()] = acl; } for ( let i in fileInfo.inheritedAcls ) { - if (existingMappings[fileInfo.inheritedAcls[i].mappingType] != null && existingMappings[fileInfo.inheritedAcls[i].mappingType].has(fileInfo.inheritedAcls[i].mappingId)) { - continue; - } - let acl = new Rule(); acl.fromValues( fileInfo.inheritedAcls[i].mappingType, @@ -195,11 +186,17 @@ class AclDavService { fileInfo.inheritedAcls[i].mappingDisplayName, fileInfo.inheritedAcls[i].mask, fileInfo.inheritedAcls[i].permissions, - ) - acls.push(acl); + true + ); + let id = acl.getUniqueMappingIdentifier(); + inheritedAclsById[id] = acl; + if (aclsById[id] == null) { + aclsById[id] = acl; + } } return { - acls, + acls: Object.values(aclsById), + inheritedAclsById, aclEnabled: fileInfo.aclEnabled, aclCanManage: fileInfo.aclCanManage, groupFolderId: fileInfo.groupFolderId diff --git a/src/components/SharingSidebarView.vue b/src/components/SharingSidebarView.vue index e24fd9b2a..6555e8533 100644 --- a/src/components/SharingSidebarView.vue +++ b/src/components/SharingSidebarView.vue @@ -90,7 +90,7 @@ - @@ -140,6 +140,7 @@ if (data.acls) { this.list = data.acls; } + this.inheritedAclsById = data.inheritedAclsById; this.aclEnabled = data.aclEnabled; this.aclCanManage = data.aclCanManage; this.groupFolderId = data.groupFolderId; @@ -229,6 +230,10 @@ } client.propPatch(this.model, list).then(() => { this.list.splice(index, 1); + const inheritedAcl = this.inheritedAclsById[rule.getUniqueMappingIdentifier()]; + if (inheritedAcl != null) { + this.list.splice(index, 0, inheritedAcl); + } }); }, @@ -237,6 +242,7 @@ const inherit = ($event < 2); const allow = ($event & (0b01)) === 1; const bit = BinaryTools.firstHigh(permission); + item = item.clone(); if (inherit) { item.mask = BinaryTools.clear(item.mask, bit) // TODO check if: we can ignore permissions, since they are inherited @@ -248,6 +254,7 @@ item.permissions = BinaryTools.clear(item.permissions, bit) } } + item.inherited = false; Vue.set(this.list, index, item) client.propPatch(this.model, this.list).then(() => { // TODO block UI during save diff --git a/src/model/Rule.js b/src/model/Rule.js index 58a23c1d2..520b10dc1 100644 --- a/src/model/Rule.js +++ b/src/model/Rule.js @@ -35,12 +35,13 @@ export default class Rule { this.permissions = props[PROPERTIES.PROPERTY_ACL_PERMISSIONS]; } - fromValues(mappingType, mappingId, mappingDisplayName, mask = 0, permissions = 31) { + fromValues(mappingType, mappingId, mappingDisplayName, mask = 0, permissions = 31, inherited = false) { this.mappingType = mappingType; this.mappingId = mappingId; this.mappingDisplayName = mappingDisplayName; this.mask = mask; this.permissions = permissions; + this.inherited = inherited; } getProperties() { @@ -56,4 +57,13 @@ export default class Rule { return this.mappingType + ':' + this.mappingId; } + clone() { + let rule = new Rule(); + Object.getOwnPropertyNames(this) + .forEach(prop => { + rule[prop] = this[prop]; + }) + + return rule; + } } From 1d0783c21d56f4cc5f421cf8a1f66149e7d18e08 Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Wed, 11 Mar 2020 12:10:01 +0100 Subject: [PATCH 3/3] Change opacity level for inherited permissions Signed-off-by: Miloslav Nenadal --- src/components/AclStateButton.vue | 8 ++++++-- src/components/SharingSidebarView.vue | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/AclStateButton.vue b/src/components/AclStateButton.vue index 60d38e95d..43438b6be 100644 --- a/src/components/AclStateButton.vue +++ b/src/components/AclStateButton.vue @@ -27,8 +27,8 @@
- - + +
@@ -47,6 +47,10 @@ name: 'AclStateButton', components: {PopoverMenu}, props: { + inherited: { + type: Boolean, + default: false + }, state: { type: Number, default: STATES.INHERIT_DENY diff --git a/src/components/SharingSidebarView.vue b/src/components/SharingSidebarView.vue index 6555e8533..8ab06d5db 100644 --- a/src/components/SharingSidebarView.vue +++ b/src/components/SharingSidebarView.vue @@ -72,22 +72,27 @@