Skip to content

Commit

Permalink
UIIN-3159: Display holdings names in Consortial holdings accordion …
Browse files Browse the repository at this point in the history
…for user without inventory permissions in member tenants (#2699)

* UIIN-3159: Display holdings names in Consortial holdings accordion for user without inventory permissions in member tenants

* UIIN-3159: Fix tests

* UIIN-3159: Fix tests
  • Loading branch information
OleksandrHladchenko1 authored Dec 20, 2024
1 parent f567735 commit 0b447d0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* React 19: refactor away from react-dom/test-utils. Refs UIIN-2888.
* Add call number browse settings. Refs UIIN-3116.
* Remove the ability to share local instance when `Inventory: View, create instances` permission is assigned. Fixes UIIN-3166.
* Display holdings names in `Consortial holdings` accordion for user without inventory permissions in member tenants. Fixes UIIN-3159

## [12.0.7](https://github.com/folio-org/ui-inventory/tree/v12.0.7) (2024-12-17)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.6...v12.0.7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const LimitedHolding = ({
instance,
holding,
tenantId,
locationName,
userTenantPermissions,
pathToAccordionsState,
}) => {
Expand All @@ -56,7 +57,7 @@ const LimitedHolding = ({

const accordionLabel = (
<HoldingAccordionLabel
location=" "
location={locationName}
holding={holding}
/>
);
Expand Down Expand Up @@ -105,6 +106,7 @@ LimitedHolding.propTypes = {
instance: PropTypes.object.isRequired,
holding: PropTypes.object.isRequired,
tenantId: PropTypes.string.isRequired,
locationName: PropTypes.string.isRequired,
userTenantPermissions: PropTypes.arrayOf(PropTypes.object).isRequired,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const renderLimitedHolding = () => {
instance={{ id: 'instanceId' }}
holding={holdingsWithLimitedInfo}
tenantId="college"
locationName="Location 1"
userTenantPermissions={userTenantLimitedPermissions}
pathToAccordionsState={[]}
/>
Expand All @@ -51,7 +52,7 @@ describe('LimitedHolding', () => {
renderLimitedHolding();

expect(screen.getByRole('button', {
name: /holdings: > prefix callnumber copynumber/i
name: /holdings: Location 1 > prefix callnumber copynumber/i
})).toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useContext } from 'react';
import PropTypes from 'prop-types';

import { DataContext } from '../../../../contexts';
import { LimitedHolding } from '../LimitedHolding';

const LimitedHoldingsList = ({
Expand All @@ -9,12 +11,15 @@ const LimitedHoldingsList = ({
userTenantPermissions,
pathToAccordionsState,
}) => {
const { locationsById } = useContext(DataContext);

return holdings.map((holding, i) => (
<LimitedHolding
key={`${holding.id}_${i}`}
instance={instance}
holding={holding}
tenantId={tenantId}
locationName={locationsById[holding.permanentLocationId].name}
userTenantPermissions={userTenantPermissions}
pathToAccordionsState={pathToAccordionsState}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
translationsProperties,
} from '../../../../../test/jest/helpers';

import { DataContext } from '../../../../contexts';
import LimitedHoldingsList from './LimitedHoldingsList';

jest.mock('../LimitedHolding', () => ({
Expand All @@ -22,21 +23,34 @@ const holdings = [{
callNumberPrefix: 'prefix',
callNumber: 'callNumber',
copyNumber: 'copyNumber',
permanentLocationId: 'permanentLocationId_1',
}, {
id: 'holdingsId2',
permanentLocationId: 'permanentLocationId_2',
}, {
id: 'holdingsId3',
permanentLocationId: 'permanentLocationId_3',
}];

const providerValue = {
locationsById: {
permanentLocationId_1: { name: 'Location 1' },
permanentLocationId_2: { name: 'Location 2' },
permanentLocationId_3: { name: 'Location 3' },
},
};

const renderLimitedHoldingsList = () => {
const component = (
<LimitedHoldingsList
instance={{ id: 'instanceId' }}
holdings={holdings}
tenantId="college"
userTenantPermissions={userTenantLimitedPermissions}
pathToAccordionsState={[]}
/>
<DataContext.Provider value={providerValue}>
<LimitedHoldingsList
instance={{ id: 'instanceId' }}
holdings={holdings}
tenantId="college"
userTenantPermissions={userTenantLimitedPermissions}
pathToAccordionsState={[]}
/>
</DataContext.Provider>
);

return renderWithIntl(component, translationsProperties);
Expand Down

0 comments on commit 0b447d0

Please sign in to comment.