From d1e4d4a9daae4f037cf8b22e1011d97680a01e27 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Tue, 2 May 2023 17:44:00 -0400 Subject: update properties view, document decorations, and sharing manager show + use correct acl --- .../views/nodes/formattedText/FormattedTextBox.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx') diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index a2c1195cb..0e4330fa5 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -19,7 +19,7 @@ import { RichTextField } from '../../../../fields/RichTextField'; import { RichTextUtils } from '../../../../fields/RichTextUtils'; import { ComputedField } from '../../../../fields/ScriptField'; import { BoolCast, Cast, DocCast, FieldValue, NumCast, ScriptCast, StrCast } from '../../../../fields/Types'; -import { GetEffectiveAcl, TraceMobx } from '../../../../fields/util'; +import { GetEffectiveAcl, normalizeEmail, TraceMobx } from '../../../../fields/util'; import { addStyleSheet, addStyleSheetRule, clearStyleSheetRules, emptyFunction, numberRange, OmitKeys, returnFalse, returnZero, setupMoveUpEvents, smoothScroll, unimplementedFunction, Utils } from '../../../../Utils'; import { GoogleApiClientUtils, Pulls, Pushes } from '../../../apis/google_docs/GoogleApiClientUtils'; import { DocServer } from '../../../DocServer'; @@ -295,11 +295,12 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent (json?.indexOf('"storedMarks"') === -1 ? json?.replace(/"selection":.*/, '') : json?.replace(/"selection":"\"storedMarks\""/, '"storedMarks"')); - - if ([AclEdit, AclAdmin, AclSelfEdit].includes(effectiveAcl)) { + + if ([AclEdit, AclAdmin, AclSelfEdit, AclAugment].includes(effectiveAcl)) { const accumTags = [] as string[]; state.tr.doc.nodesBetween(0, state.doc.content.size, (node: any, pos: number, parent: any) => { if (node.type === schema.nodes.dashField && node.attrs.fieldKey.startsWith('#')) { @@ -1689,7 +1690,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent i && node?.marks?.().some(mark => mark.type === schema.marks.user_mark && mark.attrs.userid !== Doc.CurrentUserEmail) && [AclAugment, AclSelfEdit].includes(GetEffectiveAcl(this.rootDoc))) { + if (state.doc.content.size - 1 > i && node?.marks?.().some(mark => mark.type === schema.marks.user_mark && mark.attrs.userid !== Doc.CurrentUserEmail) && [AclSelfEdit].includes(GetEffectiveAcl(this.rootDoc))) { e.preventDefault(); } } @@ -1708,7 +1709,10 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent Date: Thu, 4 May 2023 10:46:20 -0400 Subject: properties view + sharing manager are consistent, and all text updates properly --- src/client/documents/Documents.ts | 2 +- src/client/util/SharingManager.scss | 5 + src/client/util/SharingManager.tsx | 120 ++++----------------- 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 +-- src/fields/Doc.ts | 3 - src/fields/util.ts | 6 +- 14 files changed, 81 insertions(+), 198 deletions(-) (limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index f5510d7e1..9c67f1f37 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -506,7 +506,7 @@ export namespace Docs { description: '', showCaption: 'description', backgroundColor: 'lightblue', // lightblue is default color for linking dot and link documents text comment area - _removeDropProperties: new List(['isLinkButton']), + // _removeDropsties: new List(['isLinkButton']), }, }, ], diff --git a/src/client/util/SharingManager.scss b/src/client/util/SharingManager.scss index f47c48805..3cab77816 100644 --- a/src/client/util/SharingManager.scss +++ b/src/client/util/SharingManager.scss @@ -23,6 +23,11 @@ z-index: 999; } + .share-title { + display: inline-flex; + gap: 5px; + } + .share-container { .share-setup { display: flex; 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 => (