(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))
.sort((a, b) => a.cleanText.localeCompare(b.cleanText));
results.items = items;
if (!results.items.length) {
if (!results.items.length && cleanText) {
const newObject = {
value: text,
cleanText,

View File

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

View File

@ -551,7 +551,10 @@ export class ACMemberEmail extends Disposable {
}
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);
return buildACMemberEmail(this,

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 => ({
const users = getResourceUsers(org).filter(u => userRoleMap[u.id]).map(u => {
const access = userRoleMap[u.id];
return {
...this.makeFullUser(u),
access: userRoleMap[u.id]
}));
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,
};
});