diff options
author | srichman333 <sarah_n_richman@brown.edu> | 2023-06-15 12:47:31 -0400 |
---|---|---|
committer | srichman333 <sarah_n_richman@brown.edu> | 2023-06-15 12:47:31 -0400 |
commit | 40579c8b3cf0504ac10e966e640af58e8876acd3 (patch) | |
tree | cc280d53b66d244eae6bd1e5c5d00a0d6b1dc3ea /src | |
parent | e31f6403bc62faea72767f68d3bf34ac8bd28183 (diff) | |
parent | d92775bffab6470dc6142e02092b7cae2c30b5ff (diff) |
Merge branch 'collaboration-sarah' of https://github.com/brown-dash/Dash-Web into collaboration-sarah
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/tempCodeRunnerFile.ts | 1 | ||||
-rw-r--r-- | src/client/util/SharingManager.tsx | 13 | ||||
-rw-r--r-- | src/client/views/DocComponent.tsx | 4 | ||||
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 32 | ||||
-rw-r--r-- | src/client/views/MarqueeAnnotator.tsx | 2 | ||||
-rw-r--r-- | src/client/views/PropertiesView.tsx | 20 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 3 | ||||
-rw-r--r-- | src/fields/Doc.ts | 4 | ||||
-rw-r--r-- | src/fields/util.ts | 31 |
9 files changed, 45 insertions, 65 deletions
diff --git a/src/client/documents/tempCodeRunnerFile.ts b/src/client/documents/tempCodeRunnerFile.ts deleted file mode 100644 index 76ea17be0..000000000 --- a/src/client/documents/tempCodeRunnerFile.ts +++ /dev/null @@ -1 +0,0 @@ -Initializing
\ No newline at end of file diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 01f36bd29..a51a71268 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -1,4 +1,5 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { IconButton, Size } from 'browndash-components'; import { intersection } from 'lodash'; import { action, computed, observable, runInAction } from 'mobx'; import { observer } from 'mobx-react'; @@ -6,7 +7,7 @@ import * as React from 'react'; import Select from 'react-select'; import * as RequestPromise from 'request-promise'; import { Doc, DocListCast, DocListCastAsync, HierarchyMapping } from '../../fields/Doc'; -import { AclAdmin, AclPrivate, DocAcl, AclUnset, DocData } from '../../fields/DocSymbols'; +import { AclAdmin, AclPrivate, AclUnset, DocAcl, DocData } from '../../fields/DocSymbols'; import { Id } from '../../fields/FieldSymbols'; import { List } from '../../fields/List'; import { NumCast, StrCast } from '../../fields/Types'; @@ -23,7 +24,6 @@ import { GroupManager, UserOptions } from './GroupManager'; import { GroupMemberView } from './GroupMemberView'; import { SelectionManager } from './SelectionManager'; import './SharingManager.scss'; -import { IconButton, Size } from 'browndash-components'; export interface User { email: string; @@ -653,7 +653,7 @@ export class SharingManager extends React.Component<{}> { </div> </div> ) : ( - <br></br> + <br /> )} <div className="main-container"> <div className={'individual-container'}> @@ -672,9 +672,8 @@ export class SharingManager extends React.Component<{}> { <div className={'group-container'}> <div className="user-sort" onClick={action(() => (this.groupSort = this.groupSort === 'ascending' ? 'descending' : this.groupSort === 'descending' ? 'none' : 'ascending'))}> <div className="container"> - Groups - - <div className="group-info" onClick={action(() => (GroupManager.Instance?.open()))}> + Groups + <div className="group-info" onClick={action(() => GroupManager.Instance?.open())}> <FontAwesomeIcon icon={'info-circle'} color={'#e8e8e8'} size={'sm'} style={{ backgroundColor: '#1e89d7', borderRadius: '100%', border: '1px solid #1e89d7' }} /> </div> @@ -698,4 +697,4 @@ export class SharingManager extends React.Component<{}> { render() { return <MainViewModal contents={this.sharingInterface} isDisplayed={this.isOpen} interactive={true} dialogueBoxDisplayedOpacity={this.dialogueBoxOpacity} overlayDisplayedOpacity={this.overlayOpacity} closeOnExternalClick={this.close} />; } -}
\ No newline at end of file +} diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index dc9c8a0ce..db24229dc 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -214,7 +214,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>() // only make a pushpin if we have acl's to edit the document //DocUtils.LeavePushpin(doc); doc._stayInCollection = undefined; - doc.context = this.props.Document; + doc.embedContainer = this.props.Document; if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.rootDoc; Doc.ActiveDashboard && inheritParentAcls(Doc.ActiveDashboard, doc); @@ -222,7 +222,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>() const annoDocs = targetDataDoc[annotationKey ?? this.annotationKey] as List<Doc>; if (annoDocs instanceof List) annoDocs.push(...added); else targetDataDoc[annotationKey ?? this.annotationKey] = new List<Doc>(added); - targetDataDoc[(annotationKey ?? this.annotationKey) + '-lastModified'] = new DateField(new Date(Date.now())); + targetDataDoc[(annotationKey ?? this.annotationKey) + '_modificationDate'] = new DateField(new Date(Date.now())); } } return true; diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 25d70b932..80e2f1e65 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -13,7 +13,7 @@ import { InkField } from '../../fields/InkField'; import { RichTextField } from '../../fields/RichTextField'; import { ScriptField } from '../../fields/ScriptField'; import { Cast, DocCast, NumCast, StrCast } from '../../fields/Types'; -import { GetEffectiveAcl, normalizeEmail } from '../../fields/util'; +import { GetEffectiveAcl, normalizeEmail, SharingPermissions } from '../../fields/util'; import { DocumentType } from '../documents/DocumentTypes'; import { Docs } from '../documents/Documents'; import { DocumentManager } from '../util/DocumentManager'; @@ -661,7 +661,7 @@ const dragDocView = SelectionManager.Views()[0]; const rotCtr = [docwidth / 2, docheight / 2]; const tlRotated = Utils.rotPt(-rotCtr[0], -rotCtr[1], (NumCast(doc._rotation) / 180) * Math.PI); - const maxHeight = doc.nativeHeightUnfrozen || !nheight ? 0 : Math.max(nheight, NumCast(doc.scrollHeight, NumCast(doc[docView.LayoutFieldKey + '-scrollHeight']))) * docView.NativeDimScaling(); + const maxHeight = doc.nativeHeightUnfrozen || !nheight ? 0 : Math.max(nheight, NumCast(doc.scrollHeight, NumCast(doc[docView.LayoutFieldKey + '_scrollHeight']))) * docView.NativeDimScaling(); dH && (doc._height = actualdH > maxHeight && maxHeight ? maxHeight : actualdH); dW && (doc._width = actualdW); dH && (doc._layout_autoHeight = false); @@ -766,23 +766,23 @@ const dragDocView = SelectionManager.Views()[0]; // 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-' + normalizeEmail(Doc.CurrentUserEmail)]; const shareMode = StrCast(docShareMode); var shareSymbolIcon = null; switch (shareMode) { - case 'Admin': + case SharingPermissions.Admin: shareSymbolIcon = '⬢ '; break; - case 'Edit': + case SharingPermissions.Edit: shareSymbolIcon = '⬢ '; break; - case 'Augment': + case SharingPermissions.Augment: shareSymbolIcon = '⬟ '; break; - case 'View': + case SharingPermissions.View: shareSymbolIcon = '♦ '; break; - case 'Not-Shared': + case SharingPermissions.None: shareSymbolIcon = '▲ '; break; default: @@ -811,7 +811,7 @@ const dragDocView = SelectionManager.Views()[0]; seldocview.rootDoc.hideDeleteButton || SelectionManager.Views().some(docView => { const collectionAcl = docView.props.docViewPath()?.lastElement() ? GetEffectiveAcl(docView.props.docViewPath().lastElement().rootDoc[DocData]) : AclEdit; - return docView.rootDoc.stayInCollection || (collectionAcl !== AclAdmin && collectionAcl !== AclEdit && GetEffectiveAcl(docView.rootDoc) !== AclAdmin); + return (docView.rootDoc.stayInCollection && !docView.rootDoc._isTimelineLabel) || (collectionAcl !== AclAdmin && collectionAcl !== AclEdit && GetEffectiveAcl(docView.rootDoc) !== AclAdmin); }); const topBtn = (key: string, icon: string, pointerDown: undefined | ((e: React.PointerEvent) => void), click: undefined | ((e: any) => void), title: string) => ( <Tooltip key={key} title={<div className="dash-tooltip">{title}</div>} placement="top"> @@ -839,7 +839,7 @@ const dragDocView = SelectionManager.Views()[0]; // Radius constants const useRounding = seldocview.ComponentView instanceof ImageBox || seldocview.ComponentView instanceof FormattedTextBox || seldocview.ComponentView instanceof CollectionFreeFormView; - const borderRadius = numberValue(StrCast(seldocview.rootDoc.borderRounding)); + const borderRadius = numberValue(StrCast(seldocview.rootDoc.layout_borderRounding)); const docMax = Math.min(NumCast(seldocview.rootDoc.width) / 2, NumCast(seldocview.rootDoc.height) / 2); const maxDist = Math.min((this.Bounds.r - this.Bounds.x) / 2, (this.Bounds.b - this.Bounds.y) / 2); const radiusHandle = (borderRadius / docMax) * maxDist; @@ -865,7 +865,16 @@ const dragDocView = SelectionManager.Views()[0]; ); const sharingMenu = docShareMode ? ( - <div className='documentDecorations-share' onPointerDown={e => setupMoveUpEvents(this, e, e => this.onBackgroundMove(true, e), e => {}, action(e => {}))} > + <div className='documentDecorations-share' + onPointerDown={e => + setupMoveUpEvents( + this, + e, + e => this.onBackgroundMove(true, e), + returnFalse, + action(() => SettingsManager.propertiesWidth =250) + ) + }> <div className={`documentDecorations-share${shareMode}`}> <span>{shareSymbolIcon + ' ' + shareMode}</span> </div> @@ -906,7 +915,6 @@ const dragDocView = SelectionManager.Views()[0]; {hideDeleteButton ? null : topBtn('close', 'times', undefined, e => this.onCloseClick(true), 'Close')} {hideResizers || hideDeleteButton ? null : topBtn('minimize', 'window-maximize', undefined, e => this.onCloseClick(undefined), 'Minimize')} {hideTitle ? null : titleArea} - {sharingMenu} {hideOpenButton ? <div /> : topBtn('open', 'external-link-alt', this.onMaximizeDown, undefined, 'Open in Lightbox (ctrl: as alias, shift: in new collection)')} </div> {hideResizers ? null : ( diff --git a/src/client/views/MarqueeAnnotator.tsx b/src/client/views/MarqueeAnnotator.tsx index 7edc1494b..a4a2c1df9 100644 --- a/src/client/views/MarqueeAnnotator.tsx +++ b/src/client/views/MarqueeAnnotator.tsx @@ -1,7 +1,7 @@ import { action, observable, ObservableMap, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import { Doc, Opt } from '../../fields/Doc'; -import { AclAdmin, AclAugment, AclEdit, AclSelfEdit, DocData, } from '../../fields/DocSymbols'; +import { AclAdmin, AclAugment, AclEdit, AclSelfEdit, DocData } from '../../fields/DocSymbols'; import { Id } from '../../fields/FieldSymbols'; import { List } from '../../fields/List'; import { NumCast } from '../../fields/Types'; diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index abbf9a22e..43ac2aa88 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -393,19 +393,19 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { colorACLDropDown(name: string, admin: boolean, permission: string, showExpansionIcon?: boolean) { var dropDownText = ''; switch (StrCast(permission)) { - case 'Admin': + case SharingPermissions.Admin: dropDownText = '⬢ '; break; - case 'Edit': + case SharingPermissions.Edit: dropDownText = '⬢ '; break; - case 'Augment': + case SharingPermissions.Augment: dropDownText = '⬟ '; break; - case 'View': + case SharingPermissions.View: dropDownText = '♦ '; break; - case 'Not-Shared': + case SharingPermissions.None: dropDownText = '▲ '; break; } @@ -454,9 +454,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { // const effectiveAcls = GetEffectiveAcl(target); // const showAdmin = effectiveAcls == AclAdmin || docToUse!['acl-' + normalizeEmail(Doc.CurrentUserEmail)] == 'Owner'; - const curUserAcl = docToUse!['acl-' + normalizeEmail(Doc.CurrentUserEmail)] - const showAdmin = curUserAcl == 'Admin' || curUserAcl == 'Owner' - + const curUserAcl = docToUse!['acl-' + normalizeEmail(Doc.CurrentUserEmail)]; + const showAdmin = curUserAcl == 'Admin' || curUserAcl == 'Owner'; + const tableEntries = []; const usersAdded: string[] = []; // all shared users being added - organized by denormalized email @@ -496,11 +496,11 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { const commonKeys = intersection(...docs.map(doc => (this.layoutDocAcls ? doc : doc[DocData])).map(doc => doc?.[DocAcl] && Object.keys(doc[DocAcl]))); 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'){ + 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); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 884a6e75c..8421ce106 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -1089,6 +1089,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps SharingManager.Instance.users.find(users => users.user.email === this.dataDoc.author)?.sharingDoc.userColor, Doc.UserDoc().layout_showTitle && [DocumentType.RTF, DocumentType.COL].includes(this.rootDoc.type as any) ? StrCast(Doc.SharingDoc().userColor) : 'rgba(0,0,0,0.4)' ); + const sidebarWidthPercent = +StrCast(this.layoutDoc.layout_sidebarWidthPercent).replace('%', ''); const titleView = !showTitle ? null : ( <div className={`documentView-titleWrapper${showTitleHover ? '-hover' : ''}`} @@ -1096,7 +1097,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps style={{ position: this.headerMargin ? 'relative' : 'absolute', height: this.titleHeight, - width: !this.headerMargin ? `calc(100% - 18px)` : '100%', // leave room for annotation button + width: !this.headerMargin ? `calc(${sidebarWidthPercent || 100}% - 18px)` : (sidebarWidthPercent || 100) + '%', // leave room for annotation button color: lightOrDark(background), background, pointerEvents: (!this.disableClickScriptFunc && this.onClickHandler) || this.Document.ignoreClick ? 'none' : this.isContentActive() || this.props.isDocumentActive?.() ? 'all' : undefined, diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 555e768c1..3116fd70b 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -1267,9 +1267,7 @@ export namespace Doc { } // don't bother memoizing (caching) the result if called from a non-reactive context. (plus this avoids a warning message) export function IsBrushedDegreeUnmemoized(doc: Doc) { - if (!doc || GetEffectiveAcl(doc) === AclPrivate || GetEffectiveAcl(Doc.GetProto(doc)) === AclPrivate || doc.opacity === 0) { - return DocBrushStatus.unbrushed; - } + if (!doc || GetEffectiveAcl(doc) === AclPrivate || GetEffectiveAcl(Doc.GetProto(doc)) === AclPrivate || doc.opacity === 0) return DocBrushStatus.unbrushed; const status = brushManager.BrushedDoc.has(doc) ? DocBrushStatus.selfBrushed : brushManager.BrushedDoc.has(Doc.GetProto(doc)) ? DocBrushStatus.protoBrushed : DocBrushStatus.unbrushed; if (status === DocBrushStatus.unbrushed) { const lastBrushed = Array.from(brushManager.BrushedDoc.keys()).lastElement(); diff --git a/src/fields/util.ts b/src/fields/util.ts index e0f87f805..9c0f4ba1f 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -7,41 +7,16 @@ import { SerializationHelper } from '../client/util/SerializationHelper'; import { UndoManager } from '../client/util/UndoManager'; import { returnZero } from '../Utils'; import CursorField from './CursorField'; -import { - Doc, - aclLevel, - DocListCast, - DocListCastAsync, - HierarchyMapping, - ReverseHierarchyMap, - updateCachedAcls, -} from './Doc'; -import { - AclAdmin, - AclEdit, - AclPrivate, - AclAugment, - FieldKeys, - DocAcl, - DocData, - ForceServerWrite, - Height, - Initializing, - DocLayout, - UpdatingFromServer, - Width, - SelfProxy, - Update -} from './DocSymbols'; +import { aclLevel, Doc, DocListCast, DocListCastAsync, HierarchyMapping, ReverseHierarchyMap, updateCachedAcls } from './Doc'; +import { AclAdmin, AclAugment, AclEdit, AclPrivate, DocAcl, DocData, DocLayout, FieldKeys, ForceServerWrite, Height, Initializing, SelfProxy, Update, UpdatingFromServer, Width } from './DocSymbols'; import { Id, OnUpdate, Parent, ToValue } from './FieldSymbols'; import { List } from './List'; import { ObjectField } from './ObjectField'; import { PrefetchProxy, ProxyField } from './Proxy'; import { RefField } from './RefField'; import { SchemaHeaderField } from './SchemaHeaderField'; -import { ComputedField, ScriptField } from './ScriptField'; +import { ComputedField } from './ScriptField'; import { ScriptCast, StrCast } from './Types'; -import { convertCompilerOptionsFromJson } from 'typescript'; function _readOnlySetter(): never { throw new Error("Documents can't be modified in read-only mode"); |