From 50876028b994044f2a9426a4efb85a363f0d7168 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Thu, 4 May 2023 10:46:20 -0400 Subject: properties view + sharing manager are consistent, and all text updates properly --- src/client/views/DocComponent.tsx | 10 ++- src/client/views/DocumentDecorations.scss | 3 +- src/client/views/DocumentDecorations.tsx | 6 +- src/client/views/Main.tsx | 2 +- src/client/views/MarqueeAnnotator.tsx | 4 +- src/client/views/PropertiesView.scss | 4 +- src/client/views/PropertiesView.tsx | 93 +++++++--------------- .../views/nodes/formattedText/FormattedTextBox.tsx | 9 +-- .../formattedText/ProsemirrorExampleTransfer.ts | 12 +-- 9 files changed, 51 insertions(+), 92 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index 0b92fd864..5a1dae8db 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -222,8 +222,12 @@ export function ViewBoxAnnotatableComponent

() if (effectiveAcl === AclAugment) { added.map(doc => { - if ([AclAdmin, AclEdit].includes(GetEffectiveAcl(doc)) && Doc.ActiveDashboard) inheritParentAcls(Doc.ActiveDashboard, doc); doc.context = this.props.Document; + const contextDoc = Cast(doc.context, Doc, null) + if ([AclAdmin, AclEdit].includes(GetEffectiveAcl(doc))) { + if (contextDoc) inheritParentAcls(contextDoc, doc); + else if (Doc.ActiveDashboard) inheritParentAcls(Doc.ActiveDashboard, doc); + }; if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.props.Document; Doc.AddDocToList(targetDataDoc, annotationKey ?? this.annotationKey, doc); }); @@ -237,7 +241,9 @@ export function ViewBoxAnnotatableComponent

() doc.context = this.props.Document; if (annotationKey ?? this._annotationKeySuffix()) Doc.GetProto(doc).annotationOn = this.props.Document; - Doc.ActiveDashboard && inheritParentAcls(Doc.ActiveDashboard, doc); + const contextDoc = Cast(doc.context, Doc, null) + if (contextDoc) inheritParentAcls(contextDoc, doc); + else if (Doc.ActiveDashboard) inheritParentAcls(Doc.ActiveDashboard, doc); }); const annoDocs = targetDataDoc[annotationKey ?? this.annotationKey] as List; if (annoDocs instanceof List) annoDocs.push(...added); diff --git a/src/client/views/DocumentDecorations.scss b/src/client/views/DocumentDecorations.scss index ce5378e69..32bcc872a 100644 --- a/src/client/views/DocumentDecorations.scss +++ b/src/client/views/DocumentDecorations.scss @@ -237,8 +237,7 @@ $resizeHandler: 8px; color: rgb(71, 71, 71); border-color: rgb(71, 71, 71); } - .documentDecorations-shareEdit, - .documentDecorations-shareSelf-Edit{ + .documentDecorations-shareEdit{ width: calc(100% + 10px); background: rgb(235, 235, 145); color: rgb(75, 75, 5); diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 3e0a1f7a4..b769056d8 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -32,6 +32,7 @@ import { FormattedTextBox } from './nodes/formattedText/FormattedTextBox'; import { ImageBox } from './nodes/ImageBox'; import React = require('react'); import { SharingManager } from '../util/SharingManager'; +import { DocServer } from '../DocServer'; @observer export class DocumentDecorations extends React.Component<{ PanelWidth: number; PanelHeight: number; boundsLeft: number; boundsTop: number }, { value: string }> { @@ -754,9 +755,6 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P case ("Edit"): shareSymbolIcon = "⬢ "; break; - case ("Self-Edit"): - shareSymbolIcon = "⬢ "; - break; case ("Augment"): shareSymbolIcon = "⬟ "; break; @@ -794,7 +792,7 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P // const collectionAcl = docView.props.ContainingCollectionView ? GetEffectiveAcl(docView.props.ContainingCollectionDoc?.[DataSym]) : AclEdit; // return docView.rootDoc.stayInCollection || (collectionAcl !== AclAdmin && collectionAcl !== AclEdit && GetEffectiveAcl(docView.rootDoc) !== AclAdmin); const effectiveAcl = GetEffectiveAcl(Doc.GetProto(seldocview.rootDoc)) - return docView.rootDoc.stayInCollection || (effectiveAcl !== AclAdmin && effectiveAcl !== AclEdit && GetEffectiveAcl(docView.rootDoc) !== AclAdmin); + return docView.rootDoc.stayInCollection || (effectiveAcl !== AclAdmin && GetEffectiveAcl(docView.rootDoc) !== AclAdmin); }); const topBtn = (key: string, icon: string, pointerDown: undefined | ((e: React.PointerEvent) => void), click: undefined | ((e: any) => void), title: string) => ( {title}} placement="top"> diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 6b18caed0..7da9dc603 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -26,7 +26,7 @@ FieldLoader.ServerLoadStatus = { requested: 0, retrieved: 0 }; // bcz: not sure root.render(); window.location.search.includes('safe') && CollectionView.SetSafeMode(true); const info = await CurrentUserUtils.loadCurrentUser(); - if (info.email === 'guest') DocServer.Control.makeReadOnly(); + // if (info.email === 'guest') DocServer.Control.makeReadOnly(); await CurrentUserUtils.loadUserDocument(info.id); setTimeout(() => { document.getElementById('root')!.addEventListener( diff --git a/src/client/views/MarqueeAnnotator.tsx b/src/client/views/MarqueeAnnotator.tsx index 30867a774..094c9cc61 100644 --- a/src/client/views/MarqueeAnnotator.tsx +++ b/src/client/views/MarqueeAnnotator.tsx @@ -1,6 +1,6 @@ import { action, observable, ObservableMap, runInAction } from 'mobx'; import { observer } from 'mobx-react'; -import { AclAdmin, AclAugment, AclEdit, AclSelfEdit, DataSym, Doc, Opt } from '../../fields/Doc'; +import { AclAdmin, AclAugment, AclEdit, DataSym, Doc, Opt } from '../../fields/Doc'; import { Id } from '../../fields/FieldSymbols'; import { List } from '../../fields/List'; import { NumCast } from '../../fields/Types'; @@ -202,7 +202,7 @@ export class MarqueeAnnotator extends React.Component { highlight = (color: string, isLinkButton: boolean, savedAnnotations?: ObservableMap, addAsAnnotation?: boolean) => { // creates annotation documents for current highlights const effectiveAcl = GetEffectiveAcl(this.props.rootDoc[DataSym]); - const annotationDoc = [AclAugment, AclSelfEdit, AclEdit, AclAdmin].includes(effectiveAcl) && this.makeAnnotationDocument(color, isLinkButton, savedAnnotations); + const annotationDoc = [AclAugment, AclEdit, AclAdmin].includes(effectiveAcl) && this.makeAnnotationDocument(color, isLinkButton, savedAnnotations); addAsAnnotation && !savedAnnotations && annotationDoc && this.props.addDocument(annotationDoc); return (annotationDoc as Doc) ?? undefined; }; diff --git a/src/client/views/PropertiesView.scss b/src/client/views/PropertiesView.scss index 50bf6ce74..71107a5f9 100644 --- a/src/client/views/PropertiesView.scss +++ b/src/client/views/PropertiesView.scss @@ -172,8 +172,7 @@ border-radius: 6px; border: 1px solid rgb(71, 71, 71); } - & .propertiesView-shareDropDownEdit, - .propertiesView-shareDropDownSelf-Edit{ + & .propertiesView-shareDropDownEdit{ padding: 5px; background: rgb(235, 235, 145); color: rgb(75, 75, 5); @@ -426,7 +425,6 @@ background: inherit; border: none; background: inherit; - // width: 100%; text-align: justify; // for Edge text-align-last: end; &:hover { diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index a6a5347ad..984c2dc04 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -369,7 +369,8 @@ export class PropertiesView extends React.Component { 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)[DataSym])); if (user=="Public"){ - docs[0]['acl-' +user] = e.currentTarget.value as SharingPermissions; + // docs[0]['acl-' +user] = e.currentTarget.value as SharingPermissions; + SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs); } else{ @@ -385,12 +386,11 @@ export class PropertiesView extends React.Component { if (permission === '-multiple-') dropdownValues.unshift(permission); if (user !== 'Override') { dropdownValues.splice(dropdownValues.indexOf(SharingPermissions.Unset), 1); - // dropdownValues.splice(dropdownValues.indexOf(SharingPermissions.Unset), 1); } return (