mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
Revert "[AAE-5874] Re-evaluate extension rules when context changes" (#2301)
* Revert "[AAE-5874] Re-evaluate extension rules when context changes (#2296)"
This reverts commit fb140531f4
.
* [ci:force]
This commit is contained in:
committed by
Denys Vuika
parent
38cdbfa9c1
commit
de355cc300
@@ -22,6 +22,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
@@ -47,15 +48,14 @@ describe('InfoDrawerComponent', () => {
|
|||||||
};
|
};
|
||||||
const extensionServiceMock = {
|
const extensionServiceMock = {
|
||||||
getSidebarTabs: () => {},
|
getSidebarTabs: () => {},
|
||||||
getAllowedSidebarActions: () =>
|
getAllowedSidebarActions: () => [
|
||||||
of([
|
{
|
||||||
{
|
id: 'app.sidebar.close',
|
||||||
id: 'app.sidebar.close',
|
order: 100,
|
||||||
order: 100,
|
title: 'close',
|
||||||
title: 'close',
|
icon: 'highlight_off'
|
||||||
icon: 'highlight_off'
|
}
|
||||||
}
|
]
|
||||||
])
|
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -27,7 +27,7 @@ import { Component, HostListener, Input, OnChanges, OnDestroy, OnInit } from '@a
|
|||||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, SiteEntry } from '@alfresco/js-api';
|
import { MinimalNodeEntity, MinimalNodeEntryEntity, SiteEntry } from '@alfresco/js-api';
|
||||||
import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { SetInfoDrawerStateAction, ToggleInfoDrawerAction, infoDrawerPreview } from '@alfresco/aca-shared/store';
|
import { getAppSelection, SetInfoDrawerStateAction, ToggleInfoDrawerAction, infoDrawerPreview } from '@alfresco/aca-shared/store';
|
||||||
import { AppExtensionService } from '../../services/app.extension.service';
|
import { AppExtensionService } from '../../services/app.extension.service';
|
||||||
import { ContentApiService } from '../../services/content-api.service';
|
import { ContentApiService } from '../../services/content-api.service';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
@@ -60,11 +60,11 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.tabs = this.extensions.getSidebarTabs();
|
this.tabs = this.extensions.getSidebarTabs();
|
||||||
this.extensions
|
this.store
|
||||||
.getAllowedSidebarActions()
|
.select(getAppSelection)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((actions) => {
|
.subscribe(() => {
|
||||||
this.actions = actions;
|
this.actions = this.extensions.getAllowedSidebarActions();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.store
|
this.store
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
[color]="color"
|
[color]="color"
|
||||||
[attr.aria-label]="actionRef.description || actionRef.title | translate"
|
[attr.aria-label]="actionRef.description || actionRef.title | translate"
|
||||||
[attr.title]="actionRef.description || actionRef.title | translate"
|
[attr.title]="actionRef.description || actionRef.title | translate"
|
||||||
[disabled]="actionRef.disabled"
|
|
||||||
(click)="runAction()"
|
(click)="runAction()"
|
||||||
>
|
>
|
||||||
<adf-icon [value]="actionRef.icon"></adf-icon>
|
<adf-icon [value]="actionRef.icon"></adf-icon>
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
[attr.aria-label]="actionRef.description || actionRef.title | translate"
|
[attr.aria-label]="actionRef.description || actionRef.title | translate"
|
||||||
[attr.title]="actionRef.description || actionRef.title | translate"
|
[attr.title]="actionRef.description || actionRef.title | translate"
|
||||||
[matMenuTriggerFor]="menu"
|
[matMenuTriggerFor]="menu"
|
||||||
[disabled]="actionRef.disabled"
|
|
||||||
#matTrigger="matMenuTrigger"
|
#matTrigger="matMenuTrigger"
|
||||||
>
|
>
|
||||||
<adf-icon [value]="actionRef.icon"></adf-icon>
|
<adf-icon [value]="actionRef.icon"></adf-icon>
|
||||||
|
@@ -60,17 +60,9 @@ describe('AppExtensionService', () => {
|
|||||||
extensions = TestBed.inject(ExtensionService);
|
extensions = TestBed.inject(ExtensionService);
|
||||||
});
|
});
|
||||||
|
|
||||||
const applyConfig = (config: ExtensionConfig, selection?: boolean) => {
|
const applyConfig = (config: ExtensionConfig) => {
|
||||||
extensions.setup(config);
|
extensions.setup(config);
|
||||||
service.setup(config);
|
service.setup(config);
|
||||||
if (selection) {
|
|
||||||
service.selection = {
|
|
||||||
isEmpty: false,
|
|
||||||
count: 1,
|
|
||||||
libraries: null,
|
|
||||||
nodes: null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('configs', () => {
|
describe('configs', () => {
|
||||||
@@ -292,7 +284,7 @@ describe('AppExtensionService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('content actions', () => {
|
describe('content actions', () => {
|
||||||
it('should load content actions from the config', (done) => {
|
it('should load content actions from the config', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -305,26 +297,23 @@ describe('AppExtensionService', () => {
|
|||||||
{
|
{
|
||||||
id: 'aca:toolbar/separator-1',
|
id: 'aca:toolbar/separator-1',
|
||||||
order: 1,
|
order: 1,
|
||||||
type: ContentActionType.default,
|
type: ContentActionType.separator,
|
||||||
title: 'action1'
|
title: 'action1'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'aca:toolbar/separator-2',
|
id: 'aca:toolbar/separator-2',
|
||||||
order: 2,
|
order: 2,
|
||||||
type: ContentActionType.default,
|
type: ContentActionType.separator,
|
||||||
title: 'action2'
|
title: 'action2'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getAllowedToolbarActions().subscribe((actions) => {
|
expect(service.toolbarActions.length).toBe(2);
|
||||||
expect(actions.length).toBe(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sort content actions by order', (done) => {
|
it('should sort content actions by order', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -337,30 +326,27 @@ describe('AppExtensionService', () => {
|
|||||||
{
|
{
|
||||||
id: 'aca:toolbar/separator-2',
|
id: 'aca:toolbar/separator-2',
|
||||||
order: 2,
|
order: 2,
|
||||||
type: ContentActionType.default,
|
type: ContentActionType.separator,
|
||||||
title: 'action2'
|
title: 'action2'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'aca:toolbar/separator-1',
|
id: 'aca:toolbar/separator-1',
|
||||||
order: 1,
|
order: 1,
|
||||||
type: ContentActionType.default,
|
type: ContentActionType.separator,
|
||||||
title: 'action1'
|
title: 'action1'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getAllowedToolbarActions().subscribe((actions) => {
|
expect(service.toolbarActions.length).toBe(2);
|
||||||
expect(actions.length).toBe(2);
|
expect(service.toolbarActions[0].id).toBe('aca:toolbar/separator-1');
|
||||||
expect(actions[0].id).toBe('aca:toolbar/separator-1');
|
expect(service.toolbarActions[1].id).toBe('aca:toolbar/separator-2');
|
||||||
expect(actions[1].id).toBe('aca:toolbar/separator-2');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('open with', () => {
|
describe('open with', () => {
|
||||||
it('should load [open with] actions for the viewer', (done) => {
|
it('should load [open with] actions for the viewer', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -387,13 +373,10 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getOpenWithActions().subscribe((actions) => {
|
expect(service.openWithActions.length).toBe(1);
|
||||||
expect(actions.length).toBe(1);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load only enabled [open with] actions for the viewer', (done) => {
|
it('should load only enabled [open with] actions for the viewer', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -430,14 +413,11 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getOpenWithActions().subscribe((actions) => {
|
expect(service.openWithActions.length).toBe(1);
|
||||||
expect(actions.length).toBe(1);
|
expect(service.openWithActions[0].id).toBe('aca:viewer/action2');
|
||||||
expect(actions[0].id).toBe('aca:viewer/action2');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sort [open with] actions by order', (done) => {
|
it('should sort [open with] actions by order', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -473,17 +453,14 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getOpenWithActions().subscribe((actions) => {
|
expect(service.openWithActions.length).toBe(2);
|
||||||
expect(actions.length).toBe(2);
|
expect(service.openWithActions[0].id).toBe('aca:viewer/action1');
|
||||||
expect(actions[0].id).toBe('aca:viewer/action1');
|
expect(service.openWithActions[1].id).toBe('aca:viewer/action2');
|
||||||
expect(actions[1].id).toBe('aca:viewer/action2');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('should load [create] actions from config', (done) => {
|
it('should load [create] actions from config', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -504,13 +481,10 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getCreateActions().subscribe((actions) => {
|
expect(service.createActions.length).toBe(1);
|
||||||
expect(actions.length).toBe(1);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sort [create] actions by order', (done) => {
|
it('should sort [create] actions by order', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -538,12 +512,9 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getCreateActions().subscribe((actions) => {
|
expect(service.createActions.length).toBe(2);
|
||||||
expect(actions.length).toBe(2);
|
expect(service.createActions[0].id).toBe('aca:create/folder-2');
|
||||||
expect(actions[0].id).toBe('aca:create/folder-2');
|
expect(service.createActions[1].id).toBe('aca:create/folder');
|
||||||
expect(actions[1].id).toBe('aca:create/folder');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -729,7 +700,7 @@ describe('AppExtensionService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getSharedLinkViewerToolbarActions', () => {
|
describe('getSharedLinkViewerToolbarActions', () => {
|
||||||
it('should get shared link viewer actions', (done) => {
|
it('should get shared link viewer actions', () => {
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
id: 'id',
|
id: 'id',
|
||||||
@@ -753,29 +724,23 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
applyConfig(
|
applyConfig({
|
||||||
{
|
$id: 'test',
|
||||||
$id: 'test',
|
$name: 'test',
|
||||||
$name: 'test',
|
$version: '1.0.0',
|
||||||
$version: '1.0.0',
|
$license: 'MIT',
|
||||||
$license: 'MIT',
|
$vendor: 'Good company',
|
||||||
$vendor: 'Good company',
|
$runtime: '1.5.0',
|
||||||
$runtime: '1.5.0',
|
features: {
|
||||||
features: {
|
viewer: {
|
||||||
viewer: {
|
shared: {
|
||||||
shared: {
|
toolbarActions: actions
|
||||||
toolbarActions: actions
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
service.getSharedLinkViewerToolbarActions().subscribe((sharedLinkViewerToolbarActions) => {
|
|
||||||
expect(sharedLinkViewerToolbarActions).toEqual(expectedActions);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(service.getSharedLinkViewerToolbarActions()).toEqual(expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -828,7 +793,7 @@ describe('AppExtensionService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getHeaderActions', () => {
|
describe('getHeaderActions', () => {
|
||||||
it('should load user actions from the config', (done) => {
|
it('should load user actions from the config', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -841,24 +806,21 @@ describe('AppExtensionService', () => {
|
|||||||
{
|
{
|
||||||
id: 'header.action.separator.1',
|
id: 'header.action.separator.1',
|
||||||
order: 1,
|
order: 1,
|
||||||
type: ContentActionType.default
|
type: ContentActionType.separator
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'header.action.separator.2',
|
id: 'header.action.separator.2',
|
||||||
order: 2,
|
order: 2,
|
||||||
type: ContentActionType.default
|
type: ContentActionType.separator
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getHeaderActions().subscribe((headerActions) => {
|
expect(service.headerActions.length).toBe(2);
|
||||||
expect(headerActions.length).toBe(2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sort header actions by order', (done) => {
|
it('should sort header actions by order', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -882,15 +844,12 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getHeaderActions().subscribe((headerActions) => {
|
const actions = service.getHeaderActions();
|
||||||
expect(headerActions.length).toBe(2);
|
expect(actions[0].id).toBe('header.action.2');
|
||||||
expect(headerActions[0].id).toBe('header.action.2');
|
expect(actions[1].id).toBe('header.action.1');
|
||||||
expect(headerActions[1].id).toBe('header.action.1');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sort header menu children actions by order', (done) => {
|
it('should sort header menu children actions by order', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -921,12 +880,9 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getHeaderActions().subscribe((headerActions) => {
|
const actions = service.getHeaderActions()[0];
|
||||||
expect(headerActions.length).toBe(1);
|
expect(actions.children[0].id).toBe('header.action.2');
|
||||||
expect(headerActions[0].children[0].id).toBe('header.action.2');
|
expect(actions.children[1].id).toBe('header.action.1');
|
||||||
expect(headerActions[0].children[1].id).toBe('header.action.1');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1094,7 +1050,7 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
it('should set the action disabled for create actions', (done) => {
|
it('should set the action disabled for create actions', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -1107,13 +1063,10 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getCreateActions().subscribe((createActions) => {
|
expect(service.getCreateActions()).toEqual(expectedActionsWithChildren);
|
||||||
expect(createActions).toEqual(expectedActionsWithChildren);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the action disabled for sidebar actions', (done) => {
|
it('should set the action disabled for sidebar actions', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -1128,13 +1081,10 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getAllowedSidebarActions().subscribe((serviceActions) => {
|
expect(service.getAllowedSidebarActions()).toEqual(expectedActionsWithoutChildren);
|
||||||
expect(serviceActions).toEqual(expectedActionsWithoutChildren);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the action disabled for toolbar actions', (done) => {
|
it('should set the action disabled for toolbar actions', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -1147,13 +1097,10 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getAllowedToolbarActions().subscribe((serviceActions) => {
|
expect(service.getAllowedToolbarActions()).toEqual(expectedActionsWithoutChildren);
|
||||||
expect(serviceActions).toEqual(expectedActionsWithoutChildren);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the action disabled for viewer toolbar actions', (done) => {
|
it('should set the action disabled for viewer toolbar actions', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -1166,39 +1113,30 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getViewerToolbarActions().subscribe((serviceActions) => {
|
expect(service.getViewerToolbarActions()).toEqual(expectedActionsWithoutChildren);
|
||||||
expect(serviceActions).toEqual(expectedActionsWithoutChildren);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the action disabled for shared link viewer toolbar actions', (done) => {
|
it('should set the action disabled for shared link viewer toolbar actions', () => {
|
||||||
applyConfig(
|
applyConfig({
|
||||||
{
|
$id: 'test',
|
||||||
$id: 'test',
|
$name: 'test',
|
||||||
$name: 'test',
|
$version: '1.0.0',
|
||||||
$version: '1.0.0',
|
$license: 'MIT',
|
||||||
$license: 'MIT',
|
$vendor: 'Good company',
|
||||||
$vendor: 'Good company',
|
$runtime: '1.5.0',
|
||||||
$runtime: '1.5.0',
|
features: {
|
||||||
features: {
|
viewer: {
|
||||||
viewer: {
|
shared: {
|
||||||
shared: {
|
toolbarActions: actions
|
||||||
toolbarActions: actions
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
service.getSharedLinkViewerToolbarActions().subscribe((serviceActions) => {
|
|
||||||
expect(serviceActions).toEqual(expectedActionsWithoutChildren);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(service.getSharedLinkViewerToolbarActions()).toEqual(expectedActionsWithoutChildren);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the action disabled for header actions', (done) => {
|
it('should set the action disabled for header actions', () => {
|
||||||
applyConfig({
|
applyConfig({
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
$name: 'test',
|
$name: 'test',
|
||||||
@@ -1211,32 +1149,23 @@ describe('AppExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
service.getHeaderActions().subscribe((serviceActions) => {
|
expect(service.getHeaderActions()).toEqual(expectedActionsWithoutChildren);
|
||||||
expect(serviceActions).toEqual(expectedActionsWithoutChildren);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the action disabled for context menu actions', (done) => {
|
it('should set the action disabled for context menu actions', () => {
|
||||||
applyConfig(
|
applyConfig({
|
||||||
{
|
$id: 'test',
|
||||||
$id: 'test',
|
$name: 'test',
|
||||||
$name: 'test',
|
$version: '1.0.0',
|
||||||
$version: '1.0.0',
|
$license: 'MIT',
|
||||||
$license: 'MIT',
|
$vendor: 'Good company',
|
||||||
$vendor: 'Good company',
|
$runtime: '1.5.0',
|
||||||
$runtime: '1.5.0',
|
features: {
|
||||||
features: {
|
contextMenu: actions
|
||||||
contextMenu: actions
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
service.getAllowedContextMenuActions().subscribe((serviceActions) => {
|
|
||||||
expect(serviceActions).toEqual(expectedActionsWithoutChildren);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(service.getAllowedContextMenuActions()).toEqual(expectedActionsWithoutChildren);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -56,7 +56,6 @@ import { RepositoryInfo, NodeEntry } from '@alfresco/js-api';
|
|||||||
import { ViewerRules } from '../models/viewer.rules';
|
import { ViewerRules } from '../models/viewer.rules';
|
||||||
import { SettingsGroupRef } from '../models/types';
|
import { SettingsGroupRef } from '../models/types';
|
||||||
import { NodePermissionService } from '../services/node-permission.service';
|
import { NodePermissionService } from '../services/node-permission.service';
|
||||||
import { map } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -64,22 +63,21 @@ import { map } from 'rxjs/operators';
|
|||||||
export class AppExtensionService implements RuleContext {
|
export class AppExtensionService implements RuleContext {
|
||||||
private _references = new BehaviorSubject<ExtensionRef[]>([]);
|
private _references = new BehaviorSubject<ExtensionRef[]>([]);
|
||||||
|
|
||||||
|
headerActions: Array<ContentActionRef> = [];
|
||||||
|
toolbarActions: Array<ContentActionRef> = [];
|
||||||
|
viewerToolbarActions: Array<ContentActionRef> = [];
|
||||||
|
sharedLinkViewerToolbarActions: Array<ContentActionRef> = [];
|
||||||
|
contextMenuActions: Array<ContentActionRef> = [];
|
||||||
|
openWithActions: Array<ContentActionRef> = [];
|
||||||
|
createActions: Array<ContentActionRef> = [];
|
||||||
navbar: Array<NavBarGroupRef> = [];
|
navbar: Array<NavBarGroupRef> = [];
|
||||||
sidebarTabs: Array<SidebarTabRef> = [];
|
sidebarTabs: Array<SidebarTabRef> = [];
|
||||||
|
sidebarActions: Array<ContentActionRef> = [];
|
||||||
contentMetadata: any;
|
contentMetadata: any;
|
||||||
search: any;
|
search: any;
|
||||||
viewerRules: ViewerRules = {};
|
viewerRules: ViewerRules = {};
|
||||||
settingGroups: Array<SettingsGroupRef> = [];
|
settingGroups: Array<SettingsGroupRef> = [];
|
||||||
|
|
||||||
private _headerActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _toolbarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _viewerToolbarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _sharedLinkViewerToolbarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _contextMenuActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _openWithActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _createActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
private _sidebarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
|
||||||
|
|
||||||
documentListPresets: {
|
documentListPresets: {
|
||||||
files: Array<DocumentListPresetRef>;
|
files: Array<DocumentListPresetRef>;
|
||||||
libraries: Array<DocumentListPresetRef>;
|
libraries: Array<DocumentListPresetRef>;
|
||||||
@@ -108,8 +106,6 @@ export class AppExtensionService implements RuleContext {
|
|||||||
|
|
||||||
references$: Observable<ExtensionRef[]>;
|
references$: Observable<ExtensionRef[]>;
|
||||||
|
|
||||||
config: ExtensionConfig;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public auth: AuthenticationService,
|
public auth: AuthenticationService,
|
||||||
protected store: Store<AppStore>,
|
protected store: Store<AppStore>,
|
||||||
@@ -128,16 +124,12 @@ export class AppExtensionService implements RuleContext {
|
|||||||
this.navigation = result.navigation;
|
this.navigation = result.navigation;
|
||||||
this.profile = result.profile;
|
this.profile = result.profile;
|
||||||
this.repository = result.repository;
|
this.repository = result.repository;
|
||||||
|
|
||||||
if (this.config) {
|
|
||||||
this.setup(this.config);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
this.config = await this.extensions.load();
|
const config = await this.extensions.load();
|
||||||
this.setup(this.config);
|
this.setup(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(config: ExtensionConfig) {
|
setup(config: ExtensionConfig) {
|
||||||
@@ -148,15 +140,15 @@ export class AppExtensionService implements RuleContext {
|
|||||||
|
|
||||||
this.settingGroups = this.loader.getElements<SettingsGroupRef>(config, 'settings');
|
this.settingGroups = this.loader.getElements<SettingsGroupRef>(config, 'settings');
|
||||||
|
|
||||||
this._headerActions.next(this.loader.getContentActions(config, 'features.header'));
|
this.headerActions = this.loader.getContentActions(config, 'features.header');
|
||||||
this._sidebarActions.next(this.loader.getContentActions(config, 'features.sidebar.toolbar'));
|
this.sidebarActions = this.loader.getContentActions(config, 'features.sidebar.toolbar');
|
||||||
this._toolbarActions.next(this.loader.getContentActions(config, 'features.toolbar'));
|
this.toolbarActions = this.loader.getContentActions(config, 'features.toolbar');
|
||||||
this._viewerToolbarActions.next(this.loader.getContentActions(config, 'features.viewer.toolbarActions'));
|
this.viewerToolbarActions = this.loader.getContentActions(config, 'features.viewer.toolbarActions');
|
||||||
this._sharedLinkViewerToolbarActions.next(this.loader.getContentActions(config, 'features.viewer.shared.toolbarActions'));
|
this.sharedLinkViewerToolbarActions = this.loader.getContentActions(config, 'features.viewer.shared.toolbarActions');
|
||||||
this._contextMenuActions.next(this.loader.getContentActions(config, 'features.contextMenu'));
|
|
||||||
this._openWithActions.next(this.loader.getContentActions(config, 'features.viewer.openWith'));
|
|
||||||
this._createActions.next(this.loader.getElements<ContentActionRef>(config, 'features.create'));
|
|
||||||
|
|
||||||
|
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.navbar = this.loadNavBar(config);
|
||||||
this.sidebarTabs = this.loader.getElements<SidebarTabRef>(config, 'features.sidebar.tabs');
|
this.sidebarTabs = this.loader.getElements<SidebarTabRef>(config, 'features.sidebar.tabs');
|
||||||
this.contentMetadata = this.loadContentMetadata(config);
|
this.contentMetadata = this.loadContentMetadata(config);
|
||||||
@@ -352,16 +344,12 @@ export class AppExtensionService implements RuleContext {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getCreateActions(): Observable<Array<ContentActionRef>> {
|
getCreateActions(): Array<ContentActionRef> {
|
||||||
return this._createActions.pipe(
|
return this.createActions
|
||||||
map((createActions) =>
|
.filter((action) => this.filterVisible(action))
|
||||||
createActions
|
.map((action) => this.copyAction(action))
|
||||||
.filter((action) => this.filterVisible(action))
|
.map((action) => this.buildMenu(action))
|
||||||
.map((action) => this.copyAction(action))
|
.map((action) => this.setActionDisabledFromRule(action));
|
||||||
.map((action) => this.buildMenu(action))
|
|
||||||
.map((action) => this.setActionDisabledFromRule(action))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildMenu(actionRef: ContentActionRef): ContentActionRef {
|
private buildMenu(actionRef: ContentActionRef): ContentActionRef {
|
||||||
@@ -400,58 +388,48 @@ export class AppExtensionService implements RuleContext {
|
|||||||
.reduce(reduceSeparators, []);
|
.reduce(reduceSeparators, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllowedSidebarActions(): Observable<Array<ContentActionRef>> {
|
getAllowedSidebarActions(): Array<ContentActionRef> {
|
||||||
return this._sidebarActions.pipe(map((sidebarActions) => this.getAllowedActions(sidebarActions)));
|
return this.getAllowedActions(this.sidebarActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllowedToolbarActions(): Observable<Array<ContentActionRef>> {
|
getAllowedToolbarActions(): Array<ContentActionRef> {
|
||||||
return this._toolbarActions.pipe(map((toolbarActions) => this.getAllowedActions(toolbarActions)));
|
return this.getAllowedActions(this.toolbarActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
getViewerToolbarActions(): Observable<Array<ContentActionRef>> {
|
getViewerToolbarActions(): Array<ContentActionRef> {
|
||||||
return this._viewerToolbarActions.pipe(map((viewerToolbarActions) => this.getAllowedActions(viewerToolbarActions)));
|
return this.getAllowedActions(this.viewerToolbarActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpenWithActions(): Observable<Array<ContentActionRef>> {
|
getSharedLinkViewerToolbarActions(): Array<ContentActionRef> {
|
||||||
return this._openWithActions.pipe(map((openWithActions) => this.getAllowedActions(openWithActions)));
|
return this.getAllowedActions(this.sharedLinkViewerToolbarActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSharedLinkViewerToolbarActions(): Observable<Array<ContentActionRef>> {
|
getHeaderActions(): Array<ContentActionRef> {
|
||||||
return this._sharedLinkViewerToolbarActions.pipe(
|
return this.headerActions
|
||||||
map((sharedLinkViewerToolbarActions) => (!this.selection.isEmpty ? this.getAllowedActions(sharedLinkViewerToolbarActions) : []))
|
.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((childAction) => this.filterVisible(childAction))
|
||||||
|
.sort(sortByOrder)
|
||||||
|
.reduce(reduceEmptyMenus, [])
|
||||||
|
.reduce(reduceSeparators, []);
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
return action;
|
||||||
|
})
|
||||||
|
.map((action) => this.setActionDisabledFromRule(action))
|
||||||
|
.sort(sortByOrder)
|
||||||
|
.reduce(reduceEmptyMenus, [])
|
||||||
|
.reduce(reduceSeparators, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
getHeaderActions(): Observable<Array<ContentActionRef>> {
|
getAllowedContextMenuActions(): Array<ContentActionRef> {
|
||||||
return this._headerActions.pipe(
|
return this.getAllowedActions(this.contextMenuActions);
|
||||||
map((headerActions) =>
|
|
||||||
headerActions
|
|
||||||
.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((childAction) => this.filterVisible(childAction))
|
|
||||||
.sort(sortByOrder)
|
|
||||||
.reduce(reduceEmptyMenus, [])
|
|
||||||
.reduce(reduceSeparators, []);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
return action;
|
|
||||||
})
|
|
||||||
.map((action) => this.setActionDisabledFromRule(action))
|
|
||||||
.sort(sortByOrder)
|
|
||||||
.reduce(reduceEmptyMenus, [])
|
|
||||||
.reduce(reduceSeparators, [])
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAllowedContextMenuActions(): Observable<Array<ContentActionRef>> {
|
|
||||||
return this._contextMenuActions.pipe(map((contextMenuActions) => (!this.selection.isEmpty ? this.getAllowedActions(contextMenuActions) : [])));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsGroups(): Array<SettingsGroupRef> {
|
getSettingsGroups(): Array<SettingsGroupRef> {
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { ContextMenuComponent } from './context-menu.component';
|
import { ContextMenuComponent } from './context-menu.component';
|
||||||
import { ContextMenuModule } from './context-menu.module';
|
import { ContextMenuModule } from './context-menu.module';
|
||||||
@@ -75,7 +75,7 @@ describe('ContextMenuComponent', () => {
|
|||||||
contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef);
|
contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef);
|
||||||
extensionsService = TestBed.inject(AppExtensionService);
|
extensionsService = TestBed.inject(AppExtensionService);
|
||||||
|
|
||||||
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
|
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([contextItem]);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@@ -85,16 +85,15 @@ describe('ContextMenuComponent', () => {
|
|||||||
expect(contextMenuOverlayRef.close).toHaveBeenCalled();
|
expect(contextMenuOverlayRef.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render defined context menu actions items', async () => {
|
it('should render defined context menu actions items', fakeAsync(() => {
|
||||||
component.ngAfterViewInit();
|
component.ngAfterViewInit();
|
||||||
fixture.detectChanges();
|
tick(500);
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const contextMenuElements = document.body.querySelector('.aca-context-menu').querySelectorAll('button');
|
const contextMenuElements = document.body.querySelector('.aca-context-menu').querySelectorAll('button');
|
||||||
|
|
||||||
expect(contextMenuElements.length).toBe(1);
|
expect(contextMenuElements.length).toBe(1);
|
||||||
expect(contextMenuElements[0].querySelector('span').innerText).toBe(contextItem.title);
|
expect(contextMenuElements[0].querySelector('span').innerText).toBe(contextItem.title);
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should run action with provided action id', () => {
|
it('should run action with provided action id', () => {
|
||||||
spyOn(extensionsService, 'runActionById');
|
spyOn(extensionsService, 'runActionById');
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
import { Component, ViewEncapsulation, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit, Inject } from '@angular/core';
|
import { Component, ViewEncapsulation, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit, Inject } from '@angular/core';
|
||||||
import { MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
|
import { AppStore, getAppSelection } from '@alfresco/aca-shared/store';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
@@ -60,6 +62,7 @@ export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private contextMenuOverlayRef: ContextMenuOverlayRef,
|
private contextMenuOverlayRef: ContextMenuOverlayRef,
|
||||||
private extensions: AppExtensionService,
|
private extensions: AppExtensionService,
|
||||||
|
private store: Store<AppStore>,
|
||||||
@Inject(CONTEXT_MENU_DIRECTION) public direction: Direction
|
@Inject(CONTEXT_MENU_DIRECTION) public direction: Direction
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -79,10 +82,14 @@ export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.extensions
|
this.store
|
||||||
.getAllowedContextMenuActions()
|
.select(getAppSelection)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((actions) => (this.actions = actions));
|
.subscribe((selection) => {
|
||||||
|
if (selection.count) {
|
||||||
|
this.actions = this.extensions.getAllowedContextMenuActions();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
@@ -34,7 +34,6 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { of } from 'rxjs';
|
|
||||||
|
|
||||||
describe('CreateMenuComponent', () => {
|
describe('CreateMenuComponent', () => {
|
||||||
let fixture: ComponentFixture<CreateMenuComponent>;
|
let fixture: ComponentFixture<CreateMenuComponent>;
|
||||||
@@ -48,15 +47,13 @@ describe('CreateMenuComponent', () => {
|
|||||||
|
|
||||||
extensionService = TestBed.inject(AppExtensionService);
|
extensionService = TestBed.inject(AppExtensionService);
|
||||||
getCreateActionsSpy = spyOn(extensionService, 'getCreateActions');
|
getCreateActionsSpy = spyOn(extensionService, 'getCreateActions');
|
||||||
getCreateActionsSpy.and.returnValue(
|
getCreateActionsSpy.and.returnValue([
|
||||||
of([
|
{
|
||||||
{
|
id: 'action1',
|
||||||
id: 'action1',
|
type: ContentActionType.button,
|
||||||
type: ContentActionType.button,
|
title: 'action one'
|
||||||
title: 'action one'
|
}
|
||||||
}
|
]);
|
||||||
])
|
|
||||||
);
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(CreateMenuComponent);
|
fixture = TestBed.createComponent(CreateMenuComponent);
|
||||||
});
|
});
|
||||||
@@ -105,22 +102,20 @@ describe('CreateMenuComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render sub-menus', async () => {
|
it('should render sub-menus', async () => {
|
||||||
getCreateActionsSpy.and.returnValue(
|
getCreateActionsSpy.and.returnValue([
|
||||||
of([
|
{
|
||||||
{
|
id: 'level1',
|
||||||
id: 'level1',
|
type: ContentActionType.menu,
|
||||||
type: ContentActionType.menu,
|
title: 'level one',
|
||||||
title: 'level one',
|
children: [
|
||||||
children: [
|
{
|
||||||
{
|
id: 'level2',
|
||||||
id: 'level2',
|
type: ContentActionType.button,
|
||||||
type: ContentActionType.button,
|
title: 'level two'
|
||||||
title: 'level two'
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
]);
|
||||||
])
|
|
||||||
);
|
|
||||||
|
|
||||||
await clickMenu();
|
await clickMenu();
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
import { Component, Input, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
|
import { AppStore, getRuleContext } from '@alfresco/aca-shared/store';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||||
@@ -46,14 +48,14 @@ export class CreateMenuComponent implements OnInit, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
expanded: boolean;
|
expanded: boolean;
|
||||||
|
|
||||||
constructor(private extensions: AppExtensionService) {}
|
constructor(private store: Store<AppStore>, private extensions: AppExtensionService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.extensions
|
this.store
|
||||||
.getCreateActions()
|
.select(getRuleContext)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((createActions) => {
|
.subscribe(() => {
|
||||||
this.createActions = createActions;
|
this.createActions = this.extensions.getCreateActions();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,17 +26,11 @@
|
|||||||
import { AppHeaderComponent } from './header.component';
|
import { AppHeaderComponent } from './header.component';
|
||||||
import { AppState } from '@alfresco/aca-shared/store';
|
import { AppState } from '@alfresco/aca-shared/store';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { fakeAsync } from '@angular/core/testing';
|
||||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
|
||||||
import { AppExtensionService } from '../../../../projects/aca-shared/src/lib/services/app.extension.service';
|
|
||||||
import { CoreModule } from '@alfresco/adf-core';
|
|
||||||
import { AppSearchInputModule } from '../search/search-input.module';
|
|
||||||
|
|
||||||
describe('AppHeaderComponent', () => {
|
describe('AppHeaderComponent', () => {
|
||||||
let component: AppHeaderComponent;
|
let component: AppHeaderComponent;
|
||||||
let fixture: ComponentFixture<AppHeaderComponent>;
|
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{ id: 'action-1', type: 'button' },
|
{ id: 'action-1', type: 'button' },
|
||||||
@@ -44,12 +38,11 @@ describe('AppHeaderComponent', () => {
|
|||||||
] as Array<ContentActionRef>;
|
] as Array<ContentActionRef>;
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
select: jasmine.createSpy('select'),
|
select: jasmine.createSpy('select')
|
||||||
dispatch: () => {}
|
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
const appExtensionService = {
|
const appExtensionService = {
|
||||||
getHeaderActions: () => of(actions)
|
getHeaderActions: () => actions
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
const app = {
|
const app = {
|
||||||
@@ -59,27 +52,11 @@ describe('AppHeaderComponent', () => {
|
|||||||
} as AppState;
|
} as AppState;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [AppTestingModule, CoreModule.forChild(), AppSearchInputModule],
|
|
||||||
declarations: [AppHeaderComponent],
|
|
||||||
providers: [
|
|
||||||
{
|
|
||||||
provide: AppExtensionService,
|
|
||||||
useValue: appExtensionService
|
|
||||||
},
|
|
||||||
{
|
|
||||||
provide: Store,
|
|
||||||
useValue: store
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
store.select.and.callFake((memoizeFn) => {
|
store.select.and.callFake((memoizeFn) => {
|
||||||
return of(memoizeFn({ app }));
|
return of(memoizeFn({ app }));
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AppHeaderComponent);
|
component = new AppHeaderComponent(store, appExtensionService);
|
||||||
component = fixture.componentInstance;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set header color, name and logo', fakeAsync(() => {
|
it('should set header color, name and logo', fakeAsync(() => {
|
||||||
@@ -88,9 +65,8 @@ describe('AppHeaderComponent', () => {
|
|||||||
component.headerColor$.subscribe((val) => expect(val).toBe(app.headerColor));
|
component.headerColor$.subscribe((val) => expect(val).toBe(app.headerColor));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should get header actions', fakeAsync(() => {
|
it('should get header actions', () => {
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
tick();
|
|
||||||
expect(component.actions).toEqual(actions);
|
expect(component.actions).toEqual(actions);
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
@@ -23,13 +23,12 @@
|
|||||||
* 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, Output, EventEmitter, OnInit, Input, OnDestroy } from '@angular/core';
|
import { Component, ViewEncapsulation, Output, EventEmitter, OnInit, Input } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
import { AppStore, getHeaderColor, getAppName, getLogoPath, getHeaderImagePath } from '@alfresco/aca-shared/store';
|
import { AppStore, getHeaderColor, getAppName, getLogoPath, getHeaderImagePath } from '@alfresco/aca-shared/store';
|
||||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
@@ -38,8 +37,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { class: 'app-header' }
|
host: { class: 'app-header' }
|
||||||
})
|
})
|
||||||
export class AppHeaderComponent implements OnInit, OnDestroy {
|
export class AppHeaderComponent implements OnInit {
|
||||||
private onDestroy$: Subject<boolean> = new Subject<boolean>();
|
|
||||||
@Output()
|
@Output()
|
||||||
toggleClicked = new EventEmitter();
|
toggleClicked = new EventEmitter();
|
||||||
|
|
||||||
@@ -62,17 +60,7 @@ export class AppHeaderComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.appExtensions
|
this.actions = this.appExtensions.getHeaderActions();
|
||||||
.getHeaderActions()
|
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((actions) => {
|
|
||||||
this.actions = actions;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.onDestroy$.next(true);
|
|
||||||
this.onDestroy$.complete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trackByActionId(_: number, action: ContentActionRef) {
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
|
@@ -87,23 +87,11 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((selection) => {
|
.subscribe((selection) => {
|
||||||
this.selection = selection;
|
this.selection = selection;
|
||||||
|
this.actions = this.extensions.getAllowedToolbarActions();
|
||||||
|
this.viewerToolbarActions = this.extensions.getViewerToolbarActions();
|
||||||
this.canUpdateNode = this.selection.count === 1 && this.content.canUpdateNode(selection.first);
|
this.canUpdateNode = this.selection.count === 1 && this.content.canUpdateNode(selection.first);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.extensions
|
|
||||||
.getAllowedToolbarActions()
|
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((actions) => {
|
|
||||||
this.actions = actions;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.extensions
|
|
||||||
.getViewerToolbarActions()
|
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((actions) => {
|
|
||||||
this.viewerToolbarActions = actions;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.store
|
this.store
|
||||||
.select(getCurrentFolder)
|
.select(getCurrentFolder)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
@@ -153,12 +153,7 @@ export class PreviewComponent extends PageComponent implements OnInit, OnDestroy
|
|||||||
.subscribe(() => {})
|
.subscribe(() => {})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.extensions
|
this.openWith = this.extensions.openWithActions;
|
||||||
.getOpenWithActions()
|
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((actions) => {
|
|
||||||
this.openWith = actions;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@@ -64,12 +64,6 @@ describe('SharedLinkViewComponent', () => {
|
|||||||
fixture = TestBed.createComponent(SharedLinkViewComponent);
|
fixture = TestBed.createComponent(SharedLinkViewComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
appExtensionService = TestBed.inject(AppExtensionService);
|
appExtensionService = TestBed.inject(AppExtensionService);
|
||||||
appExtensionService.selection = {
|
|
||||||
isEmpty: true,
|
|
||||||
count: 0,
|
|
||||||
libraries: null,
|
|
||||||
nodes: null
|
|
||||||
};
|
|
||||||
|
|
||||||
spyGetSharedLink = spyOn(component['sharedLinksApi'], 'getSharedLink');
|
spyGetSharedLink = spyOn(component['sharedLinksApi'], 'getSharedLink');
|
||||||
|
|
||||||
@@ -99,6 +93,8 @@ describe('SharedLinkViewComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not update actions reference if selection is empty', fakeAsync(() => {
|
it('should not update actions reference if selection is empty', fakeAsync(() => {
|
||||||
|
spyOn(storeMock, 'select').and.returnValue(of({ isEmpty: true }));
|
||||||
|
|
||||||
spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } }));
|
spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } }));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -108,13 +104,8 @@ describe('SharedLinkViewComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should update actions reference if selection is not empty', fakeAsync(() => {
|
it('should update actions reference if selection is not empty', fakeAsync(() => {
|
||||||
appExtensionService.selection = {
|
spyOn(storeMock, 'select').and.returnValue(of({ isEmpty: false }));
|
||||||
isEmpty: false,
|
spyOn(appExtensionService, 'getSharedLinkViewerToolbarActions');
|
||||||
count: 1,
|
|
||||||
libraries: null,
|
|
||||||
nodes: null
|
|
||||||
};
|
|
||||||
spyOn(appExtensionService, 'getSharedLinkViewerToolbarActions').and.callThrough();
|
|
||||||
spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } }));
|
spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } }));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@@ -23,15 +23,15 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppStore, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
import { AppStore, SetSelectedNodesAction, getAppSelection } from '@alfresco/aca-shared/store';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
import { SharedLinkEntry, SharedlinksApi } from '@alfresco/js-api';
|
import { SharedLinkEntry, SharedlinksApi } from '@alfresco/js-api';
|
||||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { forkJoin, from, of, Subject } from 'rxjs';
|
import { forkJoin, from, of } from 'rxjs';
|
||||||
import { catchError, mergeMap, takeUntil } from 'rxjs/operators';
|
import { catchError, mergeMap } from 'rxjs/operators';
|
||||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -41,8 +41,7 @@ import { AppExtensionService } from '@alfresco/aca-shared';
|
|||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { class: 'app-shared-link-view' }
|
host: { class: 'app-shared-link-view' }
|
||||||
})
|
})
|
||||||
export class SharedLinkViewComponent implements OnInit, OnDestroy {
|
export class SharedLinkViewComponent implements OnInit {
|
||||||
private onDestroy$: Subject<boolean> = new Subject<boolean>();
|
|
||||||
private sharedLinksApi: SharedlinksApi;
|
private sharedLinksApi: SharedlinksApi;
|
||||||
sharedLinkId: string = null;
|
sharedLinkId: string = null;
|
||||||
viewerToolbarActions: Array<ContentActionRef> = [];
|
viewerToolbarActions: Array<ContentActionRef> = [];
|
||||||
@@ -70,17 +69,9 @@ export class SharedLinkViewComponent implements OnInit, OnDestroy {
|
|||||||
this.sharedLinkId = sharedId;
|
this.sharedLinkId = sharedId;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.extensions
|
this.store.select(getAppSelection).subscribe((selection) => {
|
||||||
.getSharedLinkViewerToolbarActions()
|
if (!selection.isEmpty) this.viewerToolbarActions = this.extensions.getSharedLinkViewerToolbarActions();
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
});
|
||||||
.subscribe((actions) => {
|
|
||||||
this.viewerToolbarActions = actions;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.onDestroy$.next(true);
|
|
||||||
this.onDestroy$.complete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trackByActionId(_: number, action: ContentActionRef) {
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
|
@@ -27,7 +27,7 @@ import { AppExtensionService, AppHookService, ContentApiService } from '@alfresc
|
|||||||
import {
|
import {
|
||||||
AppStore,
|
AppStore,
|
||||||
ClosePreviewAction,
|
ClosePreviewAction,
|
||||||
getAppSelection,
|
getRuleContext,
|
||||||
isInfoDrawerOpened,
|
isInfoDrawerOpened,
|
||||||
RefreshPreviewAction,
|
RefreshPreviewAction,
|
||||||
ReloadDocumentListAction,
|
ReloadDocumentListAction,
|
||||||
@@ -131,24 +131,18 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.store
|
this.store
|
||||||
.select(getAppSelection)
|
.select(getRuleContext)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((selection) => {
|
.subscribe((ruleContext) => {
|
||||||
this.selection = selection;
|
this.selection = ruleContext.selection;
|
||||||
});
|
|
||||||
|
|
||||||
this.extensions
|
if (this.toolbarActions.length === 0) {
|
||||||
.getViewerToolbarActions()
|
this.toolbarActions = this.extensions.getViewerToolbarActions();
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
}
|
||||||
.subscribe((actions) => {
|
|
||||||
this.toolbarActions = actions;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.extensions
|
if (this.openWith.length === 0) {
|
||||||
.getOpenWithActions()
|
this.openWith = this.extensions.openWithActions;
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
}
|
||||||
.subscribe((actions) => {
|
|
||||||
this.openWith = actions;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.route.params.subscribe((params) => {
|
this.route.params.subscribe((params) => {
|
||||||
|
Reference in New Issue
Block a user