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:
parent
624172d331
commit
6442a8a386
@ -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> {
|
||||
|
@ -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,
|
||||
);
|
||||
|
@ -39,7 +39,6 @@ export interface IGroupStore extends Store<IGroup, number> {
|
||||
updateGroupUsers(
|
||||
groupId: number,
|
||||
newUsers: IGroupUserModel[],
|
||||
existingUsers: IGroupUserModel[],
|
||||
deletableUsers: IGroupUser[],
|
||||
userName: string,
|
||||
): Promise<void>;
|
||||
|
1
src/test/fixtures/fake-group-store.ts
vendored
1
src/test/fixtures/fake-group-store.ts
vendored
@ -69,7 +69,6 @@ export default class FakeGroupStore implements IGroupStore {
|
||||
updateGroupUsers(
|
||||
groupId: number,
|
||||
newUsers: IGroupUserModel[],
|
||||
existingUsers: IGroupUserModel[],
|
||||
deletableUsers: IGroupUser[],
|
||||
userName: string,
|
||||
): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user