Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIBULKED-411 Call action notes request on identifier and query tabs #483

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/BulkEditList/BulkEditList.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
const { id: bulkOperationId } = usePathParams('/bulk-edit/:id');
const {
step,
capabilities,
criteria,
initialFileName
} = useSearchParams();
Expand All @@ -79,7 +78,7 @@
logsTab: logsFilters,
}));
}
}, [history.location]);

Check warning on line 81 in src/components/BulkEditList/BulkEditList.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useEffect has missing dependencies: 'identifierFilters', 'logsFilters', and 'queryFilters'. Either include them or remove the dependency array

Check warning on line 81 in src/components/BulkEditList/BulkEditList.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useEffect has missing dependencies: 'identifierFilters', 'logsFilters', and 'queryFilters'. Either include them or remove the dependency array

useResetAppState({
setConfirmedFileName,
Expand Down Expand Up @@ -151,7 +150,7 @@
/>
);
} else return <FormattedMessage id="ui-bulk-edit.meta.title" />;
}, [confirmedFileName, initialFileName, isIdentifierTabWithPreview, history.location.search]);

Check warning on line 153 in src/components/BulkEditList/BulkEditList.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useMemo has an unnecessary dependency: 'history.location.search'. Either exclude it or remove the dependency array

Check warning on line 153 in src/components/BulkEditList/BulkEditList.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useMemo has an unnecessary dependency: 'history.location.search'. Either exclude it or remove the dependency array

const changedPaneSubTitle = useMemo(() => {
if (!isIdentifierTabWithPreview && !isQueryTabWithPreview) return null;
Expand Down Expand Up @@ -221,7 +220,6 @@
>
<BulkEditInApp
onContentUpdatesChanged={setContentUpdates}
capabilities={capabilities}
/>
</BulkEditInAppLayer>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import {
Layout,
} from '@folio/stripes/components';

import { useLocation } from 'react-router';
import { BulkEditInAppTitle } from './BulkEditInAppTitle/BulkEditInAppTitle';
import { ContentUpdatesForm } from './ContentUpdatesForm/ContentUpdatesForm';
import {
CAPABILITIES,
CRITERIA,
getHoldingsOptions,
getInstanceOptions,
getItemsOptions,
Expand All @@ -22,24 +20,22 @@ import {
import { useItemNotes } from '../../../../hooks/api/useItemNotes';
import { useHoldingsNotes } from '../../../../hooks/api/useHoldingsNotes';
import { sortAlphabetically } from '../../../../utils/sortAlphabetically';
import { useSearchParams } from '../../../../hooks/useSearchParams';

export const BulkEditInApp = ({
onContentUpdatesChanged,
capabilities,
}) => {
const intl = useIntl();
const location = useLocation();
const search = new URLSearchParams(location.search);
const criteria = search.get('criteria');
const queryRecordType = search.get('queryRecordType');
const key = criteria === CRITERIA.QUERY ? queryRecordType : capabilities;
const {
currentRecordType,
initialFileName
} = useSearchParams();

const fileUploadedName = search.get('fileName');
const isItemCapability = capabilities === CAPABILITIES.ITEM;
const isHoldingsCapability = capabilities === CAPABILITIES.HOLDING;
const isItemRecordType = currentRecordType === CAPABILITIES.ITEM;
const isHoldingsRecordType = currentRecordType === CAPABILITIES.HOLDING;

const { itemNotes, isItemNotesLoading } = useItemNotes({ enabled: isItemCapability });
const { holdingsNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsCapability });
const { itemNotes, isItemNotesLoading } = useItemNotes({ enabled: isItemRecordType });
const { holdingsNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsRecordType });

const optionsMap = {
[CAPABILITIES.ITEM]: getItemsOptions(intl.formatMessage, itemNotes),
Expand All @@ -48,14 +44,14 @@ export const BulkEditInApp = ({
[CAPABILITIES.INSTANCE]: getInstanceOptions(intl.formatMessage),
};

const options = optionsMap[key];
const options = optionsMap[currentRecordType];
const showContentUpdatesForm = options && !isItemNotesLoading && !isHoldingsNotesLoading;
const sortedOptions = sortAlphabetically(options, intl.formatMessage({ id:'ui-bulk-edit.options.placeholder' }));

return (
<>
<Headline size="large" margin="medium">
<FormattedMessage id="ui-bulk-edit.preview.file.title" values={{ fileUploadedName }} />
<FormattedMessage id="ui-bulk-edit.preview.file.title" values={{ fileUploadedName: initialFileName }} />
</Headline>
<Accordion
label={<FormattedMessage id="ui-bulk-edit.layer.title" />}
Expand All @@ -77,6 +73,5 @@ export const BulkEditInApp = ({
};

BulkEditInApp.propTypes = {
capabilities: PropTypes.string,
onContentUpdatesChanged: PropTypes.func,
};
Loading