diff --git a/demo-shell/src/app.config.json b/demo-shell/src/app.config.json index 93410d0a9b..806171d9a2 100644 --- a/demo-shell/src/app.config.json +++ b/demo-shell/src/app.config.json @@ -33,6 +33,7 @@ "name": "Alfresco ADF Application", "copyright": "© 2016 - 2021 Alfresco Software, Inc. All Rights Reserved." }, + "notifications": true, "search": { "filterWithContains": true, "app:fields": [ diff --git a/demo-shell/src/app/services/app-notifications.service.ts b/demo-shell/src/app/services/app-notifications.service.ts index 45c2ada84f..a485c73c29 100644 --- a/demo-shell/src/app/services/app-notifications.service.ts +++ b/demo-shell/src/app/services/app-notifications.service.ts @@ -54,7 +54,7 @@ export class AppNotificationsService { private alfrescoApiService: AlfrescoApiService ) { this.alfrescoApiService.alfrescoApiInitialized.subscribe(() => { - if (this.isProcessServicesEnabled()) { + if (this.isProcessServicesEnabled() && this.notificationsEnabled) { this.alfrescoApiService.getInstance().oauth2Auth.once('token_issued', () => { const deployedApps = this.appConfigService.get('alfresco-deployed-apps', []); @@ -76,7 +76,11 @@ export class AppNotificationsService { }); } - private isProcessServicesEnabled() { + private get notificationsEnabled(): boolean { + return this.appConfigService.get('notifications', true); + } + + private isProcessServicesEnabled(): boolean { return this.authenticationService.isLoggedIn() && (this.authenticationService.isBPMProvider() || this.authenticationService.isALLProvider()); } diff --git a/docs/docassets/images/update-filter-bubble.png b/docs/docassets/images/update-filter-bubble.png new file mode 100644 index 0000000000..fed116ffaa Binary files /dev/null and b/docs/docassets/images/update-filter-bubble.png differ diff --git a/docs/process-services-cloud/components/task-filters-cloud.component.md b/docs/process-services-cloud/components/task-filters-cloud.component.md index d5b215fbde..440c90d448 100644 --- a/docs/process-services-cloud/components/task-filters-cloud.component.md +++ b/docs/process-services-cloud/components/task-filters-cloud.component.md @@ -18,6 +18,7 @@ Shows all available filters. - [Details](#details) - [Filtering APS2 task filters](#filtering-aps2-task-filters) - [Showing Filter Counters](#showing-filter-counters) + - [Updating Filter Counters](#updating-filter-counters) - [See also](#see-also) ## Basic Usage @@ -66,7 +67,7 @@ as the value of `filterParam` as shown in the table below: | id | string | The id of the task filter | | name | string | The name of the task filter, lowercase is checked | | key | string | The key of the task filter | -| index | string | The zero-based position of the filter in the array. | +| index | string | The zero-based position of the filter in the array | ### Showing Filter Counters @@ -74,6 +75,20 @@ By default, filter counters are hidden. If you want to display filter counters y ![](../../docassets/images/task-filter-counter.png) +### Updating Filter Counters + +If you want to disable notification bubbles as task filters change you can change it directly from the app.config.json. + +```json +{ + ... + "notifications": true + ... +} +``` + +![](../../docassets/images/update-filter-bubble.png) + ## See also - [Task filter Cloud Service](../services/task-filter-cloud.service.md) diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts index d181f267b4..51f98357a2 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts @@ -17,7 +17,7 @@ import { SimpleChange } from '@angular/core'; import { ComponentFixture, TestBed, async, fakeAsync, tick } from '@angular/core/testing'; -import { setupTestBed } from '@alfresco/adf-core'; +import { AppConfigService, setupTestBed } from '@alfresco/adf-core'; import { from, Observable, of } from 'rxjs'; import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service'; @@ -32,6 +32,7 @@ import { TranslateModule } from '@ngx-translate/core'; describe('TaskFiltersCloudComponent', () => { let taskFilterService: TaskFilterCloudService; + let appConfigService: AppConfigService; const fakeGlobalFilterObservable = new Observable(function (observer) { @@ -71,6 +72,8 @@ describe('TaskFiltersCloudComponent', () => { taskFilterService = TestBed.inject(TaskFilterCloudService); getTaskFilterCounterSpy = spyOn(taskFilterService, 'getTaskFilterCounter').and.returnValue(of(11)); spyOn(taskFilterService, 'getTaskNotificationSubscription').and.returnValue(of(taskNotifications)); + + appConfigService = TestBed.inject(AppConfigService); }); it('should attach specific icon for each filter if hasIcon is true', async(() => { @@ -384,6 +387,7 @@ describe('TaskFiltersCloudComponent', () => { it('should update filter counter when notification received', fakeAsync(() => { spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); + spyOn(appConfigService, 'get').and.returnValue(true); component.appName = 'my-app-1'; component.ngOnInit(); tick(5000); @@ -398,8 +402,24 @@ describe('TaskFiltersCloudComponent', () => { }); })); + it('should not update filter counter when notifications are disabled from app.config.json', fakeAsync(() => { + spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); + spyOn(appConfigService, 'get').and.returnValue(false); + component.appName = 'my-app-1'; + component.ngOnInit(); + tick(5000); + fixture.detectChanges(); + component.showIcons = true; + fixture.whenStable().then(() => { + fixture.detectChanges(); + const updatedFilterCounters = fixture.debugElement.queryAll(By.css('span.adf-active')); + expect(updatedFilterCounters.length).toBe(0); + }); + })); + it('should reset filter counter notification when filter is selected', fakeAsync(() => { spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); + spyOn(appConfigService, 'get').and.returnValue(true); let change = new SimpleChange(undefined, 'my-app-1', true); component.appName = 'my-app-1'; component.ngOnInit(); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts index 5e50346f1a..b49e8441f4 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts @@ -19,7 +19,7 @@ import { Component, EventEmitter, OnChanges, Output, SimpleChanges, OnInit } fro import { Observable } from 'rxjs'; import { TaskFilterCloudService } from '../services/task-filter-cloud.service'; import { TaskFilterCloudModel, FilterParamsModel } from '../models/filter-cloud.model'; -import { TranslationService } from '@alfresco/adf-core'; +import { AppConfigService, TranslationService } from '@alfresco/adf-core'; import { debounceTime, takeUntil } from 'rxjs/operators'; import { BaseTaskFiltersCloudComponent } from './base-task-filters-cloud.component'; import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model'; @@ -31,6 +31,7 @@ import { TaskCloudEngineEvent } from '../../../models/engine-event-cloud.model'; styleUrls: ['base-task-filters-cloud.component.scss'] }) export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent implements OnInit, OnChanges { + /** Emitted when a filter is being selected based on the filterParam input. */ @Output() filterSelected = new EventEmitter(); @@ -46,13 +47,16 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp filters$: Observable; filters: TaskFilterCloudModel[] = []; currentFilter: TaskFilterCloudModel; + enableNotifications: boolean; constructor(private taskFilterCloudService: TaskFilterCloudService, - private translationService: TranslationService) { + private translationService: TranslationService, + private appConfigService: AppConfigService) { super(); } ngOnInit() { + this.enableNotifications = this.appConfigService.get('notifications', true); this.initFilterCounterNotifications(); this.getFilters(this.appName); } @@ -98,7 +102,7 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp } initFilterCounterNotifications() { - if (this.appName) { + if (this.appName && this.enableNotifications) { this.taskFilterCloudService.getTaskNotificationSubscription(this.appName) .pipe(debounceTime(3000)) .subscribe((result: TaskCloudEngineEvent[]) => {