AAE-25417 Align app status to follow state machine (#10348)

This commit is contained in:
Diogo Bastos
2024-10-28 09:58:26 +00:00
committed by GitHub
parent de7ca76225
commit a8dd5fc5d7
8 changed files with 44 additions and 56 deletions

View File

@@ -78,7 +78,7 @@ describe('AppListCloudComponent', () => {
expect(response).toBeDefined(); expect(response).toBeDefined();
expect(response.length).toEqual(3); expect(response.length).toEqual(3);
expect(response[0].name).toEqual('application-new-1'); 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].icon).toEqual('favorite_border');
expect(response[0].theme).toEqual('theme-2'); expect(response[0].theme).toEqual('theme-2');
expect(response[1].name).toEqual('application-new-2'); expect(response[1].name).toEqual('application-new-2');

View File

@@ -16,16 +16,7 @@
*/ */
import { CustomEmptyContentTemplateDirective } from '@alfresco/adf-core'; import { CustomEmptyContentTemplateDirective } from '@alfresco/adf-core';
import { import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
AfterContentInit,
Component,
ContentChild,
EventEmitter,
Input,
OnInit,
Output,
ViewEncapsulation
} from '@angular/core';
import { Observable, of, Subject } from 'rxjs'; import { Observable, of, Subject } from 'rxjs';
import { AppsProcessCloudService } from '../services/apps-process-cloud.service'; import { AppsProcessCloudService } from '../services/apps-process-cloud.service';
import { ApplicationInstanceModel } from '../models/application-instance.model'; 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_LIST: string = 'LIST';
export const LAYOUT_GRID: string = 'GRID'; export const LAYOUT_GRID: string = 'GRID';
export const RUNNING_STATUS: string = 'RUNNING'; export const DEPLOYED_STATUS: string = 'DEPLOYED';
@Component({ @Component({
selector: 'adf-cloud-app-list', selector: 'adf-cloud-app-list',
@@ -60,20 +51,19 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
loadingError$ = new Subject<boolean>(); loadingError$ = new Subject<boolean>();
hasEmptyCustomContentTemplate: boolean = false; hasEmptyCustomContentTemplate: boolean = false;
constructor(private appsProcessCloudService: AppsProcessCloudService) { } constructor(private appsProcessCloudService: AppsProcessCloudService) {}
ngOnInit() { ngOnInit() {
if (!this.isValidType()) { if (!this.isValidType()) {
this.setDefaultLayoutType(); this.setDefaultLayoutType();
} }
this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(RUNNING_STATUS) this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(DEPLOYED_STATUS).pipe(
.pipe( catchError(() => {
catchError(() => { this.loadingError$.next(true);
this.loadingError$.next(true); return of();
return of(); })
}) );
);
} }
ngAfterContentInit() { ngAfterContentInit() {

View File

@@ -23,7 +23,7 @@ export const fakeApplicationInstance: ApplicationInstanceModel[] = [
name: 'application-new-1', name: 'application-new-1',
displayName: 'application-new-1', displayName: 'application-new-1',
createdAt: '2018-09-21T12:31:39.000Z', createdAt: '2018-09-21T12:31:39.000Z',
status: 'Running', status: 'Deployed',
theme: 'theme-2', theme: 'theme-2',
icon: 'favorite_border' icon: 'favorite_border'
}, },
@@ -49,7 +49,7 @@ export const fakeApplicationInstanceWithEnvironment: ApplicationInstanceModel[]
displayName: 'application-new-1', displayName: 'application-new-1',
environmentId: fakeEnvironmentList[0].id, environmentId: fakeEnvironmentList[0].id,
createdAt: '2018-09-21T12:31:39.000Z', createdAt: '2018-09-21T12:31:39.000Z',
status: 'Running', status: 'Deployed',
theme: 'theme-2', theme: 'theme-2',
icon: 'favorite_border' icon: 'favorite_border'
}, },

View File

@@ -72,7 +72,7 @@ describe('EditProcessFilterCloudComponent', () => {
let dialog: MatDialog; let dialog: MatDialog;
let appsService: AppsProcessCloudService; let appsService: AppsProcessCloudService;
let processService: ProcessCloudService; let processService: ProcessCloudService;
let getRunningApplicationsSpy: jasmine.Spy; let getDeployedApplicationsSpy: jasmine.Spy;
let getProcessFilterByIdSpy: jasmine.Spy; let getProcessFilterByIdSpy: jasmine.Spy;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
let userPreferencesService: UserPreferencesService; let userPreferencesService: UserPreferencesService;
@@ -145,7 +145,7 @@ describe('EditProcessFilterCloudComponent', () => {
}) })
} as any); } as any);
getProcessFilterByIdSpy = spyOn(service, 'getFilterById').and.returnValue(of(fakeFilter)); 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(alfrescoApiService, 'getInstance').and.returnValue(mock);
spyOn(userPreferencesService, 'select').and.returnValue(of({ localize: 'en', formatLong: {} })); spyOn(userPreferencesService, 'select').and.returnValue(of({ localize: 'en', formatLong: {} }));
fixture.detectChanges(); fixture.detectChanges();
@@ -561,7 +561,7 @@ describe('EditProcessFilterCloudComponent', () => {
expect(orderController.value).toEqual('ASC'); 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']; component.filterProperties = ['appName', 'processName'];
fixture.detectChanges(); fixture.detectChanges();
@@ -575,7 +575,7 @@ describe('EditProcessFilterCloudComponent', () => {
const appController = component.editProcessFilterForm.get('appName'); const appController = component.editProcessFilterForm.get('appName');
expect(getRunningApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(appController).toBeDefined(); expect(appController).toBeDefined();
expect(appController.value).toEqual('mock-app-name'); expect(appController.value).toEqual('mock-app-name');
}); });
@@ -594,7 +594,7 @@ describe('EditProcessFilterCloudComponent', () => {
const appController = component.editProcessFilterForm.get('appName'); const appController = component.editProcessFilterForm.get('appName');
const appVersionController = component.editProcessFilterForm.get('appVersion'); const appVersionController = component.editProcessFilterForm.get('appVersion');
expect(getRunningApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(appController).toBeDefined(); expect(appController).toBeDefined();
expect(appController.value).toEqual('mock-app-name'); expect(appController.value).toEqual('mock-app-name');
expect(appVersionController).toBeDefined(); expect(appVersionController).toBeDefined();
@@ -767,7 +767,7 @@ describe('EditProcessFilterCloudComponent', () => {
component.ngOnChanges({ id: processFilterIdChange2 }); component.ngOnChanges({ id: processFilterIdChange2 });
fixture.detectChanges(); fixture.detectChanges();
expect(getRunningApplicationsSpy).toHaveBeenCalledTimes(2); expect(getDeployedApplicationsSpy).toHaveBeenCalledTimes(2);
expect(component.applicationNames).toBeTruthy(); expect(component.applicationNames).toBeTruthy();
expect(component.applicationNames).toBe(formerProcessDefinitions); expect(component.applicationNames).toBe(formerProcessDefinitions);
}); });
@@ -1266,8 +1266,8 @@ describe('EditProcessFilterCloudComponent', () => {
component.environmentList = fakeEnvironmentList; component.environmentList = fakeEnvironmentList;
component.environmentId = fakeEnvironmentList[0].id; component.environmentId = fakeEnvironmentList[0].id;
getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); getDeployedApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment));
component.getRunningApplications(); component.getDeployedApplications();
expect(component.applicationNames[0].label).toBe('application-new-1 (test-env-name-1)'); expect(component.applicationNames[0].label).toBe('application-new-1 (test-env-name-1)');
}); });
}); });

View File

@@ -305,7 +305,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
this.checkMandatoryFilterProperties(); this.checkMandatoryFilterProperties();
if (this.filterProperties.includes('appName')) { if (this.filterProperties.includes('appName')) {
this.getRunningApplications(); this.getDeployedApplications();
} }
if (this.filterProperties.includes('processDefinitionName')) { 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(); return JSON.stringify(editedQuery).toLowerCase() === JSON.stringify(currentQuery).toLowerCase();
} }
getRunningApplications() { getDeployedApplications() {
this.appsProcessCloudService.getDeployedApplicationsByStatus('RUNNING', this.role).subscribe((applications) => { this.appsProcessCloudService.getDeployedApplicationsByStatus('DEPLOYED', this.role).subscribe((applications) => {
if (applications && applications.length > 0) { if (applications && applications.length > 0) {
this.applicationNames.length = 0; this.applicationNames.length = 0;
applications.map((application) => { applications.map((application) => {

View File

@@ -43,7 +43,7 @@ export interface DropdownOption {
const ACTION_SAVE = 'save'; const ACTION_SAVE = 'save';
const ACTION_SAVE_AS = 'saveAs'; const ACTION_SAVE_AS = 'saveAs';
const ACTION_DELETE = 'delete'; const ACTION_DELETE = 'delete';
const APP_RUNNING_STATUS = 'RUNNING'; const APP_DEPLOYED_STATUS = 'DEPLOYED';
const APPLICATION_NAME = 'appName'; const APPLICATION_NAME = 'appName';
const PROCESS_DEFINITION_NAME = 'processDefinitionName'; const PROCESS_DEFINITION_NAME = 'processDefinitionName';
const LAST_MODIFIED_PROPERTY = 'lastModified'; const LAST_MODIFIED_PROPERTY = 'lastModified';
@@ -239,19 +239,17 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
} }
} }
getRunningApplications() { getDeployedApplications() {
this.appsProcessCloudService this.appsProcessCloudService.getDeployedApplicationsByStatus(APP_DEPLOYED_STATUS, this.role).subscribe((applications) => {
.getDeployedApplicationsByStatus(APP_RUNNING_STATUS, this.role) if (applications && applications.length > 0) {
.subscribe((applications) => { applications.map((application) => {
if (applications && applications.length > 0) { this.applicationNames.push({
applications.map((application) => { label: this.appsProcessCloudService.getApplicationLabel(application, this.environmentList),
this.applicationNames.push({ value: application.name
label: this.appsProcessCloudService.getApplicationLabel(application, this.environmentList),
value: application.name
});
}); });
} });
}); }
});
} }
getProcessDefinitions() { getProcessDefinitions() {
@@ -407,7 +405,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
if (this.checkForProperty(APPLICATION_NAME)) { if (this.checkForProperty(APPLICATION_NAME)) {
this.applicationNames = []; this.applicationNames = [];
this.getRunningApplications(); this.getDeployedApplications();
} }
if (this.checkForProperty(PROCESS_DEFINITION_NAME)) { if (this.checkForProperty(PROCESS_DEFINITION_NAME)) {
this.processDefinitionNames = []; this.processDefinitionNames = [];

View File

@@ -48,7 +48,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
let fixture: ComponentFixture<EditServiceTaskFilterCloudComponent>; let fixture: ComponentFixture<EditServiceTaskFilterCloudComponent>;
let dialog: MatDialog; let dialog: MatDialog;
let getTaskFilterSpy: jasmine.Spy; let getTaskFilterSpy: jasmine.Spy;
let getRunningApplicationsSpy: jasmine.Spy; let getDeployedApplicationsSpy: jasmine.Spy;
let taskService: TaskCloudService; let taskService: TaskCloudService;
const afterClosedSubject = new Subject<any>(); const afterClosedSubject = new Subject<any>();
@@ -68,7 +68,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
}; };
spyOn(dialog, 'open').and.returnValue(dialogRefMock); spyOn(dialog, 'open').and.returnValue(dialogRefMock);
getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeServiceFilter)); 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(); fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture); loader = TestbedHarnessEnvironment.loader(fixture);
}); });
@@ -424,7 +424,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
expect(activityNameController.value).toBe('fake-activity'); 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']; component.filterProperties = ['appName', 'processInstanceId', 'priority'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
@@ -434,7 +434,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(getRunningApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(appController).toBeDefined(); expect(appController).toBeDefined();
expect(appController.value).toBe('mock-app-name'); expect(appController.value).toBe('mock-app-name');
}); });
@@ -680,7 +680,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
component.appName = fakeApplicationInstance[0].name; component.appName = fakeApplicationInstance[0].name;
component.environmentList = fakeEnvironmentList; component.environmentList = fakeEnvironmentList;
getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment)); getDeployedApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment));
spyOn(component, 'createTaskFilterProperties').and.returnValue(mockApplicationTaskFilterProperties); spyOn(component, 'createTaskFilterProperties').and.returnValue(mockApplicationTaskFilterProperties);
const filteredProperties = component.createAndFilterProperties(); const filteredProperties = component.createAndFilterProperties();

View File

@@ -68,7 +68,7 @@ describe('EditTaskFilterCloudComponent', () => {
let dialog: MatDialog; let dialog: MatDialog;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
let getTaskFilterSpy: jasmine.Spy; let getTaskFilterSpy: jasmine.Spy;
let getRunningApplicationsSpy: jasmine.Spy; let getDeployedApplicationsSpy: jasmine.Spy;
let taskService: TaskCloudService; let taskService: TaskCloudService;
const afterClosedSubject = new Subject<any>(); const afterClosedSubject = new Subject<any>();
@@ -91,7 +91,7 @@ describe('EditTaskFilterCloudComponent', () => {
spyOn(dialog, 'open').and.returnValue(dialogRefMock); spyOn(dialog, 'open').and.returnValue(dialogRefMock);
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mockAlfrescoApi); spyOn(alfrescoApiService, 'getInstance').and.returnValue(mockAlfrescoApi);
getTaskFilterSpy = spyOn(service, 'getTaskFilterById').and.returnValue(of(fakeFilter)); 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(); fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture); loader = TestbedHarnessEnvironment.loader(fixture);
}); });
@@ -506,7 +506,7 @@ describe('EditTaskFilterCloudComponent', () => {
expect(orderController.value).toBe('ASC'); 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']; component.filterProperties = ['appName', 'processInstanceId', 'priority'];
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ id: mockTaskFilterIdChange }); component.ngOnChanges({ id: mockTaskFilterIdChange });
@@ -515,7 +515,7 @@ describe('EditTaskFilterCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(getRunningApplicationsSpy).toHaveBeenCalled(); expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(appController).toBeDefined(); expect(appController).toBeDefined();
expect(appController.value).toBe('mock-app-name'); expect(appController.value).toBe('mock-app-name');
}); });