Change process and task search api selection from token-provided to input-provided (#10488)

This commit is contained in:
Robert Duda 2024-12-12 14:30:37 +01:00 committed by GitHub
parent ef2d184578
commit 0278544af1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 92 additions and 93 deletions

View File

@ -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

View File

@ -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

View File

@ -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', () => {

View File

@ -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<number> {
return this.searchMethod === 'POST'
return this.searchApiMethod === 'POST'
? this.processListCloudService.getProcessListCounter(new ProcessFilterCloudAdapter(filter))
: this.processListCloudService.getProcessCounter(filter.appName, filter.status)
}

View File

@ -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', () => {

View File

@ -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<void>();
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));

View File

@ -28,15 +28,3 @@ export const PROCESS_FILTERS_SERVICE_TOKEN = new InjectionToken<PreferenceCloudS
export const TASK_FILTERS_SERVICE_TOKEN = new InjectionToken<PreferenceCloudServiceInterface>('task-filters-cloud');
export const TASK_LIST_CLOUD_TOKEN = new InjectionToken<TaskListCloudServiceInterface>('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');

View File

@ -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) => {

View File

@ -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<TaskFilterCloudModel>();
@ -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<number> {
return this.searchMethod === 'POST'
return this.searchApiMethod === 'POST'
? this.taskListCloudService.getTaskListCounter(new TaskFilterCloudAdapter(filter))
: this.taskFilterCloudService.getTaskFilterCounter(filter);
}

View File

@ -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', () => {

View File

@ -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<ProcessLi
@Input()
candidateGroupId: string = '';
/** From Activiti 8.7.0 forward, use the 'POST' value and array inputs to enable advanced filtering. */
@Input()
searchApiMethod: 'GET' | 'POST' = 'GET';
/**
* 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.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
names: 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.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
assignees: 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.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
statuses: string[] = [];
/**
* Filter the tasks. Display only tasks under processes with provided definition names.
* This input will be used only if TASK_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 tasks. Display only tasks with Ids matching any of the supplied strings.
* This input will be used only if TASK_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 tasks. Display only tasks with parentTaskIds matching any of the supplied strings.
* This input will be used only if TASK_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 tasks. Display only tasks with processInstanceIds matching any of the supplied strings.
* This input will be used only if TASK_SEARCH_API_METHOD_TOKEN is provided with 'POST' value.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
processInstanceIds: string[] = [];
/**
* Filter the tasks. Display only tasks under processes with provided names.
* This input will be used only if TASK_SEARCH_API_METHOD_TOKEN is provided with 'POST' value.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
processNames: 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.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
priorities: 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.
* This input will be used only if searchApiMethod input is provided with 'POST' value.
*/
@Input()
completedByUsers: 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()
processVariableFilters: ProcessVariableFilterModel[];
@ -236,7 +240,6 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent<ProcessLi
private fetchProcessesTrigger$ = new Subject<void>();
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<ProcessLi
tap(() => 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 {