mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
dynamically load user menu options
This commit is contained in:
@@ -13,21 +13,10 @@
|
||||
</div>
|
||||
|
||||
<mat-menu #userMenu="matMenu" [overlapTrigger]="false">
|
||||
<button
|
||||
*ngIf="languagePicker$ | async"
|
||||
mat-menu-item
|
||||
[matMenuTriggerFor]="langMenu"
|
||||
>
|
||||
{{ 'APP.LANGUAGE' | translate }}
|
||||
</button>
|
||||
|
||||
<ng-container *ngIf="showLogout">
|
||||
<button mat-menu-item (click)="onLogoutEvent()" adf-logout>
|
||||
{{ 'APP.SIGN_OUT' | translate }}
|
||||
</button>
|
||||
<ng-container *ngFor="let actionRef of actions; trackBy: trackByActionId">
|
||||
<app-user-menu-item
|
||||
[actionRef]="actionRef"
|
||||
color="default"
|
||||
></app-user-menu-item>
|
||||
</ng-container>
|
||||
</mat-menu>
|
||||
|
||||
<mat-menu #langMenu="matMenu">
|
||||
<adf-language-menu></adf-language-menu>
|
||||
</mat-menu>
|
||||
|
@@ -23,17 +23,16 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<ProfileState>;
|
||||
languagePicker$: Observable<boolean>;
|
||||
actions: Array<ContentActionRef> = [];
|
||||
|
||||
get showLogout(): boolean {
|
||||
return !this.appService.withCredentials;
|
||||
}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private extensions: AppExtensionService
|
||||
) {}
|
||||
|
||||
constructor(private store: Store<AppStore>, 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;
|
||||
}
|
||||
}
|
||||
|
@@ -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 {}
|
||||
|
Reference in New Issue
Block a user