Skip to content

Commit

Permalink
Merge branch 'master' into UIIN-3191
Browse files Browse the repository at this point in the history
  • Loading branch information
mariia-aloshyna authored Feb 12, 2025
2 parents 9cc2249 + 04fcc5d commit 13f4fc1
Show file tree
Hide file tree
Showing 27 changed files with 868 additions and 472 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
* Sort holdings by location name and call number. Refs UIIN-3207.
* Remove hover-over text next to "Shelving order" on the Item record detail view. Refs UIIN-3210.
* CI: Switch to centralized/shared workflow from https://github.com/folio-org/.github. Fixes UIIN-3218.
* Set correct widths for Call number browse results columns. Fixes UIIN-3229.
* Display actual instance state (shared or local) when user is using "Drag and drop" to move inventory records. Fixes UIIN-3185.
* Add Version history button and Version history pane to details view of Item. Refs UIIN-3172.
* Add Version history button and Version history pane to details view of Holdings. Refs UIIN-3171.
* Add Version history button and Version history pane to details view of Instance. Refs UIIN-3170.
* Add new ‘Set for deletion’ flag to display on 3rd pane Instance view. Refs UIIN-3191.

## [12.0.12](https://github.com/folio-org/ui-inventory/tree/v12.0.12) (2025-01-27)
Expand Down Expand Up @@ -47,6 +52,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.
* Add `getCallNumberQuery` function to build a query string based on the call number and its type. Refs UIIN-3205.

## [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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
"version": "13.0.0",
"version": "13.1.0",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {
Expand Down Expand Up @@ -54,7 +54,7 @@
"okapiInterfaces": {
"alternative-title-types": "1.0",
"call-number-types": "1.0",
"browse": "0.6 1.0",
"browse": "1.5",
"circulation": "9.0 10.0 11.0 12.0 13.0 14.0",
"classification-types": "1.1",
"configuration": "2.0",
Expand Down
64 changes: 39 additions & 25 deletions src/Instance/InstanceDetails/InstanceDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import {
Row,
MessageBanner,
PaneCloseLink,
Paneset,

Check warning on line 29 in src/Instance/InstanceDetails/InstanceDetails.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

'Paneset' is defined but never used. Allowed unused vars must match /React/u
} from '@folio/stripes/components';
import { VersionHistoryButton } from '@folio/stripes-acq-components';

import { InstanceTitle } from './InstanceTitle';
import { InstanceAdministrativeView } from './InstanceAdministrativeView';
Expand All @@ -42,6 +44,7 @@ import { InstanceRelationshipView } from './InstanceRelationshipView';
import { InstanceNewHolding } from './InstanceNewHolding';
import { InstanceAcquisition } from './InstanceAcquisition';
import HelperApp from '../../components/HelperApp';
import { VersionHistory } from '../../views/VersionHistory';

import { DataContext } from '../../contexts';
import { ConsortialHoldings } from '../HoldingsList/consortium/ConsortialHoldings';
Expand Down Expand Up @@ -92,11 +95,13 @@ const InstanceDetails = forwardRef(({
const accordionState = useMemo(() => getAccordionState(instance, accordions), [instance]);
const [helperApp, setHelperApp] = useState();
const [isAllExpanded, setIsAllExpanded] = useState();
const [isVersionHistoryOpen, setIsVersionHistoryOpen] = useState(false);

const canCreateHoldings = stripes.hasPerm('ui-inventory.holdings.create');
const tags = instance?.tags?.tagList;
const isUserInCentralTenant = checkIfUserInCentralTenant(stripes);
const isConsortialHoldingsVisible = instance?.shared || isInstanceShadowCopy(instance?.source);
const isUserInConsortium = isUserInConsortiumMode(stripes);

const detailsLastMenu = useMemo(() => {
return (
Expand All @@ -112,6 +117,7 @@ const InstanceDetails = forwardRef(({
/>
)
}
<VersionHistoryButton onClick={() => setIsVersionHistoryOpen(true)} />
</PaneMenu>
);
}, [tagsEnabled, tags, intl]);
Expand All @@ -122,32 +128,35 @@ const InstanceDetails = forwardRef(({

const getEntity = () => instance;

const renderPaneTitle = () => {
const isInstanceShared = Boolean(isShared || isInstanceShadowCopy(instance?.source));
const paneTitle = useMemo(
() => {
const isInstanceShared = Boolean(isShared || isInstanceShadowCopy(instance?.source));

return (
<FormattedMessage
id={`ui-inventory.${isUserInConsortiumMode(stripes) ? 'consortia.' : ''}instanceRecordTitle`}
values={{
return intl.formatMessage(
{ id: `ui-inventory.${isUserInConsortium ? 'consortia.' : ''}instanceRecordTitle` },
{
isShared: isInstanceShared,
title: instance?.title,
publisherAndDate: getPublishingInfo(instance),
}}
/>
);
};

const renderPaneSubtitle = () => {
return (
<FormattedMessage
id="ui-inventory.instanceRecordSubtitle"
values={{
hrid: instance?.hrid,
updatedDate: getDate(instance?.metadata?.updatedDate),
}}
/>
);
};
}
);
},
[isShared, instance?.source, isUserInConsortium],
);
const paneSubTitle = useMemo(
() => {
return (
<FormattedMessage
id="ui-inventory.instanceRecordSubtitle"
values={{
hrid: instance?.hrid,
updatedDate: getDate(instance?.metadata?.updatedDate),
}}
/>
);
},
[instance?.hrid, instance?.metadata?.updatedDate],
);

const onToggle = newState => {
const isExpanded = Object.values(newState)[0];
Expand Down Expand Up @@ -180,14 +189,14 @@ const InstanceDetails = forwardRef(({
{...rest}
data-test-instance-details
appIcon={<AppIcon app="inventory" iconKey="instance" />}
paneTitle={renderPaneTitle()}
paneSub={renderPaneSubtitle()}
paneTitle={paneTitle}
paneSub={paneSubTitle}
actionMenu={actionMenu}
firstMenu={(
<PaneCloseLink
autoFocus={location.state?.isClosingFocused}
onClick={onClose}
aria-label={intl.formatMessage({ id: 'stripes-components.closeItem' }, { item: renderPaneTitle() })}
aria-label={intl.formatMessage({ id: 'stripes-components.closeItem' }, { item: paneTitle })}
/>
)}
lastMenu={detailsLastMenu}
Expand Down Expand Up @@ -316,6 +325,11 @@ const InstanceDetails = forwardRef(({
</AccordionSet>
</AccordionStatus>
</Pane>
{isVersionHistoryOpen && (
<VersionHistory
onClose={() => setIsVersionHistoryOpen(false)}
/>
)}
{ helperApp &&
<HelperApp
getEntity={getEntity}
Expand Down
45 changes: 43 additions & 2 deletions src/Instance/InstanceDetails/InstanceDetails.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react';
import React, { act } from 'react';
import '../../../test/jest/__mock__';
import { QueryClient, QueryClientProvider } from 'react-query';
import { screen, fireEvent } from '@folio/jest-config-stripes/testing-library/react';
import {
screen,
fireEvent,
within,
} from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';
import { MemoryRouter } from 'react-router-dom';
import { DataContext } from '../../contexts';
import { renderWithIntl, translationsProperties } from '../../../test/jest/helpers';
Expand Down Expand Up @@ -220,4 +225,40 @@ describe('InstanceDetails', () => {
expect(screen.queryByRole('button', { name: 'Consortial holdings' })).not.toBeInTheDocument();
});
});

describe('Version history component', () => {
let versionHistoryButton;

beforeEach(async () => {
await act(async () => { renderInstanceDetails(); });

versionHistoryButton = screen.getByRole('button', { name: /version history/i });
});

it('should render version history button', async () => {
expect(versionHistoryButton).toBeInTheDocument();
});

describe('when click the button', () => {
it('should render version history pane', async () => {
await act(() => userEvent.click(versionHistoryButton));

expect(screen.getByRole('region', { name: /version history/i })).toBeInTheDocument();
});
});

describe('when click the close button', () => {
it('should hide the pane', async () => {
await act(() => userEvent.click(versionHistoryButton));

const versionHistoryPane = await screen.findByRole('region', { name: /version history/i });
expect(versionHistoryPane).toBeInTheDocument();

const closeButton = await within(versionHistoryPane).findByRole('button', { name: /close/i });
await act(() => userEvent.click(closeButton));

expect(screen.queryByRole('region', { name: /version history/i })).not.toBeInTheDocument();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const InstanceMovementDetails = ({
onClose={closeInstance}
actionMenu={getActionMenu}
data-test-instance-movement-details={instance.id}
isShared={instance.shared}
id={id}
>
<Droppable
Expand Down
Loading

0 comments on commit 13f4fc1

Please sign in to comment.