From 540b8310170f599c93811291ce6d3992c323cd42 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Thu, 15 Jun 2023 10:14:16 -0400 Subject: properties view --- src/.DS_Store | Bin 10244 -> 10244 bytes src/client/util/SharingManager.scss | 3 +- src/client/util/SharingManager.tsx | 31 +++++++++++-------- src/client/views/DocumentDecorations.tsx | 4 +-- src/client/views/PropertiesView.tsx | 50 +++++++++++++++++++++++++++++-- 5 files changed, 71 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/.DS_Store b/src/.DS_Store index be99aa5af..06389d6ae 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/client/util/SharingManager.scss b/src/client/util/SharingManager.scss index aa1e11ef5..80d5807b4 100644 --- a/src/client/util/SharingManager.scss +++ b/src/client/util/SharingManager.scss @@ -107,6 +107,7 @@ .group-container { width: 50%; display: flex; + top:0; flex-direction: column; .user-sort { @@ -199,7 +200,7 @@ display: flex; position: relative; margin-top: 5px; - margin-bottom: 10px; + // margin-bottom: 10px; font-size: 22px; -webkit-user-select: none; -moz-user-select: none; diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 6112b5b69..78e502e6e 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -526,7 +526,7 @@ export class SharingManager extends React.Component<{}> { docToUse = Doc.GetProto(this.targetDoc!); const userKey = `acl-${normalizeEmail(user.email)}`; - const uniform = docs.map(doc => (this.layoutDocAcls ? doc : doc[DataSym])).every(doc => doc?.[AclSym]?.[userKey] === docs[0]?.[AclSym]?.[userKey]); + const uniform = docs.map(doc => (this.layoutDocAcls ? doc : doc[DocData])).every(doc => doc?.[DocAcl]?.[userKey] === docs[0]?.[DocAcl]?.[userKey]); const permissions = uniform ? StrCast(targetDoc?.[userKey]) : '-multiple-'; return !permissions ? null : ( @@ -574,8 +574,8 @@ export class SharingManager extends React.Component<{}> { const groupListContents = groupListMap.map(group => { const groupKey = `acl-${StrCast(group.title)}`; const uniform = docs - .map(doc => (this.layoutDocAcls ? doc : doc[DataSym])) - .every(doc => (this.layoutDocAcls ? doc?.[AclSym]?.[groupKey] === docs[0]?.[AclSym]?.[groupKey] : doc?.[DataSym]?.[AclSym]?.[groupKey] === docs[0]?.[DataSym]?.[AclSym]?.[groupKey])); + .map(doc => (this.layoutDocAcls ? doc : doc[DocData])) + .every(doc => (this.layoutDocAcls ? doc?.[DocAcl]?.[groupKey] === docs[0]?.[DocAcl]?.[groupKey] : doc?.[DocData]?.[DocAcl]?.[groupKey] === docs[0]?.[DocData]?.[DocAcl]?.[groupKey])); const permissions = uniform ? StrCast(targetDoc?.[`acl-${StrCast(group.title)}`]) : '-multiple-'; return !permissions ? null : ( @@ -670,14 +670,21 @@ export class SharingManager extends React.Component<{}> {
(this.groupSort = this.groupSort === 'ascending' ? 'descending' : this.groupSort === 'descending' ? 'none' : 'ascending'))}> - Groups{' '} - {this.groupSort === 'ascending' ? ( - - ) : this.groupSort === 'descending' ? ( - - ) : ( - - )} +
+ Groups +   +
(GroupManager.Instance?.open()))}> + +
+   + {this.groupSort === 'ascending' ? ( + + ) : this.groupSort === 'descending' ? ( + + ) : ( + + )} +
{groupListContents}
@@ -690,4 +697,4 @@ export class SharingManager extends React.Component<{}> { render() { return ; } -} +} \ No newline at end of file diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 74cf58c7b..0cd92e2cf 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -760,8 +760,8 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P } // sharing - const docShareMode = Doc.GetProto(seldocview.rootDoc)['acl-Public']; - // const docShareMode = Doc.GetProto(seldocview.rootDoc)['acl-'+normalizeEmail(Doc.CurrentUserEmail)]; + // const docShareMode = Doc.GetProto(seldocview.rootDoc)['acl-Public']; + const docShareMode = Doc.GetProto(seldocview.rootDoc)['acl-'+normalizeEmail(Doc.CurrentUserEmail)]; const shareMode = StrCast(docShareMode); var shareSymbolIcon = null; switch (shareMode) { diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index b6699c3bf..ca27e244d 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -6,7 +6,11 @@ import { Checkbox, Tooltip } from '@material-ui/core'; import { action, computed, Lambda, observable } from 'mobx'; import { observer } from 'mobx-react'; import { ColorState, SketchPicker } from 'react-color'; +<<<<<<< Updated upstream import { AclAdmin, AclSym, DataSym, Doc, Field, FieldResult, HeightSym, HierarchyMapping, NumListCast, Opt, StrListCast, WidthSym } from '../../fields/Doc'; +======= +import { AclAdmin, AclSym, DataSym, Doc, Field, FieldResult, HeightSym, NumListCast, Opt, StrListCast, WidthSym } from '../../fields/Doc'; +>>>>>>> Stashed changes import { Id } from '../../fields/FieldSymbols'; import { InkField } from '../../fields/InkField'; import { List } from '../../fields/List'; @@ -33,6 +37,8 @@ import { PropertiesDocBacklinksSelector } from './PropertiesDocBacklinksSelector import { PropertiesDocContextSelector } from './PropertiesDocContextSelector'; import './PropertiesView.scss'; import { DefaultStyleProvider } from './StyleProvider'; +import { GroupManager } from '../util/GroupManager'; +import { intersection } from 'lodash'; const higflyout = require('@hig/flyout'); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -384,6 +390,9 @@ export class PropertiesView extends React.Component { ); } + /** + * @returns a colored dropdown bar reflective of the permission + */ colorACLDropDown(name: string, admin: boolean, permission: string, showExpansionIcon?: boolean) { var dropDownText = ''; switch (StrCast(permission)) { @@ -411,7 +420,6 @@ export class PropertiesView extends React.Component { {' '} {dropDownText} {admin && permission !== 'Owner' ? this.getPermissionsSelect(name, permission) : permission} - {/* {(permission === 'Owner' && name == 'Me') || showExpansionIcon ? this.expansionIcon : null} */} @@ -426,6 +434,13 @@ export class PropertiesView extends React.Component { return u1 > u2 ? -1 : u1 === u2 ? 0 : 1; }; + /** + * Sorting algorithm to sort groups. + */ + sortGroups = (g1: Doc, g2: Doc) => { + return g1 > g2 ? -1 : g1 === g2 ? 0 : 1; + }; + /** * @returns the sharing and permissions panel. */ @@ -451,6 +466,7 @@ export class PropertiesView extends React.Component { const tableEntries = []; const usersAdded: string[] = []; // all shared users being added - organized by denormalized email +<<<<<<< Updated upstream // DocCastAsync(Doc.UserDoc().sidebarUsersDisplayed).then(sidebarUsersDisplayed => { if (commonKeys.length) { for (const key of commonKeys) { @@ -458,6 +474,15 @@ export class PropertiesView extends React.Component { const uniform = docs.every(doc => doc?.[AclSym]?.[key] === docs[0]?.[AclSym]?.[key]); if (name !== Doc.CurrentUserEmail && name !== target.author && name !== 'Public' && name !== 'Override' /* && sidebarUsersDisplayed![name] !== false*/) { tableEntries.push(this.sharingItem(name, showAdmin, uniform ? HierarchyMapping.get(target[AclSym][key])!.name : '-multiple-')); +======= + // adds each user to usersAdded + SharingManager.Instance.users.forEach(eachUser => { + var userOnDashboard = true; + var permission = StrCast(target[`acl-${normalizeEmail(eachUser.user.email)}`]); + if (Doc.ActiveDashboard) { + if (Doc.ActiveDashboard['acl-' + normalizeEmail(eachUser.user.email)] == '' || Doc.ActiveDashboard['acl-' + normalizeEmail(eachUser.user.email)] == undefined) { + userOnDashboard = false; +>>>>>>> Stashed changes } } if (userOnDashboard && !usersAdded.includes(eachUser.user.email) && eachUser.user.email != 'Public' && eachUser.user.email != target.author) { @@ -466,6 +491,7 @@ export class PropertiesView extends React.Component { } }); +<<<<<<< Updated upstream const ownerSame = Doc.CurrentUserEmail !== target.author && docs.filter(doc => doc).every(doc => doc.author === docs[0].author); // 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-")); @@ -479,8 +505,16 @@ export class PropertiesView extends React.Component { !ownerSame ) ); +======= + // adds each user to the table + usersAdded.sort(this.sortUsers); + usersAdded.map(userEmail => { + const permission = StrCast(target[`acl-${normalizeEmail(userEmail)}`]); + tableEntries.unshift(this.sharingItem(userEmail, showAdmin, permission, false)); // adds each user + }); +>>>>>>> Stashed changes - // add current user + // adds current user var userEmail = Doc.CurrentUserEmail; if (userEmail == 'guest') userEmail = 'Public'; if (!usersAdded.includes(userEmail) && userEmail != 'Public' && userEmail != target.author) { @@ -488,6 +522,18 @@ export class PropertiesView extends React.Component { usersAdded.push(userEmail); } + // adds groups + const groupList = GroupManager.Instance?.allGroups || []; + const groups = groupList.slice().sort(this.sortGroups); + const commonKeys = intersection(...docs.map(doc => (this.layoutDocAcls ? doc : doc[DataSym])).map(doc => doc?.[AclSym] && Object.keys(doc[AclSym]))); + const groupListMap: (Doc | { title: string })[] = groups.filter(({ title }) => (docs.length > 1 ? commonKeys.includes(`acl-${normalizeEmail(StrCast(title))}`) : true)); + groupListMap.map(group => { + if (group.title != 'Public'){ + const permission = StrCast(target[`acl-${StrCast(group.title)}`]); + tableEntries.unshift(this.sharingItem(StrCast(group.title), showAdmin, permission, false)); + } + }) + // shift owner to top tableEntries.unshift(this.sharingItem(StrCast(target.author), showAdmin, 'Owner'), false); -- cgit v1.2.3-70-g09d2