1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

fix: creating groups should work without users (#4033)

This commit is contained in:
Jaanus Sellin 2023-06-21 14:44:43 +03:00 committed by GitHub
parent 624172d331
commit 6442a8a386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1 additions and 10 deletions

View File

@ -194,7 +194,7 @@ export default class GroupStore implements IGroupStore {
userName: string,
transaction?: Transaction,
): Promise<void> {
const rows = users.map((user) => {
const rows = (users || []).map((user) => {
return {
group_id: groupId,
user_id: user.user.id,
@ -219,7 +219,6 @@ export default class GroupStore implements IGroupStore {
async updateGroupUsers(
groupId: number,
newUsers: IGroupUserModel[],
existingUsers: IGroupUserModel[],
deletableUsers: IGroupUser[],
userName: string,
): Promise<void> {

View File

@ -119,18 +119,12 @@ export class GroupService {
(groupUser) => groupUser.user.id == existingUser.userId,
),
);
const deletableUserIds = deletableUsers.map((g) => g.userId);
await this.groupStore.updateGroupUsers(
newGroup.id,
group.users.filter(
(user) => !existingUserIds.includes(user.user.id),
),
group.users.filter(
(user) =>
existingUserIds.includes(user.user.id) &&
!deletableUserIds.includes(user.user.id),
),
deletableUsers,
userName,
);

View File

@ -39,7 +39,6 @@ export interface IGroupStore extends Store<IGroup, number> {
updateGroupUsers(
groupId: number,
newUsers: IGroupUserModel[],
existingUsers: IGroupUserModel[],
deletableUsers: IGroupUser[],
userName: string,
): Promise<void>;

View File

@ -69,7 +69,6 @@ export default class FakeGroupStore implements IGroupStore {
updateGroupUsers(
groupId: number,
newUsers: IGroupUserModel[],
existingUsers: IGroupUserModel[],
deletableUsers: IGroupUser[],
userName: string,
): Promise<void> {