mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-10779] User info component refactor (#8187)
* [AAE-10779] Update documentation * [AAE-10779] Update demo-shell user-info component call * [AAE-10779] Ecm user info component * [AAE-10779] Identity user info component * [AAE-10779] Bpm user info component * [AAE-10779] Remove ecm-panel id references * [AAE-10779] add stories and remove old component * [AAE-10779] Update doc version and remove leftover html tag * trigger travis * [AAE-10779] rename ecm-user-info to content-user-info and bpm-user-info to process-user-info * [AAE-10779] update docs * [AAE-10779] fix demo-shell user-info * [AAE-10779] add docs
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<div
|
||||
id="userinfo_container"
|
||||
[class.adf-userinfo-name-right]="showOnRight"
|
||||
(keyup)="onKeyPress($event)"
|
||||
class="adf-userinfo-container"
|
||||
*ngIf="canShow"
|
||||
>
|
||||
<span *ngIf="showName" id="adf-userinfo-ecm-name-display" class="adf-userinfo-name">
|
||||
{{ecmUser | fullName}}
|
||||
</span>
|
||||
<button mat-button [matMenuTriggerFor]="menu" class="adf-userinfo-menu_button"
|
||||
data-automation-id="adf-user-profile">
|
||||
<div class="adf-userinfo-button-profile" id="user-profile">
|
||||
<div *ngIf="identityUser; else showEcmUserImage" id="identity-user-image">
|
||||
<div *ngIf="ecmUser?.avatarId; else initialTemplate">
|
||||
<div class="adf-userinfo-profile-container">
|
||||
<img id="logged-user-img" [src]="getEcmAvatar(ecmUser.avatarId)" alt="user-info-profile-button"
|
||||
class="adf-userinfo-profile-image"/>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template #initialTemplate>
|
||||
<div [innerHTML]="identityUser | usernameInitials:'adf-userinfo-pic'"></div>
|
||||
</ng-template>
|
||||
</div>
|
||||
<ng-template #showEcmUserImage>
|
||||
<div id="ecm-user-image">
|
||||
<div *ngIf="ecmUser.avatarId; else initialTemplate" class="adf-userinfo-profile-container">
|
||||
<img id="logged-user-img" [src]="getEcmAvatar(ecmUser.avatarId)" alt="user-info-profile-button"
|
||||
class="adf-userinfo-profile-image"/>
|
||||
</div>
|
||||
<ng-template #initialTemplate>
|
||||
<div [outerHTML]="ecmUser | usernameInitials:'adf-userinfo-pic'"></div>
|
||||
</ng-template>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<mat-menu #menu="matMenu" id="user-profile-lists" [xPosition]="menuPositionX" [yPosition]="menuPositionY"
|
||||
[overlapTrigger]="false" class="adf-userinfo-menu">
|
||||
<mat-tab-group id="tab-group-env" (click)="stopClosing($event)" selectedIndex="0" role="menuitem"
|
||||
class="adf-userinfo-tab adf-hide-tab">
|
||||
<mat-tab label="{{ 'USER_PROFILE.TAB.CS' | translate }}" role="dialog"
|
||||
*ngIf="mode === userInfoMode.CONTENT">
|
||||
<mat-card class="adf-userinfo-card">
|
||||
<mat-card-header class="adf-userinfo-card-header"
|
||||
[style.background-image]="'url(' + ecmBackgroundImage + ')'">
|
||||
<div *ngIf="ecmUser.avatarId; else initialTemplate"
|
||||
class="adf-userinfo-profile-container adf-hide-small">
|
||||
<img class="adf-userinfo-profile-picture" id="ecm-user-detail-image"
|
||||
alt="ecm-profile-image" [src]="getEcmAvatar(ecmUser.avatarId)"/>
|
||||
</div>
|
||||
<ng-template #initialTemplate>
|
||||
<div
|
||||
[outerHTML]="ecmUser | usernameInitials:'adf-userinfo-profile-initials adf-hide-small'"></div>
|
||||
</ng-template>
|
||||
|
||||
<div class="adf-userinfo-title" id="ecm-username">{{ecmUser | fullName}}</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="adf-userinfo-supporting-text">
|
||||
<div class="adf-userinfo-detail">
|
||||
<span id="ecm-full-name"
|
||||
class="adf-userinfo__detail-title">{{ecmUser | fullName}}</span>
|
||||
<span class="adf-userinfo__detail-profile" id="ecm-email"> {{ecmUser.email}} </span>
|
||||
<a class="adf-userinfo__detail-profile" href="#/profile">
|
||||
{{ 'USER_PROFILE.LABELS.MY_PROFILE' | translate }}</a>
|
||||
</div>
|
||||
<div class="adf-userinfo-detail">
|
||||
<span class="adf-userinfo__secondary-info" id="ecm-job-title-label">
|
||||
{{ 'USER_PROFILE.LABELS.ECM.JOB_TITLE' | translate }}
|
||||
<span id="ecm-job-title"
|
||||
class="adf-userinfo__detail-profile"> {{ ecmUser.jobTitle ? ecmUser.jobTitle : 'N/A' }} </span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-tab>
|
||||
<mat-tab id="identity-panel" role="dialog" *ngIf="mode === userInfoMode.CONTENT_SSO">
|
||||
<mat-card class="adf-userinfo-card">
|
||||
<mat-card-header class="adf-userinfo-card-header"
|
||||
[style.background-image]="'url(' + bpmBackgroundImage + ')'">
|
||||
<div *ngIf="ecmUser.avatarId; else initialTemplate"
|
||||
class="adf-userinfo-profile-container adf-hide-small">
|
||||
<img class="adf-userinfo-profile-picture" id="ecm-user-detail-image"
|
||||
alt="ecm-profile-image" [src]="getEcmAvatar(ecmUser.avatarId)"/>
|
||||
</div>
|
||||
<ng-template #initialTemplate>
|
||||
<div
|
||||
[outerHTML]="identityUser | usernameInitials:'adf-userinfo-profile-initials adf-hide-small'"></div>
|
||||
</ng-template>
|
||||
<div class="adf-userinfo-title" id="identity-username">{{identityUser | fullName}}</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="adf-userinfo-supporting-text">
|
||||
<div class="adf-userinfo-detail">
|
||||
<span id="identity-full-name"
|
||||
class="adf-userinfo__detail-title">{{identityUser | fullName}}</span>
|
||||
<span class="adf-userinfo__detail-profile"
|
||||
id="identity-email"> {{identityUser.email}} </span>
|
||||
<a class="adf-userinfo__detail-profile" href="#/profile">
|
||||
{{ 'USER_PROFILE.LABELS.MY_PROFILE' | translate }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</mat-menu>
|
||||
</div>
|
@@ -0,0 +1,188 @@
|
||||
.adf {
|
||||
&-userinfo-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
&-userinfo-name-right {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
&-userinfo-name {
|
||||
padding: 0 5px;
|
||||
|
||||
@media screen and (max-width: 959px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-userinfo-pic {
|
||||
background: var(--adf-user-info-color);
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 100px;
|
||||
text-align: center;
|
||||
font-weight: bolder;
|
||||
font-size: var(--theme-adf-picture-1-font-size);
|
||||
text-transform: uppercase;
|
||||
vertical-align: middle;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
&-userinfo-profile-image {
|
||||
background: var(--adf-user-info-color);
|
||||
text-align: center;
|
||||
border-radius: 90%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-right: 0;
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
&-userinfo-profile-container {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
&-userinfo-menu_button.mat-button {
|
||||
margin-right: 0;
|
||||
border-radius: 90%;
|
||||
padding: 0;
|
||||
min-width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
&-userinfo-tab .mat-tab-header {
|
||||
align-self: center;
|
||||
width: 100%;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
&-userinfo-tab .mat-tab-label {
|
||||
flex: auto;
|
||||
font-weight: 500;
|
||||
font-size: var(--theme-body-1-font-size);
|
||||
text-transform: uppercase;
|
||||
line-height: 48px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&-userinfo-card-header {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: stretch;
|
||||
line-height: normal;
|
||||
height: 100px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
&-userinfo-card.mat-card {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
&-userinfo-supporting-text {
|
||||
font-size: var(--theme-body-1-font-size);
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
line-height: 18px;
|
||||
overflow: hidden;
|
||||
padding: 32px;
|
||||
column-count: 2;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@media screen and (max-width: 599px) {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
&-userinfo-title {
|
||||
font-size: var(--theme-title-font-size);
|
||||
}
|
||||
|
||||
&-userinfo__detail-profile {
|
||||
align-items: flex-start;
|
||||
font-size: var(--theme-body-1-font-size);
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
line-height: 18px;
|
||||
display: block;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&-userinfo__detail-title {
|
||||
text-overflow: ellipsis;
|
||||
font-size: var(--theme-subheading-2-font-size);
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.04em;
|
||||
line-height: 20px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&-userinfo__secondary-info {
|
||||
font-size: var(--theme-body-1-font-size);
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
line-height: 18px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
&-userinfo-profile-picture {
|
||||
background: var(--adf-user-info-color);
|
||||
background-size: cover;
|
||||
border-radius: 50%;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
margin-left: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
&-userinfo-profile-initials {
|
||||
text-transform: uppercase;
|
||||
background-size: cover;
|
||||
background-color: var(--adf-user-info-color);
|
||||
border-radius: 50%;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
margin-left: 0;
|
||||
margin-right: 8px;
|
||||
font-size: 35px;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
line-height: 78px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
&-userinfo-button-profile {
|
||||
display: inline-block;
|
||||
border: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
&-userinfo-detail {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&-hide-tab .mat-tab-label-active {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (min-device-width: 480px) {
|
||||
.mat-menu-panel.adf-userinfo-menu {
|
||||
max-height: 450px;
|
||||
min-width: 450px;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-menu-panel.adf-userinfo-menu .mat-menu-content {
|
||||
padding: 0;
|
||||
}
|
@@ -0,0 +1,272 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
CoreTestingModule,
|
||||
fakeEcmEditedUser,
|
||||
fakeEcmUser,
|
||||
fakeEcmUserNoImage,
|
||||
IdentityUserModel,
|
||||
InitialUsernamePipe,
|
||||
setupTestBed,
|
||||
UserInfoMode
|
||||
} from '@alfresco/adf-core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { By, DomSanitizer } from '@angular/platform-browser';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
|
||||
import { ContentUserInfoComponent } from './content-user-info.component';
|
||||
|
||||
class FakeSanitizer extends DomSanitizer {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
sanitize(html) {
|
||||
return html;
|
||||
}
|
||||
|
||||
bypassSecurityTrustHtml(value: string): any {
|
||||
return value;
|
||||
}
|
||||
|
||||
bypassSecurityTrustStyle(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
bypassSecurityTrustScript(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
bypassSecurityTrustUrl(): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
bypassSecurityTrustResourceUrl(): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
describe('ContentUserInfoComponent', () => {
|
||||
const profilePictureUrl = 'alfresco-logo.svg';
|
||||
|
||||
let component: ContentUserInfoComponent;
|
||||
let fixture: ComponentFixture<ContentUserInfoComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
const identityUserMock = { firstName: 'fake-identity-first-name', lastName: 'fake-identity-last-name', email: 'fakeIdentity@email.com' };
|
||||
const identityUserWithOutLastNameMock = { firstName: 'fake-identity-first-name', lastName: null, email: 'fakeIdentity@email.com' };
|
||||
|
||||
const openUserInfo = () => {
|
||||
fixture.detectChanges();
|
||||
const imageButton = element.querySelector<HTMLButtonElement>('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
||||
const whenFixtureReady = async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule,
|
||||
ContentTestingModule,
|
||||
MatMenuModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ContentUserInfoComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
|
||||
spyOn(window, 'requestAnimationFrame').and.returnValue(1);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should not show any image if the user is not logged in', () => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img')).toBeNull();
|
||||
});
|
||||
|
||||
it('should NOT have users immediately after ngOnInit', () => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#ecm_username')).toBeNull();
|
||||
expect(element.querySelector('#user-profile-lists')).toBeNull();
|
||||
});
|
||||
|
||||
describe('when user is logged on ecm', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.ecmUser = fakeEcmUser as any;
|
||||
component.isLoggedIn = true;
|
||||
});
|
||||
|
||||
describe('ui', () => {
|
||||
|
||||
it('should show ecm only last name when user first name is null ', async () => {
|
||||
component.ecmUser = fakeEcmEditedUser as any;
|
||||
await whenFixtureReady();
|
||||
|
||||
openUserInfo();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
const ecmUsername = fixture.debugElement.query(By.css('#ecm-username'));
|
||||
expect(ecmUsername).toBeDefined();
|
||||
expect(ecmUsername).not.toBeNull();
|
||||
expect(ecmUsername.nativeElement.textContent).not.toContain('fake-ecm-first-name');
|
||||
expect(ecmUsername.nativeElement.textContent).not.toContain('null');
|
||||
});
|
||||
|
||||
it('should show the username when showName attribute is true', async () => {
|
||||
await whenFixtureReady();
|
||||
expect(component.showName).toBeTruthy();
|
||||
expect(element.querySelector('#adf-userinfo-ecm-name-display')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should hide the username when showName attribute is false', async () => {
|
||||
component.showName = false;
|
||||
await whenFixtureReady();
|
||||
expect(element.querySelector('#adf-userinfo-ecm-name-display')).toBeNull();
|
||||
});
|
||||
|
||||
it('should have the defined class to show the name on the right side', async () => {
|
||||
await whenFixtureReady();
|
||||
expect(element.querySelector('#userinfo_container').classList).toContain('adf-userinfo-name-right');
|
||||
});
|
||||
|
||||
it('should not have the defined class to show the name on the left side', async () => {
|
||||
component.namePosition = 'left';
|
||||
await whenFixtureReady();
|
||||
expect(element.querySelector('#userinfo_container').classList).not.toContain('adf-userinfo-name-right');
|
||||
});
|
||||
|
||||
describe('and has image', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
component.ecmUser = fakeEcmUser as any;
|
||||
component.isLoggedIn = true;
|
||||
spyOn(component, 'getEcmAvatar').and.returnValue(profilePictureUrl);
|
||||
await whenFixtureReady();
|
||||
});
|
||||
|
||||
it('should get the ecm current user image', async () => {
|
||||
openUserInfo();
|
||||
const loggedImage = fixture.debugElement.query(By.css('#logged-user-img'));
|
||||
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
expect(loggedImage).not.toBeNull();
|
||||
expect(loggedImage.properties.src).toContain(profilePictureUrl);
|
||||
});
|
||||
|
||||
it('should display the current user image if user has avatarId', () => {
|
||||
openUserInfo();
|
||||
const loggedImage = fixture.debugElement.query(By.css('#logged-user-img'));
|
||||
expect(component.ecmUser).toBeDefined();
|
||||
expect(component.ecmUser.avatarId).toBe('fake-avatar-id');
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
expect(loggedImage).not.toBeNull();
|
||||
expect(loggedImage.properties.src).toContain(profilePictureUrl);
|
||||
});
|
||||
|
||||
it('should get the ecm user information', async () => {
|
||||
openUserInfo();
|
||||
const ecmImage = fixture.debugElement.query(By.css('#ecm-user-detail-image'));
|
||||
const ecmFullName = fixture.debugElement.query(By.css('#ecm-full-name'));
|
||||
const ecmJobTitle = fixture.debugElement.query(By.css('#ecm-job-title-label'));
|
||||
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
expect(fixture.debugElement.query(By.css('#ecm-username'))).not.toBeNull();
|
||||
expect(ecmImage).not.toBeNull();
|
||||
expect(ecmImage.properties.src).toContain(profilePictureUrl);
|
||||
expect(ecmFullName.nativeElement.textContent).toContain('fake-ecm-first-name fake-ecm-last-name');
|
||||
expect(ecmJobTitle.nativeElement.textContent).toContain('USER_PROFILE.LABELS.ECM.JOB_TITLE');
|
||||
});
|
||||
});
|
||||
|
||||
describe('and has no image', () => {
|
||||
|
||||
beforeEach( async () => {
|
||||
component.ecmUser = fakeEcmUserNoImage as any;
|
||||
component.isLoggedIn = true;
|
||||
await whenFixtureReady();
|
||||
});
|
||||
|
||||
it('should show N/A when the job title is null', () => {
|
||||
const imageButton = element.querySelector<HTMLButtonElement>('[data-automation-id="user-initials-image"]');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
const ecmJobTitle = fixture.debugElement.query(By.css('#ecm-job-title'));
|
||||
expect(ecmJobTitle).not.toBeNull();
|
||||
expect(ecmJobTitle).not.toBeNull();
|
||||
expect(ecmJobTitle.nativeElement.textContent).toContain('N/A');
|
||||
});
|
||||
|
||||
it('should not show the tabs', () => {
|
||||
const imageButton = element.querySelector<HTMLButtonElement>('[data-automation-id="user-initials-image"]');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
const tabHeader = fixture.debugElement.query(By.css('#tab-group-env'));
|
||||
expect(tabHeader.classes['adf-hide-tab']).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display the current user Initials if the user dose not have avatarId', () => {
|
||||
fixture.detectChanges();
|
||||
const pipe = new InitialUsernamePipe(new FakeSanitizer());
|
||||
const expected = pipe.transform({
|
||||
id: 13,
|
||||
firstName: 'Wilbur',
|
||||
lastName: 'Adams',
|
||||
email: 'wilbur@app.com'
|
||||
});
|
||||
expect(expected).toBe('<div data-automation-id="user-initials-image" class="">WA</div>');
|
||||
expect(component.ecmUser).toBeDefined();
|
||||
expect(component.ecmUser.avatarId).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when identity user is logged in', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.ecmUser = fakeEcmUser as any;
|
||||
component.identityUser = identityUserMock as unknown as IdentityUserModel;
|
||||
component.isLoggedIn = true;
|
||||
component.mode = UserInfoMode.CONTENT_SSO;
|
||||
});
|
||||
|
||||
it('should not show initials if the user have avatar and provider is ECM', async () => {
|
||||
component.identityUser = identityUserWithOutLastNameMock as unknown as IdentityUserModel;
|
||||
await whenFixtureReady();
|
||||
|
||||
expect(element.querySelector('.adf-userinfo-pic')).toBeNull();
|
||||
expect(element.querySelector('.adf-userinfo-profile-image')).toBeDefined();
|
||||
expect(element.querySelector('.adf-userinfo-profile-image')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,108 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EcmUserModel, IdentityUserModel, PeopleContentService, UserInfoMode } from '@alfresco/adf-core';
|
||||
import { Component, Input, OnDestroy, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { MatMenuTrigger, MenuPositionX, MenuPositionY } from '@angular/material/menu';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-content-user-info',
|
||||
templateUrl: './content-user-info.component.html',
|
||||
styleUrls: ['./content-user-info.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ContentUserInfoComponent implements OnDestroy {
|
||||
|
||||
@ViewChild(MatMenuTrigger) trigger: MatMenuTrigger;
|
||||
|
||||
@Input()
|
||||
isLoggedIn: boolean;
|
||||
|
||||
@Input()
|
||||
ecmUser: EcmUserModel;
|
||||
|
||||
@Input()
|
||||
identityUser: IdentityUserModel;
|
||||
|
||||
@Input()
|
||||
mode: UserInfoMode = UserInfoMode.CONTENT;
|
||||
|
||||
/** Custom path for the background banner image for ACS users. */
|
||||
@Input()
|
||||
ecmBackgroundImage: string = './assets/images/ecm-background.png';
|
||||
|
||||
/** Custom path for the background banner image for APS users. */
|
||||
@Input()
|
||||
bpmBackgroundImage: string = './assets/images/bpm-background.png';
|
||||
|
||||
/** Custom choice for opening the menu at the bottom. Can be `before` or `after`. */
|
||||
@Input()
|
||||
menuPositionX: MenuPositionX = 'after';
|
||||
|
||||
/** Custom choice for opening the menu at the bottom. Can be `above` or `below`. */
|
||||
@Input()
|
||||
menuPositionY: MenuPositionY = 'below';
|
||||
|
||||
/** Shows/hides the username next to the user info button. */
|
||||
@Input()
|
||||
showName: boolean = true;
|
||||
|
||||
/** When the username is shown, this defines its position relative to the user info button.
|
||||
* Can be `right` or `left`.
|
||||
*/
|
||||
@Input()
|
||||
namePosition: string = 'right';
|
||||
|
||||
userInfoMode = UserInfoMode;
|
||||
|
||||
private destroy$ = new Subject();
|
||||
|
||||
constructor(private peopleContentService: PeopleContentService) {
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next(true);
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
onKeyPress(event: KeyboardEvent) {
|
||||
this.closeUserModal(event);
|
||||
}
|
||||
|
||||
private closeUserModal($event: KeyboardEvent) {
|
||||
if ($event.keyCode === 27) {
|
||||
this.trigger.closeMenu();
|
||||
}
|
||||
}
|
||||
|
||||
stopClosing(event: Event) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
getEcmAvatar(avatarId: string): string {
|
||||
return this.peopleContentService.getUserProfileImage(avatarId);
|
||||
}
|
||||
|
||||
get showOnRight(): boolean {
|
||||
return this.namePosition === 'right';
|
||||
}
|
||||
|
||||
get canShow(): boolean {
|
||||
return this.isLoggedIn && !!this.ecmUser && !!this.mode;
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ContentUserInfoComponent } from './content-user-info.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { PipeModule } from '@alfresco/adf-core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
|
||||
@NgModule({
|
||||
declarations: [ContentUserInfoComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatButtonModule,
|
||||
MatMenuModule,
|
||||
MatTabsModule,
|
||||
MatCardModule,
|
||||
TranslateModule,
|
||||
PipeModule
|
||||
],
|
||||
exports: [ContentUserInfoComponent]
|
||||
})
|
||||
export class ContentUserInfoModule {}
|
18
lib/content-services/src/lib/content-user-info/index.ts
Normal file
18
lib/content-services/src/lib/content-user-info/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './public-api';
|
20
lib/content-services/src/lib/content-user-info/public-api.ts
Normal file
20
lib/content-services/src/lib/content-user-info/public-api.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './content-user-info.component';
|
||||
|
||||
export * from './content-user-info.module';
|
@@ -48,6 +48,7 @@ import { ContentPipeModule } from './pipes/content-pipe.module';
|
||||
import { NodeCommentsModule } from './node-comments/node-comments.module';
|
||||
import { TreeModule } from './tree/tree.module';
|
||||
import { AlfrescoViewerModule } from './viewer/alfresco-viewer.module';
|
||||
import { ContentUserInfoModule } from './content-user-info/content-user-info.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -62,6 +63,7 @@ import { AlfrescoViewerModule } from './viewer/alfresco-viewer.module';
|
||||
DialogModule,
|
||||
SearchModule,
|
||||
DocumentListModule,
|
||||
ContentUserInfoModule,
|
||||
UploadModule,
|
||||
MaterialModule,
|
||||
SitesDropdownModule,
|
||||
@@ -98,6 +100,7 @@ import { AlfrescoViewerModule } from './viewer/alfresco-viewer.module';
|
||||
TagModule,
|
||||
WebScriptModule,
|
||||
DocumentListModule,
|
||||
ContentUserInfoModule,
|
||||
UploadModule,
|
||||
SearchModule,
|
||||
SitesDropdownModule,
|
||||
|
@@ -20,6 +20,7 @@ export * from './lib/social/index';
|
||||
export * from './lib/tag/index';
|
||||
export * from './lib/webscript/index';
|
||||
export * from './lib/document-list/index';
|
||||
export * from './lib/content-user-info/index';
|
||||
export * from './lib/upload/index';
|
||||
export * from './lib/search/index';
|
||||
export * from './lib/site-dropdown/index';
|
||||
|
Reference in New Issue
Block a user