From 55d633e892da9d51ecee4e5177fdecc28b0cf97b Mon Sep 17 00:00:00 2001 From: Uladzislau_Kutarkin Date: Fri, 13 Oct 2023 13:09:33 +0400 Subject: [PATCH] UIBULKED-352: fix comments --- src/components/BulkEditList/BulkEditList.js | 7 ++--- .../BulkEditInAppPreviewModal.js | 2 +- .../BulkEditInAppPreviewModal.test.js | 30 +++++++------------ .../ErrorsAccordion/ErrorsAccordion.js | 6 ++-- .../ErrorsAccordion/ErrorsAccordion.test.js | 5 ---- .../BulkEditListResult/Preview/Preview.js | 6 ++-- .../Preview/Preview.test.js | 22 +++++--------- translations/ui-bulk-edit/en.json | 12 ++++---- 8 files changed, 32 insertions(+), 58 deletions(-) diff --git a/src/components/BulkEditList/BulkEditList.js b/src/components/BulkEditList/BulkEditList.js index 8ce6ad7d..d61a5ff6 100644 --- a/src/components/BulkEditList/BulkEditList.js +++ b/src/components/BulkEditList/BulkEditList.js @@ -3,7 +3,7 @@ import React, { useMemo, useState, } from 'react'; -import { FormattedMessage, useIntl } from 'react-intl'; +import { FormattedMessage } from 'react-intl'; import { Pane, @@ -35,7 +35,6 @@ import BulkEditInAppLayer from './BulkEditListResult/BulkEditInAppLayer/BulkEdit export const BulkEditList = () => { const history = useHistory(); const search = new URLSearchParams(history.location.search); - const intl = useIntl(); const [isFileUploaded, setIsFileUploaded] = useState(false); const [isBulkEditModalOpen, setIsBulkEditModalOpen] = useState(false); @@ -148,8 +147,8 @@ export const BulkEditList = () => { const changedPaneSubTitle = useMemo(() => ( step === EDITING_STEPS.UPLOAD ? - - : + + : ), [countOfRecords, step]); const paneSubtitle = useMemo(() => { diff --git a/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.js b/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.js index 24fd7788..956eb279 100644 --- a/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.js +++ b/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.js @@ -163,7 +163,7 @@ const BulkEditInAppPreviewModal = ({ {contentData && !isPreviewLoading ? ( <> - + diff --git a/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.test.js b/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.test.js index c37cd922..b784d1fb 100644 --- a/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.test.js +++ b/src/components/BulkEditList/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal.test.js @@ -6,7 +6,6 @@ import { act, render, screen, fireEvent } from '@testing-library/react'; import { useOkapiKy } from '@folio/stripes/core'; import '../../../../../test/jest/__mock__'; -import { IntlProvider } from 'react-intl'; import { bulkEditLogsData } from '../../../../../test/jest/__mock__/fakeData'; import { queryClient } from '../../../../../test/jest/utils/queryClient'; import { RootContext } from '../../../../context/RootContext'; @@ -40,26 +39,19 @@ const defaultProps = { contentUpdates: undefined, }; -jest.mock('react-intl', () => ({ - ...jest.requireActual('react-intl'), - formatNumber: jest.fn() -})); - const renderPreviewModal = (props = defaultProps) => { return render( - - - - - - - - , - + + + + + + + , ); }; diff --git a/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.js b/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.js index 7917df84..632701e2 100644 --- a/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.js +++ b/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.js @@ -27,7 +27,6 @@ const ErrorsAccordion = ({ countOfErrors, matched, isInitial, - intl }) => { const location = useLocation(); const fileName = new URLSearchParams(location.search).get('fileName'); @@ -41,8 +40,8 @@ const ErrorsAccordion = ({ values={{ fileName, entries, - matched: intl.formatNumber(matched), - errors: intl.formatNumber(countOfErrors), + matched, + errors: countOfErrors, }} /> ); @@ -85,7 +84,6 @@ ErrorsAccordion.propTypes = { countOfErrors: PropTypes.number, matched: PropTypes.number, isInitial: PropTypes.bool, - intl:PropTypes.object, }; export default ErrorsAccordion; diff --git a/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.test.js b/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.test.js index 2ca99e73..30054eb8 100644 --- a/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.test.js +++ b/src/components/BulkEditList/BulkEditListResult/Preview/ErrorsAccordion/ErrorsAccordion.test.js @@ -6,16 +6,11 @@ import { errorsPreview } from '../../../../../../test/jest/__mock__/fakeData'; import ErrorsAccordion from './ErrorsAccordion'; -const mockIntl = { - formatNumber: jest.fn() -}; - const defaultProps = { errors: errorsPreview.errors, entries: 5, countOfErrors: errorsPreview.errors.length, matched: 4, - intl: mockIntl }; const renderPreviewAccordion = (history, props = defaultProps) => { diff --git a/src/components/BulkEditList/BulkEditListResult/Preview/Preview.js b/src/components/BulkEditList/BulkEditListResult/Preview/Preview.js index 2349de07..012d6d99 100644 --- a/src/components/BulkEditList/BulkEditListResult/Preview/Preview.js +++ b/src/components/BulkEditList/BulkEditListResult/Preview/Preview.js @@ -1,4 +1,4 @@ -import { FormattedMessage, useIntl } from 'react-intl'; +import { FormattedMessage } from 'react-intl'; import { Headline, AccordionSet, @@ -18,7 +18,6 @@ import { EDITING_STEPS } from '../../../../constants'; export const Preview = ({ id, title, isInitial, bulkDetails }) => { const location = useLocation(); - const intl = useIntl(); const { countOfRecords, setCountOfRecords, visibleColumns } = useContext(RootContext); const [countOfErrors, setCountOfErrors] = useState(0); const [totalCount, setTotalCount] = useState(0); @@ -55,7 +54,7 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => { @@ -82,7 +81,6 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => { matched={countOfRecords} countOfErrors={countOfErrors} isInitial={isInitial} - intl={intl} /> )} diff --git a/src/components/BulkEditList/BulkEditListResult/Preview/Preview.test.js b/src/components/BulkEditList/BulkEditListResult/Preview/Preview.test.js index 777f82c9..10748007 100644 --- a/src/components/BulkEditList/BulkEditListResult/Preview/Preview.test.js +++ b/src/components/BulkEditList/BulkEditListResult/Preview/Preview.test.js @@ -7,7 +7,6 @@ import { useOkapiKy } from '@folio/stripes/core'; import { runAxeTest } from '@folio/stripes-testing'; import '../../../../../test/jest/__mock__'; -import { IntlProvider } from 'react-intl'; import { bulkEditLogsData } from '../../../../../test/jest/__mock__/fakeData'; import { queryClient } from '../../../../../test/jest/utils/queryClient'; @@ -28,22 +27,15 @@ const defaultProps = { id: bulkOperation.id, }; -jest.mock('react-intl', () => ({ - ...jest.requireActual('react-intl'), - formatNumber: jest.fn() -})); - const renderPreview = (props = defaultProps) => { render( - - - - - - - - , - + + + + + + + , ); }; diff --git a/translations/ui-bulk-edit/en.json b/translations/ui-bulk-edit/en.json index a126bca3..6a5efd05 100644 --- a/translations/ui-bulk-edit/en.json +++ b/translations/ui-bulk-edit/en.json @@ -8,8 +8,8 @@ "list.criteriaTitle": "Set criteria", "list.logSubTitle": "Set criteria to start bulk edit", - "list.logSubTitle.matched": "{count} records match", - "list.logSubTitle.changed": "{count} records changed", + "list.logSubTitle.matched": "{count, number} records match", + "list.logSubTitle.changed": "{count, number} records changed", "list.filters.identifier": "Identifier", "list.filters.query": "Query", "list.filters.logs": "Logs", @@ -61,8 +61,8 @@ "list.preview.table.status.false": "Inactive", "list.errors.title": "Errors", - "list.errors.info": "{fileName}: {entries} entries * {matched} records matched * {errors} errors", - "list.errors.infoProcessed": "{fileName}: {entries} entries * {matched} records changed * {errors} errors", + "list.errors.info": "{fileName}: {entries} entries * {matched, number} records matched * {errors, number} errors", + "list.errors.infoProcessed": "{fileName}: {entries} entries * {matched, number} records changed * {errors, number} errors", "list.errors.table.code": "Record identifier", "list.errors.table.message": "Reason for error", @@ -90,7 +90,7 @@ "uploaderActiveTitle": "Drop to continue", "uploading": "Uploading", "cancel": "Cancel", - "recordsSuccessfullyChanged": "{value} records have been successfully changed", + "recordsSuccessfullyChanged": "{value, number} records have been successfully changed", "modal.fileExtensions.blocked.header": "Invalid file", "modal.fileExtensions.blocked.message": "Only file with .csv extension can be uploaded.", @@ -298,7 +298,7 @@ "layer.options.checkInNote": "Check in note", "layer.options.checkOutNote": "Check out note", - "previewModal.message": "{count} records will be changed if the Commit changes button is clicked. You may choose Download preview to review all changes prior to saving.", + "previewModal.message": "{count, number} records will be changed if the Commit changes button is clicked. You may choose Download preview to review all changes prior to saving.", "previewModal.previewToBeChanged": "Preview of records to be changed", "previewModal.keepEditing": "Keep editing", "previewModal.downloadPreview": "Download preview",