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

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

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* User can edit Source consortium "Holdings sources" in member tenant but not in Consortia manager. Refs UIIN-3147.
* React 19: refactor away from react-dom/test-utils. Refs UIIN-2888.
* Add call number browse settings. Refs UIIN-3116.
* 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
Loading