mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4250] Improve Error Content component (#4555)
* [ADF-4250] Improve Error Content component * [ADF-4250] Fix unit test
This commit is contained in:
committed by
Eugenio Romano
parent
4339af9f42
commit
a42d58af49
@@ -334,6 +334,36 @@
|
|||||||
"RETURN_BUTTON": {
|
"RETURN_BUTTON": {
|
||||||
"TEXT": "Back to home"
|
"TEXT": "Back to home"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"TITLE": "An error occurred.",
|
||||||
|
"DESCRIPTION": "Internal server error, try again or contact IT support [500].",
|
||||||
|
"SECONDARY_BUTTON": {
|
||||||
|
"TEXT": ""
|
||||||
|
},
|
||||||
|
"RETURN_BUTTON": {
|
||||||
|
"TEXT": "Back to home"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"502": {
|
||||||
|
"TITLE": "An error occurred.",
|
||||||
|
"DESCRIPTION": "Bad Gateway, try again or contact IT support [502].",
|
||||||
|
"SECONDARY_BUTTON": {
|
||||||
|
"TEXT": ""
|
||||||
|
},
|
||||||
|
"RETURN_BUTTON": {
|
||||||
|
"TEXT": "Back to home"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"504": {
|
||||||
|
"TITLE": "An error occurred.",
|
||||||
|
"DESCRIPTION": "The server timed out, try again or contact IT support [504].",
|
||||||
|
"SECONDARY_BUTTON": {
|
||||||
|
"TEXT": ""
|
||||||
|
},
|
||||||
|
"RETURN_BUTTON": {
|
||||||
|
"TEXT": "Back to home"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ABOUT": {
|
"ABOUT": {
|
||||||
|
@@ -141,7 +141,7 @@ describe('ErrorContentComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate to an error given by the route params', async(() => {
|
it('should navigate to an error given by the route params', async(() => {
|
||||||
spyOn(translateService, 'get').and.returnValue(of('404'));
|
spyOn(translateService, 'instant').and.returnValue(of('404'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(errorContentComponent.errorCode).toBe('404');
|
expect(errorContentComponent.errorCode).toBe('404');
|
||||||
|
@@ -36,6 +36,8 @@ import { TranslationService } from '../../services/translation.service';
|
|||||||
})
|
})
|
||||||
export class ErrorContentComponent implements OnInit, AfterContentChecked {
|
export class ErrorContentComponent implements OnInit, AfterContentChecked {
|
||||||
|
|
||||||
|
static UNKNOWN_ERROR = 'UNKNOWN';
|
||||||
|
|
||||||
/** Target URL for the secondary button. */
|
/** Target URL for the secondary button. */
|
||||||
@Input()
|
@Input()
|
||||||
secondaryButtonUrl: string = 'report-issue';
|
secondaryButtonUrl: string = 'report-issue';
|
||||||
@@ -46,7 +48,7 @@ export class ErrorContentComponent implements OnInit, AfterContentChecked {
|
|||||||
|
|
||||||
/** Error code associated with this error. */
|
/** Error code associated with this error. */
|
||||||
@Input()
|
@Input()
|
||||||
errorCode: string = 'UNKNOWN';
|
errorCode: string = ErrorContentComponent.UNKNOWN_ERROR;
|
||||||
|
|
||||||
hasSecondButton: boolean;
|
hasSecondButton: boolean;
|
||||||
|
|
||||||
@@ -59,12 +61,17 @@ export class ErrorContentComponent implements OnInit, AfterContentChecked {
|
|||||||
if (this.route) {
|
if (this.route) {
|
||||||
this.route.params.forEach((params: Params) => {
|
this.route.params.forEach((params: Params) => {
|
||||||
if (params['id']) {
|
if (params['id']) {
|
||||||
this.errorCode = params['id'];
|
this.errorCode = this.checkErrorExists(params['id']) ? params['id'] : ErrorContentComponent.UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkErrorExists(errorCode: string ) {
|
||||||
|
const errorMessage = this.translateService.instant('ERROR_CONTENT.' + errorCode);
|
||||||
|
return errorMessage !== ('ERROR_CONTENT.' + errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
getTranslations() {
|
getTranslations() {
|
||||||
this.hasSecondButton = this.translateService.instant(
|
this.hasSecondButton = this.translateService.instant(
|
||||||
'ERROR_CONTENT.' + this.errorCode + '.SECONDARY_BUTTON.TEXT') ? true : false;
|
'ERROR_CONTENT.' + this.errorCode + '.SECONDARY_BUTTON.TEXT') ? true : false;
|
||||||
|
Reference in New Issue
Block a user