mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[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:
parent
f6801b1997
commit
a8c252db8b
@ -62,8 +62,7 @@ export class AppConfigService {
|
|||||||
},
|
},
|
||||||
ecmHost: 'http://{hostname}{:port}/ecm',
|
ecmHost: 'http://{hostname}{:port}/ecm',
|
||||||
bpmHost: 'http://{hostname}{:port}/bpm',
|
bpmHost: 'http://{hostname}{:port}/bpm',
|
||||||
logLevel: 'silent',
|
logLevel: 'silent'
|
||||||
alfrescoRepositoryName: 'alfresco-1'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
status: Status = Status.INIT;
|
status: Status = Status.INIT;
|
||||||
|
@ -54,15 +54,14 @@ export class ActivitiContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all the repositories configured
|
* Returns a list of all the repositories configured
|
||||||
*
|
* @param tenantId
|
||||||
* @param accountId
|
* @param includeAccount
|
||||||
* @param folderId
|
|
||||||
*/
|
*/
|
||||||
getAlfrescoRepositories(tenantId: number, includeAccount: boolean): Observable<any> {
|
getAlfrescoRepositories(tenantId?: number, includeAccount?: boolean): Observable<any> {
|
||||||
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||||
const opts = {
|
const opts = {
|
||||||
tenantId: tenantId,
|
tenantId,
|
||||||
includeAccounts: includeAccount
|
includeAccounts: includeAccount ? includeAccount : true
|
||||||
};
|
};
|
||||||
return from(apiService.activiti.alfrescoApi.getRepositories(opts))
|
return from(apiService.activiti.alfrescoApi.getRepositories(opts))
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@ -76,7 +76,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
|
||||||
this.activitiContentService.getAlfrescoRepositories(null, true).subscribe((repoList) => {
|
this.activitiContentService.getAlfrescoRepositories().subscribe((repoList) => {
|
||||||
this.repositoryList = repoList;
|
this.repositoryList = repoList;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ describe('StartFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const selectOptionByName = (name: string) => {
|
const selectOptionByName = (name: string) => {
|
||||||
|
|
||||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||||
selectElement.click();
|
selectElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -78,6 +77,7 @@ describe('StartFormComponent', () => {
|
|||||||
startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(of(newProcess));
|
startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(of(newProcess));
|
||||||
getStartFormDefinitionSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(of(taskFormMock));
|
getStartFormDefinitionSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(of(taskFormMock));
|
||||||
applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of({ id: 1234 }));
|
applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of({ id: 1234 }));
|
||||||
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of([{ id: '1', name: 'fake-repo-name'}]));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -205,15 +205,7 @@ describe('StartFormComponent', () => {
|
|||||||
|
|
||||||
describe('CS content connection', () => {
|
describe('CS content connection', () => {
|
||||||
|
|
||||||
it('alfrescoRepositoryName default configuration property', () => {
|
it('Should get the alfrescoRepositoryName from the config json', async () => {
|
||||||
appConfig.config = Object.assign(appConfig.config, {
|
|
||||||
'alfrescoRepositoryName': null
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-1Alfresco');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('alfrescoRepositoryName configuration property should be fetched', () => {
|
|
||||||
appConfig.config = Object.assign(appConfig.config, {
|
appConfig.config = Object.assign(appConfig.config, {
|
||||||
'alfrescoRepositoryName': 'alfresco-123'
|
'alfrescoRepositoryName': 'alfresco-123'
|
||||||
});
|
});
|
||||||
@ -221,8 +213,13 @@ describe('StartFormComponent', () => {
|
|||||||
expect(component.getAlfrescoRepositoryName()).toBe('alfresco-123Alfresco');
|
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 = {};
|
||||||
component.values['file'] = {
|
component.values['file'] = {
|
||||||
isFile: true,
|
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(() => {
|
it('if values in input is a collection of nodes should be linked in the process service', async(() => {
|
||||||
|
|
||||||
component.values = {};
|
component.values = {};
|
||||||
component.values['file'] = [
|
component.values['file'] = [
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,9 @@ import {
|
|||||||
Output, SimpleChanges, ViewChild, ViewEncapsulation, OnDestroy
|
Output, SimpleChanges, ViewChild, ViewEncapsulation, OnDestroy
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ActivitiContentService, AppConfigService, AppConfigValues,
|
ActivitiContentService,
|
||||||
|
AppConfigService,
|
||||||
|
AppConfigValues,
|
||||||
FormValues
|
FormValues
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||||
@ -108,6 +110,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
processDefinitionInput: FormControl;
|
processDefinitionInput: FormControl;
|
||||||
filteredProcesses: Observable<ProcessDefinitionRepresentation[]>;
|
filteredProcesses: Observable<ProcessDefinitionRepresentation[]>;
|
||||||
maxProcessNameLength: number = this.MAX_LENGTH;
|
maxProcessNameLength: number = this.MAX_LENGTH;
|
||||||
|
alfrescoRepositoryName: string;
|
||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
@ -131,6 +134,13 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
map((value) => this._filter(value)),
|
map((value) => this._filter(value)),
|
||||||
takeUntil(this.onDestroy$)
|
takeUntil(this.onDestroy$)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.activitiContentService.getAlfrescoRepositories().subscribe((repoList) => {
|
||||||
|
if (repoList && repoList[0]) {
|
||||||
|
const alfrescoRepository = repoList[0];
|
||||||
|
this.alfrescoRepositoryName = `alfresco-${alfrescoRepository.id}-${alfrescoRepository.name}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
@ -211,7 +221,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
getAlfrescoRepositoryName(): string {
|
getAlfrescoRepositoryName(): string {
|
||||||
let alfrescoRepositoryName = this.appConfig.get<string>(AppConfigValues.ALFRESCO_REPOSITORY_NAME);
|
let alfrescoRepositoryName = this.appConfig.get<string>(AppConfigValues.ALFRESCO_REPOSITORY_NAME);
|
||||||
if (!alfrescoRepositoryName) {
|
if (!alfrescoRepositoryName) {
|
||||||
alfrescoRepositoryName = 'alfresco-1';
|
alfrescoRepositoryName = this.alfrescoRepositoryName;
|
||||||
}
|
}
|
||||||
return alfrescoRepositoryName + 'Alfresco';
|
return alfrescoRepositoryName + 'Alfresco';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user