[ACA-3603] Destination picker is not opening on My Files when clicking on Attach file widget (#5865)

* [ACA-3603] Destination picker is not opening on My Files when clicking on Attach file widget

* *

* * Fixed failing unit tests

* * Used openFileBrowseDialogByFolderId
This commit is contained in:
siva kumar
2020-08-13 17:15:01 +05:30
committed by GitHub
parent 418202cb24
commit eb5d0da079
8 changed files with 41 additions and 15 deletions

View File

@@ -22,6 +22,7 @@ export interface AttachFileWidgetDialogComponentData {
title: string;
actionName?: string;
selected: Subject<Node[]>;
currentFolderId: string;
ecmHost: string;
context?: string;
isSelectionValid?: (entry: Node) => boolean;

View File

@@ -10,6 +10,7 @@
</adf-login-dialog-panel>
<adf-content-node-selector-panel *ngIf="isLoggedIn()"
id="attach-file-content-node"
[currentFolderId]="data?.currentFolderId"
[isSelectionValid]="data?.isSelectionValid"
[showFilesInResult]="data?.showFilesInResult"
(select)="onSelect($event)"

View File

@@ -17,15 +17,15 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ContentModule, ContentNodeSelectorPanelComponent } from '@alfresco/adf-content-services';
import { EventEmitter } from '@angular/core';
import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService } from '@alfresco/adf-content-services';
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
import { ProcessTestingModule } from '../testing/process.testing.module';
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
import { setupTestBed, AuthenticationService, SitesService } from '@alfresco/adf-core';
import { setupTestBed, AuthenticationService, SitesService, AlfrescoApiService, AlfrescoApiServiceMock, NodesApiService } from '@alfresco/adf-core';
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
import { of } from 'rxjs';
import { of, throwError } from 'rxjs';
import { By } from '@angular/platform-browser';
import { Node } from '@alfresco/js-api';
import { Node, SiteEntry, NodeEntry } from '@alfresco/js-api';
import { TranslateModule } from '@ngx-translate/core';
describe('AttachFileWidgetDialogComponent', () => {
@@ -35,14 +35,18 @@ describe('AttachFileWidgetDialogComponent', () => {
const data: AttachFileWidgetDialogComponentData = {
title: 'Choose along citizen...',
actionName: 'Choose',
currentFolderId: '-my-',
selected: new EventEmitter<any>(),
ecmHost: 'http://fakeUrl.com/'
ecmHost: 'http://fakeUrl.com'
};
let element: HTMLInputElement;
let authService: AuthenticationService;
let siteService: SitesService;
let nodeService: NodesApiService;
let documentListService: DocumentListService;
let isLogged = false;
const fakeSite = new SiteEntry({ entry: { id: 'fake-site', guid: 'fake-site', title: 'fake-site', visibility: 'visible' } });
setupTestBed({
imports: [
@@ -51,8 +55,10 @@ describe('AttachFileWidgetDialogComponent', () => {
ContentModule.forRoot()
],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: data }
]
{ provide: MAT_DIALOG_DATA, useValue: data },
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
],
schemas: [NO_ERRORS_SCHEMA]
});
beforeEach(async(() => {
@@ -61,6 +67,14 @@ describe('AttachFileWidgetDialogComponent', () => {
element = fixture.nativeElement;
authService = fixture.debugElement.injector.get(AuthenticationService);
siteService = fixture.debugElement.injector.get(SitesService);
nodeService = fixture.debugElement.injector.get(NodesApiService);
documentListService = fixture.debugElement.injector.get(DocumentListService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }));
spyOn(siteService, 'getSite').and.returnValue(of(fakeSite));
spyOn(siteService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
spyOn(widget, 'isLoggedIn').and.callFake(() => {
return isLogged;

View File

@@ -54,6 +54,7 @@ export class AttachFileWidgetDialogService {
actionName,
selected,
ecmHost,
currentFolderId: '-my-',
context,
isSelectionValid: (entry: Node) => entry.isFile,
showFilesInResult: true

View File

@@ -241,7 +241,7 @@ describe('AttachFileWidgetComponent', () => {
it('should isLink property of the selected node become true when the widget has link enabled', async (done) => {
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
@@ -267,7 +267,7 @@ describe('AttachFileWidgetComponent', () => {
it('should isLink property of the selected node become false when the widget has link disabled', async (done) => {
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
@@ -293,7 +293,7 @@ describe('AttachFileWidgetComponent', () => {
it('should be able to upload files coming from content node selector', async(() => {
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
@@ -323,7 +323,7 @@ describe('AttachFileWidgetComponent', () => {
};
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValues(of(fakePngAnswer), of(fakePngUpload));
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []

View File

@@ -215,7 +215,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
this.uploadFileFromCS(selections, accountIdentifier);
});
} else {
this.contentDialog.openFileBrowseDialogBySite().subscribe(
this.contentDialog.openFileBrowseDialogByDefaultLocation().subscribe(
(selections: Node[]) => {
this.tempFilesList.push(...selections);
this.uploadFileFromCS(selections, accountIdentifier);