aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-04-30 01:10:20 -0400
committerbobzel <zzzman@gmail.com>2024-04-30 01:10:20 -0400
commit6de58d7ecbfd14beb7389c6ff56e764b5c00ba25 (patch)
tree57b396b30644ac2fa3ec48fe38bc3efb419ce88d /src/fields
parente17737982ea2ce84b4bded798ee7bdf730a75715 (diff)
changed acl- and some other field- to acl_ and field_ style
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/Doc.ts12
-rw-r--r--src/fields/util.ts22
2 files changed, 17 insertions, 17 deletions
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);