[AAE-8061] Fix the group restriction for people widget (#7601)

* FIx the restrinction

* Fix unit test about restricted groups

* Add a small sleep to make it green

* Add sleep to other checks

* Remove sleeps, improve assertions

Co-authored-by: MichalFidor <michal.fidor@hyland.com>
This commit is contained in:
Maurizio Vitale
2022-04-26 15:29:06 +01:00
committed by GitHub
parent 3f7316f393
commit 9ff1f65841
7 changed files with 81 additions and 54 deletions

View File

@@ -33,7 +33,6 @@ import { Observable, of, BehaviorSubject, Subject } from 'rxjs';
import { switchMap, debounceTime, distinctUntilChanged, mergeMap, tap, filter, map, takeUntil } from 'rxjs/operators';
import {
FullNamePipe,
IdentityGroupModel,
IdentityUserModel,
IdentityUserService,
LogService
@@ -563,15 +562,13 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
private isUserPartOfAllRestrictedGroups(user: IdentityUserModel): Observable<boolean> {
return this.getUserGroups(user.id).pipe(
map(userGroups => userGroups.filter(
restrictedGroup => userGroups.includes(restrictedGroup)
).length >= this.groupsRestriction.length)
map(userGroups => this.groupsRestriction.every(restricted => userGroups.includes(restricted)))
);
}
private getUserGroups(userId: string): Observable<IdentityGroupModel[]> {
private getUserGroups(userId: string): Observable<string[]> {
return this.identityUserService.getInvolvedGroups(userId).pipe(
map(groups => groups.map(({id, name}) => ({id, name})))
map(groups => groups.map((group) => group.name))
);
}