mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[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:
parent
e63802ef4f
commit
b79ee13d11
@ -65,26 +65,6 @@ describe('UploadDragAreaComponent', () => {
|
||||
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', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.onSuccess = null;
|
||||
|
@ -97,36 +97,14 @@ export class UploadDragAreaComponent {
|
||||
*/
|
||||
onFilesDropped(files: File[], rootId?: string, directory?: string): void {
|
||||
if (files.length) {
|
||||
if (this.checkValidity(files)) {
|
||||
this.uploadService.addToQueue(files);
|
||||
this.uploadService.uploadFilesInTheQueue(rootId || this.rootFolderId, directory || this.currentFolderPath, this.onSuccess);
|
||||
let latestFilesAdded = this.uploadService.getQueue();
|
||||
if (this.showNotificationBar) {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user