mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3897] Upload Dialog - upload file error tooltip (#4148)
This commit is contained in:
committed by
Eugenio Romano
parent
baf9204a04
commit
5b168af134
@@ -65,7 +65,9 @@
|
||||
<div
|
||||
*ngIf="file.status === FileUploadStatus.Error"
|
||||
class="adf-file-uploading-row__block adf-file-uploading-row__status--error">
|
||||
<mat-icon mat-list-icon>
|
||||
<mat-icon mat-list-icon
|
||||
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.ERROR' | translate"
|
||||
[matTooltip]="file.errorCode | adfFileUploadError">
|
||||
report_problem
|
||||
</mat-icon>
|
||||
</div>
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FileModel } from '@alfresco/adf-core';
|
||||
import { FileModel, CoreModule } from '@alfresco/adf-core';
|
||||
import { UploadModule } from '../upload.module';
|
||||
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
||||
|
||||
@@ -28,6 +28,7 @@ describe('FileUploadingListRowComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot(),
|
||||
UploadModule
|
||||
]
|
||||
}).compileComponents();
|
||||
|
@@ -0,0 +1,48 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TranslationMock } from '@alfresco/adf-core';
|
||||
import { FileUploadErrorPipe } from './file-upload-error.pipe';
|
||||
|
||||
describe('FileUploadErrorPipe', () => {
|
||||
|
||||
let pipe: FileUploadErrorPipe;
|
||||
|
||||
beforeEach(() => {
|
||||
pipe = new FileUploadErrorPipe(new TranslationMock());
|
||||
});
|
||||
|
||||
it('should return generic message when error code is null', () => {
|
||||
expect(pipe.transform(null)).toBe('FILE_UPLOAD.ERRORS.GENERIC');
|
||||
});
|
||||
|
||||
it('should return 500 message', () => {
|
||||
expect(pipe.transform(500)).toBe('FILE_UPLOAD.ERRORS.500');
|
||||
});
|
||||
|
||||
it('should return 504 message', () => {
|
||||
expect(pipe.transform(504)).toBe('FILE_UPLOAD.ERRORS.504');
|
||||
});
|
||||
|
||||
it('should return 403 message', () => {
|
||||
expect(pipe.transform(403)).toBe('FILE_UPLOAD.ERRORS.403');
|
||||
});
|
||||
|
||||
it('should return 404 message', () => {
|
||||
expect(pipe.transform(404)).toBe('FILE_UPLOAD.ERRORS.404');
|
||||
});
|
||||
});
|
33
lib/content-services/upload/pipes/file-upload-error.pipe.ts
Normal file
33
lib/content-services/upload/pipes/file-upload-error.pipe.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
|
||||
@Pipe({
|
||||
name: 'adfFileUploadError',
|
||||
pure: true
|
||||
})
|
||||
export class FileUploadErrorPipe implements PipeTransform {
|
||||
|
||||
constructor(private translation: TranslationService) {
|
||||
}
|
||||
|
||||
transform(errorCode: number): string {
|
||||
return this.translation.instant(`FILE_UPLOAD.ERRORS.${errorCode || 'GENERIC'}`);
|
||||
}
|
||||
}
|
@@ -25,6 +25,8 @@ export * from './components/upload-files.event';
|
||||
|
||||
export * from './directives/file-draggable.directive';
|
||||
|
||||
export * from './pipes/file-upload-error.pipe';
|
||||
|
||||
export * from './components/base-upload/upload-base';
|
||||
|
||||
export * from './upload.module';
|
||||
|
@@ -25,6 +25,7 @@ import { FileUploadingListComponent } from './components/file-uploading-list.com
|
||||
import { UploadButtonComponent } from './components/upload-button.component';
|
||||
import { UploadVersionButtonComponent } from './components/upload-version-button.component';
|
||||
import { UploadDragAreaComponent } from './components/upload-drag-area.component';
|
||||
import { FileUploadErrorPipe } from './pipes/file-upload-error.pipe';
|
||||
|
||||
import { CoreModule } from '@alfresco/adf-core';
|
||||
import { FileDraggableDirective } from './directives/file-draggable.directive';
|
||||
@@ -42,7 +43,8 @@ import { FileDraggableDirective } from './directives/file-draggable.directive';
|
||||
UploadVersionButtonComponent,
|
||||
FileUploadingDialogComponent,
|
||||
FileUploadingListComponent,
|
||||
FileUploadingListRowComponent
|
||||
FileUploadingListRowComponent,
|
||||
FileUploadErrorPipe
|
||||
],
|
||||
exports: [
|
||||
FileDraggableDirective,
|
||||
@@ -51,7 +53,8 @@ import { FileDraggableDirective } from './directives/file-draggable.directive';
|
||||
UploadVersionButtonComponent,
|
||||
FileUploadingDialogComponent,
|
||||
FileUploadingListComponent,
|
||||
FileUploadingListRowComponent
|
||||
FileUploadingListRowComponent,
|
||||
FileUploadErrorPipe
|
||||
]
|
||||
})
|
||||
export class UploadModule {}
|
||||
|
Reference in New Issue
Block a user