Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into UIBULKED-540
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
vashjs committed Nov 1, 2024
2 parents 3c6051f + 9e393f3 commit 6434943
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change history for ui-bulk-edit

## In progress
* [UIBULKED-540](https://folio-org.atlassian.net/browse/UIBULKED-540) Update identifiers names for Item record.

## [4.2.0](https://github.com/folio-org/ui-bulk-edit/tree/v4.2.0) (2024-10-31)

* [UIBULKED-441](https://issues.folio.org/browse/UIBULKED-441) Bulk edit form enhancements - part 1.
* [UIBULKED-442](https://issues.folio.org/browse/UIBULKED-442) Bulk edit form enhancements - part 2.
* [UIBULKED-465](https://issues.folio.org/browse/UIBULKED-465) Local approach - Incorrect numbers of changed records and errors are displayed on Confirmation screen
Expand Down Expand Up @@ -69,7 +73,8 @@
* [UIBULKED-572](https://folio-org.atlassian.net/browse/UIBULKED-572) Include additional field to 'actions'.
* [UIBULKED-497](https://folio-org.atlassian.net/browse/UIBULKED-497) "Are you sure" preview displays outdated values after User changed selection on bulk edit form and clicked "Confirm changes".
* [UIBULKED-557](https://folio-org.atlassian.net/browse/UIBULKED-557) Add hover effect to improve text visibility in dropdowns in Bulk Edit in-app form.
* [UIBULKED-540](https://folio-org.atlassian.net/browse/UIBULKED-540) Update identifiers names for Item record.
* [UIBULKED-575](https://folio-org.atlassian.net/browse/UIBULKED-575) Fix "Something went wrong" toast notifications when starting bulk edit.
* Bump "@folio/stripes-acq-components" version to v6.0.0

## [4.1.4](https://github.com/folio-org/ui-bulk-edit/tree/v4.1.4) (2024-05-29)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/bulk-edit",
"version": "4.1.4",
"version": "4.2.0",
"description": "Description for bulk edit",
"main": "index.js",
"repository": "",
Expand Down Expand Up @@ -226,7 +226,7 @@
"testing-library-selector": "^0.2.1"
},
"dependencies": {
"@folio/stripes-acq-components": "^5.0.0",
"@folio/stripes-acq-components": "^6.0.0",
"file-saver": "^2.0.5",
"history": "^5.1.0",
"lodash": "^4.17.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
Loading,
Layout,
} from '@folio/stripes/components';
import { useStripes } from '@folio/stripes/core';
import {
checkIfUserInCentralTenant,
useStripes,
} from '@folio/stripes/core';

import { BulkEditInAppTitle } from './BulkEditInAppTitle/BulkEditInAppTitle';
import { ContentUpdatesForm } from './ContentUpdatesForm/ContentUpdatesForm';
Expand Down Expand Up @@ -42,10 +45,8 @@ export const BulkEditInApp = ({
onContentUpdatesChanged,
}) => {
const { title } = useContext(RootContext);
const { user, okapi } = useStripes();
const centralTenant = user?.user?.consortium?.centralTenantId;
const tenantId = okapi.tenant;
const isCentralTenant = tenantId === centralTenant;
const stripes = useStripes();
const isCentralTenant = checkIfUserInCentralTenant(stripes);

const { formatMessage } = useIntl();
const { currentRecordType } = useSearchParams();
Expand All @@ -56,12 +57,12 @@ export const BulkEditInApp = ({
const isHoldingsRecordType = currentRecordType === CAPABILITIES.HOLDING;
const isInstanceRecordType = currentRecordType === CAPABILITIES.INSTANCE;

const { data: tenants, isLoading } = useBulkOperationTenants(bulkOperationId);
const { itemNotes, isItemNotesLoading } = useItemNotes({ enabled: isItemRecordType });
const { holdingsNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsRecordType });
const { instanceNotes, isInstanceNotesLoading } = useInstanceNotes({ enabled: isInstanceRecordType });
const { data: tenants } = useBulkOperationTenants(bulkOperationId);
const { notesEsc: itemNotesEsc, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'option', { enabled: isItemRecordType && Boolean(tenants?.length) });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'option', { enabled: isHoldingsRecordType && (Boolean(tenants?.length)) });
const { notesEsc: itemNotesEsc, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'option', { enabled: isItemRecordType && isCentralTenant && !isLoading });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'option', { enabled: isHoldingsRecordType && isCentralTenant && !isLoading });

const options = useMemo(() => ({
[CAPABILITIES.ITEM]: getItemsOptions(formatMessage, removeDuplicatesByValue(isCentralTenant ? itemNotesEsc : itemNotes, tenants)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React from 'react';
import { useIntl } from 'react-intl';
import PropTypes from 'prop-types';

import { useStripes } from '@folio/stripes/core';
import {
checkIfUserInCentralTenant,
useStripes,
} from '@folio/stripes/core';
import {
Datepicker,
Select,
Expand Down Expand Up @@ -61,15 +64,13 @@ import {
} from '../../../../../utils/helpers';

export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option }) => {
const { user, okapi } = useStripes();
const stripes = useStripes();
const { formatMessage } = useIntl();
const {
currentRecordType,
} = useSearchParams();
const { id: bulkOperationId } = usePathParams('/bulk-edit/:id');
const centralTenant = user?.user?.consortium?.centralTenantId;
const tenantId = okapi.tenant;
const isCentralTenant = tenantId === centralTenant;
const isCentralTenant = checkIfUserInCentralTenant(stripes);

const isUserCapability = currentRecordType === CAPABILITIES.USER;
const isItemCapability = currentRecordType === CAPABILITIES.ITEM;
Expand All @@ -82,13 +83,13 @@ export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option
const { itemNotes, usItemNotesLoading } = useItemNotes({ enabled: isItemCapability });
const { instanceNotes, isInstanceNotesLoading } = useInstanceNotes({ enabled: isInstanceCapability });
const { data: tenants } = useBulkOperationTenants(bulkOperationId);
const { notesEsc: itemsNotes, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'action', { enabled: isItemCapability && Boolean(tenants?.length) });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'action', { enabled: isHoldingsCapability && Boolean(tenants?.length) });
const { locationsEsc, isFetching: isLocationEscLoading } = useLocationEsc(tenants, { enabled: Boolean(tenants?.length) });
const { escData: loanTypesEsc, isFetching: isLoanTypesEscLoading } = useLoanTypesEsc(tenants, { enabled: Boolean(tenants?.length) });
const { notesEsc: itemsNotes, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'action', { enabled: isItemCapability && isCentralTenant });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'action', { enabled: isHoldingsCapability && isCentralTenant });
const { locationsEsc, isFetching: isLocationEscLoading } = useLocationEsc(tenants, { enabled: isCentralTenant });
const { escData: loanTypesEsc, isFetching: isLoanTypesEscLoading } = useLoanTypesEsc(tenants, { enabled: isCentralTenant });

const { electronicAccessRelationships, isElectronicAccessLoading } = useElectronicAccessRelationships({ enabled: isHoldingsCapability });
const { escData: urlRelationshipsEsc, isFetching: isElectronicAccessEscLoading } = useElectronicAccessEsc(tenants, { enabled: Boolean(tenants?.length) });
const { escData: urlRelationshipsEsc, isFetching: isElectronicAccessEscLoading } = useElectronicAccessEsc(tenants, { enabled: isCentralTenant });
// exclude from second action the first action value
const filteredElectronicAccessRelationships = electronicAccessRelationships.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value);
const filteredElectronicAccessRelationshipsEsc = urlRelationshipsEsc?.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const BulkEditPreviewModal = ({
id: bulkDetails?.id,
approach: APPROACHES.IN_APP,
step: EDITING_STEPS.COMMIT,
}).then(showErrorMessage);
});

onChangesCommited();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
import { useBulkOperationDelete } from '../../../../hooks/api/useBulkOperationDelete';
import { ListFileUploader } from '../../../shared/ListFileUploader';
import { useSearchParams } from '../../../../hooks/useSearchParams';
import { useErrorMessages } from '../../../../hooks/useErrorMessages';

const BulkEditManualUploadModal = ({
operationId,
Expand All @@ -39,7 +38,6 @@ const BulkEditManualUploadModal = ({
const callout = useShowCallout();
const controller = useRef(null);
const { identifier, criteria } = useSearchParams();
const { showErrorMessage } = useErrorMessages();

const { fileUpload } = useUpload();
const { bulkOperationStart } = useBulkOperationStart();
Expand Down Expand Up @@ -104,7 +102,7 @@ const BulkEditManualUploadModal = ({
id: operationId,
step: EDITING_STEPS.COMMIT,
approach: APPROACHES.MANUAL,
}).then(showErrorMessage);
});

setCountOfRecords(committedNumOfRecords);

Expand Down
3 changes: 1 addition & 2 deletions src/hooks/api/useBulkOperationDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ export const useBulkOperationDelete = (mutationOptions = {}) => {

const { mutateAsync: bulkOperationDelete, isLoading } = useMutation({
mutationFn: async ({ operationId }) => {
return ky.post(`bulk-operations/${operationId}/cancel`).json();
return ky.post(`bulk-operations/${operationId}/cancel`);
},
onError: showErrorMessage,
onSuccess: showErrorMessage,
...mutationOptions,
});

Expand Down
1 change: 1 addition & 0 deletions src/hooks/api/useBulkOperationTenants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useBulkOperationTenants = (id, options = {}) => {
queryKey: [namespace],
queryFn: () => ky.get(`bulk-operations/used-tenants/${id}`).json(),
keepPreviousData: true,
enabled: !!id,
...options,
});

Expand Down

0 comments on commit 6434943

Please sign in to comment.