[ACA-3251] Move InfoDrawer and Toolbar components to aca-shared (#1466)

* moved tool bar

* moved info drawer

* moved appextension service

* moved pagination service

* Fix imports

* * fixed lints

* * fixed space

* added travis configuration

* * comments fixed

* * comments fixed

* * lint fixed

Co-authored-by: dhrn <dharan.g@muraai.com>
This commit is contained in:
davidcanonieto
2020-05-12 14:34:26 +01:00
committed by GitHub
parent 6dc01c4b17
commit 6417337f9d
70 changed files with 326 additions and 87 deletions

View File

@@ -0,0 +1,23 @@
<div *ngIf="isLoading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<ng-container *ngIf="!isLoading && !!displayNode">
<adf-info-drawer
[title]="'APP.INFO_DRAWER.TITLE'"
cdkTrapFocus
cdkTrapFocusAutoCapture
>
<adf-info-drawer-tab
*ngFor="let tab of tabs"
[icon]="tab.icon"
[label]="tab.title"
>
<adf-dynamic-tab
[node]="displayNode"
[id]="tab.component"
[attr.data-automation-id]="tab.component"
>
</adf-dynamic-tab>
</adf-info-drawer-tab>
</adf-info-drawer>
</ng-container>

View File

@@ -0,0 +1,169 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { NO_ERRORS_SCHEMA } from '@angular/core';
import { InfoDrawerComponent } from './info-drawer.component';
import { TestBed, ComponentFixture, async } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import {
SetInfoDrawerStateAction,
ToggleInfoDrawerAction
} from '@alfresco/aca-shared/store';
import { LibTestingModule } from '../../testing/lib-testing-module';
import { AppExtensionService } from '../../services/app.extension.service';
import { ContentApiService } from '../../services/content-api.service';
import { of } from 'rxjs';
describe('InfoDrawerComponent', () => {
let fixture: ComponentFixture<InfoDrawerComponent>;
let component: InfoDrawerComponent;
let contentApiService: ContentApiService;
let tab;
let appExtensionService: AppExtensionService;
const storeMock = {
dispatch: jasmine.createSpy('dispatch')
};
const extensionServiceMock = {
getSidebarTabs: () => {}
};
beforeEach(() => {
TestBed.configureTestingModule({
imports: [LibTestingModule],
declarations: [InfoDrawerComponent],
providers: [
ContentApiService,
{ provide: AppExtensionService, useValue: extensionServiceMock },
{ provide: Store, useValue: storeMock }
],
schemas: [NO_ERRORS_SCHEMA]
});
fixture = TestBed.createComponent(InfoDrawerComponent);
component = fixture.componentInstance;
appExtensionService = TestBed.get(AppExtensionService);
contentApiService = TestBed.get(ContentApiService);
tab = { title: 'tab1' };
spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]);
});
afterEach(() => {
fixture.destroy();
});
it('should get tabs configuration on initialization', () => {
fixture.detectChanges();
expect(component.tabs).toEqual([tab]);
});
it('should set state to false OnDestroy event', () => {
fixture.detectChanges();
component.ngOnDestroy();
expect(storeMock.dispatch).toHaveBeenCalledWith(
new SetInfoDrawerStateAction(false)
);
});
it('should set displayNode when node is library', async(() => {
spyOn(contentApiService, 'getNodeInfo');
const nodeMock: any = {
entry: { id: 'nodeId' },
isLibrary: true
};
component.node = nodeMock;
fixture.detectChanges();
component.ngOnChanges();
expect(component.displayNode).toBe(nodeMock);
expect(contentApiService.getNodeInfo).not.toHaveBeenCalled();
}));
it('should call getNodeInfo() when node is a shared file', async(() => {
const response: any = { entry: { id: 'nodeId' } };
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
const nodeMock: any = { entry: { nodeId: 'nodeId' }, isLibrary: false };
component.node = nodeMock;
fixture.detectChanges();
component.ngOnChanges();
expect(component.displayNode).toBe(response);
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
}));
it('should call getNodeInfo() when node is a favorite file', async(() => {
const response: any = { entry: { id: 'nodeId' } };
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
const nodeMock: any = {
entry: { id: 'nodeId', guid: 'guidId' },
isLibrary: false
};
component.node = nodeMock;
fixture.detectChanges();
component.ngOnChanges();
expect(component.displayNode).toBe(response);
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
}));
it('should call getNodeInfo() when node is a recent file', async(() => {
const response: any = { entry: { id: 'nodeId' } };
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
const nodeMock: any = {
entry: {
id: 'nodeId',
content: { mimeType: 'image/jpeg' }
},
isLibrary: false
};
component.node = nodeMock;
fixture.detectChanges();
component.ngOnChanges();
expect(component.displayNode).toBe(response);
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
}));
it('should dispatch close panel on Esc keyboard event', () => {
const event = new KeyboardEvent('keydown', {
code: 'Escape',
key: 'Escape',
keyCode: 27
} as KeyboardEventInit);
fixture.detectChanges();
fixture.debugElement.nativeElement.dispatchEvent(event);
expect(storeMock.dispatch).toHaveBeenCalledWith(
new ToggleInfoDrawerAction()
);
});
});

View File

@@ -0,0 +1,115 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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,
HostListener,
Input,
OnChanges,
OnDestroy,
OnInit
} from '@angular/core';
import {
MinimalNodeEntity,
MinimalNodeEntryEntity,
SiteEntry
} from '@alfresco/js-api';
import { SidebarTabRef } from '@alfresco/adf-extensions';
import { Store } from '@ngrx/store';
import {
SetInfoDrawerStateAction,
ToggleInfoDrawerAction
} from '@alfresco/aca-shared/store';
import { AppExtensionService } from '../../services/app.extension.service';
import { ContentApiService } from '../../services/content-api.service';
@Component({
selector: 'aca-info-drawer',
templateUrl: './info-drawer.component.html'
})
export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
@Input()
nodeId: string;
@Input()
node: MinimalNodeEntity;
isLoading = false;
displayNode: MinimalNodeEntryEntity | SiteEntry;
tabs: Array<SidebarTabRef> = [];
@HostListener('keydown.escape')
onEscapeKeyboardEvent(): void {
this.close();
}
constructor(
private store: Store<any>,
private contentApi: ContentApiService,
private extensions: AppExtensionService
) {}
ngOnInit() {
this.tabs = this.extensions.getSidebarTabs();
}
ngOnDestroy() {
this.store.dispatch(new SetInfoDrawerStateAction(false));
}
ngOnChanges() {
if (this.node) {
if (this.node['isLibrary']) {
return this.setDisplayNode(this.node);
}
const entry: any = this.node.entry;
const id = entry.nodeId || entry.id;
return this.loadNodeInfo(id);
}
}
private close() {
this.store.dispatch(new ToggleInfoDrawerAction());
}
private loadNodeInfo(nodeId: string) {
if (nodeId) {
this.isLoading = true;
this.contentApi.getNodeInfo(nodeId).subscribe(
entity => {
this.setDisplayNode(entity);
this.isLoading = false;
},
() => (this.isLoading = false)
);
}
}
private setDisplayNode(node: any) {
this.displayNode = node;
}
}

View File

@@ -0,0 +1,43 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { InfoDrawerComponent } from './info-drawer.component';
import { InfoDrawerModule } from '@alfresco/adf-core';
import { ExtensionsModule } from '@alfresco/adf-extensions';
import { MatProgressBarModule } from '@angular/material';
@NgModule({
imports: [
CommonModule,
InfoDrawerModule,
MatProgressBarModule,
ExtensionsModule
],
declarations: [InfoDrawerComponent],
exports: [InfoDrawerComponent]
})
export class SharedInfoDrawerModule {}

View File

@@ -0,0 +1,50 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ToolbarMenuItemComponent } from './toolbar-menu-item/toolbar-menu-item.component';
import { ToolbarMenuComponent } from './toolbar-menu/toolbar-menu.component';
import { ToolbarActionComponent } from './toolbar-action/toolbar-action.component';
import { ToolbarButtonComponent } from './toolbar-button/toolbar-button.component';
import { CoreModule } from '@alfresco/adf-core';
import { ExtensionsModule } from '@alfresco/adf-extensions';
@NgModule({
imports: [CommonModule, CoreModule, ExtensionsModule],
declarations: [
ToolbarButtonComponent,
ToolbarActionComponent,
ToolbarMenuItemComponent,
ToolbarMenuComponent
],
exports: [
ToolbarButtonComponent,
ToolbarActionComponent,
ToolbarMenuItemComponent,
ToolbarMenuComponent
]
})
export class SharedToolbarModule {}

View File

@@ -0,0 +1,28 @@
<ng-container [ngSwitch]="actionRef.type">
<ng-container *ngSwitchCase="'default'">
<app-toolbar-button [type]="type" [actionRef]="actionRef" [color]="color">
</app-toolbar-button>
</ng-container>
<ng-container *ngSwitchCase="'button'">
<app-toolbar-button [type]="type" [actionRef]="actionRef" [color]="color">
</app-toolbar-button>
</ng-container>
<adf-toolbar-divider
*ngSwitchCase="'separator'"
[id]="actionRef.id"
></adf-toolbar-divider>
<ng-container *ngSwitchCase="'menu'">
<app-toolbar-menu [actionRef]="actionRef" [color]="color">
</app-toolbar-menu>
</ng-container>
<ng-container *ngSwitchCase="'custom'">
<adf-dynamic-component
[data]="actionRef.data"
[id]="actionRef.component"
></adf-dynamic-component>
</ng-container>
</ng-container>

View File

@@ -0,0 +1,32 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { ToolbarActionComponent } from './toolbar-action.component';
describe('ToolbarActionComponent', () => {
it('should be defined', () => {
expect(ToolbarActionComponent).toBeDefined();
});
});

View File

@@ -0,0 +1,62 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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,
ViewEncapsulation,
ChangeDetectionStrategy,
Input,
DoCheck,
ChangeDetectorRef
} from '@angular/core';
import { ContentActionRef } from '@alfresco/adf-extensions';
@Component({
selector: 'aca-toolbar-action',
templateUrl: './toolbar-action.component.html',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'aca-toolbar-action' }
})
export class ToolbarActionComponent implements DoCheck {
@Input()
type = 'icon-button';
@Input()
color = '';
@Input()
actionRef: ContentActionRef;
constructor(private cd: ChangeDetectorRef) {}
// todo: review after ADF 2.6
// preview component : change detection workaround for children without input
ngDoCheck() {
if (this.actionRef.id.includes('app.viewer')) {
this.cd.markForCheck();
}
}
}

View File

@@ -0,0 +1,17 @@
<ng-container [ngSwitch]="type">
<ng-container *ngSwitchCase="'icon-button'">
<button
[id]="actionRef.id"
mat-icon-button
[color]="color"
[attr.aria-label]="actionRef.description || actionRef.title | translate"
[attr.title]="actionRef.description || actionRef.title | translate"
(click)="runAction()"
>
<adf-icon [value]="actionRef.icon"></adf-icon>
</button>
</ng-container>
<ng-container *ngSwitchCase="'menu-item'">
<app-toolbar-menu-item [actionRef]="actionRef"></app-toolbar-menu-item>
</ng-container>
</ng-container>

View File

@@ -0,0 +1,32 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { ToolbarButtonComponent } from './toolbar-button.component';
describe('ToolbarButtonComponent', () => {
it('should be defined', () => {
expect(ToolbarButtonComponent).toBeDefined();
});
});

View File

@@ -0,0 +1,65 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 '../../../services/app.extension.service';
export enum ToolbarButtonType {
ICON_BUTTON = 'icon-button',
MENU_ITEM = 'menu-item'
}
@Component({
selector: 'app-toolbar-button',
templateUrl: 'toolbar-button.component.html',
encapsulation: ViewEncapsulation.None,
host: { class: 'app-toolbar-button' }
})
export class ToolbarButtonComponent {
@Input()
type: ToolbarButtonType = ToolbarButtonType.ICON_BUTTON;
@Input()
color = '';
@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;
}
}

View File

@@ -0,0 +1,49 @@
<ng-container [ngSwitch]="actionRef.type">
<ng-container *ngSwitchCase="'menu'">
<button
mat-menu-item
role="menuitem"
[disabled]="actionRef.disabled"
[matMenuTriggerFor]="childMenu"
>
<adf-icon [value]="actionRef.icon"></adf-icon>
<span>{{ actionRef.title | translate }}</span>
</button>
<mat-menu #childMenu="matMenu" class="app-create-menu__sub-menu">
<ng-container
*ngFor="let child of actionRef.children; trackBy: trackById"
>
<app-toolbar-menu-item [actionRef]="child"></app-toolbar-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
[id]="actionRef.id"
role="button"
mat-menu-item
[role]="'button'"
color="primary"
[disabled]="actionRef.disabled"
[attr.title]="
(actionRef.disabled
? actionRef['description-disabled']
: actionRef.description || actionRef.title) | translate
"
(click)="runAction()"
>
<adf-icon [value]="actionRef.icon"></adf-icon>
<span>{{ actionRef.title | translate }}</span>
</button>
</ng-container>
</ng-container>

View File

@@ -0,0 +1,32 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { ToolbarMenuItemComponent } from './toolbar-menu-item.component';
describe('ToolbarMenuItemComponent', () => {
it('should be defined', () => {
expect(ToolbarMenuItemComponent).toBeDefined();
});
});

View File

@@ -0,0 +1,65 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 '../../../services/app.extension.service';
@Component({
selector: 'app-toolbar-menu-item',
templateUrl: 'toolbar-menu-item.component.html',
styles: [
`
.app-toolbar-menu-item:last-child > .mat-divider-horizontal {
display: none;
}
`
],
encapsulation: ViewEncapsulation.None,
host: { class: 'app-toolbar-menu-item' }
})
export class ToolbarMenuItemComponent {
@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;
}
}

View File

@@ -0,0 +1,26 @@
<button
[id]="actionRef.id"
[color]="color"
mat-icon-button
[attr.aria-label]="actionRef.description || actionRef.title | translate"
[attr.title]="actionRef.description || actionRef.title | translate"
[matMenuTriggerFor]="menu"
>
<adf-icon [value]="actionRef.icon"></adf-icon>
</button>
<mat-menu #menu="matMenu" [overlapTrigger]="false">
<ng-container *ngFor="let child of actionRef.children; trackBy: trackById">
<ng-container [ngSwitch]="child.type">
<ng-container *ngSwitchCase="'custom'">
<adf-dynamic-component
[id]="child.component"
[data]="child.data"
></adf-dynamic-component>
</ng-container>
<ng-container *ngSwitchDefault>
<app-toolbar-menu-item [actionRef]="child"></app-toolbar-menu-item>
</ng-container>
</ng-container>
</ng-container>
</mat-menu>

View File

@@ -0,0 +1,32 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { ToolbarMenuComponent } from './toolbar-menu.component';
describe('ToolbarMenuComponent', () => {
it('should be defined', () => {
expect(ToolbarMenuComponent).toBeDefined();
});
});

View File

@@ -0,0 +1,53 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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';
@Component({
selector: 'app-toolbar-menu',
templateUrl: 'toolbar-menu.component.html',
encapsulation: ViewEncapsulation.None,
host: { class: 'app-toolbar-menu' }
})
export class ToolbarMenuComponent {
@Input()
actionRef: ContentActionRef;
@Input()
color = '';
get hasChildren(): boolean {
return (
this.actionRef &&
this.actionRef.children &&
this.actionRef.children.length > 0
);
}
trackById(_: number, obj: { id: string }) {
return obj.id;
}
}

View File

@@ -26,6 +26,9 @@
import { NgModule } from '@angular/core';
import { ContextActionsDirective } from './contextmenu.directive';
/**
* @deprecated in 1.11.0, use SharedDirectivesModule instead.
*/
@NgModule({
declarations: [ContextActionsDirective],
exports: [ContextActionsDirective]

View File

@@ -0,0 +1,80 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { PaginationDirective } from './pagination.directive';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import {
UserPreferencesService,
AppConfigService,
PaginationComponent,
CoreModule,
PaginationModel
} from '@alfresco/adf-core';
import { LibTestingModule } from '../testing/lib-testing-module';
import { SharedDirectivesModule } from './shared.directives.module';
describe('PaginationDirective', () => {
let preferences: UserPreferencesService;
let config: AppConfigService;
let pagination: PaginationComponent;
let fixture: ComponentFixture<PaginationComponent>;
let directive: PaginationDirective;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [LibTestingModule, SharedDirectivesModule, CoreModule.forRoot()]
});
preferences = TestBed.get(UserPreferencesService);
config = TestBed.get(AppConfigService);
fixture = TestBed.createComponent(PaginationComponent);
pagination = fixture.componentInstance;
directive = new PaginationDirective(pagination, preferences, config);
});
afterEach(() => {
fixture.destroy();
directive.ngOnDestroy();
});
it('should setup supported page sizes from app config', () => {
spyOn(config, 'get').and.returnValue([21, 31, 41]);
directive.ngOnInit();
expect(pagination.supportedPageSizes).toEqual([21, 31, 41]);
});
it('should update preferences on page size change', () => {
directive.ngOnInit();
pagination.changePageSize.emit(
new PaginationModel({
maxItems: 100
})
);
expect(preferences.paginationSize).toBe(100);
});
});

View File

@@ -0,0 +1,63 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { Directive, OnInit, OnDestroy } from '@angular/core';
import {
PaginationComponent,
UserPreferencesService,
PaginationModel,
AppConfigService
} from '@alfresco/adf-core';
import { Subscription } from 'rxjs';
@Directive({
selector: '[acaPagination]'
})
export class PaginationDirective implements OnInit, OnDestroy {
private subscriptions: Subscription[] = [];
constructor(
private pagination: PaginationComponent,
private preferences: UserPreferencesService,
private config: AppConfigService
) {}
ngOnInit() {
this.pagination.supportedPageSizes = this.config.get(
'pagination.supportedPageSizes'
);
this.subscriptions.push(
this.pagination.changePageSize.subscribe((event: PaginationModel) => {
this.preferences.paginationSize = event.maxItems;
})
);
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => subscription.unsubscribe());
this.subscriptions = [];
}
}

View File

@@ -0,0 +1,35 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { NgModule } from '@angular/core';
import { PaginationDirective } from './pagination.directive';
import { ContextActionsModule } from './contextmenu/contextmenu.module';
@NgModule({
imports: [ContextActionsModule],
declarations: [PaginationDirective],
exports: [PaginationDirective, ContextActionsModule]
})
export class SharedDirectivesModule {}

View File

@@ -0,0 +1,48 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { Route } from '@angular/router';
export interface SettingsGroupRef {
id: string;
name: string;
parameters: Array<SettingsParameterRef>;
rules?: {
visible?: string;
[key: string]: string;
};
}
export interface SettingsParameterRef {
id?: string;
name: string;
key: string;
type: 'string' | 'boolean';
value?: any;
}
export interface ExtensionRoute extends Route {
parentRoute?: string;
}

View File

@@ -0,0 +1,31 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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/>.
*/
export interface ViewerRules {
/**
* Checks if user can preview the node.
*/
canPreview?: string;
}

View File

@@ -0,0 +1,892 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 } from '@angular/core/testing';
import { LibTestingModule } from '../testing/lib-testing-module';
import { AppExtensionService } from './app.extension.service';
import { Store, Action } from '@ngrx/store';
import { AppStore } from '@alfresco/aca-shared/store';
import {
ContentActionType,
mergeArrays,
sortByOrder,
filterEnabled,
reduceSeparators,
reduceEmptyMenus,
ExtensionService,
ExtensionConfig,
ComponentRegisterService,
NavBarGroupRef
} from '@alfresco/adf-extensions';
import { AppConfigService } from '@alfresco/adf-core';
describe('AppExtensionService', () => {
let service: AppExtensionService;
let store: Store<AppStore>;
let extensions: ExtensionService;
let components: ComponentRegisterService;
let appConfigService: AppConfigService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [LibTestingModule]
});
appConfigService = TestBed.get(AppConfigService);
store = TestBed.get(Store);
service = TestBed.get(AppExtensionService);
extensions = TestBed.get(ExtensionService);
components = TestBed.get(ComponentRegisterService);
});
const applyConfig = (config: ExtensionConfig) => {
extensions.setup(config);
service.setup(config);
};
describe('configs', () => {
it('should merge two arrays based on [id] keys', () => {
const left = [
{
name: 'item0'
},
{
id: '#1',
name: 'item1'
},
{
id: '#2',
name: 'item2'
}
];
const right = [
{
name: 'extra-1'
},
{
id: '#2',
name: 'custom2',
tag: 'extra tag'
}
];
const result = mergeArrays(left, right);
expect(result).toEqual([
{
id: '#1',
name: 'item1'
},
{
id: '#2',
name: 'custom2',
tag: 'extra tag'
},
{
name: 'item0'
},
{
name: 'extra-1'
}
]);
});
});
describe('actions', () => {
beforeEach(() => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
actions: [
{
id: 'aca:actions/create-folder',
type: 'CREATE_FOLDER',
payload: 'folder-name'
}
]
});
});
it('should load actions from the config', () => {
expect(extensions.actions.length).toBe(1);
});
it('should find action by id', () => {
const action = extensions.getActionById('aca:actions/create-folder');
expect(action).toBeTruthy();
expect(action.type).toBe('CREATE_FOLDER');
expect(action.payload).toBe('folder-name');
});
it('should not find action by id', () => {
const action = extensions.getActionById('missing');
expect(action).toBeFalsy();
});
it('should run the action via store', () => {
spyOn(store, 'dispatch').and.stub();
service.runActionById('aca:actions/create-folder');
expect(store.dispatch).toHaveBeenCalledWith({
type: 'CREATE_FOLDER',
payload: 'folder-name'
} as Action);
});
it('should still invoke store if action is missing', () => {
spyOn(store, 'dispatch').and.stub();
service.runActionById('missing');
expect(store.dispatch).toHaveBeenCalled();
});
});
describe('expressions', () => {
it('should eval static value', () => {
const value = extensions.runExpression('hello world');
expect(value).toBe('hello world');
});
it('should eval string as an expression', () => {
const value = extensions.runExpression('$( "hello world" )');
expect(value).toBe('hello world');
});
it('should eval expression with no context', () => {
const value = extensions.runExpression('$( 1 + 1 )');
expect(value).toBe(2);
});
it('should eval expression with context', () => {
const context = {
a: 'hey',
b: 'there'
};
const expression = '$( context.a + " " + context.b + "!" )';
const value = extensions.runExpression(expression, context);
expect(value).toBe('hey there!');
});
});
describe('auth guards', () => {
let guard1;
let guard2;
beforeEach(() => {
guard1 = {};
guard2 = {};
extensions.authGuards['guard1'] = guard1;
extensions.authGuards['guard2'] = guard2;
});
it('should fetch auth guards by ids', () => {
const guards = extensions.getAuthGuards(['guard2', 'guard1']);
expect(guards.length).toBe(2);
expect(guards[0]).toEqual(guard1);
expect(guards[1]).toEqual(guard2);
});
it('should not fetch auth guards for missing ids', () => {
const guards = extensions.getAuthGuards(null);
expect(guards).toEqual([]);
});
it('should fetch only known guards', () => {
const guards = extensions.getAuthGuards(['missing', 'guard1']);
expect(guards.length).toBe(1);
expect(guards[0]).toEqual(guard1);
});
});
describe('components', () => {
let component1;
beforeEach(() => {
component1 = {};
components.setComponents({
'component-1': component1
});
});
it('should fetch registered component', () => {
const component = service.getComponentById('component-1');
expect(component).toEqual(component1);
});
it('should not fetch registered component', () => {
const component = service.getComponentById('missing');
expect(component).toBeFalsy();
});
});
describe('routes', () => {
let component1, component2;
let guard1;
beforeEach(() => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
routes: [
{
id: 'aca:routes/about',
path: 'ext/about',
component: 'aca:components/about',
layout: 'aca:layouts/main',
auth: ['aca:auth'],
data: {
title: 'Custom About'
}
}
]
});
component1 = {};
component2 = {};
components.setComponents({
'aca:components/about': component1,
'aca:layouts/main': component2
});
guard1 = {};
extensions.authGuards['aca:auth'] = guard1;
});
it('should load routes from the config', () => {
expect(extensions.routes.length).toBe(1);
});
it('should find a route by id', () => {
const route = extensions.getRouteById('aca:routes/about');
expect(route).toBeTruthy();
expect(route.path).toBe('ext/about');
});
it('should not find a route by id', () => {
const route = extensions.getRouteById('some-route');
expect(route).toBeFalsy();
});
it('should build application routes', () => {
const routes = service.getApplicationRoutes();
expect(routes.length).toBe(1);
const route = routes[0];
expect(route.path).toBe('ext/about');
expect(route.component).toEqual(component2);
expect(route.canActivateChild).toEqual([guard1]);
expect(route.canActivate).toEqual([guard1]);
expect(route.children.length).toBe(1);
expect(route.children[0].path).toBe('');
expect(route.children[0].component).toEqual(component1);
});
});
describe('content actions', () => {
it('should load content actions from the config', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
toolbar: [
{
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.toolbarActions.length).toBe(2);
});
it('should sort content actions by order', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
toolbar: [
{
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.toolbarActions.length).toBe(2);
expect(service.toolbarActions[0].id).toBe('aca:toolbar/separator-1');
expect(service.toolbarActions[1].id).toBe('aca:toolbar/separator-2');
});
});
describe('open with', () => {
it('should load [open with] actions for the viewer', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
viewer: {
openWith: [
{
disabled: false,
id: 'aca:viewer/action1',
order: 100,
icon: 'build',
title: 'Snackbar',
type: ContentActionType.default,
actions: {
click: 'aca:actions/info'
}
}
]
}
}
});
expect(service.openWithActions.length).toBe(1);
});
it('should load only enabled [open with] actions for the viewer', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
viewer: {
openWith: [
{
id: 'aca:viewer/action2',
order: 200,
icon: 'build',
title: 'Snackbar',
type: ContentActionType.default,
actions: {
click: 'aca:actions/info'
}
},
{
disabled: true,
id: 'aca:viewer/action1',
order: 100,
icon: 'build',
title: 'Snackbar',
type: ContentActionType.default,
actions: {
click: 'aca:actions/info'
}
}
]
}
}
});
expect(service.openWithActions.length).toBe(1);
expect(service.openWithActions[0].id).toBe('aca:viewer/action2');
});
it('should sort [open with] actions by order', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
viewer: {
openWith: [
{
id: 'aca:viewer/action2',
order: 200,
icon: 'build',
title: 'Snackbar',
type: ContentActionType.default,
actions: {
click: 'aca:actions/info'
}
},
{
id: 'aca:viewer/action1',
order: 100,
icon: 'build',
title: 'Snackbar',
type: ContentActionType.default,
actions: {
click: 'aca:actions/info'
}
}
]
}
}
});
expect(service.openWithActions.length).toBe(2);
expect(service.openWithActions[0].id).toBe('aca:viewer/action1');
expect(service.openWithActions[1].id).toBe('aca:viewer/action2');
});
});
describe('create', () => {
it('should load [create] actions from config', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
create: [
{
id: 'aca:create/folder',
order: 100,
icon: 'create_new_folder',
title: 'ext: Create Folder',
type: ContentActionType.default
}
]
}
});
expect(service.createActions.length).toBe(1);
});
it('should sort [create] actions by order', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
create: [
{
id: 'aca:create/folder',
order: 100,
icon: 'create_new_folder',
title: 'ext: Create Folder',
type: ContentActionType.default
},
{
id: 'aca:create/folder-2',
order: 10,
icon: 'create_new_folder',
title: 'ext: Create Folder',
type: ContentActionType.default
}
]
}
});
expect(service.createActions.length).toBe(2);
expect(service.createActions[0].id).toBe('aca:create/folder-2');
expect(service.createActions[1].id).toBe('aca:create/folder');
});
});
describe('sorting', () => {
it('should sort by provided order', () => {
const sorted = [
{ id: '1', order: 10 },
{ id: '2', order: 1 },
{ id: '3', order: 5 }
].sort(sortByOrder);
expect(sorted[0].id).toBe('2');
expect(sorted[1].id).toBe('3');
expect(sorted[2].id).toBe('1');
});
it('should use implicit order', () => {
const sorted = [{ id: '3' }, { id: '2' }, { id: '1', order: 1 }].sort(
sortByOrder
);
expect(sorted[0].id).toBe('1');
expect(sorted[1].id).toBe('3');
expect(sorted[2].id).toBe('2');
});
});
describe('filtering', () => {
it('should filter out disabled items', () => {
const items = [
{ id: 1, disabled: true },
{ id: 2 },
{ id: 3, disabled: true }
].filter(filterEnabled);
expect(items.length).toBe(1);
expect(items[0].id).toBe(2);
});
it('should filter out all disabled items', () => {
const items: any[] = [
{ id: '1', disabled: true },
{
id: '2',
someItems: [
{ id: '21', disabled: true },
{ id: '22', disabled: false },
{ id: '23' }
],
someObjectProp: {
innerItems: [{ id: '24' }, { id: '25', disabled: true }]
}
},
{ id: 3, disabled: true }
];
const result = service.filterDisabled(items);
expect(result.length).toBe(1);
expect(result[0].id).toBe('2');
expect(result[0].someItems.length).toBe(2);
expect(result[0].someItems[0].id).toBe('22');
expect(result[0].someItems[1].id).toBe('23');
expect(result[0].someObjectProp).not.toBeNull();
expect(result[0].someObjectProp.innerItems.length).toBe(1);
expect(result[0].someObjectProp.innerItems[0].id).toBe('24');
});
});
it('should reduce duplicate separators', () => {
const actions = [
{ id: '1', type: ContentActionType.button },
{ id: '2', type: ContentActionType.separator },
{ id: '3', type: ContentActionType.separator },
{ id: '4', type: ContentActionType.separator },
{ id: '5', type: ContentActionType.button }
];
const result = actions.reduce(reduceSeparators, []);
expect(result.length).toBe(3);
expect(result[0].id).toBe('1');
expect(result[1].id).toBe('2');
expect(result[2].id).toBe('5');
});
it('should trim trailing separators', () => {
const actions = [
{ id: '1', type: ContentActionType.button },
{ id: '2', type: ContentActionType.separator }
];
const result = actions.reduce(reduceSeparators, []);
expect(result.length).toBe(1);
expect(result[0].id).toBe('1');
});
it('should reduce empty menus', () => {
const actions = [
{ id: '1', type: ContentActionType.button },
{
id: '2',
type: ContentActionType.menu
},
{
id: '3',
type: ContentActionType.menu,
children: [{ id: '3-1', type: ContentActionType.button }]
}
];
const result = actions.reduce(reduceEmptyMenus, []);
expect(result.length).toBe(2);
expect(result[0].id).toBe('1');
expect(result[1].id).toBe('3');
});
describe('getApplicationNavigation', () => {
beforeEach(() => {
extensions.setEvaluators({
notVisible: () => false,
isVisible: () => true
});
});
it('should create navigation data', () => {
const navigation = service.getApplicationNavigation([
{ items: [{ route: 'route1' }, { route: 'route2' }] },
{ items: [{ children: [{ route: 'route3' }] }] }
]);
expect(navigation).toEqual([
{
items: [
{ route: 'route1', url: '/route1' },
{ route: 'route2', url: '/route2' }
]
},
{
items: [{ children: [{ route: 'route3', url: '/route3' }] }]
}
] as NavBarGroupRef[]);
});
it('should filter out disabled items', () => {
const navigation = service.getApplicationNavigation([
{ items: [{ route: 'route1' }, { route: 'route2', disabled: true }] },
{ items: [{ children: [{ route: 'route3', disabled: true }] }] }
]);
expect(navigation).toEqual([
{ items: [{ route: 'route1', url: '/route1' }] },
{ items: [{ children: [] }] }
] as NavBarGroupRef[]);
});
it('should filter out items based on rule', () => {
const navigation = service.getApplicationNavigation([
{
id: 'groupId',
items: [
{
id: 'itemId',
route: 'route1',
rules: { visible: 'notVisible' }
}
]
}
]);
expect(navigation).toEqual([{ id: 'groupId', items: [] }]);
});
it('should filter out group based on rule', () => {
const navigation = service.getApplicationNavigation([
{
id: 'group1',
rules: {
visible: 'notVisible'
},
items: [
{
id: 'item1',
route: 'route1'
}
]
},
{
id: 'group2',
items: []
}
]);
expect(navigation).toEqual([{ id: 'group2', items: [] }]);
});
});
describe('getSharedLinkViewerToolbarActions', () => {
it('should get shared link viewer actions', () => {
const actions = [
{
id: 'id',
type: ContentActionType.button,
icon: 'icon',
actions: {
click: 'click'
}
}
];
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
viewer: {
shared: {
toolbarActions: actions
}
}
}
});
expect(service.getSharedLinkViewerToolbarActions()).toEqual(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');
});
});
});

View File

@@ -0,0 +1,597 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { Injectable, Type } from '@angular/core';
import { Store } from '@ngrx/store';
import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';
import {
AppStore,
getRuleContext,
getLanguagePickerState
} from '@alfresco/aca-shared/store';
import {
SelectionState,
NavigationState,
ExtensionConfig,
RuleEvaluator,
ContentActionRef,
ContentActionType,
ExtensionLoaderService,
SidebarTabRef,
NavBarGroupRef,
sortByOrder,
reduceSeparators,
reduceEmptyMenus,
ExtensionService,
ProfileState,
mergeObjects,
ExtensionRef,
RuleContext,
DocumentListPresetRef,
IconRef
} from '@alfresco/adf-extensions';
import {
AppConfigService,
AuthenticationService,
LogService
} from '@alfresco/adf-core';
import { BehaviorSubject, Observable } from 'rxjs';
import { RepositoryInfo, NodeEntry } from '@alfresco/js-api';
import { ViewerRules } from '../models/viewer.rules';
import { SettingsGroupRef, ExtensionRoute } from '../models/types';
import { NodePermissionService } from '../services/node-permission.service';
@Injectable({
providedIn: 'root'
})
export class AppExtensionService implements RuleContext {
private _references = new BehaviorSubject<ExtensionRef[]>([]);
defaults = {
layout: 'app.layout.main',
auth: ['app.auth']
};
headerActions: Array<ContentActionRef> = [];
toolbarActions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = [];
sharedLinkViewerToolbarActions: Array<ContentActionRef> = [];
contextMenuActions: Array<ContentActionRef> = [];
openWithActions: Array<ContentActionRef> = [];
createActions: Array<ContentActionRef> = [];
navbar: Array<NavBarGroupRef> = [];
sidebar: Array<SidebarTabRef> = [];
contentMetadata: any;
viewerRules: ViewerRules = {};
userActions: Array<ContentActionRef> = [];
settingGroups: Array<SettingsGroupRef> = [];
documentListPresets: {
files: Array<DocumentListPresetRef>;
libraries: Array<DocumentListPresetRef>;
favoriteLibraries: Array<DocumentListPresetRef>;
shared: Array<DocumentListPresetRef>;
recent: Array<DocumentListPresetRef>;
favorites: Array<DocumentListPresetRef>;
trashcan: Array<DocumentListPresetRef>;
searchLibraries: Array<DocumentListPresetRef>;
} = {
files: [],
libraries: [],
favoriteLibraries: [],
shared: [],
recent: [],
favorites: [],
trashcan: [],
searchLibraries: []
};
selection: SelectionState;
navigation: NavigationState;
profile: ProfileState;
repository: RepositoryInfo;
withCredentials: boolean;
languagePicker: boolean;
references$: Observable<ExtensionRef[]>;
constructor(
public auth: AuthenticationService,
protected store: Store<AppStore>,
protected loader: ExtensionLoaderService,
protected extensions: ExtensionService,
public permissions: NodePermissionService,
protected appConfig: AppConfigService,
protected matIconRegistry: MatIconRegistry,
protected sanitizer: DomSanitizer,
protected logger: LogService
) {
this.references$ = this._references.asObservable();
this.store.select(getRuleContext).subscribe(result => {
this.selection = result.selection;
this.navigation = result.navigation;
this.profile = result.profile;
this.repository = result.repository;
});
this.store.select(getLanguagePickerState).subscribe(result => {
this.languagePicker = result;
});
}
async load() {
const config = await this.extensions.load();
this.setup(config);
}
setup(config: ExtensionConfig) {
if (!config) {
this.logger.error('Extension configuration not found');
return;
}
this.settingGroups = this.loader.getElements<SettingsGroupRef>(
config,
'settings'
);
this.headerActions = this.loader.getContentActions(
config,
'features.header'
);
this.toolbarActions = this.loader.getContentActions(
config,
'features.toolbar'
);
this.viewerToolbarActions = this.loader.getContentActions(
config,
'features.viewer.toolbarActions'
);
this.sharedLinkViewerToolbarActions = this.loader.getContentActions(
config,
'features.viewer.shared.toolbarActions'
);
this.contextMenuActions = this.loader.getContentActions(
config,
'features.contextMenu'
);
this.openWithActions = this.loader.getContentActions(
config,
'features.viewer.openWith'
);
this.createActions = this.loader.getElements<ContentActionRef>(
config,
'features.create'
);
this.navbar = this.loadNavBar(config);
this.sidebar = this.loader.getElements<SidebarTabRef>(
config,
'features.sidebar'
);
this.userActions = this.loader.getContentActions(
config,
'features.userActions'
);
this.contentMetadata = this.loadContentMetadata(config);
this.documentListPresets = {
files: this.getDocumentListPreset(config, 'files'),
libraries: this.getDocumentListPreset(config, 'libraries'),
favoriteLibraries: this.getDocumentListPreset(
config,
'favoriteLibraries'
),
shared: this.getDocumentListPreset(config, 'shared'),
recent: this.getDocumentListPreset(config, 'recent'),
favorites: this.getDocumentListPreset(config, 'favorites'),
trashcan: this.getDocumentListPreset(config, 'trashcan'),
searchLibraries: this.getDocumentListPreset(config, 'search-libraries')
};
this.withCredentials = this.appConfig.get<boolean>(
'auth.withCredentials',
false
);
if (config.features && config.features.viewer) {
this.viewerRules = (config.features.viewer['rules'] as ViewerRules) || {};
}
this.registerIcons(config);
const references = (config.$references || [])
.filter(entry => typeof entry === 'object')
.map(entry => entry as ExtensionRef);
this._references.next(references);
}
protected registerIcons(config: ExtensionConfig) {
const icons: Array<IconRef> = this.loader
.getElements<IconRef>(config, 'features.icons')
.filter(entry => !entry.disabled);
for (const icon of icons) {
const [ns, id] = icon.id.split(':');
const value = icon.value;
if (!value) {
console.warn(`Missing icon value for "${icon.id}".`);
} else if (!ns || !id) {
console.warn(`Incorrect icon id format: "${icon.id}".`);
} else {
this.matIconRegistry.addSvgIconInNamespace(
ns,
id,
this.sanitizer.bypassSecurityTrustResourceUrl(value)
);
}
}
}
protected loadNavBar(config: ExtensionConfig): Array<NavBarGroupRef> {
return this.loader.getElements<NavBarGroupRef>(config, 'features.navbar');
}
protected getDocumentListPreset(config: ExtensionConfig, key: string) {
return this.loader
.getElements<DocumentListPresetRef>(
config,
`features.documentList.${key}`
)
.filter(entry => !entry.disabled);
}
getApplicationNavigation(elements): Array<NavBarGroupRef> {
return elements
.filter(group => this.filterVisible(group))
.map(group => {
return {
...group,
items: (group.items || [])
.filter(entry => !entry.disabled)
.filter(item => this.filterVisible(item))
.sort(sortByOrder)
.map(item => {
if (item.children && item.children.length > 0) {
item.children = item.children
.filter(entry => !entry.disabled)
.filter(child => this.filterVisible(child))
.sort(sortByOrder)
.map(child => {
if (child.component) {
return {
...child
};
}
if (!child.click) {
const childRouteRef = this.extensions.getRouteById(
child.route
);
const childUrl = `/${
childRouteRef ? childRouteRef.path : child.route
}`;
return {
...child,
url: childUrl
};
}
return {
...child,
action: child.click
};
});
return {
...item
};
}
if (item.component) {
return { ...item };
}
if (!item.click) {
const routeRef = this.extensions.getRouteById(item.route);
const url = `/${routeRef ? routeRef.path : item.route}`;
return {
...item,
url
};
}
return {
...item,
action: item.click
};
})
.reduce(reduceEmptyMenus, [])
};
});
}
loadContentMetadata(config: ExtensionConfig): any {
const elements = this.loader.getElements<any>(
config,
'features.content-metadata-presets'
);
if (!elements.length) {
return null;
}
let presets = {};
presets = this.filterDisabled(mergeObjects(presets, ...elements));
try {
this.appConfig.config['content-metadata'] = { presets };
} catch (error) {
this.logger.error(
error,
'- could not change content-metadata from app.config -'
);
}
return { presets };
}
filterDisabled(object: Array<{ disabled: boolean }> | { disabled: boolean }) {
if (Array.isArray(object)) {
return object
.filter(item => !item.disabled)
.map(item => this.filterDisabled(item));
} else if (typeof object === 'object') {
if (!object.disabled) {
Object.keys(object).forEach(prop => {
object[prop] = this.filterDisabled(object[prop]);
});
return object;
}
} else {
return object;
}
}
getNavigationGroups(): Array<NavBarGroupRef> {
return this.navbar;
}
getSidebarTabs(): Array<SidebarTabRef> {
return this.sidebar.filter(action => this.filterVisible(action));
}
getComponentById(id: string): Type<{}> {
return this.extensions.getComponentById(id);
}
getApplicationRoutes(): Array<ExtensionRoute> {
return this.extensions.routes.map(route => {
const guards = this.extensions.getAuthGuards(
route.auth && route.auth.length > 0 ? route.auth : this.defaults.auth
);
return {
path: route.path,
component: this.getComponentById(route.layout || this.defaults.layout),
canActivateChild: guards,
canActivate: guards,
parentRoute: route.parentRoute,
children: [
{
path: '',
component: this.getComponentById(route.component),
data: route.data
}
]
};
});
}
getCreateActions(): Array<ContentActionRef> {
return this.createActions
.filter(action => this.filterVisible(action))
.map(action => this.copyAction(action))
.map(action => this.buildMenu(action))
.map(action => {
let disabled = false;
if (action.rules && action.rules.enabled) {
disabled = !this.extensions.evaluateRule(action.rules.enabled, this);
}
return {
...action,
disabled
};
});
}
private buildMenu(actionRef: ContentActionRef): ContentActionRef {
if (
actionRef.type === ContentActionType.menu &&
actionRef.children &&
actionRef.children.length > 0
) {
const children = actionRef.children
.filter(action => this.filterVisible(action))
.map(action => this.buildMenu(action));
actionRef.children = children
.map(action => {
let disabled = false;
if (action.rules && action.rules.enabled) {
disabled = !this.extensions.evaluateRule(
action.rules.enabled,
this
);
}
return {
...action,
disabled
};
})
.sort(sortByOrder)
.reduce(reduceEmptyMenus, [])
.reduce(reduceSeparators, []);
}
return actionRef;
}
private getAllowedActions(actions: ContentActionRef[]): ContentActionRef[] {
return (actions || [])
.filter(action => this.filterVisible(action))
.map(action => {
if (action.type === ContentActionType.menu) {
const copy = this.copyAction(action);
if (copy.children && copy.children.length > 0) {
copy.children = copy.children
.filter(entry => !entry.disabled)
.filter(childAction => this.filterVisible(childAction))
.sort(sortByOrder)
.reduce(reduceSeparators, []);
}
return copy;
}
return action;
})
.reduce(reduceEmptyMenus, [])
.reduce(reduceSeparators, []);
}
getAllowedToolbarActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.toolbarActions);
}
getViewerToolbarActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.viewerToolbarActions);
}
getSharedLinkViewerToolbarActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.sharedLinkViewerToolbarActions);
}
getHeaderActions(): Array<ContentActionRef> {
return this.headerActions.filter(action => this.filterVisible(action));
}
getAllowedContextMenuActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.contextMenuActions);
}
getUserActions(): Array<ContentActionRef> {
return this.userActions
.filter(action => this.filterVisible(action))
.sort(sortByOrder);
}
getSettingsGroups(): Array<SettingsGroupRef> {
return this.settingGroups.filter(group => this.filterVisible(group));
}
copyAction(action: ContentActionRef): ContentActionRef {
return {
...action,
children: (action.children || []).map(child => this.copyAction(child))
};
}
filterVisible(
action: ContentActionRef | SettingsGroupRef | SidebarTabRef
): boolean {
if (action && action.rules && action.rules.visible) {
return this.extensions.evaluateRule(action.rules.visible, this);
}
return true;
}
isViewerExtensionDisabled(extension: any): boolean {
if (extension) {
if (extension.disabled) {
return true;
}
if (extension.rules && extension.rules.disabled) {
return this.extensions.evaluateRule(extension.rules.disabled, this);
}
}
return false;
}
runActionById(id: string) {
const action = this.extensions.getActionById(id);
if (action) {
const { type, payload } = action;
const context = {
selection: this.selection
};
const expression = this.extensions.runExpression(payload, context);
this.store.dispatch({ type, payload: expression });
} else {
this.store.dispatch({ type: id });
}
}
// todo: move to ADF/RuleService
isRuleDefined(ruleId: string): boolean {
return ruleId && this.getEvaluator(ruleId) ? true : false;
}
// todo: move to ADF/RuleService
evaluateRule(ruleId: string, ...args: any[]): boolean {
const evaluator = this.getEvaluator(ruleId);
if (evaluator) {
return evaluator(this, ...args);
}
return false;
}
getEvaluator(key: string): RuleEvaluator {
return this.extensions.getEvaluator(key);
}
canPreviewNode(node: NodeEntry) {
const rules = this.viewerRules;
if (this.isRuleDefined(rules.canPreview)) {
const canPreview = this.evaluateRule(rules.canPreview, node);
if (!canPreview) {
return false;
}
}
return true;
}
}

View File

@@ -23,11 +23,12 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { NgModule, ModuleWithProviders } from '@angular/core';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { ContentApiService } from './services/content-api.service';
import { NodePermissionService } from './services/node-permission.service';
import { AppService } from './services/app.service';
import { ContextActionsModule } from './directives/contextmenu/contextmenu.module';
@NgModule({
imports: [ContextActionsModule],
exports: [ContextActionsModule]

View File

@@ -0,0 +1,98 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { NgModule } from '@angular/core';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import {
AlfrescoApiService,
AlfrescoApiServiceMock,
PipeModule,
TranslateLoaderService,
TranslationMock,
TranslationService
} from '@alfresco/adf-core';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
export const initialState = {
app: {
appName: 'Alfresco Content Application',
headerColor: '#ffffff',
logoPath: 'assets/images/alfresco-logo-white.svg',
headerImagePath: 'assets/images/mastHead-bg-shapesPattern.svg',
languagePicker: false,
sharedUrl: '',
user: {
isAdmin: null,
id: null,
firstName: '',
lastName: ''
},
selection: {
nodes: [],
libraries: [],
isEmpty: true,
count: 0
},
navigation: {
currentFolder: null
},
infoDrawerOpened: false,
infoDrawerMetadataAspect: '',
showFacetFilter: true,
documentDisplayMode: 'list',
repository: {
status: {
isQuickShareEnabled: true
}
} as any
}
};
@NgModule({
imports: [
NoopAnimationsModule,
HttpClientModule,
RouterTestingModule,
StoreModule.forRoot({ app: param => param }, { initialState }),
EffectsModule.forRoot([]),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderService
}
}),
PipeModule
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: TranslationService, useClass: TranslationMock },
AlfrescoApiService
]
})
export class LibTestingModule {}

View File

@@ -31,6 +31,11 @@ export * from './lib/components/page-layout/page-layout.component';
export * from './lib/components/page-layout/page-layout.module';
export * from './lib/components/locked-by/locked-by.component';
export * from './lib/components/locked-by/locked-by.module';
export * from './lib/components/tool-bar/shared-toolbar.module';
export * from './lib/components/info-drawer/shared-info-drawer.module';
export * from './lib/models/types';
export * from './lib/models/viewer.rules';
export * from './lib/routing/app.routes.strategy';
export * from './lib/routing/shared.guard';
@@ -38,12 +43,13 @@ export * from './lib/routing/shared.guard';
export * from './lib/services/app.service';
export * from './lib/services/content-api.service';
export * from './lib/services/node-permission.service';
export * from './lib/services/app.extension.service';
export * from './lib/components/generic-error/generic-error.component';
export * from './lib/components/generic-error/generic-error.module';
export * from './lib/directives/contextmenu/contextmenu.directive';
export * from './lib/directives/contextmenu/contextmenu.module';
export * from './lib/directives/shared.directives.module';
export * from './lib/utils/node.utils';