aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-08-06 19:58:52 -0400
committerGitHub <noreply@github.com>2020-08-06 19:58:52 -0400
commit318f2bab4f086ce626fc3f1d099d1a09e245f95d (patch)
tree85ec890c68b240506e4255c8549a7f4586886c0b /src/client/views/collections/collectionFreeForm
parent6d8dfee38bd39b95396cbc97405516693116b58f (diff)
parent3e4329b81d96f139f38eeb182afcbd8359dcd171 (diff)
Merge pull request #501 from browngraphicslab/acls_uv
For more testing
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
-rw-r--r--src/client/views/collections/collectionFreeForm/PropertiesView.scss27
-rw-r--r--src/client/views/collections/collectionFreeForm/PropertiesView.tsx117
2 files changed, 119 insertions, 25 deletions
diff --git a/src/client/views/collections/collectionFreeForm/PropertiesView.scss b/src/client/views/collections/collectionFreeForm/PropertiesView.scss
index 5b41db90e..fef1db9aa 100644
--- a/src/client/views/collections/collectionFreeForm/PropertiesView.scss
+++ b/src/client/views/collections/collectionFreeForm/PropertiesView.scss
@@ -119,6 +119,19 @@
font-size: 10px;
padding: 10px;
margin-left: 5px;
+
+ .change-buttons {
+ display: flex;
+
+ button {
+ width: 5;
+ height: 5;
+ }
+
+ input {
+ width: 100%;
+ }
+ }
}
}
@@ -233,11 +246,15 @@
.propertiesView-sharingTable {
+ // whatever's commented out - add it back in when adding the buttons
+
+ // border: 1.5px solid black;
border: 1px solid black;
- padding: 5px;
- border-radius: 6px;
- /* width: 170px; */
- margin-right: 10px;
+ padding: 5px; // remove when adding buttons
+ border-radius: 6px; // remove when adding buttons
+ margin-right: 10px; // remove when adding buttons
+ // width: 100%;
+ // display: inline-table;
background-color: #ececec;
max-height: 130px;
overflow-y: scroll;
@@ -245,9 +262,11 @@
.propertiesView-sharingTable-item {
display: flex;
+ // padding: 5px;
padding: 3px;
align-items: center;
border-bottom: 0.5px solid grey;
+ cursor: pointer;
&:hover .propertiesView-sharingTable-item-name {
overflow-x: unset;
diff --git a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
index 89f48fc65..5634a438a 100644
--- a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
+++ b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
@@ -2,13 +2,11 @@ import React = require("react");
import { observer } from "mobx-react";
import "./PropertiesView.scss";
import { observable, action, computed, runInAction } from "mobx";
-import { Doc, Field, DocListCast, WidthSym, HeightSym, AclSym, AclPrivate, AclReadonly, AclAddonly, AclEdit, AclAdmin, Opt } from "../../../../fields/Doc";
-import { DocumentView } from "../../nodes/DocumentView";
+import { Doc, Field, WidthSym, HeightSym, AclSym, AclPrivate, AclReadonly, AclAddonly, AclEdit, AclAdmin, Opt, DocCastAsync } from "../../../../fields/Doc";
import { ComputedField } from "../../../../fields/ScriptField";
import { EditableView } from "../../EditableView";
import { KeyValueBox } from "../../nodes/KeyValueBox";
import { Cast, NumCast, StrCast } from "../../../../fields/Types";
-import { listSpec } from "../../../../fields/Schema";
import { ContentFittingDocumentView } from "../../nodes/ContentFittingDocumentView";
import { returnFalse, returnOne, emptyFunction, emptyPath, returnTrue, returnZero, returnEmptyFilter, Utils } from "../../../../Utils";
import { Id } from "../../../../fields/FieldSymbols";
@@ -16,23 +14,26 @@ import { Transform } from "../../../util/Transform";
import { PropertiesButtons } from "../../PropertiesButtons";
import { SelectionManager } from "../../../util/SelectionManager";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { Tooltip, Checkbox, Divider } from "@material-ui/core";
+import { Tooltip, Checkbox } from "@material-ui/core";
import SharingManager from "../../../util/SharingManager";
import { DocumentType } from "../../../documents/DocumentTypes";
-import FormatShapePane from "./FormatShapePane";
import { SharingPermissions, GetEffectiveAcl } from "../../../../fields/util";
import { InkField } from "../../../../fields/InkField";
import { undoBatch, UndoManager } from "../../../util/UndoManager";
import { ColorState, SketchPicker } from "react-color";
-import AntimodeMenu from "../../AntimodeMenu";
import "./FormatShapePane.scss";
import { discovery_v1 } from "googleapis";
import { PresBox } from "../../nodes/PresBox";
import { DocumentManager } from "../../../util/DocumentManager";
+import FormatShapePane from "./FormatShapePane";
const higflyout = require("@hig/flyout");
export const { anchorPoints } = higflyout;
export const Flyout = higflyout.default;
+// import * as fa from '@fortawesome/free-solid-svg-icons';
+// import { library } from "@fortawesome/fontawesome-svg-core";
+
+// library.add(fa.faPlus, fa.faMinus, fa.faCog);
interface PropertiesViewProps {
width: number;
@@ -51,8 +52,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@computed get selectedDocumentView() {
if (SelectionManager.SelectedDocuments().length) {
return SelectionManager.SelectedDocuments()[0];
- } else if (PresBox.Instance._selectedArray.length >= 1) {
- return DocumentManager.Instance.getDocumentView(PresBox.Instance.rootDoc);
+ } else if (PresBox.Instance?._selectedArray.length >= 1) {
+ return DocumentManager.Instance.getDocumentView(PresBox.Instance?.rootDoc);
} else { return undefined; }
}
@computed get isPres(): boolean {
@@ -70,6 +71,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@observable openLayout: boolean = true;
@observable openAppearance: boolean = true;
@observable openTransform: boolean = true;
+ // @observable selectedUser: string = "";
+ // @observable addButtonPressed: boolean = false;
+
//Pres Trails booleans:
@observable openAddSlide: boolean = true;
@observable openPresentationTools: boolean = true;
@@ -289,13 +293,20 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
}
}
+ /**
+ * Handles the changing of a user's permissions from the permissions panel.
+ */
@undoBatch
changePermissions = (e: any, user: string) => {
SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, this.selectedDoc!);
}
- getPermissionsSelect(user: string) {
+ /**
+ * @returns the options for the permissions dropdown.
+ */
+ getPermissionsSelect(user: string, permission: string) {
return <select className="permissions-select"
+ defaultValue={permission}
onChange={e => this.changePermissions(e, user)}>
{Object.values(SharingPermissions).map(permission => {
return (
@@ -306,6 +317,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</select>;
}
+ /**
+ * @returns the notification icon. On clicking, it should notify someone of a document been shared with them.
+ */
@computed get notifyIcon() {
return <Tooltip title={<><div className="dash-tooltip">Notify with message</div></>}>
<div className="notify-button">
@@ -314,6 +328,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</Tooltip>;
}
+ /**
+ * ... next to the owner that opens the main SharingManager interface on click.
+ */
@computed get expansionIcon() {
return <Tooltip title={<><div className="dash-tooltip">{"Show more permissions"}</div></>}>
<div className="expansion-button" onPointerDown={() => {
@@ -326,17 +343,26 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</Tooltip>;
}
- sharingItem(name: string, effectiveAcl: symbol, permission?: string) {
- return <div className="propertiesView-sharingTable-item">
+ /**
+ * @returns a row of the permissions panel
+ */
+ sharingItem(name: string, effectiveAcl: symbol, permission: string) {
+ return <div className="propertiesView-sharingTable-item"
+ // style={{ backgroundColor: this.selectedUser === name ? "#bcecfc" : "" }}
+ // onPointerDown={action(() => this.selectedUser = this.selectedUser === name ? "" : name)}
+ >
<div className="propertiesView-sharingTable-item-name" style={{ width: name !== "Me" ? "85px" : "80px" }}> {name} </div>
{/* {name !== "Me" ? this.notifyIcon : null} */}
<div className="propertiesView-sharingTable-item-permission">
- {effectiveAcl === AclAdmin && permission !== "Owner" ? this.getPermissionsSelect(name) : permission}
+ {effectiveAcl === AclAdmin && permission !== "Owner" ? this.getPermissionsSelect(name, permission) : permission}
{permission === "Owner" ? this.expansionIcon : null}
</div>
</div>;
}
+ /**
+ * @returns the sharing and permissiosn panel.
+ */
@computed get sharingTable() {
const AclMap = new Map<symbol, string>([
[AclPrivate, SharingPermissions.None],
@@ -349,13 +375,22 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
const effectiveAcl = GetEffectiveAcl(this.selectedDoc!);
const tableEntries = [];
+ // DocCastAsync(Doc.UserDoc().sidebarUsersDisplayed).then(sidebarUsersDisplayed => {
if (this.selectedDoc![AclSym]) {
for (const [key, value] of Object.entries(this.selectedDoc![AclSym])) {
const name = key.substring(4).replace("_", ".");
- if (name !== Doc.CurrentUserEmail && name !== this.selectedDoc!.author) tableEntries.push(this.sharingItem(name, effectiveAcl, AclMap.get(value)!));
+ if (name !== Doc.CurrentUserEmail && name !== this.selectedDoc!.author/* && sidebarUsersDisplayed![name] !== false*/) tableEntries.push(this.sharingItem(name, effectiveAcl, AclMap.get(value)!));
}
}
+ // if (Doc.UserDoc().sidebarUsersDisplayed) {
+ // for (const [name, value] of Object.entries(sidebarUsersDisplayed!)) {
+ // if (value === true && !this.selectedDoc![`ACL-${name.substring(8).replace(".", "_")}`]) tableEntries.push(this.sharingItem(name.substring(8), effectiveAcl, SharingPermissions.None));
+ // }
+ // }
+ // })
+
+ // shifts the current user and the owner to the top of the doc.
tableEntries.unshift(this.sharingItem("Me", effectiveAcl, Doc.CurrentUserEmail === this.selectedDoc!.author ? "Owner" : StrCast(this.selectedDoc![`ACL-${Doc.CurrentUserEmail.replace(".", "_")}`])));
if (Doc.CurrentUserEmail !== this.selectedDoc!.author) tableEntries.unshift(this.sharingItem(StrCast(this.selectedDoc!.author), effectiveAcl, "Owner"));
@@ -754,8 +789,18 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</div>;
}
- render() {
+ /**
+ * Handles adding and removing members from the sharing panel
+ */
+ // handleUserChange = (selectedUser: string, add: boolean) => {
+ // if (!Doc.UserDoc().sidebarUsersDisplayed) Doc.UserDoc().sidebarUsersDisplayed = new Doc;
+ // DocCastAsync(Doc.UserDoc().sidebarUsersDisplayed).then(sidebarUsersDisplayed => {
+ // sidebarUsersDisplayed![`display-${selectedUser}`] = add;
+ // !add && runInAction(() => this.selectedUser = "");
+ // });
+ // }
+ render() {
if (!this.selectedDoc && !this.isPres) {
return <div className="propertiesView" style={{ width: this.props.width }}>
<div className="propertiesView-title" style={{ width: this.props.width }}>
@@ -807,6 +852,36 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
{!this.openSharing ? (null) :
<div className="propertiesView-sharing-content">
{this.sharingTable}
+ {/* <div className="change-buttons">
+ <button
+ onPointerDown={action(() => this.addButtonPressed = !this.addButtonPressed)}
+ >
+ <FontAwesomeIcon icon={fa.faPlus} size={"sm"} style={{ marginTop: -3, marginLeft: -3 }} />
+ </button>
+ <button
+ id="sharingProperties-removeUser"
+ onPointerDown={() => this.handleUserChange(this.selectedUser, false)}
+ style={{ backgroundColor: this.selectedUser ? "#121721" : "#777777" }}
+ ><FontAwesomeIcon icon={fa.faMinus} size={"sm"} style={{ marginTop: -3, marginLeft: -3 }} /></button>
+ <button onClick={() => SharingManager.Instance.open(this.selectedDocumentView!)}><FontAwesomeIcon icon={fa.faCog} size={"sm"} style={{ marginTop: -3, marginLeft: -3 }} /></button>
+ {this.addButtonPressed ?
+ // <input type="text" onKeyDown={this.handleKeyPress} /> :
+ <select onChange={e => this.handleUserChange(e.target.value, true)}>
+ <option selected disabled hidden>
+ Add users
+ </option>
+ {SharingManager.Instance.users.map(user =>
+ (<option value={user.user.email}>
+ {user.user.email}
+ </option>)
+ )}
+ {GroupManager.Instance.getAllGroups().map(group =>
+ (<option value={StrCast(group.groupName)}>
+ {StrCast(group.groupName)}
+ </option>))}
+ </select> :
+ null}
+ </div> */}
</div>}
</div>
@@ -884,9 +959,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
<div className="propertiesView-name">
{this.editableTitle}
<div className="propertiesView-presSelected">
- {PresBox.Instance._selectedArray.length} selected
+ {PresBox.Instance?._selectedArray.length} selected
<div className="propertiesView-selectedList">
- {PresBox.Instance.listOfSelected}
+ {PresBox.Instance?.listOfSelected}
</div>
</div>
</div>
@@ -900,7 +975,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</div>
</div>
{this.openAddSlide ? <div className="propertiesView-settings-content">
- {PresBox.Instance.newDocumentDropdown}
+ {PresBox.Instance?.newDocumentDropdown}
</div> : null}
</div>
<div className="propertiesView-sharing">
@@ -913,7 +988,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</div>
</div>
{this.openPresTransitions ? <div className="propertiesView-sharing-content">
- {PresBox.Instance.transitionDropdown}
+ {PresBox.Instance?.transitionDropdown}
</div> : null}
</div>
<div className="propertiesView-sharing">
@@ -926,20 +1001,20 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</div>
</div>
{this.openPresProgressivize ? <div className="propertiesView-sharing-content">
- {PresBox.Instance.progressivizeDropdown}
+ {PresBox.Instance?.progressivizeDropdown}
</div> : null}
</div>
<div className="propertiesView-sharing">
<div className="propertiesView-sharing-title"
onPointerDown={() => runInAction(() => { this.openSlideOptions = !this.openSlideOptions; })}
style={{ backgroundColor: this.openSlideOptions ? "black" : "" }}>
- &nbsp; <FontAwesomeIcon icon={"cog"} /> &nbsp; {PresBox.Instance.stringType} options
+ &nbsp; <FontAwesomeIcon icon={"cog"} /> &nbsp; {PresBox.Instance?.stringType} options
<div className="propertiesView-sharing-title-icon">
<FontAwesomeIcon icon={this.openSlideOptions ? "caret-down" : "caret-right"} size="lg" color="white" />
</div>
</div>
{this.openSlideOptions ? <div className="propertiesView-sharing-content">
- {PresBox.Instance.optionsDropdown}
+ {PresBox.Instance?.optionsDropdown}
</div> : null}
</div>
<div className="propertiesView-sharing">