Skip to content

Commit

Permalink
Change process and task search api selection from token-provided to i…
Browse files Browse the repository at this point in the history
…nput-provided
  • Loading branch information
DudaRobert committed Dec 12, 2024
1 parent 3646048 commit db62551
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: [
Expand All @@ -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));
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -388,7 +388,7 @@ describe('ProcessFiltersCloudComponent', () => {

describe('API agnostic', () => {
beforeEach(() => {
configureTestingModule([]);
configureTestingModule('GET');
});

it('should emit an error with a bad response', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -118,6 +117,7 @@ describe('ProcessListCloudComponent', () => {
}
});

component.searchApiMethod = searchApiMethod;
component.isColumnSchemaCreated$ = of(true).pipe(shareReplay(1));
loader = TestbedHarnessEnvironment.loader(fixture);
};
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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';
});

Expand Down Expand Up @@ -698,7 +698,7 @@ describe('ProcessListCloudComponent', () => {

describe('API agnostic', () => {
beforeEach(() => {
configureTestingModule([]);
configureTestingModule('GET');
});

it('should use the default schemaColumn', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
Inject,
Input,
OnChanges,
Optional,
Output,
SimpleChanges,
ViewChild,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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,
Expand All @@ -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));
Expand Down
12 changes: 0 additions & 12 deletions lib/process-services-cloud/src/lib/services/cloud-token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Loading

0 comments on commit db62551

Please sign in to comment.