From 2f49497e9d74eda97b2327ca4dbcb0a11ac6c6c9 Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Fri, 24 Jul 2020 17:11:09 +0530 Subject: added admin acl + renamed LinkCreatedBox to TaskCompletedBox and added custom text functionality + popups on sharing docs and creating groups + relocated SharingPermissions --- src/client/util/SharingManager.tsx | 46 ++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'src/client/util/SharingManager.tsx') diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 9c857a7c0..452a58d21 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -20,7 +20,8 @@ import GroupMemberView from "./GroupMemberView"; import Select from "react-select"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { List } from "../../fields/List"; -import { distributeAcls } from "../../fields/util"; +import { distributeAcls, SharingPermissions } from "../../fields/util"; +import { TaskCompletionBox } from "../views/nodes/TaskCompletedBox"; library.add(fa.faCopy, fa.faTimes); @@ -29,13 +30,6 @@ export interface User { userDocumentId: string; } -export enum SharingPermissions { - Edit = "Can Edit", - Add = "Can Add", - View = "Can View", - None = "Not Shared" -} - interface GroupOptions { label: string; options: UserOptions[]; @@ -69,6 +63,8 @@ export default class SharingManager extends React.Component<{}> { @observable private permissions: SharingPermissions = SharingPermissions.Edit; @observable private individualSort: "ascending" | "descending" | "none" = "none"; @observable private groupSort: "ascending" | "descending" | "none" = "none"; + private shareDocumentButtonRef: React.RefObject = React.createRef(); + // private get linkVisible() { @@ -90,6 +86,8 @@ export default class SharingManager extends React.Component<{}> { public close = action(() => { this.isOpen = false; this.users = []; + this.selectedUsers = null; + setTimeout(action(() => { // this.copied = false; DictationOverlay.Instance.hasActiveModal = false; @@ -235,7 +233,7 @@ export default class SharingManager extends React.Component<{}> { private get sharingOptions() { return Object.values(SharingPermissions).map(permission => { return ( - ); @@ -284,15 +282,25 @@ export default class SharingManager extends React.Component<{}> { @action share = () => { - this.selectedUsers?.forEach(user => { - if (user.value.includes(indType)) { - this.setInternalSharing(this.users.find(u => u.user.email === user.label)!, this.permissions); - } - else { - this.setInternalGroupSharing(GroupManager.Instance.getGroup(user.label)!, this.permissions); - } - }); - this.selectedUsers = null; + if (this.selectedUsers) { + this.selectedUsers.forEach(user => { + if (user.value.includes(indType)) { + this.setInternalSharing(this.users.find(u => u.user.email === user.label)!, this.permissions); + } + else { + this.setInternalGroupSharing(GroupManager.Instance.getGroup(user.label)!, this.permissions); + } + }); + + const { left, width, top, height } = this.shareDocumentButtonRef.current!.getBoundingClientRect(); + TaskCompletionBox.popupX = left - 1.5 * width; + TaskCompletionBox.popupY = top - height; + TaskCompletionBox.textDisplayed = "Document shared!"; + TaskCompletionBox.taskCompleted = true; + setTimeout(action(() => TaskCompletionBox.taskCompleted = false), 2000); + + this.selectedUsers = null; + } } sortUsers = (u1: ValidatedUser, u2: ValidatedUser) => { @@ -456,7 +464,7 @@ export default class SharingManager extends React.Component<{}> { - -- cgit v1.2.3-70-g09d2