Skip to content

Commit

Permalink
Merge branch 'master' into UIBULKED-210
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js
  • Loading branch information
UladzislauKutarkin committed Feb 14, 2024
2 parents dacad27 + 664a291 commit ed51ca8
Show file tree
Hide file tree
Showing 28 changed files with 561 additions and 522 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* [UIBULKED-246](https://issues.folio.org/browse/UIBULKED-246) Enabling Build query button on Query tab.
* [UIBULKED-367](https://issues.folio.org/browse/UIBULKED-367) Logs - Provide a link to file with identifiers of the records affected by query.
* [UIBULKED-412](https://issues.folio.org/browse/UIBULKED-412) Not all but up to 10 note types are displayed in Bulk edit.
* [UIBULKED-411](https://issues.folio.org/browse/UIBULKED-411) Refactoring of ListFilters component

## [4.0.0](https://github.com/folio-org/ui-bulk-edit/tree/v4.0.0) (2023-10-12)

Expand Down
79 changes: 35 additions & 44 deletions src/components/BulkEditList/BulkEditList.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { AppIcon } from '@folio/stripes/core';
import { noop } from 'lodash/util';

import { useHistory } from 'react-router';
import { BulkEditListFilters } from './BulkEditListFilters/BulkEditListFilters';
import { BulkEditListResult } from './BulkEditListResult';
import { BulkEditActionMenu } from '../BulkEditActionMenu';
import { BulkEditManualUploadModal } from './BulkEditListResult/BulkEditManualUploadModal';
Expand All @@ -22,7 +21,9 @@ import {
CRITERIA,
APPROACHES,
EDITING_STEPS,
FILTERS,
LOGS_FILTERS,
IDENTIFIER_FILTERS,
QUERY_FILTERS,
} from '../../constants';
import { BulkEditInApp } from './BulkEditListResult/BulkEditInApp/BulkEditInApp';
import BulkEditInAppPreviewModal from './BulkEditListResult/BulkEditInAppPreviewModal/BulkEditInAppPreviewModal';
Expand All @@ -31,6 +32,8 @@ import { RootContext } from '../../context/RootContext';
import BulkEditLogs from '../BulkEditLogs/BulkEditLogs';
import { useResetAppState } from '../../hooks/useResetAppState';
import BulkEditInAppLayer from './BulkEditListResult/BulkEditInAppLayer/BulkEditInAppLayer';
import { BulkEditListSidebar } from './BulkEditListSidebar/BulkEditListSidebar';
import { useSearchParams } from '../../hooks/useSearchParams';

export const BulkEditList = () => {
const history = useHistory();
Expand All @@ -46,37 +49,35 @@ export const BulkEditList = () => {
const [confirmedFileName, setConfirmedFileName] = useState(null);
const [inAppCommitted, setInAppCommitted] = useState(false);
const [filtersTab, setFiltersTab] = useState({
identifierTab: [],
queryTab: [],
logsTab: [],
});

const { isActionMenuShown } = useBulkPermissions();
const { id: bulkOperationId } = usePathParams('/bulk-edit/:id');
const step = search.get('step');
const capabilities = search.get('capabilities');
const criteria = search.get('criteria');
const logsFilters = Object.values(FILTERS).map((el) => search.getAll(el));
const {
step,
capabilities,
criteria,
initialFileName
} = useSearchParams();
const identifierFilters = Object.values(IDENTIFIER_FILTERS).map((el) => search.getAll(el));
const queryFilters = Object.values(QUERY_FILTERS).map((el) => search.getAll(el));
const logsFilters = Object.values(LOGS_FILTERS).map((el) => search.getAll(el));

useEffect(() => {
if (history.location.search) {
setFiltersTab(prevState => ({
...prevState,
queryTab: queryFilters,
identifierTab: identifierFilters,
logsTab: logsFilters,
}));
}
}, [history.location]);

const initialFiltersState = {
criteria: CRITERIA.IDENTIFIER,
capabilities: '',
queryText: '',
recordIdentifier: '',
};

const [filters, setFilters] = useState(initialFiltersState);

useResetAppState({
initialFiltersState,
setFilters,
setConfirmedFileName,
setCountOfRecords,
setVisibleColumns,
Expand Down Expand Up @@ -133,17 +134,15 @@ export const BulkEditList = () => {
};

const paneTitle = useMemo(() => {
const fileUploadedName = search.get('fileName');

if (confirmedFileName || fileUploadedName) {
if (confirmedFileName || initialFileName) {
return (
<FormattedMessage
id="ui-bulk-edit.meta.title.uploadedFile"
values={{ fileName: confirmedFileName || fileUploadedName }}
values={{ fileName: confirmedFileName || initialFileName }}
/>
);
} else return <FormattedMessage id="ui-bulk-edit.meta.title" />;
}, [confirmedFileName, history.location.search]);
}, [confirmedFileName, initialFileName, history.location.search]);

const changedPaneSubTitle = useMemo(() => (
step === EDITING_STEPS.UPLOAD ?
Expand Down Expand Up @@ -176,37 +175,30 @@ export const BulkEditList = () => {
confirmedFileName,
inAppCommitted,
setInAppCommitted,
isFileUploaded,
setIsFileUploaded,
}}
>
<Paneset>
{/* FILTERS PANE */}
{/* LOGS_FILTERS PANE */}
<Pane
defaultWidth="300px"
paneTitle={<FormattedMessage id="ui-bulk-edit.list.criteriaTitle" />}
>
<BulkEditListFilters
filters={filters}
setFilters={setFilters}
setIsFileUploaded={setIsFileUploaded}
isFileUploaded={isFileUploaded}
setVisibleColumns={setVisibleColumns}
/>
<BulkEditListSidebar />
</Pane>

{/* RESULT PANES */}
{
isLogsTab && <BulkEditLogs />
}
{
!isLogsTab && (
<Pane
{...defaultPaneProps}
actionMenu={actionMenu}
>
<BulkEditListResult />
</Pane>
)
}
{ isLogsTab && <BulkEditLogs /> }

{ !isLogsTab && (
<Pane
{...defaultPaneProps}
actionMenu={actionMenu}
>
<BulkEditListResult />
</Pane>
)}

{/* IN_APP APPROACH */}
<BulkEditInAppLayer
Expand Down Expand Up @@ -235,7 +227,6 @@ export const BulkEditList = () => {

<BulkEditManualUploadModal
operationId={bulkOperationId}
identifier={filters.recordIdentifier}
open={isBulkEditModalOpen}
onCancel={cancelBulkEditStart}
countOfRecords={countOfRecords}
Expand Down
Loading

0 comments on commit ed51ca8

Please sign in to comment.