From a8776241b63a201a3b0fed6bbc9340282494c561 Mon Sep 17 00:00:00 2001 From: pionnegru Date: Tue, 7 Jan 2020 20:37:16 +0200 Subject: [PATCH] dynamically load user menu options --- .../current-user/current-user.component.html | 21 ++++----------- .../current-user/current-user.component.ts | 26 ++++++++++--------- .../current-user/current-user.module.ts | 13 +++++++--- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/app/components/current-user/current-user.component.html b/src/app/components/current-user/current-user.component.html index a823127cb..87092e647 100644 --- a/src/app/components/current-user/current-user.component.html +++ b/src/app/components/current-user/current-user.component.html @@ -13,21 +13,10 @@ - - - - + + - - - - diff --git a/src/app/components/current-user/current-user.component.ts b/src/app/components/current-user/current-user.component.ts index 8016bc6a6..6ccb79e58 100644 --- a/src/app/components/current-user/current-user.component.ts +++ b/src/app/components/current-user/current-user.component.ts @@ -23,17 +23,16 @@ * along with Alfresco. If not, see . */ -import { Component, ViewEncapsulation } from '@angular/core'; +import { Component, ViewEncapsulation, OnInit } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; -import { ProfileState } from '@alfresco/adf-extensions'; +import { ProfileState, ContentActionRef } from '@alfresco/adf-extensions'; import { AppStore, - SetSelectedNodesAction, getUserProfile, getLanguagePickerState } from '@alfresco/aca-shared/store'; -import { AppService } from '@alfresco/aca-shared'; +import { AppExtensionService } from '../../extensions/extension.service'; @Component({ selector: 'aca-current-user', @@ -41,20 +40,23 @@ import { AppService } from '@alfresco/aca-shared'; encapsulation: ViewEncapsulation.None, host: { class: 'aca-current-user' } }) -export class CurrentUserComponent { +export class CurrentUserComponent implements OnInit { profile$: Observable; languagePicker$: Observable; + actions: Array = []; - get showLogout(): boolean { - return !this.appService.withCredentials; - } + constructor( + private store: Store, + private extensions: AppExtensionService + ) {} - constructor(private store: Store, private appService: AppService) { + ngOnInit() { this.profile$ = this.store.select(getUserProfile); - this.languagePicker$ = store.select(getLanguagePickerState); + this.languagePicker$ = this.store.select(getLanguagePickerState); + this.actions = this.extensions.getUserActions(); } - onLogoutEvent() { - this.store.dispatch(new SetSelectedNodesAction([])); + trackByActionId(_: number, action: ContentActionRef) { + return action.id; } } diff --git a/src/app/components/current-user/current-user.module.ts b/src/app/components/current-user/current-user.module.ts index 2fa14bc3b..77f47bc8b 100644 --- a/src/app/components/current-user/current-user.module.ts +++ b/src/app/components/current-user/current-user.module.ts @@ -26,12 +26,19 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { CoreModule } from '@alfresco/adf-core'; +import { ExtensionsModule } from '@alfresco/adf-extensions'; import { CurrentUserComponent } from './current-user.component'; +import { UserMenuItemComponent } from './user-menu-item.component'; import { RouterModule } from '@angular/router'; @NgModule({ - imports: [CommonModule, CoreModule.forChild(), RouterModule], - declarations: [CurrentUserComponent], - exports: [CurrentUserComponent] + imports: [ + CommonModule, + CoreModule.forChild(), + RouterModule, + ExtensionsModule + ], + declarations: [CurrentUserComponent, UserMenuItemComponent], + exports: [CurrentUserComponent, UserMenuItemComponent] }) export class AppCurrentUserModule {}