(core) Tweak autocomplete to only suggest team members

Summary: This changes the suggestions in the User Manager autocomplete.

Test Plan: Project tests.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3656
This commit is contained in:
George Gevoian
2022-10-17 13:25:15 -07:00
parent bf24c29de4
commit efc3ba29d7
4 changed files with 22 additions and 8 deletions

View File

@@ -2208,10 +2208,14 @@ export class HomeDBManager extends EventEmitter {
}
const org: Organization = queryResult.data;
const userRoleMap = getMemberUserRoles(org, this.defaultGroupNames);
const users = getResourceUsers(org).filter(u => userRoleMap[u.id]).map(u => ({
...this.makeFullUser(u),
access: userRoleMap[u.id]
}));
const users = getResourceUsers(org).filter(u => userRoleMap[u.id]).map(u => {
const access = userRoleMap[u.id];
return {
...this.makeFullUser(u),
access,
isMember: access !== 'guests',
};
});
const personal = this._filterAccessData(scope, users, null);
return {
status: 200,
@@ -2250,12 +2254,15 @@ export class HomeDBManager extends EventEmitter {
const wsMap = getMemberUserRoles(workspace, this.defaultCommonGroupNames);
// The orgMap gives the org access inherited by each user.
const orgMap = getMemberUserRoles(workspace.org, this.defaultBasicGroupNames);
const orgMapWithMembership = getMemberUserRoles(workspace.org, this.defaultGroupNames);
// Iterate through the org since all users will be in the org.
const users: UserAccessData[] = getResourceUsers([workspace, workspace.org]).map(u => {
const orgAccess = orgMapWithMembership[u.id] || null;
return {
...this.makeFullUser(u),
access: wsMap[u.id] || null,
parentAccess: roles.getEffectiveRole(orgMap[u.id] || null)
parentAccess: roles.getEffectiveRole(orgMap[u.id] || null),
isMember: orgAccess && orgAccess !== 'guests',
};
});
const maxInheritedRole = this._getMaxInheritedRole(workspace);
@@ -2319,7 +2326,7 @@ export class HomeDBManager extends EventEmitter {
parentAccess: roles.getEffectiveRole(
roles.getStrongestRole(wsMap[u.id] || null, inheritFromOrg)
),
isMember: orgAccess !== 'guests' && orgAccess !== null,
isMember: orgAccess && orgAccess !== 'guests',
isSupport: u.id === this.getSupportUserId() ? true : undefined,
};
});