From a8dd5fc5d7f616bc7ef6d192e5083040ca94a248 Mon Sep 17 00:00:00 2001 From: Diogo Bastos <50139916+DiogoABastos@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:58:26 +0000 Subject: [PATCH] AAE-25417 Align app status to follow state machine (#10348) --- .../app-list-cloud.component.spec.ts | 2 +- .../components/app-list-cloud.component.ts | 28 ++++++------------- .../src/lib/app/mock/app-model.mock.ts | 4 +-- ...dit-process-filter-cloud.component.spec.ts | 16 +++++------ .../edit-process-filter-cloud.component.ts | 6 ++-- .../base-edit-task-filter-cloud.component.ts | 26 ++++++++--------- ...ervice-task-filter-cloud.component.spec.ts | 10 +++---- .../edit-task-filter-cloud.component.spec.ts | 8 +++--- 8 files changed, 44 insertions(+), 56 deletions(-) diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts index 799dfb72d1..1f2417fefe 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts @@ -78,7 +78,7 @@ describe('AppListCloudComponent', () => { expect(response).toBeDefined(); expect(response.length).toEqual(3); expect(response[0].name).toEqual('application-new-1'); - expect(response[0].status).toEqual('Running'); + expect(response[0].status).toEqual('Deployed'); expect(response[0].icon).toEqual('favorite_border'); expect(response[0].theme).toEqual('theme-2'); expect(response[1].name).toEqual('application-new-2'); diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts index 402682a90c..35a0ee41ee 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts @@ -16,16 +16,7 @@ */ import { CustomEmptyContentTemplateDirective } from '@alfresco/adf-core'; -import { - AfterContentInit, - Component, - ContentChild, - EventEmitter, - Input, - OnInit, - Output, - ViewEncapsulation -} from '@angular/core'; +import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { Observable, of, Subject } from 'rxjs'; import { AppsProcessCloudService } from '../services/apps-process-cloud.service'; import { ApplicationInstanceModel } from '../models/application-instance.model'; @@ -33,7 +24,7 @@ import { catchError } from 'rxjs/operators'; export const LAYOUT_LIST: string = 'LIST'; export const LAYOUT_GRID: string = 'GRID'; -export const RUNNING_STATUS: string = 'RUNNING'; +export const DEPLOYED_STATUS: string = 'DEPLOYED'; @Component({ selector: 'adf-cloud-app-list', @@ -60,20 +51,19 @@ export class AppListCloudComponent implements OnInit, AfterContentInit { loadingError$ = new Subject(); hasEmptyCustomContentTemplate: boolean = false; - constructor(private appsProcessCloudService: AppsProcessCloudService) { } + constructor(private appsProcessCloudService: AppsProcessCloudService) {} ngOnInit() { if (!this.isValidType()) { this.setDefaultLayoutType(); } - this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(RUNNING_STATUS) - .pipe( - catchError(() => { - this.loadingError$.next(true); - return of(); - }) - ); + this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(DEPLOYED_STATUS).pipe( + catchError(() => { + this.loadingError$.next(true); + return of(); + }) + ); } ngAfterContentInit() { 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 0f261f8af1..48c8b5407b 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 @@ -23,7 +23,7 @@ export const fakeApplicationInstance: ApplicationInstanceModel[] = [ name: 'application-new-1', displayName: 'application-new-1', createdAt: '2018-09-21T12:31:39.000Z', - status: 'Running', + status: 'Deployed', theme: 'theme-2', icon: 'favorite_border' }, @@ -49,7 +49,7 @@ export const fakeApplicationInstanceWithEnvironment: ApplicationInstanceModel[] displayName: 'application-new-1', environmentId: fakeEnvironmentList[0].id, createdAt: '2018-09-21T12:31:39.000Z', - status: 'Running', + status: 'Deployed', theme: 'theme-2', icon: 'favorite_border' }, diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts index af281965d8..92bb7811ab 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts @@ -72,7 +72,7 @@ describe('EditProcessFilterCloudComponent', () => { let dialog: MatDialog; let appsService: AppsProcessCloudService; let processService: ProcessCloudService; - let getRunningApplicationsSpy: jasmine.Spy; + let getDeployedApplicationsSpy: jasmine.Spy; let getProcessFilterByIdSpy: jasmine.Spy; let alfrescoApiService: AlfrescoApiService; let userPreferencesService: UserPreferencesService; @@ -145,7 +145,7 @@ describe('EditProcessFilterCloudComponent', () => { }) } as any); getProcessFilterByIdSpy = spyOn(service, 'getFilterById').and.returnValue(of(fakeFilter)); - getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); + getDeployedApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock); spyOn(userPreferencesService, 'select').and.returnValue(of({ localize: 'en', formatLong: {} })); fixture.detectChanges(); @@ -561,7 +561,7 @@ describe('EditProcessFilterCloudComponent', () => { expect(orderController.value).toEqual('ASC'); }); - it('should able to fetch running applications when appName property defined in the input', async () => { + it('should able to fetch deployed applications when appName property defined in the input', async () => { component.filterProperties = ['appName', 'processName']; fixture.detectChanges(); @@ -575,7 +575,7 @@ describe('EditProcessFilterCloudComponent', () => { const appController = component.editProcessFilterForm.get('appName'); - expect(getRunningApplicationsSpy).toHaveBeenCalled(); + expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(appController).toBeDefined(); expect(appController.value).toEqual('mock-app-name'); }); @@ -594,7 +594,7 @@ describe('EditProcessFilterCloudComponent', () => { const appController = component.editProcessFilterForm.get('appName'); const appVersionController = component.editProcessFilterForm.get('appVersion'); - expect(getRunningApplicationsSpy).toHaveBeenCalled(); + expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(appController).toBeDefined(); expect(appController.value).toEqual('mock-app-name'); expect(appVersionController).toBeDefined(); @@ -767,7 +767,7 @@ describe('EditProcessFilterCloudComponent', () => { component.ngOnChanges({ id: processFilterIdChange2 }); fixture.detectChanges(); - expect(getRunningApplicationsSpy).toHaveBeenCalledTimes(2); + expect(getDeployedApplicationsSpy).toHaveBeenCalledTimes(2); expect(component.applicationNames).toBeTruthy(); expect(component.applicationNames).toBe(formerProcessDefinitions); }); @@ -1266,8 +1266,8 @@ describe('EditProcessFilterCloudComponent', () => { component.environmentList = fakeEnvironmentList; component.environmentId = fakeEnvironmentList[0].id; - getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); - component.getRunningApplications(); + getDeployedApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); + component.getDeployedApplications(); expect(component.applicationNames[0].label).toBe('application-new-1 (test-env-name-1)'); }); }); 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 bed8034971..3000825c23 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 @@ -305,7 +305,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes this.checkMandatoryFilterProperties(); if (this.filterProperties.includes('appName')) { - this.getRunningApplications(); + this.getDeployedApplications(); } if (this.filterProperties.includes('processDefinitionName')) { @@ -434,8 +434,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes return JSON.stringify(editedQuery).toLowerCase() === JSON.stringify(currentQuery).toLowerCase(); } - getRunningApplications() { - this.appsProcessCloudService.getDeployedApplicationsByStatus('RUNNING', this.role).subscribe((applications) => { + getDeployedApplications() { + this.appsProcessCloudService.getDeployedApplicationsByStatus('DEPLOYED', this.role).subscribe((applications) => { if (applications && applications.length > 0) { this.applicationNames.length = 0; applications.map((application) => { 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 a57d2927c4..c93162d833 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 @@ -43,7 +43,7 @@ export interface DropdownOption { const ACTION_SAVE = 'save'; const ACTION_SAVE_AS = 'saveAs'; const ACTION_DELETE = 'delete'; -const APP_RUNNING_STATUS = 'RUNNING'; +const APP_DEPLOYED_STATUS = 'DEPLOYED'; const APPLICATION_NAME = 'appName'; const PROCESS_DEFINITION_NAME = 'processDefinitionName'; const LAST_MODIFIED_PROPERTY = 'lastModified'; @@ -239,19 +239,17 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC } } - getRunningApplications() { - this.appsProcessCloudService - .getDeployedApplicationsByStatus(APP_RUNNING_STATUS, this.role) - .subscribe((applications) => { - if (applications && applications.length > 0) { - applications.map((application) => { - this.applicationNames.push({ - label: this.appsProcessCloudService.getApplicationLabel(application, this.environmentList), - value: application.name - }); + getDeployedApplications() { + this.appsProcessCloudService.getDeployedApplicationsByStatus(APP_DEPLOYED_STATUS, this.role).subscribe((applications) => { + if (applications && applications.length > 0) { + applications.map((application) => { + this.applicationNames.push({ + label: this.appsProcessCloudService.getApplicationLabel(application, this.environmentList), + value: application.name }); - } - }); + }); + } + }); } getProcessDefinitions() { @@ -407,7 +405,7 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC if (this.checkForProperty(APPLICATION_NAME)) { this.applicationNames = []; - this.getRunningApplications(); + this.getDeployedApplications(); } if (this.checkForProperty(PROCESS_DEFINITION_NAME)) { this.processDefinitionNames = []; 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 dab0a9da56..9905455fc9 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 @@ -48,7 +48,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { let fixture: ComponentFixture; let dialog: MatDialog; let getTaskFilterSpy: jasmine.Spy; - let getRunningApplicationsSpy: jasmine.Spy; + let getDeployedApplicationsSpy: jasmine.Spy; let taskService: TaskCloudService; const afterClosedSubject = new Subject(); @@ -68,7 +68,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { }; spyOn(dialog, 'open').and.returnValue(dialogRefMock); getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeServiceFilter)); - getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); + getDeployedApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); }); @@ -424,7 +424,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { expect(activityNameController.value).toBe('fake-activity'); }); - it('should able to fetch running applications when appName property defined in the input', async () => { + it('should able to fetch deployed applications when appName property defined in the input', async () => { component.filterProperties = ['appName', 'processInstanceId', 'priority']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); @@ -434,7 +434,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - expect(getRunningApplicationsSpy).toHaveBeenCalled(); + expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(appController).toBeDefined(); expect(appController.value).toBe('mock-app-name'); }); @@ -680,7 +680,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { component.appName = fakeApplicationInstance[0].name; component.environmentList = fakeEnvironmentList; - getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); + getDeployedApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); spyOn(component, 'createTaskFilterProperties').and.returnValue(mockApplicationTaskFilterProperties); const filteredProperties = component.createAndFilterProperties(); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts index cde511d7f5..8e0481f505 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts @@ -68,7 +68,7 @@ describe('EditTaskFilterCloudComponent', () => { let dialog: MatDialog; let alfrescoApiService: AlfrescoApiService; let getTaskFilterSpy: jasmine.Spy; - let getRunningApplicationsSpy: jasmine.Spy; + let getDeployedApplicationsSpy: jasmine.Spy; let taskService: TaskCloudService; const afterClosedSubject = new Subject(); @@ -91,7 +91,7 @@ describe('EditTaskFilterCloudComponent', () => { spyOn(dialog, 'open').and.returnValue(dialogRefMock); spyOn(alfrescoApiService, 'getInstance').and.returnValue(mockAlfrescoApi); getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeFilter)); - getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); + getDeployedApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); }); @@ -506,7 +506,7 @@ describe('EditTaskFilterCloudComponent', () => { expect(orderController.value).toBe('ASC'); }); - it('should able to fetch running applications when appName property defined in the input', async () => { + it('should able to fetch deployed applications when appName property defined in the input', async () => { component.filterProperties = ['appName', 'processInstanceId', 'priority']; fixture.detectChanges(); component.ngOnChanges({ id: mockTaskFilterIdChange }); @@ -515,7 +515,7 @@ describe('EditTaskFilterCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - expect(getRunningApplicationsSpy).toHaveBeenCalled(); + expect(getDeployedApplicationsSpy).toHaveBeenCalled(); expect(appController).toBeDefined(); expect(appController.value).toBe('mock-app-name'); });