[AAE-5139] User name style and Discovery service initialization fix (#7010)

* [AAE-5139] User name style fix and Discovery serice fixed

* * fixed unit test

* * fixed test and us latest js-api events

* * tests fixed

* * update js api

* * fixed test and lint
This commit is contained in:
Dharan
2021-05-12 00:10:21 +05:30
committed by GitHub
parent 453198c1e8
commit e603486b00
31 changed files with 34543 additions and 132 deletions

View File

@@ -102,7 +102,6 @@ describe('content type', () => {
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await contentServicesPage.contentList.dataTablePage().waitTillContentLoaded();
await browser.sleep(8000); // wait for sso session to initiate
});
afterEach( async () => {

View File

@@ -4,8 +4,6 @@
"C279932": "login problem APS not basic",
"C279931": "login problem APS not basic",
"C279930": "login problem APS not basic",
"C593560": "https://alfresco.atlassian.net/browse/ADF-5388",
"C593559": "https://alfresco.atlassian.net/browse/ADF-5388",
"C269081": "https://alfresco.atlassian.net/browse/ADF-5385",
"C272819": "https://alfresco.atlassian.net/browse/ADF-5385",
"C290069": "https://alfresco.atlassian.net/browse/ADF-5387"

View File

@@ -72,8 +72,8 @@
<adf-empty-content
id="adf-no-permissions-template"
icon="supervisor_account"
title="PERMISSION_MANAGER.MESSAGE.EMPTY-PERMISSION"
subtitle="PERMISSION_MANAGER.MESSAGE.EMPTY-SUBTITLE">
[title]="'PERMISSION_MANAGER.MESSAGE.EMPTY-PERMISSION' | translate"
[subtitle]="'PERMISSION_MANAGER.MESSAGE.EMPTY-SUBTITLE' | translate">
</adf-empty-content>
</ng-template>
</adf-no-content-template>

View File

@@ -17,7 +17,7 @@
text-transform: uppercase;
}
&-people-icon {
&-group-icon {
height: 20px !important;
width: 20px !important;
background: mat-color($primary);

View File

@@ -26,7 +26,7 @@ import { NodePermissionService } from '../../services/node-permission.service';
template: `
<div class="adf-cell-value" [attr.id]="group ? 'group-icon' : 'person-icon'" *ngIf="!isSelected">
<ng-container *ngIf="displayText$ | async as user">
<mat-icon *ngIf="group" class="adf-people-icon">people_alt_outline</mat-icon>
<mat-icon *ngIf="group" class="adf-group-icon">people_alt_outline</mat-icon>
<div *ngIf="!group" [outerHTML]="user | usernameInitials: 'adf-people-initial'"></div>
</ng-container>
</div>

View File

@@ -1,24 +1,18 @@
@mixin member-theme($theme) {
@mixin user-name-column-theme($theme) {
$primary: map-get($theme, primary);
$foreground: map-get($theme, foreground);
.adf-user {
display: flex;
flex-direction: column;
&-name-column {
padding: 2px 10px;
font-weight: 600;
font-size: 14px;
}
&-email-column {
padding: 2px 10px;
font-size: 14px;
letter-spacing: -0.2px;
line-height: 1.43;
color: mat-color($foreground, text, 0.72);
}
}
}

View File

@@ -24,10 +24,12 @@ import { EcmUserModel } from '@alfresco/adf-core';
@Component({
selector: 'adf-user-name-column',
template: `
<div class="adf-ellipsis-cell adf-user" [attr.data-automation-id]="displayText$ | async">
<span title="{{ displayText$ | async }}"> {{ displayText$ | async }}</span>
<div class="adf-ellipsis-cell" [attr.data-automation-id]="displayText$ | async">
<span class="adf-user-name-column" title="{{ displayText$ | async }}"> {{ displayText$ | async }}</span>
<br/>
<span title="{{ subTitleText$ | async }}">{{ subTitleText$ | async }}</span>
<span class="adf-user-email-column" title="{{ subTitleText$ | async }}" *ngIf="subTitleText$ | async">
{{ subTitleText$ | async }}
</span>
</div>
`,
host: { class: 'adf-user-name-column adf-datatable-content-cell adf-expand-cell-5 adf-ellipsis-cell' },

View File

@@ -31,6 +31,7 @@
@import '../aspect-list/aspect-list-dialog.component';
@import '../permission-manager/components/permission-container/permission-container.component';
@import '../permission-manager/components/user-icon-column/user-icon-column.component';
@import '../permission-manager/components/user-name-column/user-name-column.component';
@mixin adf-content-services-theme($theme) {
@include adf-breadcrumb-theme($theme);
@@ -52,6 +53,7 @@
@include adf-permission-list-theme($theme);
@include adf-permission-container-theme($theme);
@include adf-user-icon-column-theme($theme);
@include user-name-column-theme($theme);
@include adf-add-permission-theme($theme);
@include adf-add-permission-dialog-theme($theme);
@include adf-add-permission-panel-theme($theme);

View File

@@ -43,9 +43,10 @@ describe('NodeDownloadDirective', () => {
let dialogSpy;
const mockOauth2Auth = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(),
on: jasmine.createSpy('on')
}
callCustomApi: () => Promise.resolve()
},
isEcmLoggedIn: jasmine.createSpy('isEcmLoggedIn'),
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -62,5 +62,6 @@ export let searchMockApi = {
},
isEcmLoggedIn() {
return false;
}
},
reply: () => ''
};

View File

@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { Observable, from, throwError, Observer, ReplaySubject, Subject } from 'rxjs';
import { Observable, from, throwError, Observer, ReplaySubject } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { CookieService } from './cookie.service';
import { LogService } from './log.service';
@@ -38,12 +38,6 @@ export class AuthenticationService {
private redirectUrl: RedirectionModel = null;
private bearerExcludedUrls: string[] = ['auth/realms', 'resources/', 'assets/'];
/**
* Emits oAuth token exchange event
*/
onTokenExchange: Subject<string> = new Subject<string>();
/**
* Emits Basic auth login event
*/
@@ -60,14 +54,8 @@ export class AuthenticationService {
private alfrescoApi: AlfrescoApiService,
private cookie: CookieService,
private logService: LogService) {
this.listenForOauthTokenExchange();
}
private listenForOauthTokenExchange() {
this.alfrescoApi.alfrescoApiInitialized.subscribe(() => {
this.alfrescoApi.getInstance().oauth2Auth?.on('token_issued', () => {
this.onTokenExchange.next(this.alfrescoApi.getInstance().oauth2Auth.token);
});
this.alfrescoApi.getInstance().reply('logged-in', () => this.onLogin.next());
});
}

View File

@@ -220,7 +220,7 @@ describe('Discovery Api Service', () => {
});
});
describe('Oauth', () => {
describe('OnLogin Event', () => {
setupTestBed({
imports: [
TranslateModule.forRoot(),
@@ -234,7 +234,7 @@ describe('Discovery Api Service', () => {
authenticationService = TestBed.inject(AuthenticationService);
});
it('Should retrieve the info about the product for Oauth', done => {
it('Should retrieve the info about the product on login/refresh the application', done => {
spyOn(apiService.getInstance(), 'isEcmLoggedIn').and.returnValue(true);
spyOn(service, 'getEcmProductInfo').and.returnValue(of(new EcmProductVersionModel(fakeEcmDiscoveryResponse)));
@@ -252,7 +252,7 @@ describe('Discovery Api Service', () => {
done();
}
);
authenticationService.onTokenExchange.next('<token>');
authenticationService.onLogin.next('<token>');
});
});
});

View File

@@ -16,10 +16,10 @@
*/
import { Injectable } from '@angular/core';
import { from, merge, Observable, throwError, Subject } from 'rxjs';
import { from, Observable, throwError, Subject } from 'rxjs';
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
import { AlfrescoApiService } from './alfresco-api.service';
import { catchError, filter, map, switchMap, take } from 'rxjs/operators';
import { catchError, map, switchMap, filter, take } from 'rxjs/operators';
import { Activiti, SystemPropertiesRepresentation } from '@alfresco/js-api';
import { AuthenticationService } from './authentication.service';
@@ -37,9 +37,10 @@ export class DiscoveryApiService {
private apiService: AlfrescoApiService,
private authenticationService: AuthenticationService) {
merge(this.authenticationService.onTokenExchange.pipe(take(1)), this.authenticationService.onLogin)
this.authenticationService.onLogin
.pipe(
filter(() => this.apiService.getInstance()?.isEcmLoggedIn()),
take(1),
switchMap(() => this.getEcmProductInfo())
)
.subscribe((info) => this.ecmProductInfo$.next(info));

View File

@@ -48,7 +48,8 @@ describe('NodesApiService', () => {
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -36,12 +36,12 @@ describe('AppListCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
@Component({

View File

@@ -32,12 +32,12 @@ describe('AppsProcessCloudService', () => {
const apiMock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }}),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }})
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -20,7 +20,6 @@ import { By } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of, throwError } from 'rxjs';
import {
AppConfigService,
CoreModule,
FormFieldModel,
FormFieldTypes,
@@ -33,7 +32,8 @@ import {
VersionCompatibilityService,
FormService,
UploadWidgetContentLinkModel,
ContentLinkModel
ContentLinkModel,
AlfrescoApiService
} from '@alfresco/adf-core';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
import { FormCloudService } from '../services/form-cloud.service';
@@ -53,6 +53,14 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { CloudFormRenderingService } from './cloud-form-rendering.service';
import { Node } from '@alfresco/js-api';
const mockOauth2Auth = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
},
isEcmLoggedIn: jasmine.createSpy('isEcmLoggedIn'),
reply: jasmine.createSpy('reply')
};
describe('FormCloudComponent', () => {
let formCloudService: FormCloudService;
let fixture: ComponentFixture<FormCloudComponent>;
@@ -111,6 +119,9 @@ describe('FormCloudComponent', () => {
});
beforeEach(async(() => {
const apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
formRenderingService = TestBed.inject(CloudFormRenderingService);
formCloudService = TestBed.inject(FormCloudService);
@@ -119,9 +130,6 @@ describe('FormCloudComponent', () => {
visibilityService = TestBed.inject(WidgetVisibilityService);
spyOn(visibilityService, 'refreshVisibility').and.callThrough();
const appConfigService = TestBed.inject(AppConfigService);
spyOn(appConfigService, 'get').and.returnValue([]);
fixture = TestBed.createComponent(FormCloudComponent);
formComponent = fixture.componentInstance;
fixture.detectChanges();
@@ -999,13 +1007,11 @@ describe('FormCloudComponent', () => {
expect(getLabelValue('dateField')).toEqual('Date field (D-M-YYYY)');
expect(getLabelValue('amountField')).toEqual('Amount field');
expect(translateService.getLangs()).toEqual(['en', '']);
fixture.ngZone.run(() => translateService.use('fr'));
await fixture.whenStable();
fixture.detectChanges();
expect(translateService.getLangs()).toEqual(['en', '', 'fr']);
expect(getLabelValue('textField')).toEqual('Champ de texte');
expect(getLabelValue('fildUploadField')).toEqual('Téléchargement de fichiers');
expect(getLabelValue('dateField')).toEqual('Champ de date (D-M-YYYY)');
@@ -1139,8 +1145,9 @@ describe('retrieve metadata on submit', () => {
};
beforeEach(async(() => {
const appConfigService = TestBed.inject(AppConfigService);
spyOn(appConfigService, 'get').and.returnValue([]);
const apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
formService = TestBed.inject(FormService);
fixture = TestBed.createComponent(FormCloudComponent);

View File

@@ -29,7 +29,7 @@ const responseBody = {
{ id: 'id', name: 'name', formKey: 'form-key' }
};
const oauth2Auth = jasmine.createSpyObj('oauth2Auth', ['callCustomApi', 'on']);
const oauth2Auth = jasmine.createSpyObj('oauth2Auth', ['callCustomApi']);
describe('Form Cloud service', () => {
@@ -54,7 +54,8 @@ describe('Form Cloud service', () => {
oauth2Auth: oauth2Auth,
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
});
});

View File

@@ -74,7 +74,8 @@ describe('Form Definition Selector Cloud Service', () => {
oauth2Auth: oauth2Auth,
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
});
});

View File

@@ -42,12 +42,12 @@ describe('GroupCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockIdentityGroups),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve(mockIdentityGroups)
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
function getElement<T = HTMLElement>(selector: string): T {

View File

@@ -42,12 +42,12 @@ describe('PeopleCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockUsers),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve(mockUsers)
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
const mockPreselectedUsers = [

View File

@@ -66,12 +66,12 @@ describe('EditProcessFilterCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -45,12 +45,12 @@ describe('NotificationCloudService', () => {
const apiServiceMock = {
oauth2Auth: {
token: '1234567',
on: jasmine.createSpy('on')
token: '1234567'
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -38,12 +38,12 @@ describe('PreferenceService', () => {
oauth2Auth: {
callCustomApi: () => {
return Promise.resolve(mockResponse);
},
on: jasmine.createSpy('on')
}
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
}

View File

@@ -40,12 +40,12 @@ describe('StartTaskCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(taskDetailsMock),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve(taskDetailsMock)
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
const mockUser: IdentityUserModel = {username: 'currentUser', firstName: 'Test', lastName: 'User', email: 'currentUser@test.com'};

View File

@@ -53,12 +53,12 @@ describe('EditTaskFilterCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -51,12 +51,12 @@ describe('TaskHeaderCloudComponent', () => {
const mock = {
oauth2Auth: {
callCustomApi: () => Promise.resolve({}),
on: jasmine.createSpy('on')
callCustomApi: () => Promise.resolve({})
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
setupTestBed({

View File

@@ -31,12 +31,12 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
oauth2Auth: {
callCustomApi: (_queryUrl, _operation, _context, queryParams) => {
return Promise.resolve(queryParams);
},
on: jasmine.createSpy('on')
}
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
}

View File

@@ -32,12 +32,12 @@ describe('TaskListCloudService', () => {
oauth2Auth: {
callCustomApi : (_queryUrl, _operation, _context, queryParams) => {
return Promise.resolve(queryParams);
},
on: jasmine.createSpy('on')
}
},
isEcmLoggedIn() {
return false;
}
},
reply: jasmine.createSpy('reply')
};
}

34497
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -71,7 +71,7 @@
"process services-cloud"
],
"dependencies": {
"@alfresco/js-api": "4.4.0-3475",
"@alfresco/js-api": "4.4.0-3490",
"@angular/animations": "^10.0.4",
"@angular/cdk": "10.1.3",
"@angular/common": "^10.0.4",