mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +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:
parent
7fa592ebe7
commit
30fb980afd
@ -4,10 +4,20 @@ root = true
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[package.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[resources/*.json]
|
||||
indent_size = 2
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"title": "Welcome",
|
||||
"VERSION": {
|
||||
"NO_PERMISSION": "You don't have permission to manage the versions of this content",
|
||||
"NO_PERMISSION_EVENT": "You don't have the ${event.permission} permission to ${event.action} the ${event.type}",
|
||||
"CHOOSE_FILE": "Please choose a document to see the versions of it"
|
||||
},
|
||||
"APP_LAYOUT": {
|
||||
"APP_NAME": "ADF Demo Application",
|
||||
"HOME": "Home",
|
||||
|
@ -251,13 +251,13 @@
|
||||
<ng-template #choose_document_template>
|
||||
<div class="adf-manage-versions-empty">
|
||||
<mat-icon class="adf-manage-versions-empty-icon">face</mat-icon>
|
||||
Please choose a document to see the versions of it.
|
||||
{{'VERSION.CHOOSE_FILE' | translate}}
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #no_permission_to_versions>
|
||||
<div class="adf-manage-versions-no-permission">
|
||||
<mat-icon class="adf-manage-versions-no-permission-icon">warning</mat-icon>
|
||||
You don't have permission to manage the versions of this content.
|
||||
{{'VERSION.NO_PERMISSION' | translate}}
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
@ -340,6 +340,7 @@
|
||||
[multipleFiles]="multipleFileUpload"
|
||||
[uploadFolders]="folderUpload"
|
||||
[maxFilesSize]="maxFilesSize"
|
||||
(error)="handleUploadError($event)"
|
||||
[versioning]="versioning"
|
||||
[adf-node-permission]="'create'"
|
||||
[adf-nodes]="getCurrentDocumentListNode()"
|
||||
@ -357,6 +358,7 @@
|
||||
[multipleFiles]="multipleFileUpload"
|
||||
[uploadFolders]="folderUpload"
|
||||
[versioning]="versioning"
|
||||
(error)="handleUploadError($event)"
|
||||
[adf-node-permission]="'create'"
|
||||
[adf-nodes]="getCurrentDocumentListNode()"
|
||||
(permissionEvent)="handlePermissionError($event)">
|
||||
|
@ -168,8 +168,21 @@ export class FilesComponent implements OnInit {
|
||||
}
|
||||
|
||||
handlePermissionError(event: any) {
|
||||
this.translateService.get('OPERATION.ERROR.NO_PERMISSION_EVENT', {
|
||||
permission: event.permission,
|
||||
action: event.action,
|
||||
type: event.type
|
||||
}).subscribe((message) => {
|
||||
this.notificationService.openSnackMessage(
|
||||
`You don't have the ${event.permission} permission to ${event.action} the ${event.type} `,
|
||||
message,
|
||||
4000
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
handleUploadError(event: any) {
|
||||
this.notificationService.openSnackMessage(
|
||||
event,
|
||||
4000
|
||||
);
|
||||
}
|
||||
@ -217,7 +230,11 @@ export class FilesComponent implements OnInit {
|
||||
const contentEntry = event.value.entry;
|
||||
|
||||
if (this.contentService.hasPermission(contentEntry, 'update')) {
|
||||
this.dialog.open(VersionManagerDialogAdapterComponent, { data: { contentEntry }, panelClass: 'adf-version-manager-dialog', width: '630px' });
|
||||
this.dialog.open(VersionManagerDialogAdapterComponent, {
|
||||
data: { contentEntry },
|
||||
panelClass: 'adf-version-manager-dialog',
|
||||
width: '630px'
|
||||
});
|
||||
} else {
|
||||
const translatedErrorMessage: any = this.translateService.get('OPERATION.ERROR.PERMISSION');
|
||||
this.notificationService.openSnackMessage(translatedErrorMessage.value, 4000);
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user