[AAE-5874] Re-evaluate extension rules when context changes (#2296)

* [AAE-5874] Re-evaluate extension rules when context changes

* [AAE-5874] Add disabled attribute to toolbar actions

* [AAE-5874] Fix unit tests
This commit is contained in:
Pablo Martinez Garcia
2021-09-16 15:48:43 +02:00
committed by GitHub
parent f89833461c
commit fb140531f4
17 changed files with 408 additions and 238 deletions

View File

@@ -47,14 +47,15 @@ describe('InfoDrawerComponent', () => {
};
const extensionServiceMock = {
getSidebarTabs: () => {},
getAllowedSidebarActions: () => [
{
id: 'app.sidebar.close',
order: 100,
title: 'close',
icon: 'highlight_off'
}
]
getAllowedSidebarActions: () =>
of([
{
id: 'app.sidebar.close',
order: 100,
title: 'close',
icon: 'highlight_off'
}
])
};
beforeEach(() => {

View File

@@ -27,7 +27,7 @@ import { Component, HostListener, Input, OnChanges, OnDestroy, OnInit } from '@a
import { MinimalNodeEntity, MinimalNodeEntryEntity, SiteEntry } from '@alfresco/js-api';
import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions';
import { Store } from '@ngrx/store';
import { getAppSelection, SetInfoDrawerStateAction, ToggleInfoDrawerAction, infoDrawerPreview } from '@alfresco/aca-shared/store';
import { SetInfoDrawerStateAction, ToggleInfoDrawerAction, infoDrawerPreview } from '@alfresco/aca-shared/store';
import { AppExtensionService } from '../../services/app.extension.service';
import { ContentApiService } from '../../services/content-api.service';
import { takeUntil } from 'rxjs/operators';
@@ -60,11 +60,11 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
ngOnInit() {
this.tabs = this.extensions.getSidebarTabs();
this.store
.select(getAppSelection)
this.extensions
.getAllowedSidebarActions()
.pipe(takeUntil(this.onDestroy$))
.subscribe(() => {
this.actions = this.extensions.getAllowedSidebarActions();
.subscribe((actions) => {
this.actions = actions;
});
this.store

View File

@@ -6,6 +6,7 @@
[color]="color"
[attr.aria-label]="actionRef.description || actionRef.title | translate"
[attr.title]="actionRef.description || actionRef.title | translate"
[disabled]="actionRef.disabled"
(click)="runAction()"
>
<adf-icon [value]="actionRef.icon"></adf-icon>

View File

@@ -5,6 +5,7 @@
[attr.aria-label]="actionRef.description || actionRef.title | translate"
[attr.title]="actionRef.description || actionRef.title | translate"
[matMenuTriggerFor]="menu"
[disabled]="actionRef.disabled"
#matTrigger="matMenuTrigger"
>
<adf-icon [value]="actionRef.icon"></adf-icon>