From 9855a145d18bbb0bdddc3c90eb84cffa5ad3bbd4 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Wed, 16 Feb 2022 16:40:42 -0500 Subject: [PATCH] (core) Remove UI-imposed restriction against combining public edit access and access rules Test Plan: TBD Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3272 --- app/client/aclui/AccessRules.ts | 20 +------------------- app/client/models/UserManagerModel.ts | 9 +-------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/app/client/aclui/AccessRules.ts b/app/client/aclui/AccessRules.ts index db86e5dd..37e9faa8 100644 --- a/app/client/aclui/AccessRules.ts +++ b/app/client/aclui/AccessRules.ts @@ -36,10 +36,8 @@ import { } from 'app/common/GranularAccessClause'; import {isHiddenCol} from 'app/common/gristTypes'; import {isObject} from 'app/common/gutil'; -import * as roles from 'app/common/roles'; import {SchemaTypes} from 'app/common/schema'; import {MetaRowRecord} from 'app/common/TableData'; -import {ANONYMOUS_USER_EMAIL, EVERYONE_EMAIL, getRealAccess} from 'app/common/UserAPI'; import { BaseObservable, Computed, @@ -115,8 +113,6 @@ export class AccessRules extends Disposable { private _aclUsersPopup = ACLUsersPopup.create(this); - private _publicEditAccess = Observable.create(this, false); - constructor(private _gristDoc: GristDoc) { super(); this._ruleStatus = Computed.create(this, (use) => { @@ -137,7 +133,7 @@ export class AccessRules extends Disposable { }); this._savingEnabled = Computed.create(this, this._ruleStatus, (use, s) => - (s === RuleStatus.ChangedValid) && !use(this._publicEditAccess)); + (s === RuleStatus.ChangedValid)); this._userAttrChoices = Computed.create(this, this._userAttrRules, (use, rules) => { const result: IAttrOption[] = [ @@ -341,10 +337,6 @@ export class AccessRules extends Disposable { dom.style('visibility', use => use(this._aclUsersPopup.isInitialized) ? '' : 'hidden')), ), cssConditionError({style: 'margin-left: 16px'}, - dom.maybe(this._publicEditAccess, () => dom('div', - 'Public "Editor" access is incompatible with Access Rules. ' + - 'To set rules, remove it or reduce to "Viewer".' - )), dom.text(this._errorMessage), testId('access-rules-error') ), @@ -469,16 +461,6 @@ export class AccessRules extends Disposable { if (this.isDisposed()) { return; } this._aclUsersPopup.init(pageModel, permissionData); - - // We do not allow Public Editor access in combination with Granular ACL rules. When - // _publicEditAccess is on, we show a warning and prevent saving rules. - if (permissionData) { - const publicEditAccess = permissionData.users.some(user => ( - (user.email === EVERYONE_EMAIL || user.email === ANONYMOUS_USER_EMAIL) && - roles.canEdit(getRealAccess(user, permissionData)) - )); - this._publicEditAccess.set(publicEditAccess); - } } } diff --git a/app/client/models/UserManagerModel.ts b/app/client/models/UserManagerModel.ts index 5cf05764..3a973507 100644 --- a/app/client/models/UserManagerModel.ts +++ b/app/client/models/UserManagerModel.ts @@ -1,7 +1,6 @@ import {GristDoc} from 'app/client/components/GristDoc'; import {AppModel} from 'app/client/models/AppModel'; import {DocPageModel} from 'app/client/models/DocPageModel'; -import {reportWarning} from 'app/client/models/errors'; import {ShareAnnotations, ShareAnnotator} from 'app/common/ShareAnnotator'; import {normalizeEmail} from 'app/common/emails'; import {GristLoadConfig} from 'app/common/gristUrls'; @@ -255,13 +254,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel } // Loop through the members and update the delta. for (const m of members) { - let access = m.access.get(); - if (m === this.publicMember && access === roles.EDITOR && this.gristDoc?.hasGranularAccessRules()) { - access = roles.VIEWER; - if (!options?.silent) { - reportWarning('Public "Editor" access is incompatible with Access Rules. Reduced to "Viewer".'); - } - } + const access = m.access.get(); if (!roles.isValidRole(access)) { if (!options?.silent) { throw new Error(`Cannot update user to invalid role ${access}`);