[AAE-207] support aps 1.x for upload reset (#5260)

* support aps 1.x for upload reset

* update test

* revert pdfjd change

* fix error reporting and crash from upload button

* i18n support for generic error

* fix test
This commit is contained in:
Denys Vuika 2019-11-21 15:06:00 +00:00 committed by Eugenio Romano
parent c61de922af
commit e806e97c75
8 changed files with 29 additions and 26 deletions

View File

@ -373,8 +373,8 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
});
}
openSnackMessage(event: any) {
this.notificationService.openSnackMessage(event);
openSnackMessage(message: string) {
this.notificationService.showError(message);
}
emitReadyEvent(event: NodePaging) {

View File

@ -151,7 +151,8 @@
"FILE_UPLOAD": {
"BUTTON": {
"UPLOAD_FILE": "Upload file",
"UPLOAD_FOLDER": "Upload folder"
"UPLOAD_FOLDER": "Upload folder",
"PERMISSION_CHECK_ERROR": "Error checking permission."
},
"VERSION": {
"MESSAGES": {

View File

@ -384,7 +384,7 @@ describe('UploadButtonComponent', () => {
spyOn(contentService, 'getNode').and.returnValue(throwError('error'));
component.error.subscribe((value) => {
expect(value).toBe('error');
expect(value).toBe('FILE_UPLOAD.BUTTON.PERMISSION_CHECK_ERROR');
done();
});

View File

@ -120,7 +120,13 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
this.contentService.getNode(this.rootFolderId, opts).subscribe(
(res) => this.permissionValue.next(this.nodeHasPermission(res.entry, AllowableOperationsEnum.CREATE)),
(error) => this.error.emit(error)
(error: { error: Error }) => {
if (error && error.error) {
this.error.emit(error.error.message);
} else {
this.error.emit('FILE_UPLOAD.BUTTON.PERMISSION_CHECK_ERROR');
}
}
);
}
}

View File

@ -134,8 +134,8 @@ describe('UploadWidgetComponent', () => {
});
uploadWidgetComponent.removeFile(uploadWidgetComponent.field.value[0]);
expect(uploadWidgetComponent.field.value.length).toBe(0);
expect(uploadWidgetComponent.field.json.value.length).toBe(0);
expect(uploadWidgetComponent.field.value).toBeNull();
expect(uploadWidgetComponent.field.json.value).toBeNull();
expect(uploadWidgetComponent.hasFile).toBeFalsy();
});

View File

@ -108,7 +108,7 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
}
}
private removeElementFromList(file) {
private removeElementFromList(file: any) {
const index = this.field.value.indexOf(file);
if (index !== -1) {
@ -119,17 +119,13 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
this.hasFile = this.field.value.length > 0;
this.resetFormValueWithNoFiles();
}
private resetFormValueWithNoFiles() {
if (this.field.value.length === 0) {
this.field.value = [];
this.field.json.value = [];
if (!this.hasFile) {
this.field.value = null;
this.field.json.value = null;
}
}
getIcon(mimeType) {
getIcon(mimeType: string): string {
return this.thumbnailService.getMimeTypeIcon(mimeType);
}

14
package-lock.json generated
View File

@ -12753,12 +12753,12 @@
}
},
"pdfjs-dist": {
"version": "2.0.943",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.0.943.tgz",
"integrity": "sha512-iLhNcm4XceTHRaSU5o22ZGCm4YpuW5+rf4+BJFH/feBhMQLbCGBry+Jet8Q419QDI4qgARaIQzXuiNrsNWS8Yw==",
"version": "2.0.489",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.0.489.tgz",
"integrity": "sha1-Y+VLKSqGeQpFRpfrRNQ0e4+/rSc=",
"requires": {
"node-ensure": "^0.0.0",
"worker-loader": "^2.0.0"
"worker-loader": "^1.1.1"
}
},
"pend": {
@ -19517,9 +19517,9 @@
}
},
"worker-loader": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-2.0.0.tgz",
"integrity": "sha512-tnvNp4K3KQOpfRnD20m8xltE3eWh89Ye+5oj7wXEEHKac1P4oZ6p9oTj8/8ExqoSBnk9nu5Pr4nKfQ1hn2APJw==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-1.1.1.tgz",
"integrity": "sha512-qJZLVS/jMCBITDzPo/RuweYSIG8VJP5P67mP/71alGyTZRe1LYJFdwLjLalY3T5ifx0bMDRD3OB6P2p1escvlg==",
"requires": {
"loader-utils": "^1.0.0",
"schema-utils": "^0.4.0"

View File

@ -114,15 +114,15 @@
"moment-es6": "^1.0.0",
"ng2-charts": "1.6.0",
"ngx-monaco-editor": "7.0.0",
"pdfjs-dist": "2.0.943",
"pdfjs-dist": "2.0.489",
"raphael": "2.2.7",
"reflect-metadata": "0.1.13",
"remark-validate-links": "^8.0.0",
"rxjs": "^6.2.2",
"snyk": "^1.250.0",
"systemjs": "0.19.27",
"web-animations-js": "2.3.1",
"zone.js": "~0.8.26",
"snyk": "^1.250.0"
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.4",