diff options
author | bobzel <zzzman@gmail.com> | 2024-04-30 01:10:20 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-04-30 01:10:20 -0400 |
commit | 6de58d7ecbfd14beb7389c6ff56e764b5c00ba25 (patch) | |
tree | 57b396b30644ac2fa3ec48fe38bc3efb419ce88d /src | |
parent | e17737982ea2ce84b4bded798ee7bdf730a75715 (diff) |
changed acl- and some other field- to acl_ and field_ style
Diffstat (limited to 'src')
21 files changed, 127 insertions, 137 deletions
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts index 4e3496608..b4ad9c17d 100644 --- a/src/client/documents/DocumentTypes.ts +++ b/src/client/documents/DocumentTypes.ts @@ -33,7 +33,6 @@ export enum DocumentType { PRES = 'presentation', PRESELEMENT = 'preselement', COMPARISON = 'comparison', - GROUP = 'group', PUSHPIN = 'pushpin', MAPROUTE = 'maproute', CALENDAR = 'calendar', diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index cf397e85a..ddb6f65b6 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -246,8 +246,8 @@ export class DocumentOptions { _nativeWidth?: NUMt = new NumInfo('native width of document contents (e.g., the pixel width of an image)', false); _nativeHeight?: NUMt = new NumInfo('native height of document contents (e.g., the pixel height of an image)', false); - 'acl-Guest'?: STRt = new StrInfo("permissions granted to users logged in as 'guest' (either view, or private)"); // public permissions - '_acl-Guest'?: string; // public permissions + acl_Guest?: STRt = new StrInfo("permissions granted to users logged in as 'guest' (either view, or private)"); // public permissions + _acl_Guest?: string; // public permissions type?: DTYPEt = new DTypeInfo('type of document', true); type_collection?: COLLt = new CTypeInfo('how collection is rendered'); // sub type of a collection _type_collection?: COLLt = new CTypeInfo('how collection is rendered'); // sub type of a collection @@ -535,6 +535,7 @@ export namespace Docs { { layout: { view: FormattedTextBox, dataField: 'text' }, options: { + acl: '', _height: 35, _xMargin: 10, _yMargin: 10, @@ -550,21 +551,21 @@ export namespace Docs { DocumentType.SEARCH, { layout: { view: SearchBox, dataField: defaultDataKey }, - options: { _width: 400 }, + options: { acl: '', _width: 400 }, }, ], [ DocumentType.IMG, { layout: { view: ImageBox, dataField: defaultDataKey }, - options: { freeform: '', systemIcon: 'BsFileEarmarkImageFill' }, + options: { acl: '', freeform: '', systemIcon: 'BsFileEarmarkImageFill' }, }, ], [ DocumentType.WEB, { layout: { view: WebBox, dataField: defaultDataKey }, - options: { _height: 300, _layout_fitWidth: true, layout_nativeDimEditable: true, layout_reflowVertical: true, waitForDoubleClickToClick: 'always', systemIcon: 'BsGlobe' }, + options: { acl: '', _height: 300, _layout_fitWidth: true, layout_nativeDimEditable: true, layout_reflowVertical: true, waitForDoubleClickToClick: 'always', systemIcon: 'BsGlobe' }, }, ], [ @@ -572,6 +573,7 @@ export namespace Docs { { layout: { view: CollectionView, dataField: defaultDataKey }, options: { + acl: '', _layout_fitWidth: true, freeform: '', _freeform_panX: 0, @@ -588,42 +590,42 @@ export namespace Docs { DocumentType.KVP, { layout: { view: KeyValueBox, dataField: defaultDataKey }, - options: { _layout_fitWidth: true, _height: 150 }, + options: { acl: '', _layout_fitWidth: true, _height: 150 }, }, ], [ DocumentType.VID, { layout: { view: VideoBox, dataField: defaultDataKey }, - options: { _layout_currentTimecode: 0, systemIcon: 'BsFileEarmarkPlayFill' }, + options: { acl: '', _layout_currentTimecode: 0, systemIcon: 'BsFileEarmarkPlayFill' }, }, ], [ DocumentType.AUDIO, { layout: { view: AudioBox, dataField: defaultDataKey }, - options: { _height: 100, layout_fitWidth: true, layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true, systemIcon: 'BsFillVolumeUpFill' }, + options: { acl: '', _height: 100, layout_fitWidth: true, layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true, systemIcon: 'BsFillVolumeUpFill' }, }, ], [ DocumentType.REC, { layout: { view: VideoBox, dataField: defaultDataKey }, - options: { _height: 100, backgroundColor: 'pink', systemIcon: 'BsFillMicFill' }, + options: { acl: '', _height: 100, backgroundColor: 'pink', systemIcon: 'BsFillMicFill' }, }, ], [ DocumentType.PDF, { layout: { view: PDFBox, dataField: defaultDataKey }, - options: { _layout_curPage: 1, _layout_fitWidth: true, layout_nativeDimEditable: true, layout_reflowVertical: true, systemIcon: 'BsFileEarmarkPdfFill' }, + options: { acl: '', _layout_curPage: 1, _layout_fitWidth: true, layout_nativeDimEditable: true, layout_reflowVertical: true, systemIcon: 'BsFileEarmarkPdfFill' }, }, ], [ DocumentType.MAP, { layout: { view: MapBox, dataField: defaultDataKey }, - options: { map: '', _height: 600, _width: 800, layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true, systemIcon: 'BsFillPinMapFill' }, + options: { acl: '', map: '', _height: 600, _width: 800, layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true, systemIcon: 'BsFillPinMapFill' }, }, ], [ @@ -631,6 +633,7 @@ export namespace Docs { { layout: { view: LinkBox, dataField: 'link' }, options: { + acl: '', childDontRegisterViews: true, layout_hideLinkAnchors: true, _height: 1, @@ -647,88 +650,77 @@ export namespace Docs { { data: new List<Doc>(), layout: { view: EmptyBox, dataField: defaultDataKey }, - options: { title: 'Global Script Database' }, + options: { acl: '', title: 'Global Script Database' }, }, ], [ DocumentType.SCRIPTING, { layout: { view: ScriptingBox, dataField: defaultDataKey }, - options: { systemIcon: 'BsFileEarmarkCodeFill' }, + options: { acl: '', systemIcon: 'BsFileEarmarkCodeFill' }, }, ], [ DocumentType.LABEL, { layout: { view: LabelBox, dataField: 'title' }, - options: { _singleLine: true, layout_nativeDimEditable: true, layout_reflowHorizontal: true, layout_reflowVertical: true }, + options: { acl: '', _singleLine: true, layout_nativeDimEditable: true, layout_reflowHorizontal: true, layout_reflowVertical: true }, }, ], [ DocumentType.EQUATION, { layout: { view: EquationBox, dataField: 'text' }, - options: { - fontSize: '14px', - layout_reflowHorizontal: true, - layout_reflowVertical: true, - layout_nativeDimEditable: true, - layout_hideDecorationTitle: true, - systemIcon: 'BsCalculatorFill', - }, // systemIcon: 'BsSuperscript' + BsSubscript + options: { acl: '', fontSize: '14px', layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true, layout_hideDecorationTitle: true, systemIcon: 'BsCalculatorFill' }, // systemIcon: 'BsSuperscript' + BsSubscript }, ], [ DocumentType.FUNCPLOT, { layout: { view: FunctionPlotBox, dataField: defaultDataKey }, - options: { - layout_reflowHorizontal: true, - layout_reflowVertical: true, - layout_nativeDimEditable: true, - }, + options: { acl: '', layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true }, }, ], [ DocumentType.BUTTON, { layout: { view: LabelBox, dataField: 'title' }, - options: { layout_nativeDimEditable: true, layout_reflowHorizontal: true, layout_reflowVertical: true }, + options: { acl: '', layout_nativeDimEditable: true, layout_reflowHorizontal: true, layout_reflowVertical: true }, }, ], [ DocumentType.PRES, { layout: { view: PresBox, dataField: defaultDataKey }, - options: { defaultDoubleClick: 'ignore', hideClickBehaviors: true, layout_hideLinkAnchors: true }, + options: { acl: '', defaultDoubleClick: 'ignore', hideClickBehaviors: true, layout_hideLinkAnchors: true }, }, ], [ DocumentType.FONTICON, { layout: { view: FontIconBox, dataField: 'icon' }, - options: { defaultDoubleClick: 'ignore', waitForDoubleClickToClick: 'never', layout_hideContextMenu: true, layout_hideLinkButton: true, _width: 40, _height: 40 }, + options: { acl: '', defaultDoubleClick: 'ignore', waitForDoubleClickToClick: 'never', layout_hideContextMenu: true, layout_hideLinkButton: true, _width: 40, _height: 40 }, }, ], [ DocumentType.WEBCAM, { layout: { view: RecordingBox, dataField: defaultDataKey }, - options: { systemIcon: 'BsFillCameraVideoFill' }, + options: { acl: '', systemIcon: 'BsFillCameraVideoFill' }, }, ], [ DocumentType.PRESELEMENT, { layout: { view: PresElementBox, dataField: defaultDataKey }, - options: { title: 'pres element template', _layout_fitWidth: true, _xMargin: 0, isTemplateDoc: true, isTemplateForField: 'data' }, + options: { acl: '', title: 'pres element template', _layout_fitWidth: true, _xMargin: 0, isTemplateDoc: true, isTemplateForField: 'data' }, }, ], [ DocumentType.CONFIG, { layout: { view: CollectionView, dataField: defaultDataKey }, - options: { config: '', layout_hideLinkButton: true, layout_unrendered: true }, + options: { acl: '', config: '', layout_hideLinkButton: true, layout_unrendered: true }, }, ], [ @@ -737,6 +729,7 @@ export namespace Docs { // NOTE: this is unused!! ink fields are filled in directly within the InkDocument() method layout: { view: InkingStroke, dataField: 'stroke' }, options: { + acl: '', systemIcon: 'BsFillPencilFill', // layout_nativeDimEditable: true, layout_reflowVertical: true, @@ -751,7 +744,7 @@ export namespace Docs { DocumentType.SCREENSHOT, { layout: { view: ScreenshotBox, dataField: defaultDataKey }, - options: { layout_nativeDimEditable: true, systemIcon: 'BsCameraFill' }, + options: { acl: '', layout_nativeDimEditable: true, systemIcon: 'BsCameraFill' }, }, ], [ @@ -759,35 +752,48 @@ export namespace Docs { { data: '', layout: { view: ComparisonBox, dataField: defaultDataKey }, - options: { backgroundColor: 'gray', dropAction: dropActionType.move, waitForDoubleClickToClick: 'always', layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true, systemIcon: 'BsLayoutSplit' }, + options: { + acl: '', + backgroundColor: 'gray', + dropAction: dropActionType.move, + waitForDoubleClickToClick: 'always', + layout_reflowHorizontal: true, + layout_reflowVertical: true, + layout_nativeDimEditable: true, + systemIcon: 'BsLayoutSplit', + }, }, ], [ DocumentType.GROUPDB, { layout: { view: EmptyBox, dataField: defaultDataKey }, - options: { title: 'Global Group Database' }, - }, - ], - [ - DocumentType.GROUP, - { - layout: { view: EmptyBox, dataField: defaultDataKey }, - options: {}, + options: { acl: '', title: 'Global Group Database' }, }, ], [ DocumentType.DATAVIZ, { layout: { view: DataVizBox, dataField: defaultDataKey }, - options: { dataViz_title: '', dataViz_line: '', dataViz_pie: '', dataViz_histogram: '', dataViz: 'table', _layout_fitWidth: true, layout_reflowHorizontal: true, layout_reflowVertical: true, layout_nativeDimEditable: true }, + options: { + acl: '', + dataViz_title: '', + dataViz_line: '', + dataViz_pie: '', + dataViz_histogram: '', + dataViz: 'table', + _layout_fitWidth: true, + layout_reflowHorizontal: true, + layout_reflowVertical: true, + layout_nativeDimEditable: true, + }, }, ], [ DocumentType.LOADING, { layout: { view: LoadingBox, dataField: '' }, - options: { _layout_fitWidth: true, _fitHeight: true, layout_nativeDimEditable: true }, + options: { acl: '', _layout_fitWidth: true, _fitHeight: true, layout_nativeDimEditable: true }, }, ], [ @@ -795,41 +801,28 @@ export namespace Docs { { data: '', layout: { view: PhysicsSimulationBox, dataField: defaultDataKey, _width: 1000, _height: 800 }, - options: { - _height: 100, - mass1: '', - mass2: '', - layout_nativeDimEditable: true, - position: '', - acceleration: '', - pendulum: '', - spring: '', - wedge: '', - simulation: '', - review: '', - systemIcon: 'BsShareFill', - }, + options: { acl: '', _height: 100, mass1: '', mass2: '', layout_nativeDimEditable: true, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '', systemIcon: 'BsShareFill' }, }, ], [ DocumentType.PUSHPIN, { layout: { view: MapPushpinBox, dataField: defaultDataKey }, - options: {}, + options: { acl: '' }, }, ], [ DocumentType.MAPROUTE, { layout: { view: CollectionView, dataField: defaultDataKey }, - options: {}, + options: { acl: '' }, }, ], [ DocumentType.CALENDAR, { layout: { view: CalendarBox, dataField: defaultDataKey }, - options: {}, + options: { acl: '' }, }, ], ]); @@ -926,7 +919,7 @@ export namespace Docs { type, isBaseProto: true, _width: 300, - 'acl-Guest': SharingPermissions.View, + acl_Guest: SharingPermissions.View, ...(template.options || {}), layout: layout.view?.LayoutString(layout.dataField), data: template.data, @@ -971,8 +964,8 @@ export namespace Docs { const viewKeys = ['x', 'y', 'isSystem']; // keys that should be addded to the view document even though they don't begin with an "_" const { omit: dataProps, extract: viewProps } = OmitKeys(options, viewKeys, '^_'); - // dataProps['acl-Override'] = SharingPermissions.Unset; - dataProps['acl-Guest'] = options['acl-Guest'] ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View); + // dataProps.acl_Override = SharingPermissions.Unset; + dataProps.acl_Guest = options.acl_Guest ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View); dataProps.isSystem = viewProps.isSystem; dataProps.isDataDoc = true; dataProps.author = ClientUtils.CurrentUserEmail(); @@ -996,7 +989,7 @@ export namespace Docs { if (!noView) { const viewFirstProps: { [id: string]: any } = { author: ClientUtils.CurrentUserEmail() }; - viewFirstProps['acl-Guest'] = options['_acl-Guest'] ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View); + viewFirstProps.acl_Guest = options._acl_Guest ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View); let viewDoc: Doc; // determines whether viewDoc should be created using placeholder Doc or default if (placeholderDoc) { @@ -1004,7 +997,7 @@ export namespace Docs { placeholderDoc._width = options._width !== undefined ? Number(options._width) : undefined; viewDoc = Doc.assign(placeholderDoc, viewFirstProps, true, true); Array.from(Object.keys(placeholderDoc)) - .filter(key => key.startsWith('acl')) + .filter(key => key.startsWith('acl_')) .forEach(key => { dataDoc[key] = viewDoc[key] = placeholderDoc[key]; }); @@ -1157,8 +1150,8 @@ export namespace Docs { I.rotation = 0; I.defaultDoubleClick = 'ignore'; I.author_date = new DateField(); - I['acl-Guest'] = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View; - // I['acl-Override'] = SharingPermissions.Unset; + I.acl_Guest = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View; + // I.acl_Override = SharingPermissions.Unset; I[Initializing] = false; return ink; @@ -1335,7 +1328,7 @@ export namespace Docs { const doc = DockDocument( configs.map(c => c.doc), JSON.stringify(layoutConfig), - ClientUtils.CurrentUserEmail() === 'guest' ? options : { 'acl-Guest': SharingPermissions.View, ...options }, + ClientUtils.CurrentUserEmail() === 'guest' ? options : { acl_Guest: SharingPermissions.View, ...options }, id ); configs.forEach(c => { @@ -1539,8 +1532,8 @@ export namespace DocUtils { source, target, { - 'acl-Guest': SharingPermissions.Augment, - '_acl-Guest': SharingPermissions.Augment, + acl_Guest: SharingPermissions.Augment, + _acl_Guest: SharingPermissions.Augment, title: ComputedField.MakeFunction('generateLinkTitle(this)') as any, link_anchor_1_useSmallAnchor: source.useSmallAnchor ? true : undefined, link_anchor_2_useSmallAnchor: target.useSmallAnchor ? true : undefined, diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index eae5b2d6a..00279e7e1 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -836,7 +836,7 @@ pie title Minerals in my tap water linkDocs.author = ClientUtils.CurrentUserEmail(); linkDocs.isSystem = true; linkDocs.data = new List<Doc>([]); - linkDocs["acl-Guest"] = SharingPermissions.Augment; + linkDocs.acl_Guest = SharingPermissions.Augment; doc.myLinkDatabase = new PrefetchProxy(linkDocs); } } @@ -857,7 +857,7 @@ pie title Minerals in my tap water // childContextMenuScripts: new List<ScriptField>([addToDashboards!,]), // childContextMenuLabels: new List<string>(["Add to Dashboards",]), // childContextMenuIcons: new List<string>(["user-plus",]), - "acl-Guest": SharingPermissions.Augment, "_acl-Guest": SharingPermissions.Augment, + acl_Guest: SharingPermissions.Augment, _acl_Guest: SharingPermissions.Augment, childDragAction: dropActionType.embed, isSystem: true, childContentPointerEvents: "none", childLimitHeight: 0, _yMargin: 0, _gridGap: 15, childDontRegisterViews:true, // NOTE: treeView_HideTitle & _layout_showTitle is for a TreeView's editable title, _layout_showTitle is for DocumentViews title bar _layout_showTitle: "title", treeView_HideTitle: true, ignoreClick: true, _lockedPosition: true, layout_boxShadow: "0 0", _chromeHidden: true, dontRegisterView: true, diff --git a/src/client/util/ServerStats.tsx b/src/client/util/ServerStats.tsx index 891561245..57363663d 100644 --- a/src/client/util/ServerStats.tsx +++ b/src/client/util/ServerStats.tsx @@ -14,7 +14,7 @@ export class ServerStats extends React.Component<{}> { @observable _stats: { [key: string]: any } | undefined = undefined; // private get linkVisible() { - // return this.targetDoc ? this.targetDoc["acl-" + PublicKey] !== SharingPermissions.None : false; + // return this.targetDoc ? this.targetDoc['acl_' + PublicKey] !== SharingPermissions.None : false; // } constructor(props: {}) { diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 5b4ac5aff..19a7948e6 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -90,7 +90,7 @@ export class SharingManager extends React.Component<{}> { @observable private myDocAcls: boolean = false; // whether the My Docs checkbox is selected or not // private get linkVisible() { - // return this.targetDoc ? this.targetDoc["acl-" + PublicKey] !== SharingPermissions.None : false; + // return this.targetDoc ? this.targetDoc['acl_' + PublicKey] !== SharingPermissions.None : false; // } constructor(props: {}) { @@ -172,10 +172,10 @@ export class SharingManager extends React.Component<{}> { // the list of users shared with const userListContents = users - // .filter(({ user }) => (docs.length > 1 ? commonKeys.includes(`acl-${normalizeEmail(user.email)}`) : docs[0]?.author !== user.email)) + // .filter(({ user }) => (docs.length > 1 ? commonKeys.includes(`acl_${normalizeEmail(user.email)}`) : docs[0]?.author !== user.email)) .filter(({ user }) => docs[0]?.author !== user.email) .map(({ user, linkDatabase, sharingDoc, userColor }) => { - const userKey = `acl-${normalizeEmail(user.email)}`; + const userKey = `acl_${normalizeEmail(user.email)}`; const uniform = docs.every(doc => doc?.[DocAcl]?.[userKey] === docs[0]?.[DocAcl]?.[userKey]); // const permissions = uniform ? StrCast(targetDoc?.[userKey]) : '-multiple-'; let permissions = targetDoc[DocAcl][userKey] ? HierarchyMapping.get(targetDoc[DocAcl][userKey])?.name : StrCast(targetDoc[userKey]); @@ -204,7 +204,7 @@ export class SharingManager extends React.Component<{}> { const sameAuthor = docs.every(doc => doc?.author === docs[0]?.author); // the owner of the doc and the current user are placed at the top of the user list. - const userKey = `acl-${normalizeEmail(ClientUtils.CurrentUserEmail())}`; + const userKey = `acl_${normalizeEmail(ClientUtils.CurrentUserEmail())}`; const curUserPermission = StrCast(targetDoc[userKey]); // const curUserPermission = HierarchyMapping.get(effectiveAcls[0])!.name userListContents.unshift( @@ -230,10 +230,10 @@ export class SharingManager extends React.Component<{}> { ); // the list of groups shared with - const groupListMap: (Doc | { title: string })[] = groups.filter(({ title }) => (docs.length > 1 ? commonKeys.includes(`acl-${normalizeEmail(StrCast(title))}`) : true)); + const groupListMap: (Doc | { title: string })[] = groups.filter(({ title }) => (docs.length > 1 ? commonKeys.includes(`acl_${normalizeEmail(StrCast(title))}`) : true)); groupListMap.unshift({ title: 'Guest' }); // , { title: "ALL" }); const groupListContents = groupListMap.map(group => { - const groupKey = `acl-${StrCast(group.title)}`; + const groupKey = `acl_${StrCast(group.title)}`; const uniform = docs.every(doc => doc?.[DocAcl]?.[groupKey] === docs[0]?.[DocAcl]?.[groupKey]); const permissions = uniform ? StrCast(targetDoc?.[groupKey]) : '-multiple-'; @@ -442,7 +442,7 @@ export class SharingManager extends React.Component<{}> { setInternalSharing = undoable((recipient: ValidatedUser, permission: string, targetDoc: Doc | undefined) => { const { user, sharingDoc } = recipient; const target = targetDoc || this.targetDoc!; - const acl = `acl-${normalizeEmail(user.email)}`; + const acl = `acl_${normalizeEmail(user.email)}`; const docs = SelectionManager.Views.length < 2 ? [target] : SelectionManager.Views.map(docView => docView.Document); docs.map(doc => (this.layoutDocAcls || doc.dockingConfig ? doc : Doc.GetProto(doc))).forEach(doc => { distributeAcls(acl, permission as SharingPermissions, doc, undefined, this.upgradeNested ? true : undefined); @@ -459,7 +459,7 @@ export class SharingManager extends React.Component<{}> { */ setInternalGroupSharing = undoable((group: Doc | { title: string }, permission: string, targetDoc?: Doc) => { const target = targetDoc || this.targetDoc!; - const acl = `acl-${normalizeEmail(StrCast(group.title))}`; + const acl = `acl_${normalizeEmail(StrCast(group.title))}`; const docs = SelectionManager.Views.length < 2 ? [target] : SelectionManager.Views.map(docView => docView.Document); docs.map(doc => (this.layoutDocAcls || doc.dockingConfig ? doc : Doc.GetProto(doc))).forEach(doc => { @@ -578,7 +578,7 @@ export class SharingManager extends React.Component<{}> { } else { docs.forEach(doc => { if (GetEffectiveAcl(doc) === AclAdmin) { - distributeAcls(`acl-${shareWith}`, permission, doc, undefined); + distributeAcls(`acl_${shareWith}`, permission, doc, undefined); } }); } @@ -618,7 +618,7 @@ export class SharingManager extends React.Component<{}> { removeGroup = (group: Doc) => { if (group.docsShared) { DocListCast(group.docsShared).forEach(doc => { - const acl = `acl-${StrCast(group.title)}`; + const acl = `acl_${StrCast(group.title)}`; distributeAcls(acl, SharingPermissions.None, doc); const members: string[] = JSON.parse(StrCast(group.members)); @@ -634,7 +634,7 @@ export class SharingManager extends React.Component<{}> { // if (!targetDoc) { // return; // } - // targetDoc["acl-" + PublicKey] = permission; + // targetDoc['acl_' + PublicKey] = permission; // }s /** diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx index 25415a4f0..c4855d2e7 100644 --- a/src/client/views/DashboardView.tsx +++ b/src/client/views/DashboardView.tsx @@ -165,7 +165,7 @@ export class DashboardView extends ObservableReactComponent<{}> { : this.getDashboards(this.selectedDashboardGroup).map(dashboard => { const href = ImageCast(dashboard.thumb)?.url?.href; const shared = Object.keys(dashboard[DocAcl]) - .filter(key => key !== `acl-${normalizeEmail(ClientUtils.CurrentUserEmail())}` && !['acl-Me', 'acl-Guest'].includes(key)) + .filter(key => key !== `acl_${normalizeEmail(ClientUtils.CurrentUserEmail())}` && !['acl_Me', 'acl_Guest'].includes(key)) .some(key => dashboard[DocAcl][key] !== AclPrivate); return ( <div diff --git a/src/client/views/FilterPanel.tsx b/src/client/views/FilterPanel.tsx index 994107c01..ed9fc8dfb 100644 --- a/src/client/views/FilterPanel.tsx +++ b/src/client/views/FilterPanel.tsx @@ -222,7 +222,7 @@ export class FilterPanel extends ObservableReactComponent<filterProps> { <div className="filterBox-treeView"> <div className="filterBox-select"> <div style={{ width: '100%' }}> - <FieldsDropdown Document={this.Document} selectFunc={this.facetClick} showPlaceholder placeholder="add a filter" addedFields={['acl-Guest', LinkedTo]} /> + <FieldsDropdown Document={this.Document} selectFunc={this.facetClick} showPlaceholder placeholder="add a filter" addedFields={['acl_Guest', LinkedTo]} /> </div> {/* THE FOLLOWING CODE SHOULD BE DEVELOPER FOR BOOLEAN EXPRESSION (AND / OR) */} {/* <div className="filterBox-select-bool"> diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index 5e1c80f0c..f4ded8367 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -231,7 +231,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps @computed get noviceFields() { const noviceReqFields = ['author', 'author_date', 'tags', '_layout_curPage']; - return this.editableFields(key => key.indexOf('modificationDate') !== -1 || (key[0] === key[0].toUpperCase() && !key.startsWith('acl')), noviceReqFields); + return this.editableFields(key => key.indexOf('modificationDate') !== -1 || (key[0] === key[0].toUpperCase() && !key.startsWith('acl_')), noviceReqFields); } @undoBatch @@ -473,7 +473,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps SharingManager.Instance.users.forEach(eachUser => { let userOnDoc = true; if (seldoc) { - if (Doc.GetT(seldoc, 'acl-' + normalizeEmail(eachUser.user.email), 'string', true) === '' || Doc.GetT(seldoc, 'acl-' + normalizeEmail(eachUser.user.email), 'string', true) === undefined) { + if (Doc.GetT(seldoc, 'acl_' + normalizeEmail(eachUser.user.email), 'string', true) === '' || Doc.GetT(seldoc, 'acl_' + normalizeEmail(eachUser.user.email), 'string', true) === undefined) { userOnDoc = false; } } @@ -485,7 +485,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps // sorts and then adds each user to the table usersAdded.sort(this.sortUsers); usersAdded.forEach(userEmail => { - const userKey = `acl-${normalizeEmail(userEmail)}`; + const userKey = `acl_${normalizeEmail(userEmail)}`; const aclField = Doc.GetT(this.layoutDocAcls ? target : Doc.GetProto(target), userKey, 'string', true); const permission = StrCast(aclField); individualTableEntries.unshift(this.sharingItem(userEmail, showAdmin, permission!, false)); // adds each user @@ -494,7 +494,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps // adds current user let userEmail = ClientUtils.CurrentUserEmail(); if (userEmail === 'guest') userEmail = 'Guest'; - const userKey = `acl-${normalizeEmail(userEmail)}`; + const userKey = `acl_${normalizeEmail(userEmail)}`; if (!usersAdded.includes(userEmail) && userEmail !== 'Guest' && userEmail !== target.author) { let permission; if (this.layoutDocAcls) { @@ -514,7 +514,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps groupList.sort(this.sortGroups); groupList.forEach(group => { if (group.title !== 'Guest' && this.selectedDoc) { - const groupKey = 'acl-' + normalizeEmail(StrCast(group.title)); + const groupKey = 'acl_' + normalizeEmail(StrCast(group.title)); if (this.selectedDoc[groupKey] !== '' && this.selectedDoc[groupKey] !== undefined) { let permission; if (this.layoutDocAcls) { @@ -529,7 +529,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps }); // guest permission - const guestPermission = StrCast((this.layoutDocAcls ? target : Doc.GetProto(target))['acl-Guest']); + const guestPermission = StrCast((this.layoutDocAcls ? target : Doc.GetProto(target)).acl_Guest); return ( <div> @@ -1733,8 +1733,8 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps } if (this.isPres && PresBox.Instance) { const selectedItem: boolean = PresBox.Instance.selectedArray.size > 0; - const type = [DocumentType.AUDIO, DocumentType.VID].includes(DocCast(PresBox.Instance.activeItem?.annotationOn)?.type as any as DocumentType) - ? (DocCast(PresBox.Instance.activeItem?.annotationOn)?.type as any as DocumentType) + const type = [DocumentType.AUDIO, DocumentType.VID].find(dt => dt === DocCast(PresBox.Instance.activeItem?.annotationOn)?.type) + ? DocCast(PresBox.Instance.activeItem?.annotationOn)?.type : PresBox.targetRenderedDoc(PresBox.Instance.activeItem)?.type; return ( <div className="propertiesView" style={{ width: this._props.width }}> diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx index 51352d3e2..fda320077 100644 --- a/src/client/views/collections/CollectionCarouselView.tsx +++ b/src/client/views/collections/CollectionCarouselView.tsx @@ -52,7 +52,7 @@ export class CollectionCarouselView extends CollectionSubView() { }; captionStyleProvider = (doc: Doc | undefined, captionProps: Opt<FieldViewProps>, property: string): any => { // first look for properties on the document in the carousel, then fallback to properties on the container - const childValue = doc?.['caption-' + property] ? this._props.styleProvider?.(doc, captionProps, property) : undefined; + const childValue = doc?.['caption_' + property] ? this._props.styleProvider?.(doc, captionProps, property) : undefined; return childValue ?? this._props.styleProvider?.(this.layoutDoc, captionProps, property); }; panelHeight = () => this._props.PanelHeight() - (StrCast(this.layoutDoc._layout_showCaption) ? 50 : 0); diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx index 6dba9e155..f945a7aa4 100644 --- a/src/client/views/collections/CollectionMenu.tsx +++ b/src/client/views/collections/CollectionMenu.tsx @@ -53,7 +53,7 @@ export class CollectionMenu extends AntimodeMenu<CollectionMenuProps> { makeObservable(this); CollectionMenu.Instance = this; this._canFade = false; // don't let the inking menu fade away - this.Pinned = Cast(Doc.UserDoc()['menuCollections-pinned'], 'boolean', true); + this.Pinned = Cast(Doc.UserDoc().menuCollections_pinned, 'boolean', true); this.jumpTo(300, 300); } @@ -71,7 +71,7 @@ export class CollectionMenu extends AntimodeMenu<CollectionMenuProps> { @action toggleMenuPin = () => { - Doc.UserDoc()['menuCollections-pinned'] = this.Pinned = !this.Pinned; + Doc.UserDoc().menuCollections_pinned = this.Pinned = !this.Pinned; if (!this.Pinned && this._left < 0) { this.jumpTo(300, 300); } @@ -280,8 +280,8 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu _saveFilterCommand = { params: ['target'], title: 'save filter', - script: `this.target._childFilters = compareLists(this['target-childFilters'],this.target._childFilters) ? undefined : copyField(this['target-childFilters']); - this.target._searchFilterDocs = compareLists(this['target-searchFilterDocs'],this.target._searchFilterDocs) ? undefined: copyField(this['target-searchFilterDocs']);`, + script: `this.target._childFilters = compareLists(this.target_childFilters,this.target._childFilters) ? undefined : copyField(this.target_childFilters); + this.target._searchFilterDocs = compareLists(this.target_searchFilterDocs,this.target._searchFilterDocs) ? undefined: copyField(this.target_searchFilterDocs);`, immediate: undoBatch(() => { this.target._childFilters = undefined; this.target._searchFilterDocs = undefined; @@ -289,8 +289,8 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu initialize: (button: Doc) => { const activeDash = Doc.ActiveDashboard; if (activeDash) { - button['target-childFilters'] = (Doc.MySearcher._childFilters || activeDash._childFilters) instanceof ObjectField ? ObjectField.MakeCopy((Doc.MySearcher._childFilters || activeDash._childFilters) as any as ObjectField) : undefined; - button['target-searchFilterDocs'] = activeDash._searchFilterDocs instanceof ObjectField ? ObjectField.MakeCopy(activeDash._searchFilterDocs as any as ObjectField) : undefined; + button.target_childFilters = (Doc.MySearcher._childFilters || activeDash._childFilters) instanceof ObjectField ? ObjectField.MakeCopy((Doc.MySearcher._childFilters || activeDash._childFilters) as any as ObjectField) : undefined; + button.target_searchFilterDocs = activeDash._searchFilterDocs instanceof ObjectField ? ObjectField.MakeCopy(activeDash._searchFilterDocs as any as ObjectField) : undefined; } }, }; diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx index a0d84ab28..d6cbe0dab 100644 --- a/src/client/views/collections/CollectionView.tsx +++ b/src/client/views/collections/CollectionView.tsx @@ -70,7 +70,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr } get collectionViewType(): CollectionViewType | undefined { - const viewField = StrCast(this.layoutDoc._type_collection); + const viewField = StrCast(this.layoutDoc._type_collection) as any as CollectionViewType; if (CollectionView._safeMode) { switch (viewField) { case CollectionViewType.Freeform: @@ -79,7 +79,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr default: } // prettier-ignore } - return viewField as any as CollectionViewType; + return viewField; } screenToLocalTransform = () => (this._props.renderDepth ? this.ScreenToLocalBoxXf() : this.ScreenToLocalBoxXf().scale(this._props.PanelWidth() / this.bodyPanelWidth())); diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 986c1e357..c1a889539 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1664,7 +1664,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection doc.x = scr?.[0]; doc.y = scr?.[1]; }); - this._props.addDocTab(childDocs as any as Doc, OpenWhere.inParentFromScreen); + this._props.addDocTab(childDocs, OpenWhere.inParentFromScreen); }; @undoBatch diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 303ff4b98..278d30d6a 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -1,6 +1,5 @@ /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/click-events-have-key-events */ -import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Tooltip } from '@mui/material'; import { action, computed, makeObservable, observable } from 'mobx'; @@ -156,7 +155,7 @@ export class LinkMenuItem extends ObservableReactComponent<LinkMenuItemProps> { @observable _hover = false; docView = () => this._props.docView; render() { - const destinationIcon = Doc.toIcon(this._props.destinationDoc) as any as IconProp; + const destinationIcon = Doc.toIcon(this._props.destinationDoc); const title = StrCast(this._props.destinationDoc.title).length > 18 ? StrCast(this._props.destinationDoc.title).substr(0, 14) + '...' : this._props.destinationDoc.title; diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx index 6a86af6a7..7b1847ae4 100644 --- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx +++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx @@ -160,7 +160,7 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF const timecode = Math.round(time); Object.keys(vals).forEach(val => { const findexed = Cast(d[`${val}_indexed`], listSpec('string'), []).slice(); - findexed[timecode] = vals[val] as any as string; + findexed[timecode] = vals[val] || ''; d[`${val}_indexed`] = new List<string>(findexed); }); } @@ -169,7 +169,7 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF const timecode = Math.round(time); Object.keys(vals).forEach(val => { const findexed = Cast(d[`${val}_indexed`], listSpec('number'), []).slice(); - findexed[timecode] = vals[val] as any as number; + findexed[timecode] = vals[val] || 0; d[`${val}_indexed`] = new List<number>(findexed); }); } diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index db28d0a48..6d3d4be06 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -6,11 +6,10 @@ import { observer } from 'mobx-react'; import { extname } from 'path'; import * as React from 'react'; import { ClientUtils, DashColor, returnEmptyString, returnFalse, returnOne, returnZero, setupMoveUpEvents } from '../../../ClientUtils'; -import { Doc, Opt } from '../../../fields/Doc'; +import { Doc, DocListCast, Opt } from '../../../fields/Doc'; import { DocData } from '../../../fields/DocSymbols'; import { Id } from '../../../fields/FieldSymbols'; import { InkTool } from '../../../fields/InkField'; -import { List } from '../../../fields/List'; import { ObjectField } from '../../../fields/ObjectField'; import { Cast, ImageCast, NumCast, StrCast } from '../../../fields/Types'; import { ImageField } from '../../../fields/URLField'; @@ -341,7 +340,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() impl @computed get paths() { const field = Cast(this.dataDoc[this.fieldKey], ImageField, null); // retrieve the primary image URL that is being rendered from the data doc - const alts = this.dataDoc[this.fieldKey + '_alternates'] as any as List<Doc>; // retrieve alternate documents that may be rendered as alternate images + const alts = DocListCast(this.dataDoc[this.fieldKey + '_alternates']); // retrieve alternate documents that may be rendered as alternate images const defaultUrl = new URL(ClientUtils.prepend('/assets/unknown-file-icon-hi.png')); const altpaths = alts diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx index f96dd2b76..a9aa017a1 100644 --- a/src/client/views/nodes/KeyValuePair.tsx +++ b/src/client/views/nodes/KeyValuePair.tsx @@ -101,7 +101,7 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> { </button> <input className="keyValuePair-td-key-check" type="checkbox" style={hover} onChange={this.handleCheck} ref={this.checkbox} /> <Tooltip title={Object.entries(new DocumentOptions()).find((pair: [string, FInfo]) => pair[0].replace(/^_/, '') === this._props.keyName)?.[1].description ?? ''}> - <div className="keyValuePair-keyField" style={{ marginLeft: 20 * (this._props.keyName.match(/_/g)?.length || 0), color: keyStyle }}> + <div className="keyValuePair-keyField" style={{ marginLeft: 20 * (this._props.keyName.replace(/__/g, '').match(/_/g)?.length || 0), color: keyStyle }}> {'('.repeat(parenCount)} {this._props.keyName} {')'.repeat(parenCount)} diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx index ed9635bdd..4fe7ec993 100644 --- a/src/client/views/nodes/trails/PresBox.tsx +++ b/src/client/views/nodes/trails/PresBox.tsx @@ -1607,7 +1607,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() { </div> </Tooltip> </div> - {[DocumentType.AUDIO, DocumentType.VID].includes(targetType as any as DocumentType) ? null : ( + {[DocumentType.AUDIO, DocumentType.VID].find(dt => dt === targetType) ? null : ( <> <div className="ribbon-doubleButton"> <div className="presBox-subheading">Slide Duration</div> diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index c9aaa5158..9083d6ca3 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -156,9 +156,9 @@ export const ReverseHierarchyMap: Map<string, { level: aclLevel; acl: symbol; im export function updateCachedAcls(doc: Doc) { if (doc) { const target = (doc as any)?.__fieldTuples ?? doc; - const permissions: { [key: string]: symbol } = !target.author || target.author === ClientUtils.CurrentUserEmail() ? { 'acl-Me': AclAdmin } : {}; + const permissions: { [key: string]: symbol } = !target.author || target.author === ClientUtils.CurrentUserEmail() ? { acl_Me: AclAdmin } : {}; Object.keys(target).forEach(key => { - key.startsWith('acl') && (permissions[key] = ReverseHierarchyMap.get(StrCast(target[key]))!.acl); + key.startsWith('acl_') && (permissions[key] = ReverseHierarchyMap.get(StrCast(target[key]))!.acl); }); if (Object.keys(permissions).length || doc[DocAcl]?.length) { runInAction(() => { @@ -382,7 +382,7 @@ export class Doc extends RefField { this[UpdatingFromServer] = true; this[fKey] = value; this[UpdatingFromServer] = false; - if (fKey.startsWith('acl')) { + if (fKey.startsWith('acl_')) { updateCachedAcls(this); } if (prev === AclPrivate && GetEffectiveAcl(this) !== AclPrivate) { @@ -390,7 +390,7 @@ export class Doc extends RefField { } }; const writeMode = DocServer.getFieldWriteMode(fKey); - if (fKey.startsWith('acl') || writeMode !== DocServer.WriteMode.Playground) { + if (fKey.startsWith('acl_') || writeMode !== DocServer.WriteMode.Playground) { delete this[CachedUpdates][fKey]; // eslint-disable-next-line no-await-in-loop await fn(); @@ -832,7 +832,7 @@ export namespace Doc { newLayoutDoc.rootDocument = targetDoc; newLayoutDoc.embedContainer = targetDoc; newLayoutDoc.resolvedDataDoc = dataDoc; - newLayoutDoc['acl-Guest'] = SharingPermissions.Edit; + newLayoutDoc.acl_Guest = SharingPermissions.Edit; if (dataDoc[templateField] === undefined && (templateLayoutDoc[templateField] as any)?.length) { dataDoc[templateField] = ObjectField.MakeCopy(templateLayoutDoc[templateField] as List<Doc>); // ComputedField.MakeFunction(`ObjectField.MakeCopy(templateLayoutDoc["${templateField}"])`, { templateLayoutDoc: Doc.name }, { templateLayoutDoc }); @@ -970,7 +970,7 @@ export namespace Doc { delegate.proto = doc; delegate.author = ClientUtils.CurrentUserEmail(); Object.keys(doc) - .filter(key => key.startsWith('acl')) + .filter(key => key.startsWith('acl_')) .forEach(key => { delegate[key] = doc[key]; }); diff --git a/src/fields/util.ts b/src/fields/util.ts index 72b0ef721..9361430cb 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -107,7 +107,7 @@ const _setterImpl = action((target: any, prop: string | symbol | number, valueIn if (value === undefined) (target as Doc|ObjectField)[FieldChanged]?.(undefined, { $unset: { ['fields.' + prop]: '' } }); else (target as Doc|ObjectField)[FieldChanged]?.(undefined, { $set: { ['fields.' + prop]: value instanceof ObjectField ? SerializationHelper.Serialize(value) :value}}); - if (prop === 'author' || prop.toString().startsWith('acl')) updateCachedAcls(target); + if (prop === 'author' || prop.toString().startsWith('acl_')) updateCachedAcls(target); } else { DocServer.registerDocWithCachedUpdate(receiver, prop as string, curValue); } @@ -184,7 +184,7 @@ export function SetCachedGroups(groups: string[]) { } function getEffectiveAcl(target: any, user?: string): symbol { const targetAcls = target[DocAcl]; - if (targetAcls?.['acl-Me'] === AclAdmin || GetCachedGroupByName('Admin')) return AclAdmin; + if (targetAcls?.acl_Me === AclAdmin || GetCachedGroupByName('Admin')) return AclAdmin; const userChecked = user || ClientUtils.CurrentUserEmail(); // if the current user is the author of the document / the current user is a member of the admin group if (targetAcls && Object.keys(targetAcls).length) { @@ -210,7 +210,7 @@ function getEffectiveAcl(target: any, user?: string): symbol { /** * Recursively distributes the access right for a user across the children of a document and its annotations. - * @param key the key storing the access right (e.g. acl-groupname) + * @param key the key storing the access right (e.g. acl_groupname) * @param acl the access right being stored (e.g. "Can Edit") * @param target the document on which this access right is being set * @param visited list of Doc's already distributed to. @@ -219,7 +219,7 @@ function getEffectiveAcl(target: any, user?: string): symbol { */ // eslint-disable-next-line default-param-last export function distributeAcls(key: string, acl: SharingPermissions, target: Doc, visited: Doc[] = [], allowUpgrade?: boolean, layoutOnly = false) { - const selfKey = `acl-${normalizeEmail(ClientUtils.CurrentUserEmail())}`; + const selfKey = `acl_${normalizeEmail(ClientUtils.CurrentUserEmail())}`; if (!target || visited.includes(target) || key === selfKey) return; visited.push(target); @@ -268,15 +268,15 @@ export function distributeAcls(key: string, acl: SharingPermissions, target: Doc * Copies parent's acl fields to the child */ export function inheritParentAcls(parent: Doc, child: Doc, layoutOnly: boolean) { - [...Object.keys(parent), ...(ClientUtils.CurrentUserEmail() !== parent.author ? ['acl-Owner'] : [])] - .filter(key => key.startsWith('acl')) + [...Object.keys(parent), ...(ClientUtils.CurrentUserEmail() !== parent.author ? ['acl_Owner'] : [])] + .filter(key => key.startsWith('acl_')) .forEach(key => { - // if the default acl mode is private, then don't inherit the acl-guest permission, but set it to private. - // const permission: string = key === 'acl-guest' && Doc.defaultAclPrivate ? AclPrivate : parent[key]; - const parAcl = ReverseHierarchyMap.get(StrCast(key === 'acl-Owner' ? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Edit) : parent[key]))?.acl; + // if the default acl mode is private, then don't inherit the acl_guest permission, but set it to private. + // const permission: string = key === 'acl_Guest' && Doc.defaultAclPrivate ? AclPrivate : parent[key]; + const parAcl = ReverseHierarchyMap.get(StrCast(key === 'acl_Owner' ? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Edit) : parent[key]))?.acl; if (parAcl) { const sharePermission = HierarchyMapping.get(parAcl)?.name; - sharePermission && distributeAcls(key === 'acl-Owner' ? `acl-${normalizeEmail(StrCast(parent.author))}` : key, sharePermission, child, undefined, false, layoutOnly); + sharePermission && distributeAcls(key === 'acl_Owner' ? `acl_${normalizeEmail(StrCast(parent.author))}` : key, sharePermission, child, undefined, false, layoutOnly); } }); } @@ -303,7 +303,7 @@ export function setter(target: any, inProp: string | symbol | number, value: any const effectiveAcl = inProp === 'constructor' || typeof inProp === 'symbol' ? AclAdmin : GetPropAcl(target, prop); if (effectiveAcl !== AclEdit && effectiveAcl !== AclAugment && effectiveAcl !== AclAdmin) return true; // if you're trying to change an acl but don't have Admin access / you're trying to change it to something that isn't an acceptable acl, you can't - if (typeof prop === 'string' && prop.startsWith('acl') && (effectiveAcl !== AclAdmin || ![...Object.values(SharingPermissions), undefined].includes(value))) return true; + if (typeof prop === 'string' && prop.startsWith('acl_') && (effectiveAcl !== AclAdmin || ![...Object.values(SharingPermissions), undefined].includes(value))) return true; if (typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('_')) { if (!prop.startsWith('__')) prop = prop.substring(1); diff --git a/src/server/authentication/DashUserModel.ts b/src/server/authentication/DashUserModel.ts index a288bfeab..bfa6d7bdb 100644 --- a/src/server/authentication/DashUserModel.ts +++ b/src/server/authentication/DashUserModel.ts @@ -61,7 +61,7 @@ const userSchema = new mongoose.Schema( * Password hash middleware. */ userSchema.pre('save', function save(next) { - const user = this as any as DashUserModel; + const user = this; if (!user.isModified('password')) { return next(); } @@ -70,7 +70,7 @@ userSchema.pre('save', function save(next) { return next(err); } bcrypt.hash( - user.password, + user.password ?? '', salt, () => {}, (cryptErr: mongoose.Error, hash: string) => { diff --git a/src/server/authentication/Passport.ts b/src/server/authentication/Passport.ts index a5222e531..ca9e3058e 100644 --- a/src/server/authentication/Passport.ts +++ b/src/server/authentication/Passport.ts @@ -18,11 +18,11 @@ passport.deserializeUser<any, any>((id, done) => { passport.use( new LocalStrategy({ usernameField: 'email', passReqToCallback: true }, (req, email, password, done) => { User.findOne({ email: email.toLowerCase() }) - .then((user: any) => { + .then((user: DashUserModel) => { if (!user) { done(undefined, false, { message: 'Invalid email or password' }); // invalid email } else { - (user as any as DashUserModel).comparePassword(password, (error: Error, isMatch: boolean) => { + user.comparePassword(password, (error: Error, isMatch: boolean) => { if (error) return done(error); if (!isMatch) return done(undefined, false, { message: 'Invalid email or password' }); // invalid password // valid authentication HERE |