From db62551ee6f4b090c9bbc027b388adba895c6adb Mon Sep 17 00:00:00 2001 From: Robert Duda Date: Thu, 12 Dec 2024 14:03:24 +0100 Subject: [PATCH] Change process and task search api selection from token-provided to input-provided --- .../process-list-cloud.component.md | 9 ++--- .../components/task-list-cloud.component.md | 13 ++++---- .../process-filters-cloud.component.spec.ts | 18 +++++----- .../process-filters-cloud.component.ts | 8 +++-- .../process-list-cloud.component.spec.ts | 18 +++++----- .../process-list-cloud.component.ts | 29 ++++++++-------- .../src/lib/services/cloud-token.service.ts | 12 ------- .../task-filters-cloud.component.spec.ts | 18 +++++----- .../task-filters-cloud.component.ts | 9 +++-- .../task-list-cloud.component.spec.ts | 18 +++++----- .../components/task-list-cloud.component.ts | 33 ++++++++++--------- 11 files changed, 92 insertions(+), 93 deletions(-) diff --git a/docs/process-services-cloud/components/process-list-cloud.component.md b/docs/process-services-cloud/components/process-list-cloud.component.md index e5257dd17e6..8bfe8eaaed0 100644 --- a/docs/process-services-cloud/components/process-list-cloud.component.md +++ b/docs/process-services-cloud/components/process-list-cloud.component.md @@ -80,10 +80,11 @@ when the process list is empty: | stickyHeader | `boolean` | false | Toggles the sticky header mode. | | suspendedFrom | `string` | "" | Filter the processes. Display only process with suspendedFrom equal to the supplied date. | | suspendedTo | `string` | "" | Filter the processes. Display only process with suspendedTo equal to the supplied date. | -| names | `string[]` | [] | Filter the processes. Display only processes with names matching any of the supplied strings. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -initiators | `string[]` | [] | Filter the processes. Display only processes started by any of the users whose usernames are present in the array. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| appVersions | `string[]` | [] | Filter the processes. Display only processes present in any of the specified app versions. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| statuses | `string[]` | [] | Filter the processes. Display only processes with provided statuses. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | +| searchApiMethod | `'POST' \| 'GET'` | `'GET'` | The HTTP method to use when searching for tasks. 'POST' value is supported from Activiti 8.7.0 forward. | +| names | `string[]` | [] | Filter the processes. Display only processes with names matching any of the supplied strings. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +initiators | `string[]` | [] | Filter the processes. Display only processes started by any of the users whose usernames are present in the array. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| appVersions | `string[]` | [] | Filter the processes. Display only processes present in any of the specified app versions. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| statuses | `string[]` | [] | Filter the processes. Display only processes with provided statuses. This input will be used only if `searchApiMethod` input is provided with `POST` value. | ### Events diff --git a/docs/process-services-cloud/components/task-list-cloud.component.md b/docs/process-services-cloud/components/task-list-cloud.component.md index 99a11c73505..c9f6702a314 100644 --- a/docs/process-services-cloud/components/task-list-cloud.component.md +++ b/docs/process-services-cloud/components/task-list-cloud.component.md @@ -87,12 +87,13 @@ when the task list is empty: | standalone | `boolean` | false | Filter the tasks. Display only the tasks that belong to a process in case is false or tasks that doesn't belong to a process in case of true. | | status | `string` | "" | Filter the tasks. Display only tasks with status equal to the supplied value. | | stickyHeader | `boolean` | false | Toggles the sticky header mode. | -| names | `string[]` | [] | Filter the tasks. Display only tasks with names matching any of the supplied strings. This input will be used only if `TASK_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| processDefinitionNames | `string[]` | [] | Filter the tasks. Display only tasks under provided processes. This input will be used only if `TASK_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| statuses | `string[]` | [] | Filter the tasks. Display only tasks with provided statuses. This input will be used only if `TASK_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| assignees | `string[]` | [] | Filter the tasks. Display only tasks with assignees whose usernames are present in the array. This input will be used only if `TASK_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| priorities | `string[]` | [] | Filter the tasks. Display only tasks with provided priorities. This input will be used only if `TASK_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | -| completedByUsers | `string[]` | [] | Filter the tasks. Display only tasks completed by users whose usernames are present in the array. This input will be used only if `TASK_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. | +| searchApiMethod | `'POST' \| 'GET'` | `'GET'` | The HTTP method to use when searching for tasks. 'POST' value is supported from Activiti 8.7.0 forward. | +| names | `string[]` | [] | Filter the tasks. Display only tasks with names matching any of the supplied strings. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| processDefinitionNames | `string[]` | [] | Filter the tasks. Display only tasks under provided processes. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| statuses | `string[]` | [] | Filter the tasks. Display only tasks with provided statuses. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| assignees | `string[]` | [] | Filter the tasks. Display only tasks with assignees whose usernames are present in the array. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| priorities | `string[]` | [] | Filter the tasks. Display only tasks with provided priorities. This input will be used only if `searchApiMethod` input is provided with `POST` value. | +| completedByUsers | `string[]` | [] | Filter the tasks. Display only tasks completed by users whose usernames are present in the array. This input will be used only if `searchApiMethod` input is provided with `POST` value. | ### Events diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts index abf5816c4f7..4807b9c8ecb 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts @@ -21,7 +21,7 @@ import { of, throwError } from 'rxjs'; import { ProcessFilterCloudService } from '../services/process-filter-cloud.service'; import { ProcessFiltersCloudComponent } from './process-filters-cloud.component'; import { By } from '@angular/platform-browser'; -import { PROCESS_FILTERS_SERVICE_TOKEN, PROCESS_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; +import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service'; import { mockProcessFilters } from '../mock/process-filters-cloud.mock'; import { AppConfigService, AppConfigServiceMock, NoopTranslateModule } from '@alfresco/adf-core'; @@ -44,7 +44,7 @@ describe('ProcessFiltersCloudComponent', () => { let getProcessFiltersSpy: jasmine.Spy; let getProcessNotificationSubscriptionSpy: jasmine.Spy; - const configureTestingModule = (providers: any[]) => { + const configureTestingModule = (searchApiMethod: 'GET' | 'POST') => { TestBed.configureTestingModule({ imports: [NoopTranslateModule, NoopAnimationsModule, MatListModule], providers: [ @@ -56,12 +56,12 @@ describe('ProcessFiltersCloudComponent', () => { }}, { provide: ProcessFilterCloudService, useValue: ProcessFilterCloudServiceMock }, NotificationCloudService, - ApolloModule, - ...providers + ApolloModule ] }); fixture = TestBed.createComponent(ProcessFiltersCloudComponent); component = fixture.componentInstance; + component.searchApiMethod = searchApiMethod; processFilterService = TestBed.inject(ProcessFilterCloudService); getProcessFiltersSpy = spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(mockProcessFilters)); @@ -72,9 +72,9 @@ describe('ProcessFiltersCloudComponent', () => { fixture.destroy(); }); - describe('PROCESS_SEARCH_API_METHOD_TOKEN injected with GET value', () => { + describe('searchApiMethod set to GET', () => { beforeEach(() => { - configureTestingModule([{ provide: PROCESS_SEARCH_API_METHOD_TOKEN, useValue: 'GET' }]); + configureTestingModule('GET'); }); it('should attach specific icon for each filter if hasIcon is true', async () => { @@ -229,9 +229,9 @@ describe('ProcessFiltersCloudComponent', () => { }); }); - describe('PROCESS_SEARCH_API_METHOD_TOKEN injected with POST value', () => { + describe('searchApiMethod set to POST', () => { beforeEach(() => { - configureTestingModule([{ provide: PROCESS_SEARCH_API_METHOD_TOKEN, useValue: 'POST' }]); + configureTestingModule('POST'); }); it('should attach specific icon for each filter if hasIcon is true', async () => { @@ -388,7 +388,7 @@ describe('ProcessFiltersCloudComponent', () => { describe('API agnostic', () => { beforeEach(() => { - configureTestingModule([]); + configureTestingModule('GET'); }); it('should emit an error with a bad response', () => { diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts index 63497d882cf..d48dff8ea78 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts @@ -34,7 +34,6 @@ import { AppConfigService, TranslationService } from '@alfresco/adf-core'; import { FilterParamsModel } from '../../../task/task-filters/models/filter-cloud.model'; import { debounceTime, tap } from 'rxjs/operators'; import { ProcessListCloudService } from '../../../process/process-list/services/process-list-cloud.service'; -import { PROCESS_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; import { ProcessFilterCloudAdapter } from '../../process-list/models/process-cloud-query-request.model'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @@ -49,6 +48,10 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges { @Input() appName: string = ''; + /** (optional) From Activiti 8.7.0 forward, use the 'POST' method to get the process count */ + @Input() + searchApiMethod: 'GET' | 'POST' = 'GET'; + /** (optional) The filter to be selected by default */ @Input() filterParam: FilterParamsModel; @@ -90,7 +93,6 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges { private readonly translationService = inject(TranslationService); private readonly appConfigService = inject(AppConfigService); private readonly processListCloudService = inject(ProcessListCloudService); - private readonly searchMethod = inject<'GET' | 'POST'>(PROCESS_SEARCH_API_METHOD_TOKEN, { optional: true }); ngOnInit() { this.enableNotifications = this.appConfigService.get('notifications', true); @@ -322,7 +324,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges { } private fetchProcessFilterCounter(filter: ProcessFilterCloudModel): Observable { - return this.searchMethod === 'POST' + return this.searchApiMethod === 'POST' ? this.processListCloudService.getProcessListCounter(new ProcessFilterCloudAdapter(filter)) : this.processListCloudService.getProcessCounter(filter.appName, filter.status) } diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts index 1f8180f9104..de2fb706b14 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts @@ -35,7 +35,7 @@ import { of } from 'rxjs'; import { shareReplay, skip } from 'rxjs/operators'; import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module'; import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model'; -import { PROCESS_LISTS_PREFERENCES_SERVICE_TOKEN, PROCESS_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; +import { PROCESS_LISTS_PREFERENCES_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { ProcessListCloudPreferences } from '../models/process-cloud-preferences'; import { PROCESS_LIST_CUSTOM_VARIABLE_COLUMN } from '../../../models/data-column-custom-data'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; @@ -76,10 +76,9 @@ describe('ProcessListCloudComponent', () => { const fakeCustomSchemaName = 'fakeCustomSchema'; const schemaWithVariable = 'schemaWithVariableId'; - const configureTestingModule = (providers: any[]) => { + const configureTestingModule = (searchApiMethod: 'GET' | 'POST') => { TestBed.configureTestingModule({ - imports: [ProcessServiceCloudTestingModule], - providers: providers + imports: [ProcessServiceCloudTestingModule] }); appConfig = TestBed.inject(AppConfigService); processListCloudService = TestBed.inject(ProcessListCloudService); @@ -118,6 +117,7 @@ describe('ProcessListCloudComponent', () => { } }); + component.searchApiMethod = searchApiMethod; component.isColumnSchemaCreated$ = of(true).pipe(shareReplay(1)); loader = TestbedHarnessEnvironment.loader(fixture); }; @@ -126,9 +126,9 @@ describe('ProcessListCloudComponent', () => { fixture.destroy(); }); - describe('PROCESS_SEARCH_API_METHOD_TOKEN injected with GET value', () => { + describe('searchApiMethod set to GET', () => { beforeEach(() => { - configureTestingModule([{ provide: PROCESS_SEARCH_API_METHOD_TOKEN, useValue: 'GET' }]); + configureTestingModule('GET'); }); it('should load spinner and show the content', async () => { @@ -420,9 +420,9 @@ describe('ProcessListCloudComponent', () => { }); }); - describe('PROCESS_SEARCH_API_METHOD_TOKEN injected with POST value', () => { + describe('searchApiMethod set to POST', () => { beforeEach(() => { - configureTestingModule([{ provide: PROCESS_SEARCH_API_METHOD_TOKEN, useValue: 'POST' }]); + configureTestingModule('POST'); component.appName = 'fake-app-name'; }); @@ -698,7 +698,7 @@ describe('ProcessListCloudComponent', () => { describe('API agnostic', () => { beforeEach(() => { - configureTestingModule([]); + configureTestingModule('GET'); }); it('should use the default schemaColumn', () => { diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts index 266c367c2ae..887a22730eb 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts @@ -23,7 +23,6 @@ import { Inject, Input, OnChanges, - Optional, Output, SimpleChanges, ViewChild, @@ -51,10 +50,7 @@ import { ProcessListRequestModel, ProcessQueryCloudRequestModel } from '../model import { ProcessListCloudSortingModel, ProcessListRequestSortingModel } from '../models/process-list-sorting.model'; import { filter, map, switchMap, take, tap } from 'rxjs/operators'; import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface'; -import { - PROCESS_LISTS_PREFERENCES_SERVICE_TOKEN, - PROCESS_SEARCH_API_METHOD_TOKEN -} from '../../../services/cloud-token.service'; +import { PROCESS_LISTS_PREFERENCES_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { ProcessListCloudPreferences } from '../models/process-cloud-preferences'; import { ProcessListDatatableAdapter } from '../datatable/process-list-datatable-adapter'; import { @@ -216,58 +212,62 @@ export class ProcessListCloudComponent @Input() isResizingEnabled: boolean = false; + /** From Activiti 8.7.0 forward, use 'POST' value and array inputs to enable advanced filtering. */ + @Input() + searchApiMethod: 'GET' | 'POST' = 'GET'; + /** * Filter the processes. Display only processes with names matching any of the supplied strings. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() names: string[] = []; /** * Filter the processes. Display only processes with instance Ids matching any of the supplied strings. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() ids: string[] = []; /** * Filter the processes. Display only processes with parent Ids matching any of the supplied strings. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() parentIds: string[] = []; /** * Filter the processes. Display only processes with definition names matching any of the supplied strings. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() processDefinitionNames: string[] = []; /** * Filter the processes. Display only processes started by any of the users whose usernames are present in the array. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() initiators: string[] = []; /** * Filter the processes. Display only processes present in any of the specified app versions. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() appVersions: string[] = []; /** * Filter the processes. Display only processes with provided statuses. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() statuses: string[] = []; /** * Filter the processes. Display only processes with specific process variables. - * This input will be used only if PROCESS_SEARCH_API_METHOD_TOKEN is provided with 'POST' value. + * This input will be used only if searchApiMethod input is provided with 'POST' value. */ @Input() processVariables: ProcessVariableFilterModel[]; @@ -318,7 +318,6 @@ export class ProcessListCloudComponent private fetchProcessesTrigger$ = new Subject(); constructor( - @Inject(PROCESS_SEARCH_API_METHOD_TOKEN) @Optional() private searchMethod: 'GET' | 'POST', private processListCloudService: ProcessListCloudService, appConfigService: AppConfigService, private userPreferences: UserPreferencesService, @@ -343,7 +342,7 @@ export class ProcessListCloudComponent tap(() => this.isLoading = true), filter(([isColumnSchemaCreated]) => isColumnSchemaCreated), switchMap(() => { - if (this.searchMethod === 'POST') { + if (this.searchApiMethod === 'POST') { const requestNode = this.createProcessListRequestNode(); this.processListRequestNode = requestNode; return this.processListCloudService.fetchProcessList(requestNode).pipe(take(1)); diff --git a/lib/process-services-cloud/src/lib/services/cloud-token.service.ts b/lib/process-services-cloud/src/lib/services/cloud-token.service.ts index 1785dc2e4cf..d9ca89cd0ce 100644 --- a/lib/process-services-cloud/src/lib/services/cloud-token.service.ts +++ b/lib/process-services-cloud/src/lib/services/cloud-token.service.ts @@ -28,15 +28,3 @@ export const PROCESS_FILTERS_SERVICE_TOKEN = new InjectionToken('task-filters-cloud'); export const TASK_LIST_CLOUD_TOKEN = new InjectionToken('task-list-cloud'); - -/** - * Token used to indicate the API used to search for tasks. - * 'POST' value should be provided only if the used Activiti version is 8.7.0 or higher. - */ -export const TASK_SEARCH_API_METHOD_TOKEN = new InjectionToken<'GET' | 'POST'>('task-search-method'); - -/** - * Token used to indicate the API used to search for processes. - * 'POST' value should be provided only if the used Activiti version is 8.7.0 or higher. - */ -export const PROCESS_SEARCH_API_METHOD_TOKEN = new InjectionToken<'GET' | 'POST'>('process-search-method'); 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 9a158551f7e..f1eae314406 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 @@ -20,7 +20,7 @@ import { SimpleChange } from '@angular/core'; import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { first, of, throwError } from 'rxjs'; -import { TASK_FILTERS_SERVICE_TOKEN, TASK_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; +import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service'; import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module'; import { defaultTaskFiltersMock, fakeGlobalFilter, taskNotifications } from '../mock/task-filters-cloud.mock'; @@ -45,10 +45,10 @@ describe('TaskFiltersCloudComponent', () => { let getTaskListFiltersSpy: jasmine.Spy; let getTaskListCounterSpy: jasmine.Spy; - const configureTestingModule = (providers: any[]) => { + const configureTestingModule = (searchApiMethod: 'GET' | 'POST') => { TestBed.configureTestingModule({ imports: [ProcessServiceCloudTestingModule, TaskFiltersCloudModule], - providers: [{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService }, ...providers] + providers: [{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: LocalPreferenceCloudService }] }); taskFilterService = TestBed.inject(TaskFilterCloudService); taskListService = TestBed.inject(TaskListCloudService); @@ -62,15 +62,17 @@ describe('TaskFiltersCloudComponent', () => { fixture = TestBed.createComponent(TaskFiltersCloudComponent); component = fixture.componentInstance; loader = TestbedHarnessEnvironment.loader(fixture); + + component.searchApiMethod = searchApiMethod; }; afterEach(() => { fixture.destroy(); }); - describe('TASK_SEARCH_API_METHOD_TOKEN injected with GET value', () => { + describe('searchApiMethod set to GET', () => { beforeEach(() => { - configureTestingModule([{ provide: TASK_SEARCH_API_METHOD_TOKEN, useValue: 'GET' }]); + configureTestingModule('GET'); }); it('should attach specific icon for each filter if hasIcon is true', async () => { @@ -242,9 +244,9 @@ describe('TaskFiltersCloudComponent', () => { }); }); - describe('TASK_SEARCH_API_METHOD_TOKEN injected with POST value', () => { + describe('searchApiMethod set to POST', () => { beforeEach(() => { - configureTestingModule([{ provide: TASK_SEARCH_API_METHOD_TOKEN, useValue: 'POST' }]); + configureTestingModule('POST'); component.showIcons = true; component.appName = 'my-app-1'; }); @@ -360,7 +362,7 @@ describe('TaskFiltersCloudComponent', () => { describe('API agnostic', () => { beforeEach(() => { - configureTestingModule([]); + configureTestingModule('GET'); }); it('should emit an error with a bad response', (done) => { 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 cc4281533d8..b3dc850fa17 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,6 +19,7 @@ import { Component, EventEmitter, inject, + Input, OnChanges, OnInit, Output, @@ -35,7 +36,6 @@ import { TaskDetailsCloudModel } from '../../start-task/models/task-details-clou import { TaskCloudEngineEvent } from '../../../models/engine-event-cloud.model'; import { TaskListCloudService } from '../../task-list/services/task-list-cloud.service'; import { TaskFilterCloudAdapter } from '../../../models/filter-cloud-model'; -import { TASK_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @Component({ @@ -45,6 +45,10 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; encapsulation: ViewEncapsulation.None }) export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent implements OnInit, OnChanges { + /** (optional) From Activiti 8.7.0 forward, use the 'POST' method to get the task count. */ + @Input() + searchApiMethod: 'GET' | 'POST' = 'GET'; + /** Emitted when a filter is being selected based on the filterParam input. */ @Output() filterSelected = new EventEmitter(); @@ -71,7 +75,6 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp private readonly taskListCloudService = inject(TaskListCloudService); private readonly translationService = inject(TranslationService); private readonly appConfigService = inject(AppConfigService); - private readonly searchMethod = inject<'GET' | 'POST'>(TASK_SEARCH_API_METHOD_TOKEN, { optional: true }); ngOnInit() { this.enableNotifications = this.appConfigService.get('notifications', true); @@ -151,7 +154,7 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp } private fetchTaskFilterCounter(filter: TaskFilterCloudModel): Observable { - return this.searchMethod === 'POST' + return this.searchApiMethod === 'POST' ? this.taskListCloudService.getTaskListCounter(new TaskFilterCloudAdapter(filter)) : this.taskFilterCloudService.getTaskFilterCounter(filter); } diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts index 834fa0256f2..4049299b28a 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts @@ -27,7 +27,7 @@ import { ProcessServiceCloudTestingModule } from '../../../testing/process-servi import { TaskListCloudSortingModel } from '../../../models/task-list-sorting.model'; import { shareReplay, skip } from 'rxjs/operators'; import { TaskListCloudServiceInterface } from '../../../services/task-list-cloud.service.interface'; -import { TASK_LIST_CLOUD_TOKEN, TASK_LIST_PREFERENCES_SERVICE_TOKEN, TASK_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; +import { TASK_LIST_CLOUD_TOKEN, TASK_LIST_PREFERENCES_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { TaskListCloudModule } from '../task-list-cloud.module'; import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface'; import { HarnessLoader } from '@angular/cdk/testing'; @@ -94,7 +94,7 @@ describe('TaskListCloudComponent', () => { updatePreference: of({}) }); - const configureTestingModule = (providers: any[]) => { + const configureTestingModule = (searchApiMethod: 'GET' | 'POST') => { TestBed.configureTestingModule({ imports: [ProcessServiceCloudTestingModule], providers: [ @@ -105,8 +105,7 @@ describe('TaskListCloudComponent', () => { { provide: TASK_LIST_PREFERENCES_SERVICE_TOKEN, useValue: preferencesService - }, - ...providers + } ] }); appConfig = TestBed.inject(AppConfigService); @@ -134,6 +133,7 @@ describe('TaskListCloudComponent', () => { } }); + component.searchApiMethod = searchApiMethod; component.isColumnSchemaCreated$ = of(true).pipe(shareReplay(1)); loader = TestbedHarnessEnvironment.loader(fixture); }; @@ -142,9 +142,9 @@ describe('TaskListCloudComponent', () => { fixture.destroy(); }); - describe('TASK_SEARCH_API_METHOD_TOKEN injected with GET value', () => { + describe('searchApiMethod set to GET', () => { beforeEach(() => { - configureTestingModule([{ provide: TASK_SEARCH_API_METHOD_TOKEN, useValue: 'GET' }]); + configureTestingModule('GET'); }); it('should load spinner and show the content', async () => { @@ -285,9 +285,9 @@ describe('TaskListCloudComponent', () => { }); }); - describe('TASK_SEARCH_API_METHOD_TOKEN injected with POST value', () => { + describe('searchApiMethod set to POST', () => { beforeEach(() => { - configureTestingModule([{ provide: TASK_SEARCH_API_METHOD_TOKEN, useValue: 'POST' }]); + configureTestingModule('POST'); component.appName = 'mock-app-name'; }); @@ -428,7 +428,7 @@ describe('TaskListCloudComponent', () => { describe('API agnostic', () => { beforeEach(() => { - configureTestingModule([]); + configureTestingModule('GET'); }); it('should be able to inject TaskListCloudService instance', () => { diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts index f71f4bcff59..bddba5e2d96 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts @@ -15,12 +15,12 @@ * limitations under the License. */ -import { Component, Inject, Input, Optional, ViewEncapsulation } from '@angular/core'; +import { Component, Inject, Input, ViewEncapsulation } from '@angular/core'; import { AppConfigService, UserPreferencesService } from '@alfresco/adf-core'; import { TaskListRequestModel, TaskQueryCloudRequestModel } from '../../../models/filter-cloud-model'; import { BaseTaskListCloudComponent } from './base-task-list-cloud.component'; import { TaskCloudService } from '../../services/task-cloud.service'; -import { TASK_LIST_CLOUD_TOKEN, TASK_LIST_PREFERENCES_SERVICE_TOKEN, TASK_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service'; +import { TASK_LIST_CLOUD_TOKEN, TASK_LIST_PREFERENCES_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface'; import { TaskListCloudServiceInterface } from '../../../services/task-list-cloud.service.interface'; import { BehaviorSubject, combineLatest, Subject } from 'rxjs'; @@ -148,79 +148,83 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent(); constructor( - @Inject(TASK_SEARCH_API_METHOD_TOKEN) @Optional() private searchMethod: 'GET' | 'POST', @Inject(TASK_LIST_CLOUD_TOKEN) public taskListCloudService: TaskListCloudServiceInterface, appConfigService: AppConfigService, taskCloudService: TaskCloudService, @@ -251,7 +254,7 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent this.isReloadingSubject$.next(true)), filter((isColumnSchemaCreated) => !!isColumnSchemaCreated), switchMap(() => { - if (this.searchMethod === 'POST') { + if (this.searchApiMethod === 'POST') { const requestNode = this.createTaskListRequestNode(); return this.taskListCloudService.fetchTaskList(requestNode).pipe(take(1)); } else {