mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Fix attach file widget shows Local source when only link is enabled (#5775)
This commit is contained in:
@@ -105,7 +105,8 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
isAllFileSourceSelected(): boolean {
|
isAllFileSourceSelected(): boolean {
|
||||||
return this.field.params &&
|
return this.field.params &&
|
||||||
this.field.params.fileSource &&
|
this.field.params.fileSource &&
|
||||||
this.field.params.fileSource.serviceId === 'all-file-sources';
|
this.field.params.fileSource.serviceId === 'all-file-sources' &&
|
||||||
|
!this.field.params.link;
|
||||||
}
|
}
|
||||||
|
|
||||||
isOnlyLocalSourceSelected(): boolean {
|
isOnlyLocalSourceSelected(): boolean {
|
||||||
|
@@ -63,6 +63,13 @@ const allSourceParams = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const allSourceParamsWithLinkEnabled = {
|
||||||
|
fileSource: {
|
||||||
|
serviceId: 'all-file-sources'
|
||||||
|
},
|
||||||
|
link: true
|
||||||
|
};
|
||||||
|
|
||||||
const definedSourceParams = {
|
const definedSourceParams = {
|
||||||
fileSource: {
|
fileSource: {
|
||||||
serviceId: 'goku-sources',
|
serviceId: 'goku-sources',
|
||||||
@@ -163,7 +170,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should show up all the repository option on menu list', async(() => {
|
it('should show up all the repository option on menu list', async() => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@@ -178,15 +185,51 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
attachButton.click();
|
attachButton.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(fixture.debugElement.queryAll(By.css('#attach-local-file'))).not.toBeNull();
|
const localFileOption = fixture.debugElement.queryAll(By.css('#attach-local-file'));
|
||||||
expect(fixture.debugElement.queryAll(By.css('#attach-local-file'))).not.toBeUndefined();
|
const fakeRepoOption1 = fixture.debugElement.queryAll(By.css('#attach-SHAREME'));
|
||||||
expect(fixture.debugElement.queryAll(By.css('#attach-SHAREME'))).not.toBeNull();
|
const fakeRepoOption2 = fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'));
|
||||||
expect(fixture.debugElement.queryAll(By.css('#attach-SHAREME'))).not.toBeUndefined();
|
|
||||||
expect(fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'))).not.toBeNull();
|
expect(localFileOption.length).toEqual(1);
|
||||||
expect(fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'))).not.toBeUndefined();
|
expect(localFileOption[0]).not.toBeNull();
|
||||||
|
|
||||||
|
expect(fakeRepoOption1.length).toEqual(1);
|
||||||
|
expect(fakeRepoOption1[0]).not.toBeNull();
|
||||||
|
|
||||||
|
expect(fakeRepoOption2.length).toEqual(1);
|
||||||
|
expect(fakeRepoOption2[0]).not.toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
it ('should show only remote repos when just link to files is true', async () => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
value: []
|
||||||
|
});
|
||||||
|
widget.field.id = 'attach-file-attach';
|
||||||
|
widget.field.params = <FormFieldMetadata> allSourceParamsWithLinkEnabled;
|
||||||
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenRenderingDone().then(() => {
|
||||||
|
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||||
|
expect(attachButton).not.toBeNull();
|
||||||
|
attachButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
const localFileOption = fixture.debugElement.queryAll(By.css('#attach-local-file'));
|
||||||
|
const fakeRepoOption1 = fixture.debugElement.queryAll(By.css('#attach-SHAREME'));
|
||||||
|
const fakeRepoOption2 = fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'));
|
||||||
|
|
||||||
|
expect(localFileOption.length).toEqual(0);
|
||||||
|
|
||||||
|
expect(fakeRepoOption1.length).toEqual(1);
|
||||||
|
expect(fakeRepoOption1[0]).not.toBeNull();
|
||||||
|
|
||||||
|
expect(fakeRepoOption2.length).toEqual(1);
|
||||||
|
expect(fakeRepoOption2[0]).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should be able to upload files coming from content node selector', async(() => {
|
it('should be able to upload files coming from content node selector', async(() => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
|
Reference in New Issue
Block a user