From cd62cad69b0e157df38d6fd007e05164226a0acf Mon Sep 17 00:00:00 2001 From: UladzislauKutarkin <72550466+uladzislaukutarkin@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:36:54 +0200 Subject: [PATCH] UIBULKED-472: "Uploading" is displayed instead of "Committing" on Confirmation screen if to reload the page (#512) (cherry picked from commit dce95b1423ff1a0ef7714d688f2060a69d2b08df) --- .../IdentifierTab/IdentifierTab.js | 3 --- .../BulkEditListSidebar/QueryTab/QueryTab.js | 2 -- src/components/BulkEditPane/BulkEditPane.js | 6 ------ src/components/shared/ProgressBar/ProgressBar.js | 10 ++++------ .../shared/ProgressBar/ProgressBar.test.js | 13 +++++-------- src/hooks/useResetAppState.js | 2 -- 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js b/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js index 4407205b..0f835912 100644 --- a/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js +++ b/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js @@ -36,7 +36,6 @@ export const IdentifierTab = () => { isFileUploaded, setIsFileUploaded, setVisibleColumns, - setInAppCommitted, } = useContext(RootContext); const { @@ -102,7 +101,6 @@ export const IdentifierTab = () => { setIsFileUploaded(false); setVisibleColumns(null); - setInAppCommitted(false); }, [location.search]); const handleCapabilityChange = (e) => { @@ -120,7 +118,6 @@ export const IdentifierTab = () => { setVisibleColumns(null); setIsFileUploaded(false); - setInAppCommitted(false); }; const handleDragEnter = () => { diff --git a/src/components/BulkEditPane/BulkEditListSidebar/QueryTab/QueryTab.js b/src/components/BulkEditPane/BulkEditListSidebar/QueryTab/QueryTab.js index 4ed8f7ae..87864fb5 100644 --- a/src/components/BulkEditPane/BulkEditListSidebar/QueryTab/QueryTab.js +++ b/src/components/BulkEditPane/BulkEditListSidebar/QueryTab/QueryTab.js @@ -30,7 +30,6 @@ export const QueryTab = () => { const { setIsFileUploaded, setVisibleColumns, - setInAppCommitted, } = useContext(RootContext); const { recordTypes } = useRecordTypes(); @@ -87,7 +86,6 @@ export const QueryTab = () => { setIsFileUploaded(false); setVisibleColumns(null); - setInAppCommitted(false); }; const onQueryRunSuccess = ({ id }) => { diff --git a/src/components/BulkEditPane/BulkEditPane.js b/src/components/BulkEditPane/BulkEditPane.js index d4ac8cdb..018d5e5b 100644 --- a/src/components/BulkEditPane/BulkEditPane.js +++ b/src/components/BulkEditPane/BulkEditPane.js @@ -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(); @@ -72,8 +71,6 @@ export const BulkEditPane = () => { visibleColumns, setVisibleColumns, confirmedFileName, - inAppCommitted, - setInAppCommitted, isFileUploaded, setIsFileUploaded, setIsBulkEditLayerOpen, @@ -81,7 +78,6 @@ export const BulkEditPane = () => { countOfRecords, visibleColumns, confirmedFileName, - inAppCommitted, isFileUploaded ]); @@ -108,7 +104,6 @@ export const BulkEditPane = () => { setVisibleColumns, filtersTab, setIsBulkEditLayerOpen, - setInAppCommitted, }); const handleBulkEditLayerOpen = () => { @@ -129,7 +124,6 @@ export const BulkEditPane = () => { const handleChangesCommitted = () => { handlePreviewModalClose(); handleBulkEditLayerClose(); - setInAppCommitted(true); }; const handleStartBulkEdit = (approach) => { diff --git a/src/components/shared/ProgressBar/ProgressBar.js b/src/components/shared/ProgressBar/ProgressBar.js index 7c8944ce..bb90ee44 100644 --- a/src/components/shared/ProgressBar/ProgressBar.js +++ b/src/components/shared/ProgressBar/ProgressBar.js @@ -1,4 +1,4 @@ -import React, { useContext, useEffect } from 'react'; +import React, { useEffect } from 'react'; import { useParams } from 'react-router'; import { FormattedMessage, useIntl } from 'react-intl'; @@ -6,15 +6,13 @@ 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, @@ -65,7 +63,7 @@ export const ProgressBar = () => { size="small" />
- {inAppCommitted ? + {step === EDITING_STEPS.UPLOAD ? @@ -82,7 +80,7 @@ export const ProgressBar = () => {
- {inAppCommitted ? + {step === EDITING_STEPS.UPLOAD ? : diff --git a/src/components/shared/ProgressBar/ProgressBar.test.js b/src/components/shared/ProgressBar/ProgressBar.test.js index 7d39f78c..d518a25c 100644 --- a/src/components/shared/ProgressBar/ProgressBar.test.js +++ b/src/components/shared/ProgressBar/ProgressBar.test.js @@ -5,11 +5,10 @@ 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(), @@ -17,12 +16,10 @@ jest.mock('../../../hooks/api', () => ({ const history = createMemoryHistory(); -const renderProgressBar = (inAppCommitted = false) => { +const renderProgressBar = (step = '') => { render( - - - - + + , ); }; @@ -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(); }); diff --git a/src/hooks/useResetAppState.js b/src/hooks/useResetAppState.js index dbe8a2c1..8ef03441 100644 --- a/src/hooks/useResetAppState.js +++ b/src/hooks/useResetAppState.js @@ -11,7 +11,6 @@ export const useResetAppState = ({ setCountOfRecords, filtersTab, setIsBulkEditLayerOpen, - setInAppCommitted }) => { const history = useHistory(); const queryClient = useQueryClient(); @@ -49,7 +48,6 @@ export const useResetAppState = ({ }); setIsBulkEditLayerOpen(false); - setInAppCommitted(false); } }, [history.location]); };