aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
-rw-r--r--src/client/views/PropertiesView.tsx96
1 files changed, 76 insertions, 20 deletions
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index e750dc43a..c34760d13 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -7,7 +7,7 @@ import { intersection } from 'lodash';
import { action, autorun, computed, Lambda, observable } from 'mobx';
import { observer } from 'mobx-react';
import { ColorState, SketchPicker } from 'react-color';
-import { AclAdmin, AclSym, HierarchyMapping, DataSym, Doc, DocListCast, Field, HeightSym, NumListCast, Opt, StrListCast, WidthSym } from '../../fields/Doc';
+import { AclAdmin, AclSym, HierarchyMapping, DataSym, Doc, DocListCast, Field, HeightSym, NumListCast, Opt, StrListCast, WidthSym, DocCastAsync } from '../../fields/Doc';
import { Id } from '../../fields/FieldSymbols';
import { InkField } from '../../fields/InkField';
import { List } from '../../fields/List';
@@ -364,8 +364,13 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
*/
@undoBatch
changePermissions = (e: any, user: string) => {
- const docs = (SelectionManager.Views().length < 2 ? [this.selectedDoc] : SelectionManager.Views().map(dv => dv.props.Document)).filter(doc => doc).map(doc => (this.layoutDocAcls ? doc : DocCast(doc)[DataSym]));
- SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs);
+ if (user=="Public"){
+ this.selectedDoc!['acl-' +user] = e.currentTarget.value as SharingPermissions;
+ }
+ else{
+ const docs = (SelectionManager.Views().length < 2 ? [this.selectedDoc] : SelectionManager.Views().map(dv => dv.props.Document)).filter(doc => doc).map(doc => (this.layoutDocAcls ? doc : DocCast(doc)[DataSym]));
+ SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs);
+ }
};
/**
@@ -376,11 +381,11 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
if (permission === '-multiple-') dropdownValues.unshift(permission);
if (user !== 'Override') dropdownValues.splice(dropdownValues.indexOf(SharingPermissions.Unset), 1);
return (
- <select className="permissions-select" value={permission} onChange={e => this.changePermissions(e, user)}>
+ <select className="propertiesView-permissions-select" value={permission} onChange={e => this.changePermissions(e, user)}>
{dropdownValues
.filter(permission => !Doc.noviceMode || ![SharingPermissions.View, SharingPermissions.SelfEdit].includes(permission as any))
.map(permission => (
- <option key={permission} value={permission}>
+ <option className="propertiesView-permisssions-select" key={permission} value={permission}>
{' '}
{permission}{' '}
</option>
@@ -433,8 +438,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
// onPointerDown={action(() => this.selectedUser = this.selectedUser === name ? "" : name)}
>
<div className="propertiesView-sharingTable-item-name" style={{ width: name !== 'Me' ? '85px' : '80px' }}>
- {' '}
- {name}{' '}
+ {' '}{name}{' '}
</div>
{/* {name !== "Me" ? this.notifyIcon : null} */}
<div className="propertiesView-sharingTable-item-permission">
@@ -445,13 +449,52 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
);
}
+ publicACLDropDown(admin: boolean, permission: string, showExpansionIcon?: boolean){
+ var dropDownText = "";
+ switch(StrCast(permission)){
+ case ("Edit"):
+ dropDownText = "⬢ ";
+ break;
+ case ("Self-Edit"):
+ dropDownText = "⬢ ";
+ break;
+ case ("Augment"):
+ dropDownText = "⬟ ";
+ break;
+ case ("View"):
+ dropDownText = "♦ ";
+ break;
+ case ("Not-Shared"):
+ dropDownText = "▲ ";
+ break;
+ }
+ return (
+ <div>
+ <div className={'propertiesView-shareDropDown'}>
+ <div className={`propertiesView-shareDropDown${permission}`}>
+ <div className="propertiesView-shareDropDown">
+ {' '}{dropDownText}{' '}
+ {admin && permission !== 'Owner' ? this.getPermissionsSelect("Public", permission) : permission}
+ {permission === 'Owner' || showExpansionIcon ? this.expansionIcon : null}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
/**
* @returns the sharing and permissions panel.
*/
@computed get sharingTable() {
+ // const docToUse = this.selectedDocumentView?.rootDoc;
+ const docToUse = this.selectedDoc;
+ if (!docToUse){
+ return null;
+ }
// all selected docs
const docs =
- SelectionManager.Views().length < 2 ? [this.layoutDocAcls ? this.selectedDoc : this.selectedDoc?.[DataSym]] : SelectionManager.Views().map(docView => (this.layoutDocAcls ? docView.props.Document : docView.props.Document[DataSym]));
+ SelectionManager.Views().length < 2 ? [this.layoutDocAcls ? docToUse : docToUse?.[DataSym]] : SelectionManager.Views().map(docView => (this.layoutDocAcls ? docView.props.Document : docView.props.Document[DataSym]));
const target = docs[0];
@@ -479,17 +522,27 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
// 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-"));
if (ownerSame) tableEntries.unshift(this.sharingItem(StrCast(target.author), showAdmin, 'Owner'));
- tableEntries.unshift(this.sharingItem('Public', showAdmin, docs.filter(doc => doc).every(doc => doc['acl-Public'] === target['acl-Public']) ? target['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]) ? HierarchyMapping.get(effectiveAcls[0])!.name : '-multiple-',
- !ownerSame
- )
- );
- return <div className="propertiesView-sharingTable">{tableEntries}</div>;
+ // tableEntries.unshift(this.sharingItem(target.author, showAdmin, docs.filter(doc => doc).every(doc => doc['acl-Public'] === target['acl-Public']) ? target['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]) ? HierarchyMapping.get(effectiveAcls[0])!.name : '-multiple-',
+ // !ownerSame
+ // )
+ // );
+ docs.map(doc => tableEntries.unshift(this.sharingItem(doc.author, showAdmin, doc['acl-Public'], true)));
+
+ return (
+ <div> Sharing Mode
+ <div>{this.publicACLDropDown(true, StrCast(docToUse['acl-Public']), false)}</div>
+ <div> <br></br> Who has access to the Dashboard? </div>
+ <div className="propertiesView-sharingTable">{
+ <div> {tableEntries}</div>
+ }</div>
+ </div>
+ );
}
@computed get fieldsCheckbox() {
@@ -1116,12 +1169,15 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
{!this.openSharing ? null : (
<div className="propertiesView-sharing-content">
<div className="propertiesView-buttonContainer">
- {!Doc.noviceMode ? (
+
+
+ {/* {!Doc.noviceMode ? ( // what is the layout checkbox for?
<div className="propertiesView-acls-checkbox">
<Checkbox color="primary" onChange={action(() => (this.layoutDocAcls = !this.layoutDocAcls))} checked={this.layoutDocAcls} />
<div className="propertiesView-acls-checkbox-text">Layout</div>
</div>
- ) : null}
+ ) : null} */}
+
{/* <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" />