diff --git a/lib/core/app-config/app-config.service.ts b/lib/core/app-config/app-config.service.ts index 9487c5078b..56e73cd9ed 100644 --- a/lib/core/app-config/app-config.service.ts +++ b/lib/core/app-config/app-config.service.ts @@ -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; diff --git a/lib/core/form/services/activiti-alfresco.service.ts b/lib/core/form/services/activiti-alfresco.service.ts index afb8af1a25..c6f1d0b716 100644 --- a/lib/core/form/services/activiti-alfresco.service.ts +++ b/lib/core/form/services/activiti-alfresco.service.ts @@ -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 { + getAlfrescoRepositories(tenantId?: number, includeAccount?: boolean): Observable { 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( diff --git a/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts b/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts index 0953535f12..6195cbe32d 100644 --- a/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts +++ b/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts @@ -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; }); diff --git a/lib/process-services/src/lib/process-list/components/start-process.component.spec.ts b/lib/process-services/src/lib/process-list/components/start-process.component.spec.ts index 1fab27e327..f47f1aa81f 100644 --- a/lib/process-services/src/lib/process-list/components/start-process.component.spec.ts +++ b/lib/process-services/src/lib/process-list/components/start-process.component.spec.ts @@ -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'] = [ { diff --git a/lib/process-services/src/lib/process-list/components/start-process.component.ts b/lib/process-services/src/lib/process-list/components/start-process.component.ts index 5a71edfed4..642541edfc 100644 --- a/lib/process-services/src/lib/process-list/components/start-process.component.ts +++ b/lib/process-services/src/lib/process-list/components/start-process.component.ts @@ -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; maxProcessNameLength: number = this.MAX_LENGTH; + alfrescoRepositoryName: string; private onDestroy$ = new Subject(); @@ -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(AppConfigValues.ALFRESCO_REPOSITORY_NAME); if (!alfrescoRepositoryName) { - alfrescoRepositoryName = 'alfresco-1'; + alfrescoRepositoryName = this.alfrescoRepositoryName; } return alfrescoRepositoryName + 'Alfresco'; }