Skip to content

Commit

Permalink
UIBULKED-472: "Uploading" is displayed instead of "Committing" on Con…
Browse files Browse the repository at this point in the history
…firmation screen if to reload the page (#512)

(cherry picked from commit dce95b1)
  • Loading branch information
UladzislauKutarkin authored and vashjs committed Apr 12, 2024
1 parent e52095e commit cd62cad
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const IdentifierTab = () => {
isFileUploaded,
setIsFileUploaded,
setVisibleColumns,
setInAppCommitted,
} = useContext(RootContext);

const {
Expand Down Expand Up @@ -102,7 +101,6 @@ export const IdentifierTab = () => {

setIsFileUploaded(false);
setVisibleColumns(null);
setInAppCommitted(false);
}, [location.search]);

const handleCapabilityChange = (e) => {
Expand All @@ -120,7 +118,6 @@ export const IdentifierTab = () => {

setVisibleColumns(null);
setIsFileUploaded(false);
setInAppCommitted(false);
};

const handleDragEnter = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const QueryTab = () => {
const {
setIsFileUploaded,
setVisibleColumns,
setInAppCommitted,
} = useContext(RootContext);

const { recordTypes } = useRecordTypes();
Expand Down Expand Up @@ -87,7 +86,6 @@ export const QueryTab = () => {

setIsFileUploaded(false);
setVisibleColumns(null);
setInAppCommitted(false);
};

const onQueryRunSuccess = ({ id }) => {
Expand Down
6 changes: 0 additions & 6 deletions src/components/BulkEditPane/BulkEditPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const BulkEditPane = () => {
const [contentUpdates, setContentUpdates] = useState(null);
const [visibleColumns, setVisibleColumns] = useState(null);
const [confirmedFileName, setConfirmedFileName] = useState(null);
const [inAppCommitted, setInAppCommitted] = useState(false);
const [fileInfo, setFileInfo] = useState(null);

const { isActionMenuShown } = useBulkPermissions();
Expand All @@ -72,16 +71,13 @@ export const BulkEditPane = () => {
visibleColumns,
setVisibleColumns,
confirmedFileName,
inAppCommitted,
setInAppCommitted,
isFileUploaded,
setIsFileUploaded,
setIsBulkEditLayerOpen,
}), [
countOfRecords,
visibleColumns,
confirmedFileName,
inAppCommitted,
isFileUploaded
]);

Expand All @@ -108,7 +104,6 @@ export const BulkEditPane = () => {
setVisibleColumns,
filtersTab,
setIsBulkEditLayerOpen,
setInAppCommitted,
});

const handleBulkEditLayerOpen = () => {
Expand All @@ -129,7 +124,6 @@ export const BulkEditPane = () => {
const handleChangesCommitted = () => {
handlePreviewModalClose();
handleBulkEditLayerClose();
setInAppCommitted(true);
};

const handleStartBulkEdit = (approach) => {
Expand Down
10 changes: 4 additions & 6 deletions src/components/shared/ProgressBar/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React, { useContext, useEffect } from 'react';
import React, { useEffect } from 'react';
import { useParams } from 'react-router';
import { FormattedMessage, useIntl } from 'react-intl';

import { Icon, Loading } from '@folio/stripes/components';
import { useShowCallout } from '@folio/stripes-acq-components';

import { useBulkOperationDetails } from '../../../hooks/api';
import { ERRORS, JOB_STATUSES } from '../../../constants';
import { EDITING_STEPS, ERRORS, JOB_STATUSES } from '../../../constants';
import { getBulkOperationStep } from './utils';
import css from './ProgressBar.css';
import { RootContext } from '../../../context/RootContext';
import { useSearchParams } from '../../../hooks/useSearchParams';

export const ProgressBar = () => {
const callout = useShowCallout();
const { inAppCommitted } = useContext(RootContext);
const intl = useIntl();
const {
processedFileName,
Expand Down Expand Up @@ -65,7 +63,7 @@ export const ProgressBar = () => {
size="small"
/>
<div className={css.progressBarTitleText}>
{inAppCommitted ?
{step === EDITING_STEPS.UPLOAD ?
<FormattedMessage
id="ui-bulk-edit.progressBar.committing"
/>
Expand All @@ -82,7 +80,7 @@ export const ProgressBar = () => {
</div>
<div className={css.progressBarLineStatus}>
<span>
{inAppCommitted ?
{step === EDITING_STEPS.UPLOAD ?
<FormattedMessage id="ui-bulk-edit.progresssBar.processing" />
:
<FormattedMessage id="ui-bulk-edit.progresssBar.retrieving" />
Expand Down
13 changes: 5 additions & 8 deletions src/components/shared/ProgressBar/ProgressBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@ import { render, screen } from '@testing-library/react';

import { runAxeTest } from '@folio/stripes-testing';

import { ERRORS, JOB_STATUSES } from '../../../constants';
import { EDITING_STEPS, ERRORS, JOB_STATUSES } from '../../../constants';
import { useBulkOperationDetails } from '../../../hooks/api';

import { ProgressBar } from './ProgressBar';
import { RootContext } from '../../../context/RootContext';

jest.mock('../../../hooks/api', () => ({
useBulkOperationDetails: jest.fn(),
}));

const history = createMemoryHistory();

const renderProgressBar = (inAppCommitted = false) => {
const renderProgressBar = (step = '') => {
render(
<MemoryRouter initialEntries={['/bulk-edit/1/preview?processedFileName=some.scv&criteria=identifier&progress=identifier']}>
<RootContext.Provider value={{ inAppCommitted }}>
<ProgressBar />
</RootContext.Provider>
<MemoryRouter initialEntries={[`/bulk-edit/1/preview?processedFileName=some.scv&criteria=identifier&progress=identifier&step=${step}`]}>
<ProgressBar />
</MemoryRouter>,
);
};
Expand Down Expand Up @@ -69,7 +66,7 @@ describe('ProgressBar', () => {
it('should render with text after in app committing', async () => {
useBulkOperationDetails.mockReturnValue({ bulkDetails: bulkOperation });

renderProgressBar(true);
renderProgressBar(EDITING_STEPS.UPLOAD);

expect(screen.getByText(/progresssBar.processing/)).toBeVisible();
});
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useResetAppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const useResetAppState = ({
setCountOfRecords,
filtersTab,
setIsBulkEditLayerOpen,
setInAppCommitted
}) => {
const history = useHistory();
const queryClient = useQueryClient();
Expand Down Expand Up @@ -49,7 +48,6 @@ export const useResetAppState = ({
});

setIsBulkEditLayerOpen(false);
setInAppCommitted(false);
}
}, [history.location]);
};

0 comments on commit cd62cad

Please sign in to comment.