diff --git a/providers/__tests__/i18nProvider.test.js b/providers/__tests__/i18nProvider.test.js index eaca0e8..a4d0093 100644 --- a/providers/__tests__/i18nProvider.test.js +++ b/providers/__tests__/i18nProvider.test.js @@ -125,6 +125,7 @@ describe('i18nProvider', () => { it('translates download and PDF busy errors in Hebrew', () => { expect(i18nProvider.translate('ra.notification.file_download_incomplete')).toContain('סינון האינטרנט'); expect(i18nProvider.translate('ra.notification.pdf_render_busy')).toBe('המערכת מפיקה כרגע דוחות אחרים. נא לנסות שוב בעוד מספר דקות.'); + expect(i18nProvider.translate('ra.notification.pdf_print_timeout')).toContain('הדוח גדול מדי'); }); it('handles missing translations by returning the key', () => { @@ -150,6 +151,7 @@ describe('i18nProvider', () => { it('translates download and PDF busy errors in English', () => { expect(i18nProvider.translate('ra.notification.file_download_incomplete')).toContain('content filter'); expect(i18nProvider.translate('ra.notification.pdf_render_busy')).toBe('The system is currently generating other reports. Please try again in a few minutes.'); + expect(i18nProvider.translate('ra.notification.pdf_print_timeout')).toContain('too large'); }); }); }); diff --git a/providers/i18nProvider.js b/providers/i18nProvider.js index fe403ac..e6ddaca 100644 --- a/providers/i18nProvider.js +++ b/providers/i18nProvider.js @@ -105,6 +105,7 @@ const extendedTranslation = { application_update_available: 'גרסה חדשה זמינה.', file_download_incomplete: 'הקובץ לא התקבל במלואו. ככל הנראה סינון האינטרנט (למשל נטפרי) חסם או קטע את ההורדה. נא לפנות לספק הסינון ולבקש לאשר את האתר, או לנסות להוריד מרשת אחרת.', pdf_render_busy: 'המערכת מפיקה כרגע דוחות אחרים. נא לנסות שוב בעוד מספר דקות.', + pdf_print_timeout: 'הדוח גדול מדי להפקה כ-PDF. יש לצמצם את הסינון (למשל לטווח תאריכים קצר יותר) או להוריד אותו כקובץ Excel.', }, validation: { valueConfirm: 'ערך לא תואם', @@ -173,6 +174,7 @@ const extendedEnglishTranslation = { notification: { file_download_incomplete: 'The file was not fully received. An internet content filter (such as NetFree) most likely blocked or cut off the download. Please ask your filter provider to approve this site, or try downloading from another network.', pdf_render_busy: 'The system is currently generating other reports. Please try again in a few minutes.', + pdf_print_timeout: 'The report is too large to produce as a PDF. Narrow the filter (for example, a shorter date range) or download it as an Excel file.', }, }, } diff --git a/utils/__tests__/httpUtil.test.js b/utils/__tests__/httpUtil.test.js index 46159dd..ab1caff 100644 --- a/utils/__tests__/httpUtil.test.js +++ b/utils/__tests__/httpUtil.test.js @@ -18,6 +18,11 @@ describe('translateErrorCode', () => { expect(translateErrorCode(error).message).toBe('ra.notification.pdf_render_busy'); }); + it('translates the PDF print timeout code', () => { + const error = buildHttpError({ statusCode: 413, code: 'PDF_PRINT_TIMEOUT', message: 'too big' }); + expect(translateErrorCode(error).message).toBe('ra.notification.pdf_print_timeout'); + }); + it('leaves errors without a known code untouched', () => { const error = buildHttpError({ statusCode: 500, message: 'Internal server error' }); expect(translateErrorCode(error).message).toBe('Internal server error'); diff --git a/utils/httpUtil.js b/utils/httpUtil.js index 15e6a9f..fbc7485 100644 --- a/utils/httpUtil.js +++ b/utils/httpUtil.js @@ -5,6 +5,7 @@ import { fetchUtils } from 'react-admin'; // translation key, which react-admin's notify() translates to the user's locale. export const ERROR_CODE_TRANSLATION_KEYS = { PDF_RENDER_BUSY: 'ra.notification.pdf_render_busy', + PDF_PRINT_TIMEOUT: 'ra.notification.pdf_print_timeout', }; export const translateErrorCode = (error) => {