Skip to content

Commit

Permalink
UIBULKED-352: fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
UladzislauKutarkin committed Oct 13, 2023
1 parent 91ce06c commit 55d633e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 58 deletions.
7 changes: 3 additions & 4 deletions src/components/BulkEditList/BulkEditList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {
useMemo,
useState,
} from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import { FormattedMessage } from 'react-intl';

import {
Pane,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -148,8 +147,8 @@ export const BulkEditList = () => {

const changedPaneSubTitle = useMemo(() => (
step === EDITING_STEPS.UPLOAD ?
<FormattedMessage id="ui-bulk-edit.list.logSubTitle.matched" values={{ count: intl.formatNumber(countOfRecords) }} />
: <FormattedMessage id="ui-bulk-edit.list.logSubTitle.changed" values={{ count: intl.formatNumber(countOfRecords) }} />
<FormattedMessage id="ui-bulk-edit.list.logSubTitle.matched" values={{ count: countOfRecords }} />
: <FormattedMessage id="ui-bulk-edit.list.logSubTitle.changed" values={{ count: countOfRecords }} />
), [countOfRecords, step]);

const paneSubtitle = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const BulkEditInAppPreviewModal = ({
{contentData && !isPreviewLoading ? (
<>
<MessageBanner type="warning">
<FormattedMessage id="ui-bulk-edit.previewModal.message" values={{ count: intl.formatNumber(bulkDetails?.matchedNumOfRecords) }} />
<FormattedMessage id="ui-bulk-edit.previewModal.message" values={{ count: bulkDetails?.matchedNumOfRecords }} />
</MessageBanner>

<strong className={css.previewModalSubtitle}><FormattedMessage id="ui-bulk-edit.previewModal.previewToBeChanged" /></strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
<IntlProvider locale="en">
<MemoryRouter initialEntries={['/bulk-edit/1/initial?capabilities=ITEMS&fileName=barcodes.csv&identifier=BARCODE']}>
<QueryClientProvider client={queryClient}>
<RootContext.Provider value={{
visibleColumns,
setVisibleColumns,
}}
>
<BulkEditInAppPreviewModal {...props} />
</RootContext.Provider>
</QueryClientProvider>
</MemoryRouter>,
</IntlProvider>
<MemoryRouter initialEntries={['/bulk-edit/1/initial?capabilities=ITEMS&fileName=barcodes.csv&identifier=BARCODE']}>
<QueryClientProvider client={queryClient}>
<RootContext.Provider value={{
visibleColumns,
setVisibleColumns,
}}
>
<BulkEditInAppPreviewModal {...props} />
</RootContext.Provider>
</QueryClientProvider>
</MemoryRouter>,
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const ErrorsAccordion = ({
countOfErrors,
matched,
isInitial,
intl
}) => {
const location = useLocation();
const fileName = new URLSearchParams(location.search).get('fileName');
Expand All @@ -41,8 +40,8 @@ const ErrorsAccordion = ({
values={{
fileName,
entries,
matched: intl.formatNumber(matched),
errors: intl.formatNumber(countOfErrors),
matched,
errors: countOfErrors,
}}
/>
);
Expand Down Expand Up @@ -85,7 +84,6 @@ ErrorsAccordion.propTypes = {
countOfErrors: PropTypes.number,
matched: PropTypes.number,
isInitial: PropTypes.bool,
intl:PropTypes.object,
};

export default ErrorsAccordion;
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormattedMessage, useIntl } from 'react-intl';
import { FormattedMessage } from 'react-intl';
import {
Headline,
AccordionSet,
Expand All @@ -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);
Expand Down Expand Up @@ -55,7 +54,7 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
<MessageBanner type="success" contentClassName="SuccessBanner">
<FormattedMessage
id="ui-bulk-edit.recordsSuccessfullyChanged"
values={{ value: intl.formatNumber(countOfRecords) }}
values={{ value: countOfRecords }}
/>
</MessageBanner>
</Headline>
Expand All @@ -82,7 +81,6 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
matched={countOfRecords}
countOfErrors={countOfErrors}
isInitial={isInitial}
intl={intl}
/>
)}
</AccordionSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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(
<IntlProvider locale="en">
<MemoryRouter initialEntries={['/bulk-edit/1?queryText=patronGroup%3D%3D"1"']}>
<QueryClientProvider client={queryClient}>
<RootContext.Provider value={{ setCountOfRecords: setCountOfRecordsMock }}>
<Preview {...props} />
</RootContext.Provider>
</QueryClientProvider>
</MemoryRouter>,
</IntlProvider>
<MemoryRouter initialEntries={['/bulk-edit/1?queryText=patronGroup%3D%3D"1"']}>
<QueryClientProvider client={queryClient}>
<RootContext.Provider value={{ setCountOfRecords: setCountOfRecordsMock }}>
<Preview {...props} />
</RootContext.Provider>
</QueryClientProvider>
</MemoryRouter>,
);
};

Expand Down
12 changes: 6 additions & 6 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -61,8 +61,8 @@
"list.preview.table.status.false": "Inactive",

"list.errors.title": "Errors",
"list.errors.info": "<b>{fileName}: {entries} entries * {matched} records matched * {errors} errors</b>",
"list.errors.infoProcessed": "<b>{fileName}: {entries} entries * {matched} records changed * {errors} errors</b>",
"list.errors.info": "<b>{fileName}: {entries} entries * {matched, number} records matched * {errors, number} errors</b>",
"list.errors.infoProcessed": "<b>{fileName}: {entries} entries * {matched, number} records changed * {errors, number} errors</b>",
"list.errors.table.code": "Record identifier",
"list.errors.table.message": "Reason for error",

Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 55d633e

Please sign in to comment.