mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[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:
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user