From 4508b7feacd4ac1ea8145d3284527b523829606a Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Thu, 8 Oct 2020 13:53:31 +0530
Subject: fixes userlistcontents issue

---
 src/client/util/SharingManager.tsx | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index d2e25dc26..4aa8d74e4 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -76,7 +76,16 @@ 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 myDocAcls: boolean = false;
+    @observable private myDocAcls: boolean = false; // whether the My Docs checkbox is selected or not
+
+    // maps acl symbols to SharingPermissions
+    private AclMap = new Map<symbol, string>([
+        [AclPrivate, SharingPermissions.None],
+        [AclReadonly, SharingPermissions.View],
+        [AclAddonly, SharingPermissions.Add],
+        [AclEdit, SharingPermissions.Edit],
+        [AclAdmin, SharingPermissions.Admin]
+    ]);
 
     // private get linkVisible() {
     //     return this.sharingDoc ? this.sharingDoc[PublicKey] !== SharingPermissions.None : false;
@@ -368,20 +377,12 @@ export class SharingManager extends React.Component<{}> {
     }
 
     distributeOverCollection = (targetDoc?: Doc) => {
-        const AclMap = new Map<symbol, string>([
-            [AclPrivate, SharingPermissions.None],
-            [AclReadonly, SharingPermissions.View],
-            [AclAddonly, SharingPermissions.Add],
-            [AclEdit, SharingPermissions.Edit],
-            [AclAdmin, SharingPermissions.Admin]
-        ]);
-
         const target = targetDoc || this.targetDoc!;
 
         const docs = SelectionManager.SelectedDocuments().length < 2 ? [target] : SelectionManager.SelectedDocuments().map(docView => docView.props.Document);
         docs.forEach(doc => {
             for (const [key, value] of Object.entries(doc[AclSym])) {
-                distributeAcls(key, AclMap.get(value)! as SharingPermissions, target);
+                distributeAcls(key, this.AclMap.get(value)! as SharingPermissions, target);
             }
         });
     }
@@ -442,7 +443,8 @@ export class SharingManager extends React.Component<{}> {
         const targetDoc = docs[0];
 
         // tslint:disable-next-line: no-unnecessary-callback-wrapper
-        const admin = this.myDocAcls ? Boolean(docs.length) : docs.map(doc => GetEffectiveAcl(doc)).every(acl => acl === AclAdmin); // if the user has admin access to all selected docs
+        const effectiveAcls = docs.map(doc => GetEffectiveAcl(doc));
+        const admin = this.myDocAcls ? Boolean(docs.length) : effectiveAcls.every(acl => acl === AclAdmin);
 
         // users in common between all docs
         const commonKeys = intersection(...docs.map(doc => this.layoutDocAcls ? doc?.[AclSym] && Object.keys(doc[AclSym]) : doc?.[DataSym]?.[AclSym] && Object.keys(doc[DataSym][AclSym])));
@@ -506,7 +508,7 @@ export class SharingManager extends React.Component<{}> {
                         <span className={"padding"}>Me</span>
                         <div className="edit-actions">
                             <div className={"permissions-dropdown"}>
-                                {targetDoc?.[`acl-${Doc.CurrentUserEmailNormalized}`]}
+                                {effectiveAcls.every(acl => acl === effectiveAcls[0]) ? this.AclMap.get(effectiveAcls[0])! : "-multiple-"}
                             </div>
                         </div>
                     </div>
-- 
cgit v1.2.3-70-g09d2


From ae57452f05cca70a498e826fb3320bd2182ba88b Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Sat, 10 Oct 2020 21:54:20 +0530
Subject: some group fixes

---
 src/client/util/GroupManager.tsx   | 20 ++++++++++++++------
 src/client/util/SharingManager.tsx | 35 ++++++++++++++++++++++++++++-------
 2 files changed, 42 insertions(+), 13 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/GroupManager.tsx b/src/client/util/GroupManager.tsx
index fb3342e68..3264b75f7 100644
--- a/src/client/util/GroupManager.tsx
+++ b/src/client/util/GroupManager.tsx
@@ -1,11 +1,11 @@
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { action, computed, observable, runInAction } from "mobx";
+import { action, autorun, computed, Lambda, observable, reaction, runInAction } from "mobx";
 import { observer } from "mobx-react";
 import * as React from "react";
 import Select from 'react-select';
 import * as RequestPromise from "request-promise";
 import { Doc, DocListCast, DocListCastAsync, Opt } from "../../fields/Doc";
-import { Cast, StrCast } from "../../fields/Types";
+import { StrCast } from "../../fields/Types";
 import { setGroups } from "../../fields/util";
 import { Utils } from "../../Utils";
 import { DocServer } from "../DocServer";
@@ -34,10 +34,12 @@ export class GroupManager extends React.Component<{}> {
     @observable private createGroupModalOpen: boolean = false;
     private inputRef: React.RefObject<HTMLInputElement> = React.createRef(); // the ref for the input box.
     private createGroupButtonRef: React.RefObject<HTMLButtonElement> = React.createRef(); // the ref for the group creation button
-    private currentUserGroups: string[] = []; // the list of groups the current user is a member of
+    private currentUserGroups: string[] = ["Public"]; // the list of groups the current user is a member of
     @observable private buttonColour: "#979797" | "black" = "#979797";
     @observable private groupSort: "ascending" | "descending" | "none" = "none";
     private populating: boolean = false;
+    private groupListener: Opt<Lambda>;
+    private observableAllGroups: Doc[] = observable([]);
 
 
 
@@ -51,7 +53,11 @@ export class GroupManager extends React.Component<{}> {
      */
     componentDidMount() {
         this.populateUsers();
-        this.populateGroups();
+        this.groupListener = autorun(this.populateGroups);
+    }
+
+    componentWillUnmount() {
+        this.groupListener?.();
     }
 
     /**
@@ -77,13 +83,15 @@ export class GroupManager extends React.Component<{}> {
      * Populates the list of groups the current user is a member of and sets this list to be used in the GetEffectiveAcl in util.ts
      */
     populateGroups = () => {
+        this.observableAllGroups.map(g => g.members);
         DocListCastAsync(this.GroupManagerDoc?.data).then(groups => {
             groups?.forEach(group => {
                 const members: string[] = JSON.parse(StrCast(group.members));
-                if (members.includes(Doc.CurrentUserEmail)) this.currentUserGroups.push(StrCast(group.groupName));
+                if (members.includes(Doc.CurrentUserEmail) && this.currentUserGroups.indexOf(StrCast(group.groupName)) === -1) this.currentUserGroups.push(StrCast(group.groupName));
+                if (this.observableAllGroups.indexOf(group) === -1) runInAction(() => this.observableAllGroups.push(group));
             });
-            this.currentUserGroups.push("Public");
             setGroups(this.currentUserGroups);
+            console.log("populating groups");
         });
     }
 
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 6c1ec6091..742811c18 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -4,7 +4,7 @@ import { observer } from "mobx-react";
 import * as React from "react";
 import Select from "react-select";
 import * as RequestPromise from "request-promise";
-import { AclAdmin, AclPrivate, DataSym, Doc, DocListCast, Opt, AclSym, AclAddonly, AclEdit, AclReadonly } from "../../fields/Doc";
+import { AclAdmin, AclPrivate, DataSym, Doc, DocListCast, Opt, AclSym, AclAddonly, AclEdit, AclReadonly, DocListCastAsync } from "../../fields/Doc";
 import { List } from "../../fields/List";
 import { Cast, StrCast } from "../../fields/Types";
 import { distributeAcls, GetEffectiveAcl, SharingPermissions, TraceMobx, normalizeEmail } from "../../fields/util";
@@ -145,9 +145,9 @@ export class SharingManager extends React.Component<{}> {
             });
             return Promise.all(evaluating).then(() => {
                 runInAction(() => {
-                    for (let i = 0; i < sharingDocs.length; i++) {
-                        if (!this.users.find(user => user.user.email === sharingDocs[i].user.email)) {
-                            this.users.push(sharingDocs[i]);
+                    for (const sharingDoc of sharingDocs) {
+                        if (!this.users.find(user => user.user.email === sharingDoc.user.email)) {
+                            this.users.push(sharingDoc);
                         }
                     }
                 });
@@ -195,7 +195,21 @@ export class SharingManager extends React.Component<{}> {
      */
     shareWithAddedMember = (group: Doc, emailId: string) => {
         const user: ValidatedUser = this.users.find(({ user: { email } }) => email === emailId)!;
-        if (group.docsShared) DocListCast(group.docsShared).forEach(doc => Doc.IndexOf(doc, DocListCast(user.sharingDoc[storage])) === -1 && Doc.AddDocToList(user.sharingDoc, storage, doc));
+        if (group.docsShared) {
+            DocListCastAsync(group.docsShared).then(async docs => {
+                if (docs) {
+                    const memberDocs = await DocListCastAsync(user.sharingDoc[storage]);
+                    memberDocs && docs.forEach(doc => {
+                        const index = Doc.IndexOf(doc, memberDocs);
+                        console.log(index);
+                        console.log(doc);
+                        index === -1 && (console.log(Doc.AddDocToList(user.sharingDoc, storage, doc)));
+                    });
+                }
+
+            });
+            //  === -1 && Doc.AddDocToList(user.sharingDoc, storage, doc));
+        }
     }
 
     /**
@@ -225,9 +239,16 @@ export class SharingManager extends React.Component<{}> {
         const user: ValidatedUser = this.users.find(({ user: { email } }) => email === emailId)!;
 
         if (group.docsShared) {
-            DocListCast(group.docsShared).forEach(doc => {
-                Doc.IndexOf(doc, DocListCast(user.sharingDoc[storage])) !== -1 && Doc.RemoveDocFromList(user.sharingDoc, storage, doc); // remove the doc only if it is in the list
+            DocListCastAsync(group.docsShared).then(docs => {
+                docs?.forEach(doc => {
+                    DocListCastAsync(user.sharingDoc[storage]).then(sharedDocs => {
+                        sharedDocs && Doc.IndexOf(doc, sharedDocs) !== -1 && Doc.RemoveDocFromList(user.sharingDoc, storage, doc);
+                    });
+                });
             });
+            // DocListCast(group.docsShared).forEach(doc => {
+            //     Doc.IndexOf(doc, DocListCast(user.sharingDoc[storage])) !== -1 && Doc.RemoveDocFromList(user.sharingDoc, storage, doc); // remove the doc only if it is in the list
+            // });
         }
     }
 
-- 
cgit v1.2.3-70-g09d2


From 58b850cf84e258933cfc075e58311cd122e5fd0d Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Thu, 26 Nov 2020 19:53:57 +0530
Subject: some sharing menu changes

---
 src/client/util/SharingManager.tsx       | 59 ++++++++++++++++++----------
 src/client/views/nodes/DocumentView.scss | 66 +++++++++++++++++++++++---------
 src/client/views/nodes/DocumentView.tsx  | 22 +++++++++--
 3 files changed, 105 insertions(+), 42 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 53a6b2587..c4285ee30 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -6,7 +6,7 @@ import Select from "react-select";
 import * as RequestPromise from "request-promise";
 import { AclAdmin, AclPrivate, DataSym, Doc, DocListCast, Opt, AclSym, AclAddonly, AclEdit, AclReadonly, DocListCastAsync } from "../../fields/Doc";
 import { List } from "../../fields/List";
-import { Cast, StrCast } from "../../fields/Types";
+import { Cast, NumCast, StrCast } from "../../fields/Types";
 import { distributeAcls, GetEffectiveAcl, SharingPermissions, TraceMobx, normalizeEmail } from "../../fields/util";
 import { Utils } from "../../Utils";
 import { DocServer } from "../DocServer";
@@ -164,6 +164,35 @@ export class SharingManager extends React.Component<{}> {
         }
     }
 
+    /**
+     * Shares the document with a user.
+     */
+    setInternalSharing = (recipient: ValidatedUser, permission: string, targetDoc?: Doc) => {
+        const { user, sharingDoc } = recipient;
+        const target = targetDoc || this.targetDoc!;
+        const acl = `acl-${normalizeEmail(user.email)}`;
+        const myAcl = `acl-${Doc.CurrentUserEmailNormalized}`;
+
+        const docs = SelectionManager.SelectedDocuments().length < 2 ? [target] : SelectionManager.SelectedDocuments().map(docView => docView.props.Document);
+        docs.forEach(doc => {
+            doc.author === Doc.CurrentUserEmail && !doc[myAcl] && distributeAcls(myAcl, SharingPermissions.Admin, doc);
+
+            if (permission === SharingPermissions.None) {
+                if (doc[acl] && doc[acl] !== SharingPermissions.None) doc.numUsersShared = NumCast(doc.numUsersShared, 1) - 1;
+            }
+            else {
+                if (!doc[acl] || doc[acl] === SharingPermissions.None) doc.numUsersShared = NumCast(doc.numUsersShared, 0) + 1;
+            }
+
+            console.log(doc.numUsersShared);
+
+            distributeAcls(acl, permission as SharingPermissions, doc);
+
+            if (permission !== SharingPermissions.None) Doc.AddDocToList(sharingDoc, storage, doc);
+            else GetEffectiveAcl(doc, user.email) === AclPrivate && Doc.RemoveDocFromList(sharingDoc, storage, (doc.aliasOf as Doc || doc));
+        });
+    }
+
     /**
      * Sets the permission on the target for the group.
      * @param group 
@@ -179,6 +208,15 @@ export class SharingManager extends React.Component<{}> {
 
         docs.forEach(doc => {
             doc.author === Doc.CurrentUserEmail && !doc[`acl-${Doc.CurrentUserEmailNormalized}`] && distributeAcls(`acl-${Doc.CurrentUserEmailNormalized}`, SharingPermissions.Admin, doc);
+
+            if (permission === SharingPermissions.None) {
+                if (doc[acl] && doc[acl] !== SharingPermissions.None) doc.numGroupsShared = NumCast(doc.numGroupsShared, 1) - 1;
+            }
+            else {
+                if (!doc[acl] || doc[acl] === SharingPermissions.None) doc.numGroupsShared = NumCast(doc.numGroupsShared, 0) + 1;
+            }
+
+            console.log(doc.numGroupsShared);
             distributeAcls(acl, permission as SharingPermissions, doc);
 
             if (group instanceof Doc) {
@@ -271,25 +309,6 @@ export class SharingManager extends React.Component<{}> {
         }
     }
 
-    /**
-     * Shares the document with a user.
-     */
-    setInternalSharing = (recipient: ValidatedUser, permission: string, targetDoc?: Doc) => {
-        const { user, sharingDoc } = recipient;
-        const target = targetDoc || this.targetDoc!;
-        const acl = `acl-${normalizeEmail(user.email)}`;
-        const myAcl = `acl-${Doc.CurrentUserEmailNormalized}`;
-
-        const docs = SelectionManager.SelectedDocuments().length < 2 ? [target] : SelectionManager.SelectedDocuments().map(docView => docView.props.Document);
-        docs.forEach(doc => {
-            doc.author === Doc.CurrentUserEmail && !doc[myAcl] && distributeAcls(myAcl, SharingPermissions.Admin, doc);
-            distributeAcls(acl, permission as SharingPermissions, doc);
-
-            if (permission !== SharingPermissions.None) Doc.AddDocToList(sharingDoc, storage, doc);
-            else GetEffectiveAcl(doc, user.email) === AclPrivate && Doc.RemoveDocFromList(sharingDoc, storage, (doc.aliasOf as Doc || doc));
-        });
-    }
-
 
     // private setExternalSharing = (permission: string) => {
     //     const sharingDoc = this.sharingDoc;
diff --git a/src/client/views/nodes/DocumentView.scss b/src/client/views/nodes/DocumentView.scss
index ad72250b6..3cbf88839 100644
--- a/src/client/views/nodes/DocumentView.scss
+++ b/src/client/views/nodes/DocumentView.scss
@@ -34,14 +34,16 @@
         overflow-y: scroll;
         height: calc(100% - 20px);
     }
+
     .documentView-linkAnchorBoxAnchor {
-        display:flex;
+        display: flex;
         overflow: hidden;
 
         .documentView-node {
-            width:10px !important;
+            width: 10px !important;
         }
     }
+
     .documentView-treeView {
         max-height: 1.5em;
         text-overflow: ellipsis;
@@ -49,7 +51,8 @@
         white-space: pre;
         width: 100%;
         overflow: hidden;
-        > .documentView-node {
+
+        >.documentView-node {
             position: absolute;
         }
     }
@@ -58,23 +61,42 @@
         border-radius: inherit;
         width: 100%;
         height: 100%;
+
+        .sharingIndicator {
+            height: 30px;
+            width: 30px;
+            border-radius: 50%;
+            position: absolute;
+            right: -15;
+            opacity: 0.9;
+            pointer-events: auto;
+            background-color: #9dca96;
+            letter-spacing: 2px;
+            font-size: 10px;
+            transition: transform 0.2s;
+            text-align: center;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            cursor: pointer;
+        }
     }
 
     .documentView-anchorCont {
         position: absolute;
-        top: 0; 
-        left: 0; 
+        top: 0;
+        left: 0;
         width: 100%;
-        height: 100%; 
+        height: 100%;
         display: inline-block;
         pointer-events: none;
     }
 
     .documentView-lock {
-        width: 20; 
-        height: 20; 
-        position: absolute; 
-        right: -5; 
+        width: 20;
+        height: 20;
+        position: absolute;
+        right: -5;
         top: -5;
         background: transparent;
         pointer-events: all;
@@ -85,8 +107,9 @@
         justify-content: center;
         cursor: default;
     }
+
     .documentView-lock:hover {
-        opacity:1;
+        opacity: 1;
     }
 
     .documentView-contentBlocker {
@@ -97,6 +120,7 @@
         top: 0;
         left: 0;
     }
+
     .documentView-styleWrapper {
         position: absolute;
         display: inline-block;
@@ -110,7 +134,8 @@
             position: absolute;
         }
 
-        .documentView-titleWrapper, .documentView-titleWrapper-hover {
+        .documentView-titleWrapper,
+        .documentView-titleWrapper-hover {
             overflow: hidden;
             color: white;
             transform-origin: top left;
@@ -123,8 +148,9 @@
             white-space: pre;
             position: absolute;
         }
+
         .documentView-titleWrapper-hover {
-            display:none;
+            display: none;
         }
 
         .documentView-searchHighlight {
@@ -147,14 +173,16 @@
 
 }
 
-.documentView-node:hover, .documentView-node-topmost:hover {
-    > .documentView-styleWrapper {
-        > .documentView-titleWrapper-hover {
-            display:inline-block;
+.documentView-node:hover,
+.documentView-node-topmost:hover {
+    >.documentView-styleWrapper {
+        >.documentView-titleWrapper-hover {
+            display: inline-block;
         }
     }
-    > .documentView-styleWrapper {
-        > .documentView-captionWrapper {
+
+    >.documentView-styleWrapper {
+        >.documentView-captionWrapper {
             opacity: 1;
         }
     }
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index e8fcf027e..18ebb569a 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -9,7 +9,7 @@ import { RichTextField } from '../../../fields/RichTextField';
 import { listSpec } from "../../../fields/Schema";
 import { ScriptField } from '../../../fields/ScriptField';
 import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from "../../../fields/Types";
-import { GetEffectiveAcl, TraceMobx } from '../../../fields/util';
+import { GetEffectiveAcl, SharingPermissions, TraceMobx } from '../../../fields/util';
 import { MobileInterface } from '../../../mobile/MobileInterface';
 import { GestureUtils } from '../../../pen-gestures/GestureUtils';
 import { emptyFunction, OmitKeys, returnOne, returnTransparent, returnVal, Utils, returnFalse } from "../../../Utils";
@@ -42,6 +42,7 @@ import { RadialMenu } from './RadialMenu';
 import { TaskCompletionBox } from './TaskCompletedBox';
 import React = require("react");
 import { List } from '../../../fields/List';
+import { Tooltip } from '@material-ui/core';
 
 export type DocAfterFocusFunc = (notFocused: boolean) => boolean;
 export type DocFocusFunc = (doc: Doc, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc, dontCenter?: boolean, focused?: boolean) => void;
@@ -675,7 +676,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             if ((e.target as any)?.closest?.("*.lm_content")) {
                 alert("You can't perform this move most likely because you don't have permission to modify the destination.");
             }
-            else alert("linking to document tabs not yet supported.  Drop link on document content.");
+            else alert("Linking to document tabs not yet supported. Drop link on document content.");
             return;
         }
         const makeLink = action((linkDoc: Doc) => {
@@ -960,10 +961,25 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             {/* {this.allAnchors} */}
             {this.props.forcedBackgroundColor?.(this.Document) === "transparent" || (!this.isSelected() && (this.layoutDoc.isLinkButton || this.layoutDoc.hideLinkButton)) || this.props.dontRegisterView ? (null) :
                 <DocumentLinksButton View={this} links={this.allLinks} Offset={this.linkOffset} />}
-        </div>
+
+            {!this.props.Document.numUsersShared && !this.props.Document.numGroupsShared ? (null) :
+                <Tooltip title={<> <div className="dash-tooltip">Tap to open sharing menu</div></>}>
+                    <div className="sharingIndicator" onPointerDown={() => SharingManager.Instance.open(undefined, this.props.Document)}>
+                        <FontAwesomeIcon size="lg" icon={this.indicatorIcon} />
+                    </div>
+                </Tooltip >
+
+            }
+        </div >
         );
     }
 
+    get indicatorIcon() {
+        if (this.props.Document["acl-Public"] !== SharingPermissions.None) return "globe-americas";
+        else if (this.props.Document.numGroupsShared || NumCast(this.props.Document.numUsersShared, 0) > 1) return "users";
+        else return "user";
+    }
+
     // used to decide whether a link anchor view should be created or not.
     // if it's a temporal link (currently just for Audio), then the audioBox will display the anchor and we don't want to display it here.
     // would be good to generalize this some way.
-- 
cgit v1.2.3-70-g09d2


From 1f9baca276426444a4ebea06023402876f033ebe Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Fri, 27 Nov 2020 19:07:43 +0530
Subject: removed override

---
 src/client/util/SharingManager.tsx  | 13 +++++--------
 src/client/views/PropertiesView.tsx |  6 +++---
 2 files changed, 8 insertions(+), 11 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index c4285ee30..fcd10406d 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -184,8 +184,6 @@ export class SharingManager extends React.Component<{}> {
                 if (!doc[acl] || doc[acl] === SharingPermissions.None) doc.numUsersShared = NumCast(doc.numUsersShared, 0) + 1;
             }
 
-            console.log(doc.numUsersShared);
-
             distributeAcls(acl, permission as SharingPermissions, doc);
 
             if (permission !== SharingPermissions.None) Doc.AddDocToList(sharingDoc, storage, doc);
@@ -216,7 +214,6 @@ export class SharingManager extends React.Component<{}> {
                 if (!doc[acl] || doc[acl] === SharingPermissions.None) doc.numGroupsShared = NumCast(doc.numGroupsShared, 0) + 1;
             }
 
-            console.log(doc.numGroupsShared);
             distributeAcls(acl, permission as SharingPermissions, doc);
 
             if (group instanceof Doc) {
@@ -566,7 +563,7 @@ export class SharingManager extends React.Component<{}> {
 
         // the list of groups shared with
         const groupListMap: (Doc | { title: string })[] = groups.filter(({ title }) => docs.length > 1 ? commonKeys.includes(`acl-${normalizeEmail(StrCast(title))}`) : true);
-        groupListMap.unshift({ title: "Public" }, { title: "Override" });
+        groupListMap.unshift({ title: "Public" });//, { title: "Override" });
         const groupListContents = groupListMap.map(group => {
             const groupKey = `acl-${StrCast(group.title)}`;
             const uniform = docs.every(doc => this.layoutDocAcls ? doc?.[AclSym]?.[groupKey] === docs[0]?.[AclSym]?.[groupKey] : doc?.[DataSym]?.[AclSym]?.[groupKey] === docs[0]?.[DataSym]?.[AclSym]?.[groupKey]);
@@ -644,16 +641,16 @@ export class SharingManager extends React.Component<{}> {
                         </div>
 
                         <div className="acl-container">
-                            <div className="myDocs-acls">
+                            {/* <div className="myDocs-acls">
                                 <input type="checkbox" onChange={action(() => this.myDocAcls = !this.myDocAcls)} checked={this.myDocAcls} /> <label>My Docs</label>
-                            </div>
+                            </div> */}
                             {Doc.UserDoc().noviceMode ? (null) :
                                 <div className="layoutDoc-acls">
                                     <input type="checkbox" onChange={action(() => this.layoutDocAcls = !this.layoutDocAcls)} checked={this.layoutDocAcls} /> <label>Layout</label>
                                 </div>}
-                            <button className="distribute-button" onClick={() => this.distributeOverCollection()}>
+                            {/* <button className="distribute-button" onClick={() => this.distributeOverCollection()}>
                                 Distribute
-                        </button>
+                        </button> */}
                         </div>
                     </div>
                     }
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 245e612b3..db9475afd 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -416,7 +416,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
         const ownerSame = Doc.CurrentUserEmail !== target.author && docs.filter(doc => doc).every(doc => doc.author === docs[0].author);
         // shifts the current user, owner, public to the top of the doc.
-        tableEntries.unshift(this.sharingItem("Override", showAdmin, docs.filter(doc => doc).every(doc => doc["acl-Override"] === docs[0]["acl-Override"]) ? (AclMap.get(target[AclSym]?.["acl-Override"]) || "None") : "-multiple-"));
+        // tableEntries.unshift(this.sharingItem("Override", showAdmin, docs.filter(doc => doc).every(doc => doc["acl-Override"] === docs[0]["acl-Override"]) ? (AclMap.get(target[AclSym]?.["acl-Override"]) || "None") : "-multiple-"));
         tableEntries.unshift(this.sharingItem("Public", showAdmin, docs.filter(doc => doc).every(doc => doc["acl-Public"] === docs[0]["acl-Public"]) ? (AclMap.get(target[AclSym]?.["acl-Public"]) || SharingPermissions.None) : "-multiple-"));
         tableEntries.unshift(this.sharingItem("Me", showAdmin, docs.filter(doc => doc).every(doc => doc.author === Doc.CurrentUserEmail) ? "Owner" : effectiveAcls.every(acl => acl === effectiveAcls[0]) ? AclMap.get(effectiveAcls[0])! : "-multiple-", !ownerSame));
         if (ownerSame) tableEntries.unshift(this.sharingItem(StrCast(target.author), showAdmin, "Owner"));
@@ -900,11 +900,11 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                                         />
                                         <div className="propertiesView-acls-checkbox-text">Layout</div>
                                     </div>) : (null)}
-                                    <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
+                                    {/* <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
                                         <button onPointerDown={() => SharingManager.Instance.distributeOverCollection(this.selectedDoc!)}>
                                             <FontAwesomeIcon icon="redo-alt" color="white" size="1x" />
                                         </button>
-                                    </Tooltip>
+                                    </Tooltip> */}
                                 </div>
                                 {this.sharingTable}
                             </div>}
-- 
cgit v1.2.3-70-g09d2


From 45dee9388ad4f5c3c70df3a5ff1852c6bd41dec0 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Sun, 20 Dec 2020 01:23:44 +0530
Subject: added settings manager to esc key handler

---
 src/client/util/SharingManager.tsx                 | 44 +++++++++++-----------
 src/client/views/GlobalKeyHandler.ts               |  2 +
 .../views/collections/CollectionTreeView.tsx       |  4 +-
 3 files changed, 26 insertions(+), 24 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 8c36a7f3c..f1fe7c22f 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -7,7 +7,7 @@ import Select from "react-select";
 import * as RequestPromise from "request-promise";
 import { AclAddonly, AclAdmin, AclEdit, AclPrivate, AclReadonly, AclSym, DataSym, Doc, DocListCast, DocListCastAsync, Opt } from "../../fields/Doc";
 import { List } from "../../fields/List";
-import { Cast, StrCast } from "../../fields/Types";
+import { Cast, NumCast, StrCast } from "../../fields/Types";
 import { distributeAcls, GetEffectiveAcl, normalizeEmail, SharingPermissions, TraceMobx } from "../../fields/util";
 import { Utils } from "../../Utils";
 import { DocServer } from "../DocServer";
@@ -173,7 +173,7 @@ export class SharingManager extends React.Component<{}> {
         const acl = `acl-${normalizeEmail(user.email)}`;
         const myAcl = `acl-${Doc.CurrentUserEmailNormalized}`;
 
-        const docs = SelectionManager.SelectedDocuments().length < 2 ? [target] : SelectionManager.SelectedDocuments().map(docView => docView.props.Document);
+        const docs = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
         docs.forEach(doc => {
             doc.author === Doc.CurrentUserEmail && !doc[myAcl] && distributeAcls(myAcl, SharingPermissions.Admin, doc);
 
@@ -309,21 +309,21 @@ export class SharingManager extends React.Component<{}> {
     /**
      * Shares the document with a user.
      */
-    setInternalSharing = (recipient: ValidatedUser, permission: string, targetDoc?: Doc) => {
-        const { user, sharingDoc } = recipient;
-        const target = targetDoc || this.targetDoc!;
-        const acl = `acl-${normalizeEmail(user.email)}`;
-        const myAcl = `acl-${Doc.CurrentUserEmailNormalized}`;
-
-        const docs = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
-        docs.forEach(doc => {
-            doc.author === Doc.CurrentUserEmail && !doc[myAcl] && distributeAcls(myAcl, SharingPermissions.Admin, doc);
-            distributeAcls(acl, permission as SharingPermissions, doc);
-
-            if (permission !== SharingPermissions.None) Doc.AddDocToList(sharingDoc, storage, doc);
-            else GetEffectiveAcl(doc, user.email) === AclPrivate && Doc.RemoveDocFromList(sharingDoc, storage, (doc.aliasOf as Doc || doc));
-        });
-    }
+    // setInternalSharing = (recipient: ValidatedUser, permission: string, targetDoc?: Doc) => {
+    //     const { user, sharingDoc } = recipient;
+    //     const target = targetDoc || this.targetDoc!;
+    //     const acl = `acl-${normalizeEmail(user.email)}`;
+    //     const myAcl = `acl-${Doc.CurrentUserEmailNormalized}`;
+
+    //     const docs = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
+    //     docs.forEach(doc => {
+    //         doc.author === Doc.CurrentUserEmail && !doc[myAcl] && distributeAcls(myAcl, SharingPermissions.Admin, doc);
+    //         distributeAcls(acl, permission as SharingPermissions, doc);
+
+    //         if (permission !== SharingPermissions.None) Doc.AddDocToList(sharingDoc, storage, doc);
+    //         else GetEffectiveAcl(doc, user.email) === AclPrivate && Doc.RemoveDocFromList(sharingDoc, storage, (doc.aliasOf as Doc || doc));
+    //     });
+    // }
 
 
     // private setExternalSharing = (permission: string) => {
@@ -357,11 +357,11 @@ export class SharingManager extends React.Component<{}> {
         if (!uniform) dropdownValues.unshift("-multiple-");
         if (override) dropdownValues.unshift("None");
         return dropdownValues.filter(permission => permission !== SharingPermissions.View).map(permission =>
-            (
-                <option key={permission} value={permission}>
-                    {permission === SharingPermissions.Add ? "Can Augment" : permission}
-                </option>
-            )
+        (
+            <option key={permission} value={permission}>
+                {permission === SharingPermissions.Add ? "Can Augment" : permission}
+            </option>
+        )
         );
     }
 
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index c38842c4f..26dc0071c 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -27,6 +27,7 @@ import { SnappingManager } from "../util/SnappingManager";
 import { SearchBox } from "./search/SearchBox";
 import { random } from "lodash";
 import { DocumentView } from "./nodes/DocumentView";
+import { SettingsManager } from "../util/SettingsManager";
 
 const modifiers = ["control", "meta", "shift", "alt"];
 type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo | Promise<KeyControlInfo>;
@@ -128,6 +129,7 @@ export class KeyManager {
                 DictationManager.Controls.stop();
                 GoogleAuthenticationManager.Instance.cancel();
                 SharingManager.Instance.close();
+                if (!GroupManager.Instance.isOpen) SettingsManager.Instance.close();
                 GroupManager.Instance.close();
                 CollectionFreeFormViewChrome.Instance?.clearKeep();
                 window.getSelection()?.empty();
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 18921e9e0..344a6c103 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -215,12 +215,12 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
         const background = this.props.styleProvider?.(this.doc, this.props, StyleProp.BackgroundColor);
         const paddingX = `${NumCast(this.doc._xPadding, 10)}px`;
         const paddingTop = `${NumCast(this.doc._yPadding, 20)}px`;
-        // const pointerEvents = !this.props.active() && !SnappingManager.GetIsDragging() && !this._isChildActive ? "none" : undefined;
+        const pointerEvents = !this.props.active() && !SnappingManager.GetIsDragging() && !this._isChildActive ? "none" : undefined;
 
         return !this.treeChildren ? (null) : (
             <div className="collectionTreeView-container" onContextMenu={this.onContextMenu}>
                 <div className="collectionTreeView-dropTarget"
-                    style={{ background, paddingLeft: paddingX, paddingRight: paddingX, paddingTop }}//, pointerEvents }}
+                    style={{ background, paddingLeft: paddingX, paddingRight: paddingX, paddingTop, pointerEvents }}
                     onWheel={(e) => this._mainEle && this._mainEle.scrollHeight > this._mainEle.clientHeight && e.stopPropagation()}
                     onDrop={this.onTreeDrop}
                     ref={this.createTreeDropTarget}>
-- 
cgit v1.2.3-70-g09d2


From 39e8bd2671d70e1e8fd708c5210120a9d09b64fa Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Mon, 11 Jan 2021 01:34:10 +0530
Subject: initial flyout to dropdown change

---
 src/client/util/GroupManager.tsx     |  3 +--
 src/client/util/SharingManager.tsx   |  5 +++--
 src/client/views/nodes/FilterBox.tsx | 16 ++++++++++++++--
 3 files changed, 18 insertions(+), 6 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/GroupManager.tsx b/src/client/util/GroupManager.tsx
index 48676a393..b24c8f681 100644
--- a/src/client/util/GroupManager.tsx
+++ b/src/client/util/GroupManager.tsx
@@ -284,8 +284,7 @@ export class GroupManager extends React.Component<{}> {
                     placeholder="Group name"
                     onChange={action(() => this.buttonColour = this.inputRef.current?.value ? "black" : "#979797")} />
                 <Select
-                    isMulti={true}
-                    isSearchable={true}
+                    isMulti
                     options={this.options}
                     onChange={this.handleChange}
                     placeholder={"Select users"}
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index f1fe7c22f..08dfb5066 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -634,9 +634,10 @@ export class SharingManager extends React.Component<{}> {
                     {<div className="share-container">
                         <div className="share-setup">
                             <Select
-                                className={"user-search"}
-                                placeholder={"Enter user or group name..."}
+                                className="user-search"
+                                placeholder="Enter user or group name..."
                                 isMulti
+                                isSearchable
                                 closeMenuOnSelect={false}
                                 options={options}
                                 onChange={this.handleUsersChange}
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 611e11b64..150fc42b6 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -25,6 +25,8 @@ import { SelectionManager } from "../../util/SelectionManager";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
+import Select from "react-select";
+import { UserOptions } from "../../util/GroupManager";
 
 type FilterBoxDocument = makeInterface<[typeof documentSchema]>;
 const FilterBoxDocument = makeInterface(documentSchema);
@@ -207,6 +209,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
             </label>)}
         </div>;
 
+        const options = this._allFacets.map(facet => ({ value: facet, label: facet }));
+
         return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
 
             {/* <div className="filterBox-top"> */}
@@ -278,11 +282,19 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     removeDocument={returnFalse}
                     addDocument={returnFalse} />
             </div>
-            <Flyout className="filterBox-flyout" anchorPoint={anchorPoints.LEFT_TOP} content={flyout}>
+            {/* <Flyout className="filterBox-flyout" anchorPoint={anchorPoints.RIGHT_TOP} content={flyout}>
                 <div className="filterBox-addWrapper">
                     <div className="filterBox-addFilter"> + add a filter</div>
                 </div>
-            </Flyout>
+            </Flyout> */}
+            <Select
+                placeholder="Add a filter..."
+                options={options}
+                isMulti={false}
+                onChange={val => this.facetClick((val as UserOptions).value)}
+                value={null}
+                closeMenuOnSelect={false}
+            />
 
             <div className="filterBox-bottom">
                 <div className="filterBox-select-matched">
-- 
cgit v1.2.3-70-g09d2


From 9135b7c1c414dc8caf255ef3d4b2b3d3f220289c Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Fri, 9 Apr 2021 23:45:20 -0400
Subject: removed some old comments + some unused imports

---
 src/client/util/SharingManager.tsx | 6 ------
 1 file changed, 6 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index b7a39a963..5a247730e 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -644,16 +644,10 @@ export class SharingManager extends React.Component<{}> {
                         </div>
 
                         <div className="acl-container">
-                            {/* <div className="myDocs-acls">
-                                <input type="checkbox" onChange={action(() => this.myDocAcls = !this.myDocAcls)} checked={this.myDocAcls} /> <label>My Docs</label>
-                            </div> */}
                             {Doc.UserDoc().noviceMode ? (null) :
                                 <div className="layoutDoc-acls">
                                     <input type="checkbox" onChange={action(() => this.layoutDocAcls = !this.layoutDocAcls)} checked={this.layoutDocAcls} /> <label>Layout</label>
                                 </div>}
-                            {/* <button className="distribute-button" onClick={() => this.distributeOverCollection()}>
-                                Distribute
-                        </button> */}
                         </div>
                     </div>
                     }
-- 
cgit v1.2.3-70-g09d2

