diff options
| author | srichman333 <sarah_n_richman@brown.edu> | 2023-06-15 10:14:16 -0400 |
|---|---|---|
| committer | srichman333 <sarah_n_richman@brown.edu> | 2023-06-15 10:14:16 -0400 |
| commit | 540b8310170f599c93811291ce6d3992c323cd42 (patch) | |
| tree | ca92ce09ad100712a46408fc86ed4a26e6a397d0 /src/client/views/PropertiesView.tsx | |
| parent | f0474c18d092f4db49255a1e92d7f052b7398897 (diff) | |
properties view
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
| -rw-r--r-- | src/client/views/PropertiesView.tsx | 50 |
1 files changed, 48 insertions, 2 deletions
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<PropertiesViewProps> { ); } + /** + * @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<PropertiesViewProps> { {' '} {dropDownText} {admin && permission !== 'Owner' ? this.getPermissionsSelect(name, permission) : permission} - {/* {(permission === 'Owner' && name == 'Me') || showExpansionIcon ? this.expansionIcon : null} */} </div> </div> </div> @@ -427,6 +435,13 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { }; /** + * Sorting algorithm to sort groups. + */ + sortGroups = (g1: Doc, g2: Doc) => { + return g1 > g2 ? -1 : g1 === g2 ? 0 : 1; + }; + + /** * @returns the sharing and permissions panel. */ @computed get sharingTable() { @@ -451,6 +466,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { 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<PropertiesViewProps> { 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<PropertiesViewProps> { } }); +<<<<<<< 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<PropertiesViewProps> { !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<PropertiesViewProps> { 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); |
