mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-25417 Align app status to follow state machine (#10348)
This commit is contained in:
@@ -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');
|
||||
|
@@ -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<boolean>();
|
||||
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() {
|
||||
|
@@ -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'
|
||||
},
|
||||
|
@@ -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)');
|
||||
});
|
||||
});
|
||||
|
@@ -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) => {
|
||||
|
@@ -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<T> 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<T> implements OnInit, OnC
|
||||
|
||||
if (this.checkForProperty(APPLICATION_NAME)) {
|
||||
this.applicationNames = [];
|
||||
this.getRunningApplications();
|
||||
this.getDeployedApplications();
|
||||
}
|
||||
if (this.checkForProperty(PROCESS_DEFINITION_NAME)) {
|
||||
this.processDefinitionNames = [];
|
||||
|
@@ -48,7 +48,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
let fixture: ComponentFixture<EditServiceTaskFilterCloudComponent>;
|
||||
let dialog: MatDialog;
|
||||
let getTaskFilterSpy: jasmine.Spy;
|
||||
let getRunningApplicationsSpy: jasmine.Spy;
|
||||
let getDeployedApplicationsSpy: jasmine.Spy;
|
||||
let taskService: TaskCloudService;
|
||||
const afterClosedSubject = new Subject<any>();
|
||||
|
||||
@@ -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();
|
||||
|
@@ -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<any>();
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
Reference in New Issue
Block a user