mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4911] migrate identity role service (#5096)
* migrate IdentityRoleService implementation * update unit tests * move interfaces to the origin * move models to proper places * migrate model to interface * fix test * update docs
This commit is contained in:
committed by
Eugenio Romano
parent
3fc9390666
commit
f731988ca6
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { IdentityUserService, IdentityUserModel } from '@alfresco/adf-core';
|
||||
import { IdentityUserService } from '@alfresco/adf-core';
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Observable, of, BehaviorSubject, throwError } from 'rxjs';
|
||||
import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model';
|
||||
@@ -226,7 +226,7 @@ export class ProcessFilterCloudService {
|
||||
* @returns String of process instance filters preference key
|
||||
*/
|
||||
private prepareKey(appName: string): string {
|
||||
const user: IdentityUserModel = this.identityUserService.getCurrentUserInfo();
|
||||
const user = this.identityUserService.getCurrentUserInfo();
|
||||
return `process-filters-${appName}-${user.username}`;
|
||||
}
|
||||
|
||||
|
@@ -17,8 +17,7 @@
|
||||
|
||||
import { PeopleCloudComponent } from './people-cloud.component';
|
||||
import { ComponentFixture, TestBed, async, tick, fakeAsync } from '@angular/core/testing';
|
||||
import { IdentityUserService, AlfrescoApiService,
|
||||
CoreModule, IdentityUserModel, setupTestBed } from '@alfresco/adf-core';
|
||||
import { IdentityUserService, AlfrescoApiService, CoreModule, setupTestBed } from '@alfresco/adf-core';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||
import { of } from 'rxjs';
|
||||
import { mockUsers } from '../../mock/user-cloud.mock';
|
||||
@@ -111,7 +110,7 @@ describe('PeopleCloudComponent', () => {
|
||||
it('should emit selectedUser if option is valid', (done) => {
|
||||
fixture.detectChanges();
|
||||
const selectEmitSpy = spyOn(component.selectUser, 'emit');
|
||||
component.onSelect(new IdentityUserModel({ username: 'username' }));
|
||||
component.onSelect({ username: 'username' });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(selectEmitSpy).toHaveBeenCalled();
|
||||
|
@@ -73,7 +73,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
/** FormControl to search the user */
|
||||
@Input()
|
||||
searchUserCtrl: FormControl = new FormControl();
|
||||
searchUserCtrl = new FormControl();
|
||||
|
||||
/** Placeholder translation key
|
||||
*/
|
||||
@@ -82,15 +82,15 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
/** Emitted when a user is selected. */
|
||||
@Output()
|
||||
selectUser: EventEmitter<IdentityUserModel> = new EventEmitter<IdentityUserModel>();
|
||||
selectUser = new EventEmitter<IdentityUserModel>();
|
||||
|
||||
/** Emitted when a selected user is removed in multi selection mode. */
|
||||
@Output()
|
||||
removeUser: EventEmitter<IdentityUserModel> = new EventEmitter<IdentityUserModel>();
|
||||
removeUser = new EventEmitter<IdentityUserModel>();
|
||||
|
||||
/** Emitted when an warning occurs. */
|
||||
@Output()
|
||||
warning: EventEmitter<any> = new EventEmitter<any>();
|
||||
warning = new EventEmitter<any>();
|
||||
|
||||
@ViewChild('userInput')
|
||||
private userInput: ElementRef<HTMLInputElement>;
|
||||
@@ -214,7 +214,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.logService.error(error);
|
||||
}
|
||||
const isUserValid: boolean = this.userExists(result);
|
||||
return isUserValid ? new IdentityUserModel(result) : null;
|
||||
return isUserValid ? result : null;
|
||||
});
|
||||
return await Promise.all(promiseBatch);
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ describe('StartTaskCloudComponent', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const mockUser = new IdentityUserModel({username: 'currentUser', firstName: 'Test', lastName: 'User', email: 'currentUser@test.com'});
|
||||
const mockUser: IdentityUserModel = {username: 'currentUser', firstName: 'Test', lastName: 'User', email: 'currentUser@test.com'};
|
||||
|
||||
setupTestBed({
|
||||
imports: [ProcessServiceCloudTestingModule, StartTaskCloudTestingModule],
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { IdentityUserService, IdentityUserModel } from '@alfresco/adf-core';
|
||||
import { IdentityUserService } from '@alfresco/adf-core';
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Observable, of, BehaviorSubject, throwError } from 'rxjs';
|
||||
import { TaskFilterCloudModel } from '../models/filter-cloud.model';
|
||||
@@ -231,7 +231,7 @@ export class TaskFilterCloudService {
|
||||
* @returns Username string
|
||||
*/
|
||||
getUsername(): string {
|
||||
const user: IdentityUserModel = this.identityUserService.getCurrentUserInfo();
|
||||
const user = this.identityUserService.getCurrentUserInfo();
|
||||
return user.username;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user