(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

@ -83,7 +83,7 @@ export function buildACMemberEmail(
.filter(item => item.cleanText.includes(cleanText)) .filter(item => item.cleanText.includes(cleanText))
.sort((a, b) => a.cleanText.localeCompare(b.cleanText)); .sort((a, b) => a.cleanText.localeCompare(b.cleanText));
results.items = items; results.items = items;
if (!results.items.length) { if (!results.items.length && cleanText) {
const newObject = { const newObject = {
value: text, value: text,
cleanText, cleanText,

View File

@ -66,6 +66,7 @@ export interface IEditableMember {
origAccess: roles.Role|null; origAccess: roles.Role|null;
isNew: boolean; isNew: boolean;
isRemoved: boolean; isRemoved: boolean;
isTeamMember?: boolean;
} }
// An option for the select elements used in the UserManager. // An option for the select elements used in the UserManager.
@ -87,6 +88,7 @@ interface IBuildMemberOptions {
picture?: string|null; picture?: string|null;
access: roles.Role|null; access: roles.Role|null;
parentAccess: roles.BasicRole|null; parentAccess: roles.BasicRole|null;
isTeamMember?: boolean;
} }
/** /**
@ -309,6 +311,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
picture: m.picture, picture: m.picture,
access: m.access, access: m.access,
parentAccess: m.parentAccess || null, parentAccess: m.parentAccess || null,
isTeamMember: m.isMember,
}) })
); );
} }
@ -375,6 +378,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
origAccess: member.access, origAccess: member.access,
isNew: false, isNew: false,
isRemoved: false, isRemoved: false,
isTeamMember: member.isTeamMember,
}; };
} }
} }

View File

@ -551,7 +551,10 @@ export class ACMemberEmail extends Disposable {
} }
public buildDom() { public buildDom() {
const acUserItem = this._members.map((member: IEditableMember) => getUserItem(member)); const acUserItem = this._members
// Only suggest team members in autocomplete.
.filter((member: IEditableMember) => member.isTeamMember)
.map((member: IEditableMember) => getUserItem(member));
const acIndex = new ACIndexImpl<ACUserItem>(acUserItem); const acIndex = new ACIndexImpl<ACUserItem>(acUserItem);
return buildACMemberEmail(this, return buildACMemberEmail(this,

View File

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