(core) Add a Users dropdown to AccessRules page.

Summary: The list of users allows copying users' emails to clipboard, and viewing the doc as that user.

Test Plan: Added a basic test case

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2711
This commit is contained in:
Dmitry S
2021-01-22 09:01:20 -05:00
parent 586b6568af
commit 7a91d49ea1
4 changed files with 138 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import {normalizeEmail} from 'app/common/emails';
import {GristLoadConfig} from 'app/common/gristUrls';
import * as roles from 'app/common/roles';
import {ANONYMOUS_USER_EMAIL, EVERYONE_EMAIL, PermissionData, PermissionDelta, UserAPI} from 'app/common/UserAPI';
import {getRealAccess} from 'app/common/UserAPI';
import {computed, Computed, Disposable, obsArray, ObsArray, observable, Observable} from 'grainjs';
import some = require('lodash/some');
@@ -261,9 +262,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
// active user's initial access level, which is OWNER normally. (It's sometimes possible to
// open UserManager by a less-privileged user, e.g. if access was just lowered, in which
// case any attempted changes will fail on saving.)
const initInheritedAccess = roles.getWeakestRole(member.parentAccess, this.initData.maxInheritedRole || null);
const initialAccess = roles.getStrongestRole(member.access, initInheritedAccess);
const initialAccessBasicRole = roles.getEffectiveRole(initialAccess);
const initialAccessBasicRole = roles.getEffectiveRole(getRealAccess(member, this.initData));
// This pretends to be a computed to match the other case, but is really a constant.
inheritedAccess = Computed.create(this, (use) => initialAccessBasicRole);
} else {