[ADF-788] Emit error message for max file size (#2566)

* emit message error max fie size
add translation message versioning
missing editorconfig settings

* misspell fixe
This commit is contained in:
Eugenio Romano
2017-10-30 15:26:23 +00:00
committed by GitHub
parent 7fa592ebe7
commit 30fb980afd
7 changed files with 64 additions and 9 deletions

View File

@@ -283,6 +283,16 @@ describe('UploadButtonComponent', () => {
expect(filesCalledWith[0].name).toBe('smallFile.png');
});
it('should output an error when you try to upload a file too big', (done) => {
component.maxFilesSize = 100;
component.error.subscribe(() => {
done();
});
component.uploadFiles(files);
});
it('should not filter out files if max file size is not set', () => {
component.maxFilesSize = null;

View File

@@ -223,7 +223,17 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
* @param file FileModel
*/
private isFileSizeAcceptable(file: FileModel): boolean {
return this.maxFilesSize ? file.size <= this.maxFilesSize : true;
let acceptableSize = true;
if (this.maxFilesSize && file.size > this.maxFilesSize) {
acceptableSize = false;
this.translateService.get('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', {fileName: file.name}).subscribe((message: string) => {
this.error.emit(message);
})
}
return acceptableSize;
}
/**
@@ -270,7 +280,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
private hasCreatePermission(node: any): boolean {
if (node && node.allowableOperations) {
return node.allowableOperations.find(permision => permision === 'create') ? true : false;
return node.allowableOperations.find(permission => permission === 'create') ? true : false;
}
return false;
}

View File

@@ -37,7 +37,8 @@
"FOLDER_ALREADY_EXIST": "The folder {0} already exists",
"FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser, try a different browser",
"REMOVE_FILE_ERROR": "{{ fileName }} couldn't be removed, try again or check with your IT Team.",
"REMOVE_FILES_ERROR": "{{ total }} files couldn't be removed, try again or check with your IT Team."
"REMOVE_FILES_ERROR": "{{ total }} files couldn't be removed, try again or check with your IT Team.",
"EXCEED_MAX_FILE_SIZE": "The size of the file {{ fileName }} exceed the max allowed file size"
},
"ACTION": {
"UNDO": "Undo"