mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4155] ProcessServiceCloud - show AppList when service is missing (#4462)
* [ADF-4155] ProcessServiceCloud - show AppList when service is missing * [ADF-4155] - lint * [ADF-4155] - move docs content * [ADF-4155] - reset unnecesary doc file changes * [ADF-4155] - fix unit tests * [ADF-4155] AppListCloudComponent - Fix unit test * [ADF-4155] - remove calls reset * [ADF-4155] - skip app list test * [ADF-4155] - fix unit test * [ADF-4155] - app- list unit test
This commit is contained in:
committed by
Maurizio Vitale
parent
77bad96d0d
commit
0b1e5d31d8
@@ -683,5 +683,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"alfresco-deployed-apps": []
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ Last reviewed: 2019-02-06
|
|||||||
|
|
||||||
# [Process List Cloud Service](../../../lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts "Defined in process-list-cloud.service.ts")
|
# [Process List Cloud Service](../../../lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts "Defined in process-list-cloud.service.ts")
|
||||||
|
|
||||||
Searches processes.
|
Searches processes.
|
||||||
|
|
||||||
## Class members
|
## Class members
|
||||||
|
|
||||||
@@ -23,3 +23,15 @@ Searches processes.
|
|||||||
Note that for a call to `getProcessByRequest`, the
|
Note that for a call to `getProcessByRequest`, the
|
||||||
[`ProcessQueryCloudRequestModel`](../../../lib/process-services-cloud/src/lib/process/process-list/models/process-cloud-query-request.model.ts) object
|
[`ProcessQueryCloudRequestModel`](../../../lib/process-services-cloud/src/lib/process/process-list/models/process-cloud-query-request.model.ts) object
|
||||||
must at minimum have the `appName` property correctly set.
|
must at minimum have the `appName` property correctly set.
|
||||||
|
|
||||||
|
## Activiti 7
|
||||||
|
|
||||||
|
If you are generating a project for activiti7 you need to add in the **app.config.json** the list of the apps that you desire to use.
|
||||||
|
|
||||||
|
For example :
|
||||||
|
|
||||||
|
```json
|
||||||
|
"alfresco-deployed-apps" : [{"name": "simple-app"}]
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information about the app list component refer to the [documentation](https://github.com/Alfresco/alfresco-ng2-components/blob/development/docs/process-services-cloud/app-list-cloud.component.md)
|
||||||
|
@@ -17,34 +17,53 @@
|
|||||||
|
|
||||||
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { setupTestBed, CoreModule } from '@alfresco/adf-core';
|
import { setupTestBed, CoreModule, AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
import { fakeApplicationInstance } from '../mock/app-model.mock';
|
import { fakeApplicationInstance } from '../mock/app-model.mock';
|
||||||
import { AppListCloudComponent } from './app-list-cloud.component';
|
import { AppListCloudComponent } from './app-list-cloud.component';
|
||||||
import { AppsProcessCloudService } from '../services/apps-process-cloud.service';
|
import { AppsProcessCloudService } from '../services/apps-process-cloud.service';
|
||||||
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
|
||||||
import { ApplicationInstanceModel } from '../models/application-instance.model';
|
|
||||||
import { AppListCloudModule } from '../app-list-cloud.module';
|
import { AppListCloudModule } from '../app-list-cloud.module';
|
||||||
|
|
||||||
describe('AppListCloudComponent', () => {
|
describe('AppListCloudComponent', () => {
|
||||||
|
|
||||||
let component: AppListCloudComponent;
|
let component: AppListCloudComponent;
|
||||||
let fixture: ComponentFixture<AppListCloudComponent>;
|
let fixture: ComponentFixture<AppListCloudComponent>;
|
||||||
let service: AppsProcessCloudService;
|
let appsProcessCloudService: AppsProcessCloudService;
|
||||||
let getAppsSpy: jasmine.Spy;
|
let getAppsSpy: jasmine.Spy;
|
||||||
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
|
||||||
setupTestBed({
|
const mock = {
|
||||||
imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule],
|
oauth2Auth: {
|
||||||
providers: [AppsProcessCloudService]
|
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach( async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule],
|
||||||
|
providers: [
|
||||||
|
AppsProcessCloudService
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.overrideComponent(AppListCloudComponent, {
|
||||||
|
set: {
|
||||||
|
providers: [
|
||||||
|
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach( () => {
|
||||||
fixture = TestBed.createComponent(AppListCloudComponent);
|
fixture = TestBed.createComponent(AppListCloudComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
||||||
|
appsProcessCloudService = TestBed.get(AppsProcessCloudService);
|
||||||
|
|
||||||
service = TestBed.get(AppsProcessCloudService);
|
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock);
|
||||||
getAppsSpy = spyOn(service, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
|
getAppsSpy = spyOn(appsProcessCloudService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create AppListCloudComponent ', async(() => {
|
it('should create AppListCloudComponent ', async(() => {
|
||||||
@@ -60,7 +79,7 @@ describe('AppListCloudComponent', () => {
|
|||||||
it('Should fetch deployed apps', async(() => {
|
it('Should fetch deployed apps', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
component.apps$.subscribe((response: ApplicationInstanceModel[]) => {
|
component.apps$.subscribe((response: any[]) => {
|
||||||
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');
|
||||||
@@ -72,8 +91,8 @@ describe('AppListCloudComponent', () => {
|
|||||||
expect(response[1].icon).toEqual('favorite_border');
|
expect(response[1].icon).toEqual('favorite_border');
|
||||||
expect(response[1].theme).toEqual('theme-2');
|
expect(response[1].theme).toEqual('theme-2');
|
||||||
});
|
});
|
||||||
expect(getAppsSpy).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
expect(getAppsSpy).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display default adf-empty-content template when response empty', () => {
|
it('should display default adf-empty-content template when response empty', () => {
|
||||||
|
@@ -20,11 +20,15 @@
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } 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';
|
||||||
|
import { ApplicationDeploymentCloudService } from '../services/app-deployment-cloud.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-cloud-app-list',
|
selector: 'adf-cloud-app-list',
|
||||||
templateUrl: './app-list-cloud.component.html',
|
templateUrl: './app-list-cloud.component.html',
|
||||||
styleUrls: ['./app-list-cloud.component.scss']
|
styleUrls: ['./app-list-cloud.component.scss'],
|
||||||
|
providers: [
|
||||||
|
{ provide: AppsProcessCloudService, useClass: ApplicationDeploymentCloudService }
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class AppListCloudComponent implements OnInit, AfterContentInit {
|
export class AppListCloudComponent implements OnInit, AfterContentInit {
|
||||||
|
|
||||||
|
@@ -0,0 +1,51 @@
|
|||||||
|
/*!
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { AppConfigService, LogService, AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { AppsProcessCloudService } from './apps-process-cloud.service';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ApplicationInstanceModel } from '../models/application-instance.model';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ApplicationDeploymentCloudService extends AppsProcessCloudService {
|
||||||
|
|
||||||
|
deployedApps: ApplicationInstanceModel[];
|
||||||
|
|
||||||
|
constructor(apiService: AlfrescoApiService, logService: LogService, private appConfig: AppConfigService) {
|
||||||
|
super(apiService, logService, appConfig);
|
||||||
|
|
||||||
|
this.loadApps();
|
||||||
|
}
|
||||||
|
|
||||||
|
getDeployedApplicationsByStatus(status: string): Observable<ApplicationInstanceModel[]> {
|
||||||
|
return this.hasDeployedApps() ? of(this.deployedApps) : super.getDeployedApplicationsByStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
hasDeployedApps(): boolean {
|
||||||
|
return this.deployedApps && this.deployedApps.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadApps() {
|
||||||
|
const apps = this.appConfig.get<any>('alfresco-deployed-apps', []);
|
||||||
|
apps.map((app) => {
|
||||||
|
app.theme = app.theme ? app.theme : 'theme-1';
|
||||||
|
app.icon = app.icon ? app.icon : 'favorite';
|
||||||
|
});
|
||||||
|
this.deployedApps = apps;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user