aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/SharingManager.tsx25
-rw-r--r--src/client/views/PropertiesView.tsx49
2 files changed, 49 insertions, 25 deletions
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 59a88b404..0f7ce26d2 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -214,9 +214,7 @@ export class SharingManager extends React.Component<{}> {
const docs = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
- if (acl == 'acl-Public' && this.layoutDocAcls){
- acl = 'acl-Public-layout';
- }
+ if (acl == 'acl-Public' && this.layoutDocAcls) acl = 'acl-Public-layout';
// ! ensures it returns true if document has been shared successfully, false otherwise
return !docs
.map(doc => (this.layoutDocAcls ? doc : doc[DocData]))
@@ -274,7 +272,8 @@ export class SharingManager extends React.Component<{}> {
/**
* Called from the properties sidebar to change permissions of a user.
*/
- shareFromPropertiesSidebar = (shareWith: string, permission: SharingPermissions, docs: Doc[]) => {
+ shareFromPropertiesSidebar = (shareWith: string, permission: SharingPermissions, docs: Doc[], layout: boolean) => {
+ if (layout) this.layoutDocAcls = true;
if (shareWith !== 'Public' && shareWith !== 'Override') {
const user = this.users.find(({ user: { email } }) => email === (shareWith === 'Me' ? Doc.CurrentUserEmail : shareWith));
docs.forEach(doc => {
@@ -285,11 +284,17 @@ export class SharingManager extends React.Component<{}> {
const dashboards = DocListCast(Doc.MyDashboards.data);
docs.forEach(doc => {
const isDashboard = dashboards.indexOf(doc) !== -1;
- if (this.overridePrevious) this.shareFromPropertiesSidebar(shareWith, permission, DocListCast(doc.data));
- if (GetEffectiveAcl(doc) === AclAdmin) distributeAcls(`acl-${shareWith}`, permission, doc, undefined, undefined, isDashboard);
+ if (this.overridePrevious) {
+ this.shareFromPropertiesSidebar(shareWith, permission, DocListCast(doc.data), layout);
+ }
+ if (GetEffectiveAcl(doc) === AclAdmin) {
+ if ( shareWith == 'Public' && layout) shareWith = 'Public-layout';
+ distributeAcls(`acl-${shareWith}`, permission, doc, undefined, undefined, isDashboard);
+ }
this.setDashboardBackground(doc, permission as SharingPermissions);
});
}
+ this.layoutDocAcls = false;
};
/**
@@ -607,16 +612,12 @@ export class SharingManager extends React.Component<{}> {
// const permissions = uniform ? StrCast(targetDoc?.[`acl-${StrCast(group.title)}`]) : '-multiple-';
let permissions = this.layoutDocAcls ? (targetDoc[DocAcl][groupKey] ? HierarchyMapping.get(targetDoc[DocAcl][groupKey])?.name : StrCast(Doc.GetProto(targetDoc)[groupKey])) : StrCast(targetDoc[groupKey]);
if (this.layoutDocAcls){
- if (groupKey == 'acl-Public'){
- groupKey = 'acl-Public-layout'
- }
+ if (groupKey == 'acl-Public') groupKey = 'acl-Public-layout';
if (targetDoc[DocAcl][groupKey]){
permissions = HierarchyMapping.get(targetDoc[DocAcl][groupKey])?.name;
}
else{
- if (groupKey == 'acl-Public-layout'){
- groupKey = 'acl-Public'
- }
+ if (groupKey == 'acl-Public-layout') groupKey = 'acl-Public';
if (targetDoc['embedContainer']){
permissions = StrCast(Doc.GetProto(DocCast(targetDoc['embedContainer']))[groupKey]);
}
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index d5d09389f..0a8eabdb1 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -8,7 +8,7 @@ import { Lambda, action, computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import { ColorState, SketchPicker } from 'react-color';
import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from '../../Utils';
-import { Doc, Field, FieldResult, NumListCast, Opt, ReverseHierarchyMap, StrListCast } from '../../fields/Doc';
+import { Doc, Field, FieldResult, HierarchyMapping, NumListCast, Opt, ReverseHierarchyMap, StrListCast } from '../../fields/Doc';
import { AclAdmin, DocAcl, DocData, Height, Width } from '../../fields/DocSymbols';
import { Id } from '../../fields/FieldSymbols';
import { InkField } from '../../fields/InkField';
@@ -303,7 +303,7 @@ 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)[DocData]));
- SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs);
+ SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs, this.layoutDocAcls);
};
/**
@@ -450,8 +450,17 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
// sorts and then adds each user to the table
usersAdded.sort(this.sortUsers);
usersAdded.map(userEmail => {
- const permission = StrCast(target[`acl-${normalizeEmail(userEmail)}`]);
- individualTableEntries.unshift(this.sharingItem(userEmail, showAdmin, permission, false)); // adds each user
+ const userKey = `acl-${normalizeEmail(userEmail)}`;
+ var permission;
+ if (this.layoutDocAcls){
+ if (target[DocAcl][userKey]){
+ permission = HierarchyMapping.get(target[DocAcl][userKey])?.name;
+ }
+ else if (target['embedContainer']) permission = StrCast(Doc.GetProto(DocCast(target['embedContainer']))[userKey]);
+ else permission = StrCast(Doc.GetProto(target)?.[userKey]);
+ }
+ else permission = StrCast(target[userKey]);
+ individualTableEntries.unshift(this.sharingItem(userEmail, showAdmin, permission!, false)); // adds each user
});
// adds current user
@@ -473,17 +482,33 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
if (group.title != 'Public' && this.selectedDoc) {
const groupKey = 'acl-' + normalizeEmail(StrCast(group.title));
if (this.selectedDoc[groupKey] != '' && this.selectedDoc[groupKey] != undefined) {
- const permission = StrCast(target[groupKey]);
- groupTableEntries.unshift(this.sharingItem(StrCast(group.title), showAdmin, permission, false));
+ var permission;
+ if (this.layoutDocAcls){
+ if (target[DocAcl][groupKey]){
+ permission = HierarchyMapping.get(target[DocAcl][groupKey])?.name;
+ }
+ else if (target['embedContainer']) permission = StrCast(Doc.GetProto(DocCast(target['embedContainer']))[groupKey]);
+ else permission = StrCast(Doc.GetProto(target)?.[groupKey]);
+ }
+ else permission = StrCast(target[groupKey]);
+ groupTableEntries.unshift(this.sharingItem(StrCast(group.title), showAdmin, permission!, false));
}
}
});
+ // public permission
+ let publicPermission = StrCast(target['acl-Public']);
+ if (this.layoutDocAcls){
+ if (target['acl-Public-layout']) publicPermission = StrCast(target['acl-Public-layout']);
+ else if (target['embedContainer']) publicPermission = StrCast(Doc.GetProto(DocCast(target['embedContainer']))['acl-Public']);
+ else StrCast(Doc.GetProto(target)['acl-Public']);
+ }
+
return (
<div>
{' '}
Public / Guest Users
- <div>{this.colorACLDropDown('Public', showAdmin, StrCast(target['acl-Public']), false)}</div>
+ <div>{this.colorACLDropDown('Public', showAdmin, publicPermission!, false)}</div>
<div>
{' '}
<br></br> Individual Users with Access to this Document{' '}
@@ -994,12 +1019,10 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
{!this.openSharing ? null : (
<div className="propertiesView-sharing-content">
<div className="propertiesView-buttonContainer">
- {/* {!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} */}
+ <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>
{/* <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
<button onPointerDown={() => SharingManager.Instance.distributeOverCollection(this.selectedDoc!)}>