From c5023c71527b9aa5dd788beafee55b895c682158 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Fri, 7 Jul 2023 10:53:30 -0400 Subject: default is to override nested docs --- src/client/util/SharingManager.tsx | 6 +++--- src/fields/util.ts | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 64b2bb5b8..67b4d9d1a 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -79,7 +79,7 @@ export class SharingManager extends React.Component<{}> { @observable private showGroupOptions: boolean = false; // // whether to show groups as options when sharing (in the react-select component) private populating: boolean = false; // whether the list of users is populating or not @observable private layoutDocAcls: boolean = false; // whether the layout doc or data doc's acls are to be used - @observable private overrideNested: boolean = false; // whether child docs in a collection/dashboard should be changed to be less private + @observable private overrideNested: boolean = false; // whether child docs in a collection/dashboard should be changed to be less private - initially selected so default is override @observable private myDocAcls: boolean = false; // whether the My Docs checkbox is selected or not // private get linkVisible() { @@ -94,6 +94,7 @@ export class SharingManager extends React.Component<{}> { DictationOverlay.Instance.hasActiveModal = true; this.isOpen = this.targetDoc !== undefined; this.permissions = SharingPermissions.Augment; + this.overrideNested = true; }); }; @@ -202,7 +203,7 @@ export class SharingManager extends React.Component<{}> { const isDashboard = DocListCast(Doc.MyDashboards.data).indexOf(target) !== -1; // setting the same acl for a docs within the doc being shared if they haven't been set yet - // or if the 'Override Private' checkbox is selected + // or if the 'Override Nested' checkbox is selected var childDocs = DocListCast(target.data); childDocs.map(doc => { if (this.overrideNested || doc[acl] == undefined) { @@ -457,7 +458,6 @@ export class SharingManager extends React.Component<{}> { ); this.layoutDocAcls = false; - this.overrideNested = false; this.selectedUsers = null; } }; diff --git a/src/fields/util.ts b/src/fields/util.ts index fc0057827..17eb47222 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -287,15 +287,16 @@ export function distributeAcls(key: string, acl: SharingPermissions, target: Doc let layoutDocChanged = false; // determines whether fetchProto should be called or not (i.e. is there a change that should be reflected in target[AclSym]) // if it is inheriting from a collection, it only inherits if A) the key doesn't already exist or B) the right being inherited is more restrictive - if (GetEffectiveAcl(target) === AclAdmin && (!inheritingFromCollection || !target[key] || ReverseHierarchyMap.get(StrCast(target[key]))!.level > ReverseHierarchyMap.get(acl)!.level)) { - target[key] = acl; - layoutDocChanged = true; - if (isDashboard) { - DocListCastAsync(target[Doc.LayoutFieldKey(target)]).then(docs => { - docs?.forEach(d => distributeAcls(key, acl, d, inheritingFromCollection, visited)); - }); - } - } + // taken care of in SharingManager now so that users can decide if they want nested docs changed + // if (GetEffectiveAcl(target) === AclAdmin && (!inheritingFromCollection || !target[key] || ReverseHierarchyMap.get(StrCast(target[key]))!.level > ReverseHierarchyMap.get(acl)!.level)) { + // target[key] = acl; + // layoutDocChanged = true; + // if (isDashboard) { + // DocListCastAsync(target[Doc.LayoutFieldKey(target)]).then(docs => { + // docs?.forEach(d => distributeAcls(key, acl, d, inheritingFromCollection, visited)); + // }); + // } + // } let dataDocChanged = false; const dataDoc = target[DocData]; @@ -309,10 +310,11 @@ export function distributeAcls(key: string, acl: SharingPermissions, target: Doc LinkManager.Links(dataDoc).forEach(link => distributeAcls(key, acl, link, inheritingFromCollection, visited)); // maps over the children of the document - DocListCast(dataDoc[Doc.LayoutFieldKey(dataDoc)]).forEach(d => { - distributeAcls(key, acl, d, inheritingFromCollection, visited); - distributeAcls(key, acl, d[DocData], inheritingFromCollection, visited); - }); + // taken care of in SharingManager now so that users can decide if they want nested docs changed + // DocListCast(dataDoc[Doc.LayoutFieldKey(dataDoc)]).forEach(d => { + // distributeAcls(key, acl, d, inheritingFromCollection, visited); + // distributeAcls(key, acl, d[DocData], inheritingFromCollection, visited); + // }); // maps over the annotations of the document DocListCast(dataDoc[Doc.LayoutFieldKey(dataDoc) + '_annotations']).forEach(d => { -- cgit v1.2.3-70-g09d2 From 3dde1b790b0f29c0dca4d35ad91c1f389efe831a Mon Sep 17 00:00:00 2001 From: srichman333 Date: Fri, 7 Jul 2023 11:39:04 -0400 Subject: changing + inheriting layout acls fix --- src/fields/util.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/fields/util.ts b/src/fields/util.ts index 17eb47222..cc29c7df9 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -128,13 +128,13 @@ export function denormalizeEmail(email: string) { * Copies parent's acl fields to the child */ export function inheritParentAcls(parent: Doc, child: Doc) { - for (const key of Object.keys(parent)) { + for (const key of Object.keys(Doc.GetProto(parent))) { // if the default acl mode is private, then don't inherit the acl-Public permission, but set it to private. - // const permission: string = key === 'acl-Public' && Doc.defaultAclPrivate ? AclPrivate : parent[key]; - const symbol = ReverseHierarchyMap.get(StrCast(parent[key])); + // const permission: string = key === 'acl-Public' && Doc.defaultAclPrivate ? AclPrivate : Doc.GetProto(parent)[key]; + const symbol = ReverseHierarchyMap.get(StrCast(Doc.GetProto(parent)[key])); if (symbol) { const sharePermission = HierarchyMapping.get(symbol.acl!)!.name; - key.startsWith('acl') && distributeAcls(key, sharePermission, child); + key.startsWith('acl') && distributeAcls(key, sharePermission, Doc.GetProto(child)); } } } @@ -277,10 +277,10 @@ export function distributeAcls(key: string, acl: SharingPermissions, target: Doc if (!target || visited.includes(target)) return; if ((target._type_collection === CollectionViewType.Docking && visited.length > 1) || Doc.GetProto(visited[0]) !== Doc.GetProto(target)) { target[key] = acl; - if (target !== Doc.GetProto(target)) { - //apparently we can't call updateCachedAcls twice (once for the main dashboard, and again for the nested dashboard...???) - updateCachedAcls(target); - } + // if (target !== Doc.GetProto(target)) { + // //apparently we can't call updateCachedAcls twice (once for the main dashboard, and again for the nested dashboard...???) + // updateCachedAcls(target); + // } //return; } visited.push(target); @@ -301,10 +301,12 @@ export function distributeAcls(key: string, acl: SharingPermissions, target: Doc let dataDocChanged = false; const dataDoc = target[DocData]; if (dataDoc && (!inheritingFromCollection || !dataDoc[key] || ReverseHierarchyMap.get(StrCast(dataDoc[key]))! > ReverseHierarchyMap.get(acl)!)) { - if (GetEffectiveAcl(dataDoc) === AclAdmin) { - dataDoc[key] = acl; - dataDocChanged = true; - } + + // changing doc proto - but this messes up layout + // if (GetEffectiveAcl(dataDoc) === AclAdmin) { + // dataDoc[key] = acl; + // dataDocChanged = true; + // } // maps over the links of the document LinkManager.Links(dataDoc).forEach(link => distributeAcls(key, acl, link, inheritingFromCollection, visited)); -- cgit v1.2.3-70-g09d2 From dd628b8b175d866fc39342a3f91e62bda3b63ba3 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Fri, 7 Jul 2023 13:04:21 -0400 Subject: guest permission fixes --- src/client/util/SharingManager.tsx | 2 +- src/client/views/PropertiesView.tsx | 3 +-- src/fields/util.ts | 6 +++++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 67b4d9d1a..3a0672113 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -582,7 +582,7 @@ export class SharingManager extends React.Component<{}> { ) : null, - sameAuthor && targetDoc?.author !== Doc.CurrentUserEmail ? ( + sameAuthor && targetDoc?.author !== Doc.CurrentUserEmail && Doc.CurrentUserEmail != 'guest' ? (
Me
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index 14291b537..2b12a7b58 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -463,8 +463,7 @@ export class PropertiesView extends React.Component { // adds current user var userEmail = Doc.CurrentUserEmail; const userKey = `acl-${normalizeEmail(userEmail)}`; - if (userEmail == 'guest') userEmail = 'Public'; - if (!usersAdded.includes(userEmail) && userEmail != 'Public' && userEmail != target.author) { + if (!usersAdded.includes(userEmail) && userEmail != 'guest' && userEmail != target.author) { var permission; if (this.layoutDocAcls){ if (target[DocAcl][userKey]) permission = HierarchyMapping.get(target[DocAcl][userKey])?.name; diff --git a/src/fields/util.ts b/src/fields/util.ts index cc29c7df9..068323dce 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -209,9 +209,13 @@ export function SetCachedGroups(groups: string[]) { } function getEffectiveAcl(target: any, user?: string): symbol { const targetAcls = target[DocAcl]; - if (targetAcls?.['acl-Me'] === AclAdmin || GetCachedGroupByName('Admin')) return AclAdmin; + // if (targetAcls?.['acl-Me'] === AclAdmin || GetCachedGroupByName('Admin')) return AclAdmin; const userChecked = user || Doc.CurrentUserEmail; // if the current user is the author of the document / the current user is a member of the admin group + + // guest dashboard permissions error + if (userChecked == 'guest' && target._type_collection == CollectionViewType.Docking) return AclAugment; + if (targetAcls && Object.keys(targetAcls).length) { let effectiveAcl = AclPrivate; for (const [key, value] of Object.entries(targetAcls)) { -- cgit v1.2.3-70-g09d2 From aaaea6344e74b2d4585dccbc0ca3f0249d6dacd6 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Fri, 7 Jul 2023 13:19:14 -0400 Subject: no layout in DocumentDecorations --- src/client/views/DocumentDecorations.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index cdd9e62d8..4cd172034 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -832,14 +832,14 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P   {shareSymbolIcon + ' ' + shareMode}   - {!Doc.noviceMode ? ( + {/* {!Doc.noviceMode ? (
(this.showLayoutAcl = !this.showLayoutAcl))} />
Layout
- ) : null} + ) : null} */}  
-- cgit v1.2.3-70-g09d2