Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into UIIN-3162
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Jan 14, 2025
2 parents 5bdfaa5 + e038eb3 commit 18cd885
Show file tree
Hide file tree
Showing 54 changed files with 242 additions and 243 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
* 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.
* Add "linked-data 1.0" interface to "optionalOkapiInterfaces". Refs UIIN-3166.
* Fix infinite loading animation after cancel edit/duplicate or 'Save & Close' consortial holdings/items. Fixes UIIN-3167.
* Remove hover-over text next to "Effective call number" on the Item record detail view. Refs UIIN-3131.
* Change import of `exportToCsv` from `stripes-util` to `stripes-components`. Refs UIIN-3025.

## [12.0.8](https://github.com/folio-org/ui-inventory/tree/v12.0.8) (2024-12-24)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.7...v12.0.8)

* Display holdings names in `Consortial holdings` accordion for user without inventory permissions in member tenants. Fixes UIIN-3159.
* Remove the ability to share local instance when `Inventory: View, create instances` permission is assigned. Fixes UIIN-3166.
* *BREAKING* Use `browse` `1.5` interface that provides new Call Number Browse endpoints. Refs UIIN-3162.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
"orders-storage.settings": "1.0",
"organizations.organizations": "1.0",
"pieces": "3.0",
"titles": "1.2"
"titles": "1.2",
"linked-data": "1.0"
},
"permissionSets": [
{
Expand Down
6 changes: 4 additions & 2 deletions src/Holding/DuplicateHolding/DuplicateHolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DuplicateHolding = ({
state: {
backPathname: locationState,
tenantFrom,
initialTenantId,
} = {},
},
referenceTables,
Expand Down Expand Up @@ -72,12 +73,13 @@ const DuplicateHolding = ({
history.push({
pathname: locationState?.backPathname ?? `/inventory/view/${instanceId}`,
search,
state: { initialTenantId },
});
}, [search, instanceId]);

const onCancel = useCallback(async () => {
await switchAffiliation(stripes, tenantFrom, goBack);
}, [stripes, tenantFrom, goBack]);
await switchAffiliation(stripes, initialTenantId, goBack);
}, [stripes, initialTenantId, goBack]);

const onSubmit = useCallback(holdingValues => (
mutateHolding(holdingValues)
Expand Down
20 changes: 7 additions & 13 deletions src/Holding/EditHolding/EditHolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
} from '../../hooks';
import HoldingsForm from '../../edit/holdings/HoldingsForm';
import withLocation from '../../withLocation';
import {
parseHttpError,
switchAffiliation,
} from '../../utils';
import { parseHttpError } from '../../utils';

const EditHolding = ({
goTo,
Expand All @@ -35,7 +32,7 @@ const EditHolding = ({
search,
state: {
backPathname: locationState,
tenantFrom,
initialTenantId,
} = {},
} = location;
const stripes = useStripes();
Expand All @@ -59,16 +56,13 @@ const EditHolding = ({
history.push({
pathname: locationState?.backPathname ?? `/inventory/view/${instanceId}/${holdingId}`,
search,
state: { initialTenantId },
});
}, [search, instanceId, holdingId]);

const onCancel = useCallback(async () => {
await switchAffiliation(stripes, tenantFrom, goBack);
}, [stripes, tenantFrom, goBack]);

const onSuccess = useCallback(async () => {
const onSuccess = useCallback(() => {
if (!keepEditing.current) {
await switchAffiliation(stripes, tenantFrom, goBack);
goBack();
} else {
refetchHolding();
}
Expand All @@ -80,7 +74,7 @@ const EditHolding = ({
values={{ hrid: holding?.hrid }}
/>,
});
}, [switchAffiliation, stripes, tenantFrom, goBack, refetchHolding, holding, callout]);
}, [goBack, refetchHolding, holding, callout]);

const onError = async error => {
const parsedError = await parseHttpError(error.response);
Expand All @@ -107,7 +101,7 @@ const EditHolding = ({
location={location}
initialValues={holding}
onSubmit={onSubmit}
onCancel={onCancel}
onCancel={goBack}
okapi={stripes.okapi}
instance={instance}
referenceTables={referenceTables}
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
2 changes: 1 addition & 1 deletion src/Instance/ItemsList/ItemBarcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ItemBarcode = ({
search,
state: {
tenantTo: tenantId,
tenantFrom: stripes.okapi.tenant,
initialTenantId: stripes.okapi.tenant,
},
});

Expand Down
1 change: 1 addition & 0 deletions src/Instance/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const navigateToHoldingsViewPage = (history, location, instance, holding,
state: {
tenantTo,
tenantFrom,
initialTenantId: tenantFrom,
},
});
};
Expand Down
5 changes: 4 additions & 1 deletion src/Item/DuplicateItem/DuplicateItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ const DuplicateItem = ({
history.push({
pathname: `/inventory/view/${instanceId}/${holdingId}/${itemId}`,
search: location.search,
state: { tenantTo: stripes.okapi.tenant },
state: {
tenantTo: stripes.okapi.tenant,
initialTenantId: location?.state?.initialTenantId,
},
});
}, [location.search, instanceId, holdingId, itemId]);

Expand Down
20 changes: 9 additions & 11 deletions src/Item/EditItem/EditItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '../../common';
import ItemForm from '../../edit/items/ItemForm';
import useCallout from '../../hooks/useCallout';
import { parseHttpError, switchAffiliation } from '../../utils';
import { parseHttpError } from '../../utils';
import {
useItem,
useItemMutation,
Expand Down Expand Up @@ -49,18 +49,16 @@ const EditItem = ({
history.push({
pathname: `/inventory/view/${instanceId}/${holdingId}/${itemId}`,
search: location.search,
state: { tenantTo: stripes.okapi.tenant },
state: {
tenantTo: stripes.okapi.tenant,
initialTenantId: location?.state?.initialTenantId,
},
});
}, [location.search, instanceId, holdingId, itemId]);

const onCancel = useCallback(async () => {
await switchAffiliation(stripes, location?.state?.tenantFrom, goBack);
}, [stripes, location?.state?.tenantFrom, goBack]);


const onSuccess = useCallback(async () => {
const onSuccess = useCallback(() => {
if (!keepEditing.current) {
await switchAffiliation(stripes, location?.state?.tenantFrom, goBack);
goBack();
} else {
refetchItem();
}
Expand All @@ -72,7 +70,7 @@ const EditItem = ({
values={{ hrid: item.hrid }}
/>,
});
}, [switchAffiliation, stripes, location, goBack, refetchItem, callout, item]);
}, [goBack, refetchItem, callout, item]);

const onError = async error => {
const parsedError = await parseHttpError(error.response);
Expand Down Expand Up @@ -129,7 +127,7 @@ const EditItem = ({
key={holding.id}
initialValues={item}
onSubmit={onSubmit}
onCancel={onCancel}
onCancel={goBack}
okapi={stripes.okapi}
instance={instance}
holdingsRecord={holding}
Expand Down
19 changes: 8 additions & 11 deletions src/ViewHoldingsRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class ViewHoldingsRecord extends React.Component {
stripes,
location,
} = this.props;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;
const tenantFrom = location?.state?.initialTenantId || stripes.okapi.tenant;

await switchAffiliation(stripes, tenantFrom, this.goToInstanceView);
}
Expand All @@ -264,17 +264,15 @@ class ViewHoldingsRecord extends React.Component {
location,
id,
holdingsrecordid,
stripes,
initialTenantId,
} = this.props;

const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;

history.push({
pathname: `/inventory/edit/${id}/${holdingsrecordid}`,
search: location.search,
state: {
backPathname: location.pathname,
tenantFrom,
initialTenantId,
},
});
}
Expand All @@ -288,16 +286,18 @@ class ViewHoldingsRecord extends React.Component {
id,
holdingsrecordid,
stripes,
initialTenantId,
} = this.props;

const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;
const tenantFrom = stripes.okapi.tenant;

history.push({
pathname: `/inventory/copy/${id}/${holdingsrecordid}`,
search: location.search,
state: {
backPathname: location.pathname,
tenantFrom,
initialTenantId,
},
});
}
Expand Down Expand Up @@ -641,10 +641,8 @@ class ViewHoldingsRecord extends React.Component {
referenceTables,
goTo,
stripes,
location,
} = this.props;
const { instance } = this.state;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;

if (this.isAwaitingResource()) return <LoadingView />;

Expand Down Expand Up @@ -957,9 +955,7 @@ class ViewHoldingsRecord extends React.Component {
updatedDate: getDate(holdingsRecord?.metadata?.updatedDate),
})}
dismissible
onClose={async () => {
await switchAffiliation(stripes, tenantFrom, this.onClose);
}}
onClose={this.onClose}
actionMenu={this.getPaneHeaderActionMenu}
>
<Row center="xs">
Expand Down Expand Up @@ -1390,6 +1386,7 @@ ViewHoldingsRecord.propTypes = {
goTo: PropTypes.func.isRequired,
isInstanceShared: PropTypes.bool,
onUpdateOwnership: PropTypes.func,
initialTenantId: PropTypes.string,
};

export default flowRight(
Expand Down
Loading

0 comments on commit 18cd885

Please sign in to comment.