Skip to content

Commit

Permalink
Release v11.0.1 (#2443)
Browse files Browse the repository at this point in the history
* UIIN-2802 Retain browse query when switching Inventory browse options (#2417)

* UIIN-2802 Keep query when changing Browse options

* UIIN-2802 Update changelog

* UIIN-2802 Remove unneeded mock code

* UIIN-2802 Update changelog

(cherry picked from commit 1477513)

* UIIN-2802 Set prevSearchIndex when perfoming Browse, not when changing option (#2424)

(cherry picked from commit fdbf09e)

* UIIN-2784: Set central tenant id in the request when Member tenant deletes a shared record (#2416)

* UIIN-2784: Set central tenant id in the request when Member tenant deletes a shared record

* UIIN-2784: Set central tenant id in the request when Member tenant deletes a shared record

* Update utils.test.js

* UIIN-2784: Throw error in catch block

* UIIN-2784: Remove try catch

* UIIN-2784: Throw exception if response is failed

* UIIN-2784: Fix tests

(cherry picked from commit 0ca01a0)

* UIIN-2814 Apply staffSuppress.false in Holdings/Items search (#2420)

* UIIN-2814 Fix staff suppress false not applied for first holdings/items search

* UIIN-2814 Update changelog

* UIIN-2814 fix issue with crash when filters are empty

* UIIN-2814 Added tests for holdings staff suppress

* UIIN-2814 Fix tests

(cherry picked from commit 144db41)

* UIIN-2814 Clear USER_TOUCHED_STAFF_SUPPRESS_STORAGE_KEY flag when switching between search segments (follow-up) (#2435)

* UIIN-2814 Clear USER_TOUCHED_STAFF_SUPPRESS_STORAGE_KEY flag when switching between search segments

* UIIN-2814 fix eslint

(cherry picked from commit 4512f51)

* UIIN-2815: Pass tenantId when open holding details during moving holdings/items (#2427)

(cherry picked from commit cf33184)

* UIIN-2780: ECS - Member consortial accordion is not displaying when user have according affiliation but don't have permissions for view holdings (#2429)

(cherry picked from commit 7e785df)

* Release v11.0.1

---------

Co-authored-by: Denys Bohdan <[email protected]>
Co-authored-by: Oleksandr Hladchenko <[email protected]>
  • Loading branch information
3 people authored Apr 12, 2024
1 parent 8561dfe commit aee9c87
Show file tree
Hide file tree
Showing 63 changed files with 1,644 additions and 333 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change history for ui-inventory

## [11.0.1](https://github.com/folio-org/ui-inventory/tree/v11.0.1) (2024-04-11)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v11.0.0...v11.0.1)

* Keep query and results list when switching Browse options. Refs UIIN-2802.
* Set central tenant id in the request when Member tenant deletes a shared record. Fixes UIIN-2784.
* Apply staff suppress filter for first search in Holdings/Items. Fixes UIIN-2814.
* Pass tenantId when open holding details during moving holdings/items. Fixes UIIN-2815.
* ECS - Member consortial accordion is not displaying when a user has affiliations but does not have permission to view holdings. Fixes UIIN-2843.

## [11.0.0](https://github.com/folio-org/ui-inventory/tree/v11.0.0) (2024-03-21)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v10.0.11...v11.0.0)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
"version": "11.0.0",
"version": "11.0.1",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {
Expand Down
34 changes: 9 additions & 25 deletions src/Instance/HoldingsList/Holding/HoldingAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import {
Accordion,
Row,
Col,
Icon,
} from '@folio/stripes/components';

import { callNumberLabel } from '../../../utils';

import HoldingButtonsGroup from './HoldingButtonsGroup';
import { HoldingButtonsGroup } from './HoldingButtonsGroup';
import HoldingAccordionLabel from './HoldingAccordionLabel';
import {
useLocationsQuery,
useHoldingItemsQuery,
Expand Down Expand Up @@ -69,31 +67,17 @@ const HoldingAccordion = ({
/>;

const accId = pathToAccordion.join('.');
const accordionLabel = (
<HoldingAccordionLabel
location={location}
holding={holding}
/>
);

return (
<Accordion
id={accId}
label={(
<>
<FormattedMessage
id="ui-inventory.holdingsHeader"
values={{
location,
callNumber: callNumberLabel(holding),
copyNumber: holding.copyNumber,
}}
/>
{holding.discoverySuppress &&
<span>
<Icon
size="medium"
icon="exclamation-circle"
status="warn"
/>
</span>
}
</>
)}
label={accordionLabel}
displayWhenOpen={holdingButtonsGroup(true)}
displayWhenClosed={holdingButtonsGroup(false)}
closedByDefault
Expand Down
41 changes: 41 additions & 0 deletions src/Instance/HoldingsList/Holding/HoldingAccordionLabel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';

import { Icon } from '@folio/stripes/components';

import { callNumberLabel } from '../../../utils';

const HoldingAccordionLabel = ({
location,
holding,
}) => {
return (
<>
<FormattedMessage
id="ui-inventory.holdingsHeader"
values={{
location,
callNumber: callNumberLabel(holding),
copyNumber: holding.copyNumber,
}}
/>
{holding.discoverySuppress &&
<span>
<Icon
size="medium"
icon="exclamation-circle"
status="warn"
/>
</span>
}
</>
);
};

HoldingAccordionLabel.propTypes = {
location: PropTypes.string,
holding: PropTypes.object,
};

export default HoldingAccordionLabel;
34 changes: 34 additions & 0 deletions src/Instance/HoldingsList/Holding/HoldingAccordionLabel.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { screen } from '@folio/jest-config-stripes/testing-library/react';

import '../../../../test/jest/__mock__';

import {
renderWithIntl,
translationsProperties,
} from '../../../../test/jest/helpers';

import HoldingAccordionLabel from './HoldingAccordionLabel';

const renderHoldingAccordionLabel = () => {
const component = (
<HoldingAccordionLabel
location="library location"
holding={{
callNumberPrefix: 'callNumberPrefix',
callNumber: 'callNumber',
callNumberSuffix: 'callNumberSuffix',
copyNumber: 'copyNumber'
}}
/>
);

return renderWithIntl(component, translationsProperties);
};

describe('HoldingAccordionLabel', () => {
it('should display correct holdings label', () => {
renderHoldingAccordionLabel();

expect(screen.getByText(/holdings: library location > callNumberPrefix callNumber callNumberSuffix copyNumber/i)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';

import { Button } from '@folio/stripes/components';
import { useStripes } from '@folio/stripes/core';

import { switchAffiliation } from '../../../../utils';

const AddItemButton = ({
holding,
tenantId,
onAddItem,
disabled,
}) => {
const stripes = useStripes();

return (
<Button
id={`clickable-new-item-${holding.id}`}
onClick={async () => {
await switchAffiliation(stripes, tenantId, onAddItem);
}}
buttonStyle="primary paneHeaderNewButton"
disabled={disabled}
>
<FormattedMessage id="ui-inventory.addItem" />
</Button>
);
};

AddItemButton.propTypes = {
holding: PropTypes.object.isRequired,
tenantId: PropTypes.string.isRequired,
onAddItem: PropTypes.func.isRequired,
disabled: PropTypes.bool,
};

export default AddItemButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
fireEvent,
screen,
waitFor,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../../../test/jest/__mock__';

import {
renderWithIntl,
translationsProperties,
} from '../../../../../test/jest/helpers';

import AddItemButton from './AddItemButton';

const mockOnAddItem = jest.fn();

const renderAddItemButton = () => {
const component = (
<AddItemButton
holding={{ id: 'holdingsId' }}
tenantId="college"
onAddItem={mockOnAddItem}
/>
);

return renderWithIntl(component, translationsProperties);
};

describe('AddItemButton', () => {
it('should display Add item button', () => {
renderAddItemButton();

expect(screen.getByRole('button', { name: /add item/i })).toBeInTheDocument();
});

describe('when clicking Add item button', () => {
it('should call onAddItem callback', async () => {
renderAddItemButton();

const addItem = screen.getByRole('button', { name: /add item/i });

fireEvent.click(addItem);

await waitFor(() => expect(mockOnAddItem).toHaveBeenCalled());
});
});
});
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import React, { memo } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

import {
checkIfUserInCentralTenant,
IfPermission,
useStripes,
} from '@folio/stripes/core';
import {
Button,
Badge,
Icon,
} from '@folio/stripes/components';

import { switchAffiliation } from '../../../utils';

import { MoveToDropdown } from './MoveToDropdown';
import { MoveToDropdown } from '../MoveToDropdown';
import ViewHoldingsButton from './ViewHoldingsButton';
import AddItemButton from './AddItemButton';
import ItemsCountBadge from './ItemsCountBadge';

const HoldingButtonsGroup = ({
withMoveDropdown,
Expand Down Expand Up @@ -45,31 +40,22 @@ const HoldingButtonsGroup = ({
)
}
{showViewHoldingsButton &&
<Button
id={`clickable-view-holdings-${holding.id}`}
data-test-view-holdings
onClick={async () => {
await switchAffiliation(stripes, tenantId, onViewHolding);
}}
>
<FormattedMessage id="ui-inventory.viewHoldings" />
</Button>
<ViewHoldingsButton
holding={holding}
tenantId={tenantId}
onViewHolding={onViewHolding}
/>
}
{!isUserInCentralTenant && showAddItemButton && (
<IfPermission perm="ui-inventory.item.create">
<Button
id={`clickable-new-item-${holding.id}`}
data-test-add-item
onClick={async () => {
await switchAffiliation(stripes, tenantId, onAddItem);
}}
buttonStyle="primary paneHeaderNewButton"
>
<FormattedMessage id="ui-inventory.addItem" />
</Button>
<AddItemButton
holding={holding}
tenantId={tenantId}
onAddItem={onAddItem}
/>
</IfPermission>
)}
{!isOpen && <Badge>{itemCount ?? <Icon icon="spinner-ellipsis" width="10px" />}</Badge>}
{!isOpen && <ItemsCountBadge itemCount={itemCount} />}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { screen, fireEvent } from '@folio/jest-config-stripes/testing-library/react';

import '../../../../test/jest/__mock__';
import '../../../../../test/jest/__mock__';

import renderWithIntl from '../../../../test/jest/helpers/renderWithIntl';
import translations from '../../../../test/jest/helpers/translationsProperties';
import renderWithIntl from '../../../../../test/jest/helpers/renderWithIntl';
import translations from '../../../../../test/jest/helpers/translationsProperties';

import { switchAffiliation } from '../../../utils';
import { switchAffiliation } from '../../../../utils';

import HoldingButtonsGroup from './HoldingButtonsGroup';

jest.mock('../../../utils', () => ({
...jest.requireActual('../../../utils'),
jest.mock('../../../../utils', () => ({
...jest.requireActual('../../../../utils'),
switchAffiliation: jest.fn(),
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';

import {
Badge,
Icon,
} from '@folio/stripes/components';

const ItemsCountBadge = ({ itemCount }) => {
return <Badge>{itemCount ?? <Icon icon="spinner-ellipsis" width="10px" />}</Badge>;
};

ItemsCountBadge.propTypes = {
itemCount: PropTypes.number,
};

export default ItemsCountBadge;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { screen } from '@folio/jest-config-stripes/testing-library/react';

import '../../../../../test/jest/__mock__';

import {
renderWithIntl,
translationsProperties,
} from '../../../../../test/jest/helpers';

import ItemsCountBadge from './ItemsCountBadge';

const renderItemsCountBadge = () => {
const component = <ItemsCountBadge itemCount={6} />;

return renderWithIntl(component, translationsProperties);
};

describe('ItemsCountBadge', () => {
it('should display badge with item count', () => {
renderItemsCountBadge();

expect(screen.getByText('6')).toBeInTheDocument();
});
});
Loading

0 comments on commit aee9c87

Please sign in to comment.