[ADF-641] fix upload issues with various file types (#1887)

* fix upload issues with various file types

- removes file type check as most browsers leave this field empty
- allows uploading all types of files

* remove obsolete tests
This commit is contained in:
Denys Vuika 2017-05-19 16:06:27 +01:00 committed by Eugenio Romano
parent e63802ef4f
commit b79ee13d11
2 changed files with 5 additions and 47 deletions

View File

@ -65,26 +65,6 @@ describe('UploadDragAreaComponent', () => {
TestBed.resetTestingModule(); TestBed.resetTestingModule();
}); });
it('should show an folder non supported error in console when the file type is empty', () => {
component.showNotificationBar = false;
spyOn(logService, 'error');
let fileFake = new File([''], 'folder-fake', {type: ''});
component.onFilesDropped([fileFake]);
expect(logService.error).toHaveBeenCalledWith('FILE_UPLOAD.MESSAGES.FOLDER_NOT_SUPPORTED');
});
it('should show an folder non supported error in the notification bar when the file type is empty', () => {
component.showErrorNotificationBar = jasmine.createSpy('_showErrorNotificationBar');
component.showNotificationBar = true;
let fileFake = new File([''], 'folder-fake', {type: ''});
component.onFilesDropped([fileFake]);
expect(component.showErrorNotificationBar).toHaveBeenCalledWith('FILE_UPLOAD.MESSAGES.FOLDER_NOT_SUPPORTED');
});
it('should upload the list of files dropped', () => { it('should upload the list of files dropped', () => {
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake'; component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
component.onSuccess = null; component.onSuccess = null;

View File

@ -97,37 +97,15 @@ export class UploadDragAreaComponent {
*/ */
onFilesDropped(files: File[], rootId?: string, directory?: string): void { onFilesDropped(files: File[], rootId?: string, directory?: string): void {
if (files.length) { if (files.length) {
if (this.checkValidity(files)) { this.uploadService.addToQueue(files);
this.uploadService.addToQueue(files); this.uploadService.uploadFilesInTheQueue(rootId || this.rootFolderId, directory || this.currentFolderPath, this.onSuccess);
this.uploadService.uploadFilesInTheQueue(rootId || this.rootFolderId, directory || this.currentFolderPath, this.onSuccess); let latestFilesAdded = this.uploadService.getQueue();
let latestFilesAdded = this.uploadService.getQueue(); if (this.showNotificationBar) {
if (this.showNotificationBar) { this.showUndoNotificationBar(latestFilesAdded);
this.showUndoNotificationBar(latestFilesAdded);
}
} else {
let errorMessage: any;
errorMessage = this.translateService.get('FILE_UPLOAD.MESSAGES.FOLDER_NOT_SUPPORTED');
if (this.showNotificationBar) {
this.showErrorNotificationBar(errorMessage.value);
} else {
this.logService.error(errorMessage.value);
}
} }
} }
} }
/**
* Check il the file is valid or not
* @param files
* @returns {boolean}
*/
checkValidity(files: File[]): boolean {
if (files.length && files[0].type === '') {
return false;
}
return true;
}
/** /**
* Called when the file are dropped in the drag area * Called when the file are dropped in the drag area
* @param item - FileEntity * @param item - FileEntity