dynamically load user menu options

This commit is contained in:
pionnegru
2020-01-07 20:37:16 +02:00
parent 75b9b017dd
commit a8776241b6
3 changed files with 29 additions and 31 deletions

View File

@@ -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;
}
}