mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-06-16 17:54:45 +00:00
Merge pull request #1294 from Alfresco/dev-pionnegru-ACA-2867
[ACA-2867] User - actions menu extensibility
This commit is contained in:
commit
289fca759f
@ -166,6 +166,8 @@ The button will be visible only when the linked rule evaluates to `true`.
|
|||||||
| 1.8.0 | canManagePermissions | Checks if user can manage permissions for the selected node. |
|
| 1.8.0 | canManagePermissions | Checks if user can manage permissions for the selected node. |
|
||||||
| 1.8.0 | canToggleEditOffline | Checks if user can toggle **Edit Offline** mode for selected node. |
|
| 1.8.0 | canToggleEditOffline | Checks if user can toggle **Edit Offline** mode for selected node. |
|
||||||
| 1.8.0 | user.isAdmin | Checks if user is admin. |
|
| 1.8.0 | user.isAdmin | Checks if user is admin. |
|
||||||
|
| 1.9.0 | app.canShowLanguagePicker | Whether language picker menu should be present or not. |
|
||||||
|
| 1.9.0 | app.canShowLogout | Whether logout action should be present or not. |
|
||||||
|
|
||||||
## Navigation Evaluators
|
## Navigation Evaluators
|
||||||
|
|
||||||
|
@ -676,6 +676,12 @@
|
|||||||
"items": { "$ref": "#/definitions/iconRef" },
|
"items": { "$ref": "#/definitions/iconRef" },
|
||||||
"minItems": 1
|
"minItems": 1
|
||||||
},
|
},
|
||||||
|
"userActions": {
|
||||||
|
"description": "User option menu extensions",
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "#/definitions/contentActionRef" },
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
"header": {
|
"header": {
|
||||||
"description": "Application header extensions",
|
"description": "Application header extensions",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -439,4 +439,40 @@ describe('app.evaluators', () => {
|
|||||||
expect(app.isShared(context)).toBe(true);
|
expect(app.isShared(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('canShowLanguagePicker', () => {
|
||||||
|
it('should return true when property is true', () => {
|
||||||
|
const context: any = {
|
||||||
|
languagePicker: true
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(app.canShowLanguagePicker(context)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false when property is false', () => {
|
||||||
|
const context: any = {
|
||||||
|
languagePicker: false
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(app.canShowLanguagePicker(context)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('canShowLogout', () => {
|
||||||
|
it('should return false when `withCredentials` property is true', () => {
|
||||||
|
const context: any = {
|
||||||
|
withCredentials: true
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(app.canShowLogout(context)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true when `withCredentials` property is false', () => {
|
||||||
|
const context: any = {
|
||||||
|
withCredentials: false
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(app.canShowLanguagePicker(context)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -27,6 +27,11 @@ import { RuleContext } from '@alfresco/adf-extensions';
|
|||||||
import * as navigation from './navigation.rules';
|
import * as navigation from './navigation.rules';
|
||||||
import * as repository from './repository.rules';
|
import * as repository from './repository.rules';
|
||||||
|
|
||||||
|
export interface AcaRuleContext extends RuleContext {
|
||||||
|
languagePicker: boolean;
|
||||||
|
withCredentials: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if user can copy selected node.
|
* Checks if user can copy selected node.
|
||||||
* JSON ref: `app.canCopyNode`
|
* JSON ref: `app.canCopyNode`
|
||||||
@ -526,3 +531,21 @@ export function canToggleFavorite(context: RuleContext): boolean {
|
|||||||
].some(Boolean)
|
].some(Boolean)
|
||||||
].every(Boolean);
|
].every(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if application should render language picker menu.
|
||||||
|
* JSON ref: `canShowLanguagePicker`
|
||||||
|
* @param context Rule execution context
|
||||||
|
*/
|
||||||
|
export function canShowLanguagePicker(context: AcaRuleContext): boolean {
|
||||||
|
return context.languagePicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if application should render logout option.
|
||||||
|
* JSON ref: `canShowLogout`
|
||||||
|
* @param context Rule execution context
|
||||||
|
*/
|
||||||
|
export function canShowLogout(context: AcaRuleContext): boolean {
|
||||||
|
return !context.withCredentials;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,8 @@ import { NgModule } from '@angular/core';
|
|||||||
import { GenericErrorModule } from '@alfresco/aca-shared';
|
import { GenericErrorModule } from '@alfresco/aca-shared';
|
||||||
import { LocationLinkComponent } from './location-link/location-link.component';
|
import { LocationLinkComponent } from './location-link/location-link.component';
|
||||||
import { ToggleSharedComponent } from './toggle-shared/toggle-shared.component';
|
import { ToggleSharedComponent } from './toggle-shared/toggle-shared.component';
|
||||||
|
import { LanguagePickerComponent } from './language-picker/language-picker.component';
|
||||||
|
import { LogoutComponent } from './logout/logout.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@ -38,13 +40,25 @@ import { ToggleSharedComponent } from './toggle-shared/toggle-shared.component';
|
|||||||
ExtensionsModule,
|
ExtensionsModule,
|
||||||
GenericErrorModule
|
GenericErrorModule
|
||||||
],
|
],
|
||||||
declarations: [LocationLinkComponent, ToggleSharedComponent],
|
declarations: [
|
||||||
|
LocationLinkComponent,
|
||||||
|
ToggleSharedComponent,
|
||||||
|
LanguagePickerComponent,
|
||||||
|
LogoutComponent
|
||||||
|
],
|
||||||
exports: [
|
exports: [
|
||||||
ExtensionsModule,
|
ExtensionsModule,
|
||||||
LocationLinkComponent,
|
LocationLinkComponent,
|
||||||
GenericErrorModule,
|
GenericErrorModule,
|
||||||
ToggleSharedComponent
|
ToggleSharedComponent,
|
||||||
|
LanguagePickerComponent,
|
||||||
|
LogoutComponent
|
||||||
],
|
],
|
||||||
entryComponents: [LocationLinkComponent, ToggleSharedComponent]
|
entryComponents: [
|
||||||
|
LocationLinkComponent,
|
||||||
|
ToggleSharedComponent,
|
||||||
|
LanguagePickerComponent,
|
||||||
|
LogoutComponent
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class AppCommonModule {}
|
export class AppCommonModule {}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'aca-language-picker',
|
||||||
|
template: `
|
||||||
|
<button mat-menu-item [matMenuTriggerFor]="langMenu">
|
||||||
|
{{ 'APP.LANGUAGE' | translate }}
|
||||||
|
</button>
|
||||||
|
<mat-menu #langMenu="matMenu">
|
||||||
|
<adf-language-menu></adf-language-menu>
|
||||||
|
</mat-menu>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
export class LanguagePickerComponent {}
|
70
src/app/components/common/logout/logout.component.spec.ts
Normal file
70
src/app/components/common/logout/logout.component.spec.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
|
import {
|
||||||
|
TranslateModule,
|
||||||
|
TranslateLoader,
|
||||||
|
TranslateFakeLoader
|
||||||
|
} from '@ngx-translate/core';
|
||||||
|
import { LogoutComponent } from './logout.component';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
||||||
|
|
||||||
|
describe('LogoutComponent', () => {
|
||||||
|
let fixture: ComponentFixture<LogoutComponent>;
|
||||||
|
let component: LogoutComponent;
|
||||||
|
let store;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
TranslateModule.forRoot({
|
||||||
|
loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }
|
||||||
|
})
|
||||||
|
],
|
||||||
|
declarations: [LogoutComponent],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: Store,
|
||||||
|
useValue: {
|
||||||
|
dispatch: jasmine.createSpy('dispatch')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
store = TestBed.get(Store);
|
||||||
|
fixture = TestBed.createComponent(LogoutComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reset selected nodes from store', () => {
|
||||||
|
component.onLogoutEvent();
|
||||||
|
|
||||||
|
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));
|
||||||
|
});
|
||||||
|
});
|
44
src/app/components/common/logout/logout.component.ts
Normal file
44
src/app/components/common/logout/logout.component.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { AppStore, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'aca-logout',
|
||||||
|
template: `
|
||||||
|
<button mat-menu-item (click)="onLogoutEvent()" adf-logout>
|
||||||
|
{{ 'APP.SIGN_OUT' | translate }}
|
||||||
|
</button>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
export class LogoutComponent {
|
||||||
|
constructor(private store: Store<AppStore>) {}
|
||||||
|
|
||||||
|
onLogoutEvent() {
|
||||||
|
this.store.dispatch(new SetSelectedNodesAction([]));
|
||||||
|
}
|
||||||
|
}
|
@ -13,21 +13,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-menu #userMenu="matMenu" [overlapTrigger]="false">
|
<mat-menu #userMenu="matMenu" [overlapTrigger]="false">
|
||||||
<button
|
<ng-container *ngFor="let actionRef of actions; trackBy: trackByActionId">
|
||||||
*ngIf="languagePicker$ | async"
|
<app-user-menu-item
|
||||||
mat-menu-item
|
[actionRef]="actionRef"
|
||||||
[matMenuTriggerFor]="langMenu"
|
color="default"
|
||||||
>
|
></app-user-menu-item>
|
||||||
{{ 'APP.LANGUAGE' | translate }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<ng-container *ngIf="showLogout">
|
|
||||||
<button mat-menu-item (click)="onLogoutEvent()" adf-logout>
|
|
||||||
{{ 'APP.SIGN_OUT' | translate }}
|
|
||||||
</button>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
|
|
||||||
<mat-menu #langMenu="matMenu">
|
|
||||||
<adf-language-menu></adf-language-menu>
|
|
||||||
</mat-menu>
|
|
||||||
|
@ -24,9 +24,91 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CurrentUserComponent } from './current-user.component';
|
import { CurrentUserComponent } from './current-user.component';
|
||||||
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
|
import { AppExtensionService } from '../../extensions/extension.service';
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import {
|
||||||
|
AppState,
|
||||||
|
SetUserProfileAction,
|
||||||
|
SetLanguagePickerAction
|
||||||
|
} from '@alfresco/aca-shared/store';
|
||||||
|
|
||||||
describe('CurrentUserComponent', () => {
|
describe('CurrentUserComponent', () => {
|
||||||
it('should be defined', () => {
|
let fixture: ComponentFixture<CurrentUserComponent>;
|
||||||
expect(CurrentUserComponent).toBeDefined();
|
let component: CurrentUserComponent;
|
||||||
|
let appExtensionService;
|
||||||
|
let store: Store<AppState>;
|
||||||
|
const person = {
|
||||||
|
entry: {
|
||||||
|
id: 'user-id',
|
||||||
|
firstName: 'Test',
|
||||||
|
lastName: 'User',
|
||||||
|
email: 'user@email.com',
|
||||||
|
enabled: true,
|
||||||
|
isAdmin: false,
|
||||||
|
userName: 'user-name'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [AppTestingModule],
|
||||||
|
declarations: [CurrentUserComponent],
|
||||||
|
providers: [AppExtensionService],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(CurrentUserComponent);
|
||||||
|
appExtensionService = TestBed.get(AppExtensionService);
|
||||||
|
store = TestBed.get(Store);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get profile data', done => {
|
||||||
|
const expectedProfile = {
|
||||||
|
firstName: 'Test',
|
||||||
|
lastName: 'User',
|
||||||
|
userName: 'Test User',
|
||||||
|
isAdmin: true,
|
||||||
|
id: 'user-id',
|
||||||
|
groups: []
|
||||||
|
};
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
store.dispatch(
|
||||||
|
new SetUserProfileAction({ person: person.entry, groups: [] })
|
||||||
|
);
|
||||||
|
|
||||||
|
component.profile$.subscribe((profile: any) => {
|
||||||
|
expect(profile).toEqual(jasmine.objectContaining(expectedProfile));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set language picker state', done => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
store.dispatch(new SetLanguagePickerAction(true));
|
||||||
|
|
||||||
|
component.languagePicker$.subscribe((languagePicker: boolean) => {
|
||||||
|
expect(languagePicker).toBe(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set menu actions', () => {
|
||||||
|
const actions = <any>[
|
||||||
|
{
|
||||||
|
id: 'action-id'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
spyOn(appExtensionService, 'getUserActions').and.returnValue(actions);
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.actions).toBe(actions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,17 +23,16 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* 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 { Store } from '@ngrx/store';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { ProfileState } from '@alfresco/adf-extensions';
|
import { ProfileState, ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
import {
|
import {
|
||||||
AppStore,
|
AppStore,
|
||||||
SetSelectedNodesAction,
|
|
||||||
getUserProfile,
|
getUserProfile,
|
||||||
getLanguagePickerState
|
getLanguagePickerState
|
||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
import { AppService } from '@alfresco/aca-shared';
|
import { AppExtensionService } from '../../extensions/extension.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'aca-current-user',
|
selector: 'aca-current-user',
|
||||||
@ -41,20 +40,23 @@ import { AppService } from '@alfresco/aca-shared';
|
|||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { class: 'aca-current-user' }
|
host: { class: 'aca-current-user' }
|
||||||
})
|
})
|
||||||
export class CurrentUserComponent {
|
export class CurrentUserComponent implements OnInit {
|
||||||
profile$: Observable<ProfileState>;
|
profile$: Observable<ProfileState>;
|
||||||
languagePicker$: Observable<boolean>;
|
languagePicker$: Observable<boolean>;
|
||||||
|
actions: Array<ContentActionRef> = [];
|
||||||
|
|
||||||
get showLogout(): boolean {
|
constructor(
|
||||||
return !this.appService.withCredentials;
|
private store: Store<AppStore>,
|
||||||
}
|
private extensions: AppExtensionService
|
||||||
|
) {}
|
||||||
|
|
||||||
constructor(private store: Store<AppStore>, private appService: AppService) {
|
ngOnInit() {
|
||||||
this.profile$ = this.store.select(getUserProfile);
|
this.profile$ = this.store.select(getUserProfile);
|
||||||
this.languagePicker$ = store.select(getLanguagePickerState);
|
this.languagePicker$ = this.store.select(getLanguagePickerState);
|
||||||
|
this.actions = this.extensions.getUserActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
onLogoutEvent() {
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
this.store.dispatch(new SetSelectedNodesAction([]));
|
return action.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,19 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
|
import { ExtensionsModule } from '@alfresco/adf-extensions';
|
||||||
import { CurrentUserComponent } from './current-user.component';
|
import { CurrentUserComponent } from './current-user.component';
|
||||||
|
import { UserMenuItemComponent } from './user-menu-item.component';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CommonModule, CoreModule.forChild(), RouterModule],
|
imports: [
|
||||||
declarations: [CurrentUserComponent],
|
CommonModule,
|
||||||
exports: [CurrentUserComponent]
|
CoreModule.forChild(),
|
||||||
|
RouterModule,
|
||||||
|
ExtensionsModule
|
||||||
|
],
|
||||||
|
declarations: [CurrentUserComponent, UserMenuItemComponent],
|
||||||
|
exports: [CurrentUserComponent, UserMenuItemComponent]
|
||||||
})
|
})
|
||||||
export class AppCurrentUserModule {}
|
export class AppCurrentUserModule {}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<div class="aca-user-actions-menu">
|
||||||
|
<ng-container [ngSwitch]="actionRef.type">
|
||||||
|
<ng-container *ngSwitchCase="'menu'">
|
||||||
|
<button mat-menu-item [id]="actionRef.id" [matMenuTriggerFor]="childMenu">
|
||||||
|
<span>{{ actionRef.title | translate }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<mat-menu #childMenu="matMenu">
|
||||||
|
<ng-container
|
||||||
|
*ngFor="let child of actionRef.children; trackBy: trackById"
|
||||||
|
>
|
||||||
|
<app-user-menu-item [actionRef]="child"></app-user-menu-item>
|
||||||
|
</ng-container>
|
||||||
|
</mat-menu>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngSwitchCase="'separator'">
|
||||||
|
<mat-divider></mat-divider>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngSwitchCase="'custom'">
|
||||||
|
<adf-dynamic-component [id]="actionRef.component"></adf-dynamic-component>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngSwitchDefault>
|
||||||
|
<button
|
||||||
|
mat-menu-item
|
||||||
|
color="primary"
|
||||||
|
[id]="actionRef.id"
|
||||||
|
(click)="runAction()"
|
||||||
|
>
|
||||||
|
<span>{{ actionRef.title | translate }}</span>
|
||||||
|
</button>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
126
src/app/components/current-user/user-menu-item.component.spec.ts
Normal file
126
src/app/components/current-user/user-menu-item.component.spec.ts
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
|
import { AppExtensionService } from '../../extensions/extension.service';
|
||||||
|
import { UserMenuItemComponent } from './user-menu-item.component';
|
||||||
|
import {
|
||||||
|
TranslateModule,
|
||||||
|
TranslateLoader,
|
||||||
|
TranslateFakeLoader
|
||||||
|
} from '@ngx-translate/core';
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
|
|
||||||
|
describe('UserMenuItemComponent', () => {
|
||||||
|
let fixture: ComponentFixture<UserMenuItemComponent>;
|
||||||
|
let component: UserMenuItemComponent;
|
||||||
|
let appExtensionService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
AppTestingModule,
|
||||||
|
TranslateModule.forRoot({
|
||||||
|
loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }
|
||||||
|
})
|
||||||
|
],
|
||||||
|
declarations: [UserMenuItemComponent],
|
||||||
|
providers: [AppExtensionService],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(UserMenuItemComponent);
|
||||||
|
appExtensionService = TestBed.get(AppExtensionService);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
fixture.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render button action', () => {
|
||||||
|
component.actionRef = {
|
||||||
|
id: 'action-button',
|
||||||
|
title: 'Test Button',
|
||||||
|
actions: {
|
||||||
|
click: 'TEST_EVENT'
|
||||||
|
}
|
||||||
|
} as ContentActionRef;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const buttonElement = fixture.nativeElement.querySelector('#action-button');
|
||||||
|
expect(buttonElement).not.toBe(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render menu action', () => {
|
||||||
|
component.actionRef = {
|
||||||
|
type: 'menu',
|
||||||
|
id: 'action-menu',
|
||||||
|
title: 'Test Button',
|
||||||
|
actions: {
|
||||||
|
click: 'TEST_EVENT'
|
||||||
|
}
|
||||||
|
} as ContentActionRef;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const menuElement = fixture.nativeElement.querySelector('#action-menu');
|
||||||
|
expect(menuElement).not.toBe(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render custom action', () => {
|
||||||
|
component.actionRef = {
|
||||||
|
type: 'custom',
|
||||||
|
id: 'action-custom',
|
||||||
|
component: 'custom-component'
|
||||||
|
} as ContentActionRef;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const componentElement = fixture.nativeElement.querySelector(
|
||||||
|
'#custom-component'
|
||||||
|
);
|
||||||
|
expect(componentElement).not.toBe(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should run defined action', () => {
|
||||||
|
spyOn(appExtensionService, 'runActionById');
|
||||||
|
|
||||||
|
component.actionRef = {
|
||||||
|
id: 'action-button',
|
||||||
|
title: 'Test Button',
|
||||||
|
actions: {
|
||||||
|
click: 'TEST_EVENT'
|
||||||
|
}
|
||||||
|
} as ContentActionRef;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const buttonElement = fixture.nativeElement.querySelector('#action-button');
|
||||||
|
buttonElement.dispatchEvent(new MouseEvent('click'));
|
||||||
|
expect(appExtensionService.runActionById).toHaveBeenCalledWith(
|
||||||
|
'TEST_EVENT'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
58
src/app/components/current-user/user-menu-item.component.ts
Normal file
58
src/app/components/current-user/user-menu-item.component.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Component, Input, ViewEncapsulation } from '@angular/core';
|
||||||
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
|
import { AppExtensionService } from '../../extensions/extension.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-user-menu-item',
|
||||||
|
templateUrl: 'user-menu-item.component.html',
|
||||||
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
host: { class: 'app-user-menu-item' }
|
||||||
|
})
|
||||||
|
export class UserMenuItemComponent {
|
||||||
|
@Input()
|
||||||
|
actionRef: ContentActionRef;
|
||||||
|
|
||||||
|
constructor(private extensions: AppExtensionService) {}
|
||||||
|
|
||||||
|
runAction() {
|
||||||
|
if (this.hasClickAction(this.actionRef)) {
|
||||||
|
this.extensions.runActionById(this.actionRef.actions.click);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private hasClickAction(actionRef: ContentActionRef): boolean {
|
||||||
|
if (actionRef && actionRef.actions && actionRef.actions.click) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trackById(_: number, obj: { id: string }) {
|
||||||
|
return obj.id;
|
||||||
|
}
|
||||||
|
}
|
@ -51,6 +51,8 @@ import {
|
|||||||
} from '@alfresco/adf-content-services';
|
} from '@alfresco/adf-content-services';
|
||||||
import { ToggleSharedComponent } from '../components/common/toggle-shared/toggle-shared.component';
|
import { ToggleSharedComponent } from '../components/common/toggle-shared/toggle-shared.component';
|
||||||
import { ViewNodeComponent } from '../components/toolbar/view-node/view-node.component';
|
import { ViewNodeComponent } from '../components/toolbar/view-node/view-node.component';
|
||||||
|
import { LanguagePickerComponent } from '../components/common/language-picker/language-picker.component';
|
||||||
|
import { LogoutComponent } from '../components/common/logout/logout.component';
|
||||||
|
|
||||||
export function setupExtensions(service: AppExtensionService): Function {
|
export function setupExtensions(service: AppExtensionService): Function {
|
||||||
return () => service.load();
|
return () => service.load();
|
||||||
@ -101,7 +103,9 @@ export class CoreExtensionsModule {
|
|||||||
'app.columns.trashcanName': TrashcanNameColumnComponent,
|
'app.columns.trashcanName': TrashcanNameColumnComponent,
|
||||||
'app.columns.location': LocationLinkComponent,
|
'app.columns.location': LocationLinkComponent,
|
||||||
'app.toolbar.toggleEditOffline': ToggleEditOfflineComponent,
|
'app.toolbar.toggleEditOffline': ToggleEditOfflineComponent,
|
||||||
'app.toolbar.viewNode': ViewNodeComponent
|
'app.toolbar.viewNode': ViewNodeComponent,
|
||||||
|
'app.languagePicker': LanguagePickerComponent,
|
||||||
|
'app.logout': LogoutComponent
|
||||||
});
|
});
|
||||||
|
|
||||||
extensions.setAuthGuards({
|
extensions.setAuthGuards({
|
||||||
@ -166,7 +170,9 @@ export class CoreExtensionsModule {
|
|||||||
'app.navigation.isSharedFileViewer': rules.isSharedFileViewer,
|
'app.navigation.isSharedFileViewer': rules.isSharedFileViewer,
|
||||||
|
|
||||||
'repository.isQuickShareEnabled': rules.hasQuickShareEnabled,
|
'repository.isQuickShareEnabled': rules.hasQuickShareEnabled,
|
||||||
'user.isAdmin': rules.isAdmin
|
'user.isAdmin': rules.isAdmin,
|
||||||
|
'app.canShowLanguagePicker': rules.canShowLanguagePicker,
|
||||||
|
'app.canShowLogout': rules.canShowLogout
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,18 +39,21 @@ import {
|
|||||||
ExtensionConfig,
|
ExtensionConfig,
|
||||||
ComponentRegisterService
|
ComponentRegisterService
|
||||||
} from '@alfresco/adf-extensions';
|
} from '@alfresco/adf-extensions';
|
||||||
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
describe('AppExtensionService', () => {
|
describe('AppExtensionService', () => {
|
||||||
let service: AppExtensionService;
|
let service: AppExtensionService;
|
||||||
let store: Store<AppStore>;
|
let store: Store<AppStore>;
|
||||||
let extensions: ExtensionService;
|
let extensions: ExtensionService;
|
||||||
let components: ComponentRegisterService;
|
let components: ComponentRegisterService;
|
||||||
|
let appConfigService: AppConfigService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AppTestingModule]
|
imports: [AppTestingModule]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
appConfigService = TestBed.get(AppConfigService);
|
||||||
store = TestBed.get(Store);
|
store = TestBed.get(Store);
|
||||||
service = TestBed.get(AppExtensionService);
|
service = TestBed.get(AppExtensionService);
|
||||||
extensions = TestBed.get(ExtensionService);
|
extensions = TestBed.get(ExtensionService);
|
||||||
@ -784,4 +787,114 @@ describe('AppExtensionService', () => {
|
|||||||
expect(service.getSharedLinkViewerToolbarActions()).toEqual(<any>actions);
|
expect(service.getSharedLinkViewerToolbarActions()).toEqual(<any>actions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('withCredentials', () => {
|
||||||
|
it('should set `withCredentials` to true from app configuration', () => {
|
||||||
|
appConfigService.config = {
|
||||||
|
auth: { withCredentials: true }
|
||||||
|
};
|
||||||
|
applyConfig({
|
||||||
|
$id: 'test',
|
||||||
|
$name: 'test',
|
||||||
|
$version: '1.0.0',
|
||||||
|
$license: 'MIT',
|
||||||
|
$vendor: 'Good company',
|
||||||
|
$runtime: '1.5.0'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(service.withCredentials).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set `withCredentials` to false from app configuration', () => {
|
||||||
|
appConfigService.config = {
|
||||||
|
auth: { withCredentials: false }
|
||||||
|
};
|
||||||
|
applyConfig({
|
||||||
|
$id: 'test',
|
||||||
|
$name: 'test',
|
||||||
|
$version: '1.0.0',
|
||||||
|
$license: 'MIT',
|
||||||
|
$vendor: 'Good company',
|
||||||
|
$runtime: '1.5.0'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(service.withCredentials).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set `withCredentials` to false as default value if no app configuration', () => {
|
||||||
|
appConfigService.config = {};
|
||||||
|
applyConfig({
|
||||||
|
$id: 'test',
|
||||||
|
$name: 'test',
|
||||||
|
$version: '1.0.0',
|
||||||
|
$license: 'MIT',
|
||||||
|
$vendor: 'Good company',
|
||||||
|
$runtime: '1.5.0'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(service.withCredentials).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('userActions', () => {
|
||||||
|
it('should load user actions from the config', () => {
|
||||||
|
applyConfig({
|
||||||
|
$id: 'test',
|
||||||
|
$name: 'test',
|
||||||
|
$version: '1.0.0',
|
||||||
|
$license: 'MIT',
|
||||||
|
$vendor: 'Good company',
|
||||||
|
$runtime: '1.5.0',
|
||||||
|
features: {
|
||||||
|
userActions: [
|
||||||
|
{
|
||||||
|
id: 'aca:toolbar/separator-1',
|
||||||
|
order: 1,
|
||||||
|
type: ContentActionType.separator,
|
||||||
|
title: 'action1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'aca:toolbar/separator-2',
|
||||||
|
order: 2,
|
||||||
|
type: ContentActionType.separator,
|
||||||
|
title: 'action2'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(service.userActions.length).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should sort user actions by order', () => {
|
||||||
|
applyConfig({
|
||||||
|
$id: 'test',
|
||||||
|
$name: 'test',
|
||||||
|
$version: '1.0.0',
|
||||||
|
$license: 'MIT',
|
||||||
|
$vendor: 'Good company',
|
||||||
|
$runtime: '1.5.0',
|
||||||
|
features: {
|
||||||
|
userActions: [
|
||||||
|
{
|
||||||
|
id: 'aca:toolbar/separator-2',
|
||||||
|
order: 2,
|
||||||
|
type: ContentActionType.separator,
|
||||||
|
title: 'action2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'aca:toolbar/separator-1',
|
||||||
|
order: 1,
|
||||||
|
type: ContentActionType.separator,
|
||||||
|
title: 'action1'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(service.userActions.length).toBe(2);
|
||||||
|
expect(service.userActions[0].id).toBe('aca:toolbar/separator-1');
|
||||||
|
expect(service.userActions[1].id).toBe('aca:toolbar/separator-2');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,11 @@ import { Store } from '@ngrx/store';
|
|||||||
import { Route } from '@angular/router';
|
import { Route } from '@angular/router';
|
||||||
import { MatIconRegistry } from '@angular/material/icon';
|
import { MatIconRegistry } from '@angular/material/icon';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { AppStore, getRuleContext } from '@alfresco/aca-shared/store';
|
import {
|
||||||
|
AppStore,
|
||||||
|
getRuleContext,
|
||||||
|
getLanguagePickerState
|
||||||
|
} from '@alfresco/aca-shared/store';
|
||||||
import { NodePermissionService } from '@alfresco/aca-shared';
|
import { NodePermissionService } from '@alfresco/aca-shared';
|
||||||
import {
|
import {
|
||||||
SelectionState,
|
SelectionState,
|
||||||
@ -78,6 +82,7 @@ export class AppExtensionService implements RuleContext {
|
|||||||
sidebar: Array<SidebarTabRef> = [];
|
sidebar: Array<SidebarTabRef> = [];
|
||||||
contentMetadata: any;
|
contentMetadata: any;
|
||||||
viewerRules: ViewerRules = {};
|
viewerRules: ViewerRules = {};
|
||||||
|
userActions: Array<ContentActionRef> = [];
|
||||||
|
|
||||||
documentListPresets: {
|
documentListPresets: {
|
||||||
files: Array<DocumentListPresetRef>;
|
files: Array<DocumentListPresetRef>;
|
||||||
@ -103,6 +108,8 @@ export class AppExtensionService implements RuleContext {
|
|||||||
navigation: NavigationState;
|
navigation: NavigationState;
|
||||||
profile: ProfileState;
|
profile: ProfileState;
|
||||||
repository: RepositoryInfo;
|
repository: RepositoryInfo;
|
||||||
|
withCredentials: boolean;
|
||||||
|
languagePicker: boolean;
|
||||||
|
|
||||||
references$: Observable<ExtensionRef[]>;
|
references$: Observable<ExtensionRef[]>;
|
||||||
|
|
||||||
@ -124,6 +131,10 @@ export class AppExtensionService implements RuleContext {
|
|||||||
this.profile = result.profile;
|
this.profile = result.profile;
|
||||||
this.repository = result.repository;
|
this.repository = result.repository;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.store.select(getLanguagePickerState).subscribe(result => {
|
||||||
|
this.languagePicker = result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
@ -170,6 +181,10 @@ export class AppExtensionService implements RuleContext {
|
|||||||
config,
|
config,
|
||||||
'features.sidebar'
|
'features.sidebar'
|
||||||
);
|
);
|
||||||
|
this.userActions = this.loader.getContentActions(
|
||||||
|
config,
|
||||||
|
'features.userActions'
|
||||||
|
);
|
||||||
this.contentMetadata = this.loadContentMetadata(config);
|
this.contentMetadata = this.loadContentMetadata(config);
|
||||||
|
|
||||||
this.documentListPresets = {
|
this.documentListPresets = {
|
||||||
@ -186,6 +201,11 @@ export class AppExtensionService implements RuleContext {
|
|||||||
searchLibraries: this.getDocumentListPreset(config, 'search-libraries')
|
searchLibraries: this.getDocumentListPreset(config, 'search-libraries')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.withCredentials = this.appConfig.get<boolean>(
|
||||||
|
'auth.withCredentials',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
if (config.features && config.features.viewer) {
|
if (config.features && config.features.viewer) {
|
||||||
this.viewerRules = <ViewerRules>(config.features.viewer['rules'] || {});
|
this.viewerRules = <ViewerRules>(config.features.viewer['rules'] || {});
|
||||||
}
|
}
|
||||||
@ -473,6 +493,12 @@ export class AppExtensionService implements RuleContext {
|
|||||||
return this.getAllowedActions(this.contextMenuActions);
|
return this.getAllowedActions(this.contextMenuActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserActions(): Array<ContentActionRef> {
|
||||||
|
return this.userActions
|
||||||
|
.filter(action => this.filterVisible(action))
|
||||||
|
.sort(sortByOrder);
|
||||||
|
}
|
||||||
|
|
||||||
copyAction(action: ContentActionRef): ContentActionRef {
|
copyAction(action: ContentActionRef): ContentActionRef {
|
||||||
return {
|
return {
|
||||||
...action,
|
...action,
|
||||||
|
@ -22,6 +22,26 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"features": {
|
"features": {
|
||||||
|
"userActions": [
|
||||||
|
{
|
||||||
|
"id": "app.languagePicker",
|
||||||
|
"order": 100,
|
||||||
|
"type": "custom",
|
||||||
|
"component": "app.languagePicker",
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.canShowLanguagePicker"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.logout",
|
||||||
|
"order": 200,
|
||||||
|
"type": "custom",
|
||||||
|
"component": "app.logout",
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.canShowLogout"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"header": [
|
"header": [
|
||||||
{
|
{
|
||||||
"id": "app.header.more",
|
"id": "app.header.more",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user