aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocComponent.tsx
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-06-30 12:09:04 -0400
committersrichman333 <sarah_n_richman@brown.edu>2023-06-30 12:09:04 -0400
commit45e36e459f34a16d8c8f7ae11685d50018e379ab (patch)
tree862aba78d276df5840cee28a7fdc1d6fb29768d0 /src/client/views/DocComponent.tsx
parentf021733defb7899493fbf673e17d4b5f48fd7263 (diff)
fixed inherit parent acls to update shared docs list
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r--src/client/views/DocComponent.tsx35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 6f350e0fc..aa8b145be 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -3,8 +3,8 @@ import { DateField } from '../../fields/DateField';
import { DocListCast, Opt, Doc, ReverseHierarchyMap, HierarchyMapping } from '../../fields/Doc';
import { AclAdmin, AclAugment, AclEdit, AclPrivate, AclReadonly, DocAcl, DocData } from '../../fields/DocSymbols';
import { List } from '../../fields/List';
-import { Cast, ScriptCast, StrCast } from '../../fields/Types';
-import { denormalizeEmail, distributeAcls, GetEffectiveAcl, inheritParentAcls, SharingPermissions } from '../../fields/util';
+import { Cast, DocCast, ScriptCast, StrCast } from '../../fields/Types';
+import { denormalizeEmail, distributeAcls, GetEffectiveAcl, inheritParentAcls, normalizeEmail, SharingPermissions } from '../../fields/util';
import { returnFalse } from '../../Utils';
import { DocUtils } from '../documents/Documents';
import { DocumentType } from '../documents/DocumentTypes';
@@ -12,6 +12,7 @@ import { InteractionUtils } from '../util/InteractionUtils';
import { UndoManager } from '../util/UndoManager';
import { DocumentView } from './nodes/DocumentView';
import { Touchable } from './Touchable';
+import { SharingManager } from '../util/SharingManager';
/// DocComponent returns a generic React base class used by views that don't have 'fieldKey' props (e.g.,CollectionFreeFormDocumentView, DocumentView)
export interface DocComponentProps {
@@ -206,13 +207,22 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
if (effectiveAcl === AclAugment) {
added.map(doc => {
- // if ([AclAdmin, AclEdit].includes(GetEffectiveAcl(doc)) && Doc.ActiveDashboard) inheritParentAcls(Doc.ActiveDashboard, doc);
doc.embedContainer = this.props.Document;
if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.props.Document;
Doc.AddDocToList(targetDataDoc, annotationKey ?? this.annotationKey, doc);
+ const parent = DocCast(doc.embedContainer);
+ doc.embedContainer && inheritParentAcls(parent, doc);
+ for (const key of Object.keys(parent)) {
+ const symbol = ReverseHierarchyMap.get(StrCast(parent[key]))
+ if (symbol && key.startsWith('acl')){
+ const sharePermission = HierarchyMapping.get(symbol.acl!)!.name;
+ const user = SharingManager.Instance?.users.filter(({ user: { email } }) => normalizeEmail(email) == key.slice(4))[0];
+ if (user && sharePermission !== SharingPermissions.None) return Doc.AddDocToList(user.sharingDoc, 'data', doc);
+ }
+ }
});
- } else {
- added
+ } else {
+ added
.filter(doc => [AclAdmin, AclEdit].includes(GetEffectiveAcl(doc)))
.map(doc => {
// only make a pushpin if we have acl's to edit the document
@@ -220,9 +230,18 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
doc._stayInCollection = undefined;
doc.embedContainer = this.props.Document;
if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.rootDoc;
-
- // Doc.ActiveDashboard && inheritParentAcls(Doc.ActiveDashboard, doc);
- });
+ const parent = DocCast(doc.embedContainer);
+ doc.embedContainer && inheritParentAcls(parent, doc);
+ for (const key of Object.keys(Doc.GetProto(parent))) {
+ const symbol = ReverseHierarchyMap.get(StrCast(parent[key]))
+ if (symbol && key.startsWith('acl')){
+ const sharePermission = HierarchyMapping.get(symbol.acl!)!.name;
+ const user = SharingManager.Instance?.users.filter(({ user: { email } }) => normalizeEmail(email) == key.slice(4))[0];
+ if (user && sharePermission !== SharingPermissions.None) return Doc.AddDocToList(user.sharingDoc, 'data', doc);
+ }
+ }
+ });
+
const annoDocs = targetDataDoc[annotationKey ?? this.annotationKey] as List<Doc>;
if (annoDocs instanceof List) annoDocs.push(...added);
else targetDataDoc[annotationKey ?? this.annotationKey] = new List<Doc>(added);