[ACA-3245] Fetch alfresco repo name from an API (#5676)

* [ACA-3245] Fetch alfresco repo name from an API

* [ACA-3245] Take the repo name from the API only when it is not defined in the app config

* [ACA-3245] Remo alfresco-1 as default in app.config service

* [ACA-3245] Remove passing null argument when calling getRepositories function

* [ACA-3245] Revert removing function parameter includeAccounts

* [ACA-3245] Add tenantId as optional

* [ACA-3245] Revert method

* [ACA-3245] Change both parameters to optional

* [ACA-3245] Rename param
This commit is contained in:
arditdomi 2020-05-13 20:56:29 +01:00 committed by GitHub
parent f6801b1997
commit a8c252db8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 23 deletions

View File

@ -62,8 +62,7 @@ export class AppConfigService {
},
ecmHost: 'http://{hostname}{:port}/ecm',
bpmHost: 'http://{hostname}{:port}/bpm',
logLevel: 'silent',
alfrescoRepositoryName: 'alfresco-1'
logLevel: 'silent'
};
status: Status = Status.INIT;

View File

@ -54,15 +54,14 @@ export class ActivitiContentService {
/**
* Returns a list of all the repositories configured
*
* @param accountId
* @param folderId
* @param tenantId
* @param includeAccount
*/
getAlfrescoRepositories(tenantId: number, includeAccount: boolean): Observable<any> {
getAlfrescoRepositories(tenantId?: number, includeAccount?: boolean): Observable<any> {
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
const opts = {
tenantId: tenantId,
includeAccounts: includeAccount
tenantId,
includeAccounts: includeAccount ? includeAccount : true
};
return from(apiService.activiti.alfrescoApi.getRepositories(opts))
.pipe(

View File

@ -76,7 +76,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
ngOnInit() {
super.ngOnInit();
this.activitiContentService.getAlfrescoRepositories(null, true).subscribe((repoList) => {
this.activitiContentService.getAlfrescoRepositories().subscribe((repoList) => {
this.repositoryList = repoList;
});

View File

@ -54,7 +54,6 @@ describe('StartFormComponent', () => {
});
const selectOptionByName = (name: string) => {
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
selectElement.click();
fixture.detectChanges();
@ -78,6 +77,7 @@ describe('StartFormComponent', () => {
startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(of(newProcess));
getStartFormDefinitionSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(of(taskFormMock));
applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of({ id: 1234 }));
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of([{ id: '1', name: 'fake-repo-name'}]));
});
afterEach(() => {
@ -205,15 +205,7 @@ describe('StartFormComponent', () => {
describe('CS content connection', () => {
it('alfrescoRepositoryName default configuration property', () => {
appConfig.config = Object.assign(appConfig.config, {
'alfrescoRepositoryName': null
});
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-1Alfresco');
});
it('alfrescoRepositoryName configuration property should be fetched', () => {
it('Should get the alfrescoRepositoryName from the config json', async () => {
appConfig.config = Object.assign(appConfig.config, {
'alfrescoRepositoryName': 'alfresco-123'
});
@ -221,8 +213,13 @@ describe('StartFormComponent', () => {
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-123Alfresco');
});
it('if values in input is a node should be linked in the process service', async(() => {
it('Should take the alfrescoRepositoryName from the API when there is no alfrescoRepositoryName defined in config json', async () => {
fixture.detectChanges();
await fixture.whenStable();
expect(component.alfrescoRepositoryName).toBe('alfresco-1-fake-repo-name');
});
it('if values in input is a node should be linked in the process service', async(() => {
component.values = {};
component.values['file'] = {
isFile: true,
@ -238,7 +235,6 @@ describe('StartFormComponent', () => {
}));
it('if values in input is a collection of nodes should be linked in the process service', async(() => {
component.values = {};
component.values['file'] = [
{

View File

@ -20,7 +20,9 @@ import {
Output, SimpleChanges, ViewChild, ViewEncapsulation, OnDestroy
} from '@angular/core';
import {
ActivitiContentService, AppConfigService, AppConfigValues,
ActivitiContentService,
AppConfigService,
AppConfigValues,
FormValues
} from '@alfresco/adf-core';
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
@ -108,6 +110,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
processDefinitionInput: FormControl;
filteredProcesses: Observable<ProcessDefinitionRepresentation[]>;
maxProcessNameLength: number = this.MAX_LENGTH;
alfrescoRepositoryName: string;
private onDestroy$ = new Subject<boolean>();
@ -131,6 +134,13 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
map((value) => this._filter(value)),
takeUntil(this.onDestroy$)
);
this.activitiContentService.getAlfrescoRepositories().subscribe((repoList) => {
if (repoList && repoList[0]) {
const alfrescoRepository = repoList[0];
this.alfrescoRepositoryName = `alfresco-${alfrescoRepository.id}-${alfrescoRepository.name}`;
}
});
}
ngOnDestroy() {
@ -211,7 +221,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
getAlfrescoRepositoryName(): string {
let alfrescoRepositoryName = this.appConfig.get<string>(AppConfigValues.ALFRESCO_REPOSITORY_NAME);
if (!alfrescoRepositoryName) {
alfrescoRepositoryName = 'alfresco-1';
alfrescoRepositoryName = this.alfrescoRepositoryName;
}
return alfrescoRepositoryName + 'Alfresco';
}