diff options
author | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-06-26 16:29:52 +0530 |
---|---|---|
committer | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-06-26 16:29:52 +0530 |
commit | 9d9ca5adaa19ff80e6e7f4aab1adccf659c80f47 (patch) | |
tree | 64f4950c6e9b35eb3ad62683d6dcd59c138508fb /src/client/util/GroupManager.tsx | |
parent | 27543c9fe72fe4a6276b714307e365dd886240a5 (diff) |
added GroupManager privacy + setting up group sharing + permissions + group sharing ui
Diffstat (limited to 'src/client/util/GroupManager.tsx')
-rw-r--r-- | src/client/util/GroupManager.tsx | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/client/util/GroupManager.tsx b/src/client/util/GroupManager.tsx index 7f48ca014..fa8da86c1 100644 --- a/src/client/util/GroupManager.tsx +++ b/src/client/util/GroupManager.tsx @@ -88,7 +88,7 @@ export default class GroupManager extends React.Component<{}> { /** * @returns a list of all group documents. */ - getAllGroups(): Doc[] { + private getAllGroups(): Doc[] { const groupDoc = this.GroupManagerDoc; return groupDoc ? DocListCast(groupDoc.data) : []; } @@ -97,12 +97,32 @@ export default class GroupManager extends React.Component<{}> { * @returns a group document based on the group name. * @param groupName */ - getGroup(groupName: string): Doc | undefined { + private getGroup(groupName: string): Doc | undefined { const groupDoc = this.getAllGroups().find(group => group.groupName === groupName); return groupDoc; } /** + * @returns a readonly copy of a single group document + */ + getGroupCopy(groupName: string): Doc | undefined { + const groupDoc = this.getGroup(groupName); + if (groupDoc) { + const { members, owners } = groupDoc; + return Doc.assign(new Doc, { groupName, members: StrCast(members), owners: StrCast(owners) }); + } + return undefined; + } + /** + * @returns a readonly copy of the list of group documents + */ + getAllGroupsCopy(): Doc[] { + return this.getAllGroups().map(({ groupName, owners, members }) => + Doc.assign(new Doc, { groupName: (groupName as string), owners: (owners as string), members: (members as string) }) + ); + } + + /** * @returns the members of the admin group. */ get adminGroupMembers(): string[] { @@ -194,7 +214,6 @@ export default class GroupManager extends React.Component<{}> { */ @action handleChange = (selectedOptions: any) => { - console.log(selectedOptions); this.selectedUsers = selectedOptions as UserOptions[]; } @@ -312,7 +331,7 @@ export default class GroupManager extends React.Component<{}> { <div className="group-row"> <div className="group-name">{group.groupName}</div> <button onClick={action(() => this.currentGroup = group)}> - {this.hasEditAccess(this.getGroup(StrCast(group.groupName)) as Doc) ? "Edit" : "View"} + {this.hasEditAccess(group) ? "Edit" : "View"} </button> </div> )} |