diff options
author | bobzel <zzzman@gmail.com> | 2023-07-07 15:57:51 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-07-07 15:57:51 -0400 |
commit | cf88809ea2299395db70ce608c193df7f24f0fb2 (patch) | |
tree | 57206a4b1281410a4371c5ae4616d388e1d694b7 /src/client/views/DocComponent.tsx | |
parent | 0f0d646e45de42c7f84f6fa316c80d1413f92e5c (diff) |
fixed self-ownership of copied Docs created by someone else. prevent dash from being pasted into itself. fixed inheritance of acls
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r-- | src/client/views/DocComponent.tsx | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index 44af51341..422d2d6d7 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -190,36 +190,24 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>() } const added = docs; if (added.length) { - const aclKeys = Object.keys(Doc.GetProto(this.props.Document)[DocAcl] ?? {}); - - GetEffectiveAcl(this.rootDoc) === AclAdmin && - aclKeys.forEach(key => + Object.keys(Doc.GetProto(this.rootDoc)[DocAcl]) // apply all collection acls (except pseudo-acl 'Me') to each added doc + .filter(key => key !== 'acl-Me') + .forEach(key => added.forEach(d => { - if (key != 'acl-Me') { - const permissionString = StrCast(Doc.GetProto(this.props.Document)[key]); - const permissionSymbol = ReverseHierarchyMap.get(permissionString)?.acl; - const permission = permissionSymbol && HierarchyMapping.get(permissionSymbol)?.name; - distributeAcls(key, permission ?? SharingPermissions.Augment, Doc.GetProto(d)); - } + const permissionString = StrCast(Doc.GetProto(this.props.Document)[key]); + const permissionSymbol = ReverseHierarchyMap.get(permissionString)?.acl; + const permission = permissionSymbol && HierarchyMapping.get(permissionSymbol)?.name; + distributeAcls(key, permission ?? SharingPermissions.Augment, d); }) ); - if (effectiveAcl === AclAugment) { + if ([AclAugment, AclEdit, AclAdmin].includes(effectiveAcl)) { added.map(doc => { + doc._dragOnlyWithinContainer = undefined; if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.rootDoc; - Doc.AddDocToList(targetDataDoc, annotationKey ?? this.annotationKey, doc); - Doc.SetContainer(doc, targetDataDoc); + Doc.SetContainer(doc, this.rootDoc); inheritParentAcls(targetDataDoc, doc); }); - } else { - added - .filter(doc => [AclAdmin, AclEdit].includes(GetEffectiveAcl(doc))) - .map(doc => { - doc._dragOnlyWithinContainer = undefined; - if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.rootDoc; - Doc.SetContainer(doc, this.rootDoc); - inheritParentAcls(targetDataDoc, doc); - }); const annoDocs = targetDataDoc[annotationKey ?? this.annotationKey] as List<Doc>; if (annoDocs instanceof List) annoDocs.push(...added.filter(add => !annoDocs.includes(add))); |