aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/SharingManager.tsx
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-05-04 10:46:20 -0400
committersrichman333 <sarah_n_richman@brown.edu>2023-05-04 10:46:20 -0400
commit50876028b994044f2a9426a4efb85a363f0d7168 (patch)
tree00c3c0ccc93603a980da1cfa13fd6cec331f036d /src/client/util/SharingManager.tsx
parentd1e4d4a9daae4f037cf8b22e1011d97680a01e27 (diff)
properties view + sharing manager are consistent, and all text updates properly
Diffstat (limited to 'src/client/util/SharingManager.tsx')
-rw-r--r--src/client/util/SharingManager.tsx120
1 files changed, 22 insertions, 98 deletions
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 5e61f6d3c..40a282db0 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -25,6 +25,7 @@ import { GroupMemberView } from './GroupMemberView';
import { LinkManager } from './LinkManager';
import { SelectionManager } from './SelectionManager';
import './SharingManager.scss';
+import { IconButton, Size } from 'browndash-components';
export interface User {
email: string;
@@ -159,27 +160,14 @@ export class SharingManager extends React.Component<{}> {
const myAcl = `acl-${Doc.CurrentUserEmailNormalized}`;
const isDashboard = DocListCast(Doc.MyDashboards.data).indexOf(target) !== -1;
- // var docs: Doc[] = [];
- // const dashboardList = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
- // const dashboard = dashboardList[0]
- // docs.push(dashboard!)
- // const tabs = DocListCast(dashboard?.data)
- // tabs.forEach(tab => {
- // docs.push(tab)
- // var newDocs = DocListCast(tab.data)
- // newDocs.forEach(newDoc =>
- // docs.push(newDoc))
- // })
-
- // if (!docs){
- // return null;
- // }
+ // setting the same acl for a docs within the doc being shared
+ var childDocs = DocListCast(target.data)
+ childDocs.map(doc => {
+ this.setInternalSharing(recipient, permission, doc)
+ })
const docs = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
- //var docs: Doc[] = [];
- docs.push(targetDoc!)
-
// ! ensures it returns true if document has been shared successfully, false otherwise
return !docs
.map(doc => (this.layoutDocAcls ? doc : doc[DataSym]))
@@ -191,7 +179,6 @@ export class SharingManager extends React.Component<{}> {
} else {
if (!doc[acl] || doc[acl] === SharingPermissions.None) doc.numUsersShared = NumCast(doc.numUsersShared, 0) + 1;
}
- doc = targetDoc
distributeAcls(acl, permission as SharingPermissions, doc, undefined, undefined, isDashboard);
this.setDashboardBackground(doc, permission as SharingPermissions);
@@ -211,19 +198,15 @@ export class SharingManager extends React.Component<{}> {
const key = normalizeEmail(StrCast(group.title));
const acl = `acl-${key}`;
const isDashboard = DocListCast(Doc.MyDashboards.data).indexOf(target) !== -1;
-
- var docs: Doc[] = [];
- const dashboardList = SelectionManager.Views().length < 2 ? [this.targetDoc] : SelectionManager.Views().map(docView => docView.props.Document);
- const dashboard = dashboardList[0]
- const tabs = DocListCast(dashboard?.data)
- tabs.forEach(tab => {
- var newDocs = DocListCast(tab.data)
- newDocs.forEach(newDoc => docs.push(newDoc))
- })
- if (!docs){
- return null;
- }
+ // setting the same acl for a docs within the doc being shared
+ var childDocs = DocListCast(target.data)
+ childDocs.map(doc => {
+ this.setInternalGroupSharing(group, permission, doc)
+ })
+
+ const docs = SelectionManager.Views().length < 2 ? [target] : SelectionManager.Views().map(docView => docView.props.Document);
+
// ! ensures it returns true if document has been shared successfully, false otherwise
return !docs
.map(doc => (this.layoutDocAcls ? doc : doc[DataSym]))
@@ -292,6 +275,7 @@ export class SharingManager extends React.Component<{}> {
const dashboards = DocListCast(Doc.MyDashboards.data);
docs.forEach(doc => {
const isDashboard = dashboards.indexOf(doc) !== -1;
+ this.shareFromPropertiesSidebar(shareWith, permission, DocListCast(doc.data))
if (GetEffectiveAcl(doc) === AclAdmin) distributeAcls(`acl-${shareWith}`, permission, doc, undefined, undefined, isDashboard);
this.setDashboardBackground(doc, permission as SharingPermissions);
});
@@ -364,30 +348,15 @@ export class SharingManager extends React.Component<{}> {
// return;
// }
// targetDoc["acl-" + PublicKey] = permission;
- // }
-
- private get sharingUrl() {
- if (!this.targetDoc) {
- return undefined;
- }
- const baseUrl = Utils.prepend("/doc/" + this.targetDoc[Id]);
- return `${baseUrl}?sharing=true`;
- }
+ // }s
/**
* Copies the Public sharing url to the user's clipboard.
*/
private copyURL = (e: any) => {
- Utils.CopyText(this.sharingUrl!)
+ Utils.CopyText(Utils.shareUrl(this.targetDoc![Id]))
}
- // copy = action(() => {
- // if (this.sharingUrl) {
- // Utils.CopyText(this.sharingUrl);
- // this.copied = true;
- // }
- // });
-
/**
* Returns the SharingPermissions (Admin, Can Edit etc) access that's used to share
*/
@@ -396,7 +365,6 @@ export class SharingManager extends React.Component<{}> {
if (!uniform) dropdownValues.unshift('-multiple-');
if (!override) dropdownValues.splice(dropdownValues.indexOf(SharingPermissions.Unset), 1);
return dropdownValues
- .filter(permission => permission != SharingPermissions.SelfEdit && (!Doc.noviceMode || ![SharingPermissions.SelfEdit].includes(permission as any)))
.map(permission => (
<option key={permission} value={permission}>
{permission}
@@ -546,19 +514,6 @@ export class SharingManager extends React.Component<{}> {
// users in common between all docs
const commonKeys = intersection(...docs.map(doc => (this.layoutDocAcls ? doc : doc[DataSym])).map(doc => doc?.[AclSym] && Object.keys(doc[AclSym])));
- // including all users on dashboard
- // SharingManager.Instance.users.forEach(eachUser => {
- // var userOnDashboard = true;
- // if(Doc.ActiveDashboard){
- // if(Doc.ActiveDashboard['acl-'+normalizeEmail(eachUser.user.email)]=='' || Doc.ActiveDashboard['acl-'+normalizeEmail(eachUser.user.email)]==undefined){
- // userOnDashboard = false;
- // }
- // }
- // if (userOnDashboard && !commonKeys.includes(`acl-${normalizeEmail(eachUser.user.email)}`)){
- // users.push(eachUser.user);
- // }
- // });
-
// the list of users shared with
const userListContents: (JSX.Element | null)[] = users
@@ -570,19 +525,6 @@ export class SharingManager extends React.Component<{}> {
const dashboard = Doc.ActiveDashboard
var docToUse = dashboard
- // const tabs = DocListCast(dashboard?.data)
- // tabs.forEach(tab => {
- // if (tab.title == targetDoc.title){
- // docToUse = tab
- // }
- // var newdocsList = DocListCast(tab.data)
- // newdocsList.forEach(newDoc => {
- // if (newDoc.title == targetDoc.title){
- // docToUse = newDoc
- // }
- // })
- // })
-
docToUse = Doc.GetProto(this.targetDoc!)
const userKey = `acl-${normalizeEmail(user.email)}`;
@@ -641,22 +583,6 @@ export class SharingManager extends React.Component<{}> {
return !permissions ? null : (
<div key={groupKey} className={'container'}>
<div className={'padding'} >{StrCast(group.title)}</div>
- <div>
- {StrCast(group.title)==='Public' ? (
- <div title={"Copy Public URL"} onClick={this.copyURL}>
- {/* <IconButton
- size={Size.SMALL}
- isCircle={true}
- hoverStyle="gray"
- onClick={() => this.copyURL}
- icon={<FontAwesomeIcon icon="copy" />}
- /> */}
- <FontAwesomeIcon icon={'copy'} size={'sm'} />
- </div>
- ) : (
- <div/>
- )}
- </div>
{group instanceof Doc ? (
<div className="group-info" onClick={action(() => (GroupManager.Instance.currentGroup = group))}>
<FontAwesomeIcon icon={'info-circle'} color={'#e8e8e8'} size={'sm'} style={{ backgroundColor: '#1e89d7', borderRadius: '100%', border: '1px solid #1e89d7' }} />
@@ -679,19 +605,16 @@ export class SharingManager extends React.Component<{}> {
<div className={'sharing-interface'}>
{GroupManager.Instance?.currentGroup ? <GroupMemberView group={GroupManager.Instance.currentGroup} onCloseButtonClick={action(() => (GroupManager.Instance.currentGroup = undefined))} /> : null}
<div className="sharing-contents">
- <p className={'share-title'}>
+ <p className="share-title">
<b>Share </b>
{this.focusOn(docs.length < 2 ? StrCast(targetDoc?.title, 'this document') : '-multiple-')}
+ {/* <FontAwesomeIcon title={"Copy Public URL"} icon={'copy'} size={'sm'} onClick={this.copyURL}/> */}
+ <IconButton size={Size.SMALL} isCircle={true} tooltip='Copy Public URL' hoverStyle="gray" onClick={this.copyURL}icon={<FontAwesomeIcon icon="copy" />}/>
</p>
<div className={'close-button'} onClick={this.close}>
<FontAwesomeIcon icon={'times'} color={'black'} size={'lg'} />
</div>
- {/* {this.linkVisible ?
- <div>
- {this.sharingUrl}
- </div> :
- (null)} */}
- {
+ { admin ?
<div className="share-container">
<div className="share-setup">
<Select
@@ -730,6 +653,7 @@ export class SharingManager extends React.Component<{}> {
)}
</div>
</div>
+ : <br></br>
}
<div className="main-container">
<div className={'individual-container'}>