diff --git a/projects/aca-content/assets/app.extensions.json b/projects/aca-content/assets/app.extensions.json index a37f660b1..34d8568eb 100644 --- a/projects/aca-content/assets/app.extensions.json +++ b/projects/aca-content/assets/app.extensions.json @@ -85,19 +85,19 @@ "component": "app.notification-center", "order": 50 }, - { - "id": "app.header.user", - "type": "custom", - "component": "app.user", - "order": 100 - }, { "id": "app.header.more", "type": "menu", "order": 10000, - "icon": "more_vert", + "icon": "apps", "title": "APP.ACTIONS.MORE", "children": [ + { + "id": "app.header.user", + "type": "custom", + "component": "app.user", + "order": 100 + }, { "id": "app.languagePicker", "order": 100, diff --git a/projects/aca-content/src/lib/components/common/common.module.ts b/projects/aca-content/src/lib/components/common/common.module.ts index 5f794f01a..533bd33d5 100644 --- a/projects/aca-content/src/lib/components/common/common.module.ts +++ b/projects/aca-content/src/lib/components/common/common.module.ts @@ -34,9 +34,10 @@ import { LanguagePickerComponent } from './language-picker/language-picker.compo import { LogoutComponent } from './logout/logout.component'; import { ContentModule } from '@alfresco/adf-content-services'; import { UserInfoComponent } from './user-info/user-info.component'; +import { RouterModule } from '@angular/router'; @NgModule({ - imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild(), ExtensionsModule, GenericErrorModule], + imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild(), ExtensionsModule, GenericErrorModule, RouterModule], declarations: [LocationLinkComponent, ToggleSharedComponent, LanguagePickerComponent, LogoutComponent, UserInfoComponent], exports: [ ExtensionsModule, diff --git a/projects/aca-content/src/lib/components/common/user-info/user-info.component.html b/projects/aca-content/src/lib/components/common/user-info/user-info.component.html index 2b07657e2..7017c6af6 100644 --- a/projects/aca-content/src/lib/components/common/user-info/user-info.component.html +++ b/projects/aca-content/src/lib/components/common/user-info/user-info.component.html @@ -1,14 +1,4 @@ - - - - \ No newline at end of file + diff --git a/projects/aca-content/src/lib/components/common/user-info/user-info.component.ts b/projects/aca-content/src/lib/components/common/user-info/user-info.component.ts index a0897ee83..351d6d121 100644 --- a/projects/aca-content/src/lib/components/common/user-info/user-info.component.ts +++ b/projects/aca-content/src/lib/components/common/user-info/user-info.component.ts @@ -6,21 +6,18 @@ * agreement is prohibited. */ -import { IdentityUserModel, IdentityUserService, AuthenticationService, UserInfoMode } from '@alfresco/adf-core'; +import { IdentityUserService, AuthenticationService } from '@alfresco/adf-core'; import { Component, OnInit } from '@angular/core'; import { Observable, of } from 'rxjs'; -import { EcmUserModel, PeopleContentService } from '@alfresco/adf-content-services'; +import { PeopleContentService } from '@alfresco/adf-content-services'; +import { map } from 'rxjs/operators'; @Component({ selector: 'app-user-info', templateUrl: './user-info.component.html' }) export class UserInfoComponent implements OnInit { - mode: UserInfoMode; - ecmUser$: Observable; - identityUser$: Observable; - selectedIndex: number; - userInfoMode = UserInfoMode; + displayName$: Observable; constructor( private peopleContentService: PeopleContentService, @@ -35,15 +32,12 @@ export class UserInfoComponent implements OnInit { getUserInfo() { if (this.authService.isOauth()) { this.loadIdentityUserInfo(); - this.mode = UserInfoMode.SSO; if (this.authService.isECMProvider() && this.authService.isEcmLoggedIn()) { - this.mode = UserInfoMode.CONTENT_SSO; this.loadEcmUserInfo(); } } else if (this.isEcmLoggedIn()) { this.loadEcmUserInfo(); - this.mode = UserInfoMode.CONTENT; } } @@ -55,11 +49,21 @@ export class UserInfoComponent implements OnInit { } private loadEcmUserInfo(): void { - this.ecmUser$ = this.peopleContentService.getCurrentUserInfo(); + this.displayName$ = this.peopleContentService.getCurrentUserInfo().pipe(map((model) => this.parseDisplayName(model))); } private loadIdentityUserInfo() { - this.identityUser$ = of(this.identityUserService.getCurrentUserInfo()); + this.displayName$ = of(this.identityUserService.getCurrentUserInfo()).pipe(map((model) => this.parseDisplayName(model))); + } + + private parseDisplayName(model: { firstName?: string; email?: string }): string { + let result = model.firstName; + + if (model.email) { + result = `${model.firstName} (${model.email})`; + } + + return result; } private isEcmLoggedIn() { diff --git a/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.html b/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.html index 178a8c994..d83b01b50 100644 --- a/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.html +++ b/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.html @@ -13,7 +13,8 @@ {{ appName$ | async | translate }} - - + + + diff --git a/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.ts b/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.ts index 615bac805..c2c70f604 100644 --- a/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.ts +++ b/projects/aca-content/src/lib/components/sidenav/components/sidenav-header.component.ts @@ -23,11 +23,14 @@ * along with Alfresco. If not, see . */ -import { Component, EventEmitter, Output, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { Store } from '@ngrx/store'; -import { Observable } from 'rxjs'; +import { Observable, Subject } from 'rxjs'; import { AppStore, getAppName, getLogoPath } from '@alfresco/aca-shared/store'; import { AppConfigService } from '@alfresco/adf-core'; +import { ContentActionRef } from '@alfresco/adf-extensions'; +import { AppExtensionService } from '@alfresco/aca-shared'; +import { takeUntil } from 'rxjs/operators'; @Component({ selector: 'app-sidenav-header', @@ -35,17 +38,38 @@ import { AppConfigService } from '@alfresco/adf-core'; encapsulation: ViewEncapsulation.None, host: { class: 'app-sidenav-header' } }) -export class SidenavHeaderComponent { +export class SidenavHeaderComponent implements OnInit, OnDestroy { + private onDestroy$ = new Subject(); + appName$: Observable; logo$: Observable; landingPage: string; + actions: Array = []; @Output() toggleNavBar = new EventEmitter(); - constructor(public store: Store, private appConfigService: AppConfigService) { + constructor(public store: Store, private appConfigService: AppConfigService, private appExtensions: AppExtensionService) { this.appName$ = store.select(getAppName); this.logo$ = store.select(getLogoPath); this.landingPage = this.appConfigService.get('landingPage', '/personal-files'); } + + ngOnInit() { + this.appExtensions + .getHeaderActions() + .pipe(takeUntil(this.onDestroy$)) + .subscribe((actions) => { + this.actions = actions; + }); + } + + ngOnDestroy() { + this.onDestroy$.next(true); + this.onDestroy$.complete(); + } + + trackByActionId(_: number, action: ContentActionRef) { + return action.id; + } } diff --git a/projects/aca-content/src/lib/components/sidenav/navigation-menu/navigation-menu.component.html b/projects/aca-content/src/lib/components/sidenav/navigation-menu/navigation-menu.component.html deleted file mode 100644 index 7bc78c4e5..000000000 --- a/projects/aca-content/src/lib/components/sidenav/navigation-menu/navigation-menu.component.html +++ /dev/null @@ -1,26 +0,0 @@ - - -
- account_circle - {{ displayName }} -
- - - - - - - - -
diff --git a/projects/aca-content/src/lib/components/sidenav/navigation-menu/navigation-menu.component.ts b/projects/aca-content/src/lib/components/sidenav/navigation-menu/navigation-menu.component.ts deleted file mode 100644 index 627405c2a..000000000 --- a/projects/aca-content/src/lib/components/sidenav/navigation-menu/navigation-menu.component.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved. - * - * License rights for this program may be obtained from Alfresco Software, Ltd. - * pursuant to a written agreement and any use of this program without such an - * agreement is prohibited. - */ - -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { ContentApiService } from '@alfresco/aca-shared'; - -@Component({ - selector: 'app-navigation-menu', - templateUrl: './navigation-menu.component.html', - encapsulation: ViewEncapsulation.None -}) -export class NavigationMenuComponent implements OnInit { - displayName = ''; - - constructor(private contentApi: ContentApiService) {} - - ngOnInit() { - this.contentApi.getPerson('-me-').subscribe((person) => { - const personDetails = person?.entry; - - this.displayName = personDetails.displayName; - - if (personDetails.email) { - this.displayName = `${personDetails.displayName} (${personDetails.email})`; - } - }); - } -} diff --git a/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts b/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts index 9b54837ec..cefa022a4 100644 --- a/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts +++ b/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts @@ -35,11 +35,11 @@ import { ActiveLinkDirective } from './directives/active-link.directive'; import { ExpandMenuComponent } from './components/expand-menu.component'; import { ButtonMenuComponent } from './components/button-menu.component'; import { ActionDirective } from './directives/action.directive'; -import { NavigationMenuComponent } from './navigation-menu/navigation-menu.component'; import { SidenavHeaderComponent } from './components/sidenav-header.component'; +import { SharedToolbarModule } from '@alfresco/aca-shared'; @NgModule({ - imports: [CoreModule.forChild(), ExtensionsModule.forChild(), RouterModule, AppCreateMenuModule], + imports: [CoreModule.forChild(), ExtensionsModule.forChild(), RouterModule, AppCreateMenuModule, SharedToolbarModule], declarations: [ MenuPanelDirective, ExpansionPanelDirective, @@ -48,7 +48,6 @@ import { SidenavHeaderComponent } from './components/sidenav-header.component'; ExpandMenuComponent, ButtonMenuComponent, SidenavComponent, - NavigationMenuComponent, SidenavHeaderComponent ], exports: [