diff --git a/lib/process-services-cloud/src/lib/app/mock/app-model.mock.ts b/lib/process-services-cloud/src/lib/app/mock/app-model.mock.ts index b9b0dbe52b..36a961e6c4 100644 --- a/lib/process-services-cloud/src/lib/app/mock/app-model.mock.ts +++ b/lib/process-services-cloud/src/lib/app/mock/app-model.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { fakeEnvironmentList } from '../../common'; +import { fakeEnvironmentList } from '../../common/mock/environment.mock'; import { ApplicationInstanceModel } from '../models/application-instance.model'; export const fakeApplicationInstance: ApplicationInstanceModel[] = [ diff --git a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts index c56b8fdf0c..f8611005dc 100644 --- a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts @@ -20,9 +20,10 @@ import { throwError } from 'rxjs'; import { setupTestBed, AppConfigService, AlfrescoApiService, CoreTestingModule } from '@alfresco/adf-core'; import { HttpErrorResponse } from '@angular/common/http'; import { AppsProcessCloudService } from './apps-process-cloud.service'; -import { fakeApplicationInstance } from '../mock/app-model.mock'; +import { fakeApplicationInstance, fakeApplicationInstanceWithEnvironment } from '../mock/app-model.mock'; import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module'; import { TranslateModule } from '@ngx-translate/core'; +import { fakeEnvironmentList } from '../../common/mock/environment.mock'; describe('AppsProcessCloudService', () => { @@ -103,4 +104,15 @@ describe('AppsProcessCloudService', () => { } ); }); + + + it('should return label with application name', () => { + const applicationLabel = service.getApplicationLabel(fakeApplicationInstance[0]); + expect(applicationLabel).toBe('application-new-1'); + }); + + it('should return label with application name and environment name', () => { + const applicationLabel = service.getApplicationLabel(fakeApplicationInstanceWithEnvironment[0], fakeEnvironmentList); + expect(applicationLabel).toBe('application-new-1 (test-env-name-1)'); + }); }); diff --git a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts index 42b70509cc..1dab9a978f 100644 --- a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts @@ -21,6 +21,7 @@ import { map, catchError } from 'rxjs/operators'; import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core'; import { Oauth2Auth } from '@alfresco/js-api'; import { ApplicationInstanceModel } from '../models/application-instance.model'; +import { Environment } from '../../common/interface/environment.interface'; @Injectable({ providedIn: 'root' }) export class AppsProcessCloudService { @@ -58,6 +59,16 @@ export class AppsProcessCloudService { this.deployedApps = apps; } + getApplicationLabel(application: ApplicationInstanceModel, environmentList?: Environment[]): string { + const envName = environmentList?.find((env: Environment) => env.id === application.environmentId)?.name; + + if (application.environmentId && environmentList && envName) { + return `${application.name} (${envName})`; + } else { + return application.name; + } + } + private getApplicationsByStatus(status: string, role?: string): Observable { if (status === '') { return of([]); diff --git a/lib/process-services-cloud/src/lib/common/mock/index.ts b/lib/process-services-cloud/src/lib/common/mock/index.ts deleted file mode 100644 index a7e30cc675..0000000000 --- a/lib/process-services-cloud/src/lib/common/mock/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * @license - * Copyright 2019 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './public-api'; diff --git a/lib/process-services-cloud/src/lib/common/mock/public-api.ts b/lib/process-services-cloud/src/lib/common/mock/public-api.ts deleted file mode 100644 index 067c7af91f..0000000000 --- a/lib/process-services-cloud/src/lib/common/mock/public-api.ts +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * @license - * Copyright 2019 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './date-range-filter.mock'; -export * from './environment.mock'; diff --git a/lib/process-services-cloud/src/lib/common/public-api.ts b/lib/process-services-cloud/src/lib/common/public-api.ts index 4287712fc5..b4c2a300e2 100644 --- a/lib/process-services-cloud/src/lib/common/public-api.ts +++ b/lib/process-services-cloud/src/lib/common/public-api.ts @@ -16,4 +16,3 @@ */ export * from './interface/index'; -export * from './mock/index'; diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts index 6ecf1e7a45..5c888609c9 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts @@ -413,21 +413,12 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes .subscribe((applications) => { if (applications && applications.length > 0) { applications.map((application) => { - if (application.environmentId) { - this.applicationNames.push({ label: `${application.name} (${this.getEnvironmentName(application.environmentId)})`, value: application.name }); - } else { - this.applicationNames.push({ label: application.name, value: application.name }); - } - + this.applicationNames.push({ label: this.appsProcessCloudService.getApplicationLabel(application, this.environmentList), value: application.name }); }); } }); } - private getEnvironmentName(environmentId: string): string { - return this.environmentList.find((env: any) => env['id'] === environmentId)?.name; - } - getProcessDefinitions() { this.processDefinitionNames = []; diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts index 9ff7d69b35..7516f00e8a 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts @@ -68,10 +68,6 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC @Input() id: string; - /** Environment ID of the application. */ - @Input() - environmentId: string; - /** List of environments. */ @Input() environmentList: Environment[] = []; @@ -108,14 +104,6 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC @Input() sortProperties: string[] = []; - /** Task Filter to use*/ - @Input() - taskFilter: T; - - /** Emitted when a task filter property changes. */ - @Output() - filterChange = new EventEmitter(); - /** Emitted when a filter action occurs (i.e Save, Save As, Delete). */ @Output() action = new EventEmitter(); @@ -138,8 +126,15 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ALL' }; + @Input() + taskFilter: T; + changedTaskFilter: T; + /** Emitted when a task filter property changes. */ + @Output() + filterChange = new EventEmitter(); + protected onDestroy$ = new Subject(); isLoading: boolean = false; @@ -253,20 +248,12 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC .subscribe((applications) => { if (applications && applications.length > 0) { applications.map((application) => { - if (application.environmentId) { - this.applicationNames.push({ label: `${application.name} (${this.getEnvironmentName(application.environmentId)})`, value: application.name }); - } else { - this.applicationNames.push({ label: application.name, value: application.name }); - } + this.applicationNames.push({ label: this.appsProcessCloudService.getApplicationLabel(application, this.environmentList), value: application.name }); }); } }); } - private getEnvironmentName(environmentId: string): string { - return this.environmentList.find((env: any) => env['id'] === environmentId)?.name; - } - getProcessDefinitions() { this.taskCloudService.getProcessDefinitions(this.appName) .subscribe((processDefinitions) => { diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts index 14ce0e96d7..c34664fe2c 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts @@ -36,7 +36,7 @@ import { EditServiceTaskFilterCloudComponent } from './edit-service-task-filter- import { MatIconTestingModule } from '@angular/material/icon/testing'; import { ProcessDefinitionCloud } from '../../../../models/process-definition-cloud.model'; import { TaskFilterDialogCloudComponent } from '../task-filter-dialog/task-filter-dialog-cloud.component'; -import { fakeEnvironmentList } from 'lib/process-services-cloud/src/lib/common/mock/environment.mock'; +import { fakeEnvironmentList } from '../../../../common/mock/environment.mock'; import { mockApplicationTaskFilterProperties } from '../../mock/edit-task-filter-cloud.mock'; describe('EditServiceTaskFilterCloudComponent', () => { @@ -756,7 +756,6 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should add environment name to each application selector option label', () => { component.appName = fakeApplicationInstance[0].name; component.environmentList = fakeEnvironmentList; - component.environmentId = fakeEnvironmentList[0].id; getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); spyOn(component, 'createTaskFilterProperties').and.returnValue(mockApplicationTaskFilterProperties);