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,
|
userName: string,
|
||||||
transaction?: Transaction,
|
transaction?: Transaction,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const rows = users.map((user) => {
|
const rows = (users || []).map((user) => {
|
||||||
return {
|
return {
|
||||||
group_id: groupId,
|
group_id: groupId,
|
||||||
user_id: user.user.id,
|
user_id: user.user.id,
|
||||||
@ -219,7 +219,6 @@ export default class GroupStore implements IGroupStore {
|
|||||||
async updateGroupUsers(
|
async updateGroupUsers(
|
||||||
groupId: number,
|
groupId: number,
|
||||||
newUsers: IGroupUserModel[],
|
newUsers: IGroupUserModel[],
|
||||||
existingUsers: IGroupUserModel[],
|
|
||||||
deletableUsers: IGroupUser[],
|
deletableUsers: IGroupUser[],
|
||||||
userName: string,
|
userName: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
@ -119,18 +119,12 @@ export class GroupService {
|
|||||||
(groupUser) => groupUser.user.id == existingUser.userId,
|
(groupUser) => groupUser.user.id == existingUser.userId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const deletableUserIds = deletableUsers.map((g) => g.userId);
|
|
||||||
|
|
||||||
await this.groupStore.updateGroupUsers(
|
await this.groupStore.updateGroupUsers(
|
||||||
newGroup.id,
|
newGroup.id,
|
||||||
group.users.filter(
|
group.users.filter(
|
||||||
(user) => !existingUserIds.includes(user.user.id),
|
(user) => !existingUserIds.includes(user.user.id),
|
||||||
),
|
),
|
||||||
group.users.filter(
|
|
||||||
(user) =>
|
|
||||||
existingUserIds.includes(user.user.id) &&
|
|
||||||
!deletableUserIds.includes(user.user.id),
|
|
||||||
),
|
|
||||||
deletableUsers,
|
deletableUsers,
|
||||||
userName,
|
userName,
|
||||||
);
|
);
|
||||||
|
@ -39,7 +39,6 @@ export interface IGroupStore extends Store<IGroup, number> {
|
|||||||
updateGroupUsers(
|
updateGroupUsers(
|
||||||
groupId: number,
|
groupId: number,
|
||||||
newUsers: IGroupUserModel[],
|
newUsers: IGroupUserModel[],
|
||||||
existingUsers: IGroupUserModel[],
|
|
||||||
deletableUsers: IGroupUser[],
|
deletableUsers: IGroupUser[],
|
||||||
userName: string,
|
userName: string,
|
||||||
): Promise<void>;
|
): 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(
|
updateGroupUsers(
|
||||||
groupId: number,
|
groupId: number,
|
||||||
newUsers: IGroupUserModel[],
|
newUsers: IGroupUserModel[],
|
||||||
existingUsers: IGroupUserModel[],
|
|
||||||
deletableUsers: IGroupUser[],
|
deletableUsers: IGroupUser[],
|
||||||
userName: string,
|
userName: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
Loading…
Reference in New Issue
Block a user