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

UIREQ-1032, UIREQ-1034, UIREQ-1035 - Request detail view update for Lending, Borrowing and Pickup DCB roles #1118

Merged
merged 8 commits into from
Nov 10, 2023
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change history for ui-requests

## [9.1.0] in progress

* Hide all actions except "Cancel Request" in Action menu (Lending library). Refs UIREQ-1032.
* Hide all actions except "Cancel Request" in Action menu and DCB item links (Borrowing library). Refs UIREQ-1034.
* Hide all actions except "Cancel Request" in Action menu and DCB item links (Pickup library). Refs UIREQ-1035.

## [9.0.0](https://github.com/folio-org/ui-requests/tree/v9.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v8.0.2...v9.0.0)

Expand Down
3 changes: 2 additions & 1 deletion src/ItemDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {

import {
isValidRequest,
isVirtualItem,
openRequestStatusFilters,
} from './utils';
import { itemStatusesTranslations } from './constants';
Expand Down Expand Up @@ -58,7 +59,7 @@ const ItemDetail = ({
const isRequestValid = isValidRequest({ instanceId, holdingsRecordId });
const recordLink = () => {
if (itemId) {
return isRequestValid
return isRequestValid && !isVirtualItem(instanceId, holdingsRecordId)
? <Link to={`/inventory/view/${instanceId}/${holdingsRecordId}/${itemId}`}>{item.barcode || itemId}</Link>
: (item.barcode || itemId);
}
Expand Down
25 changes: 25 additions & 0 deletions src/ItemDetail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,29 @@ describe('ItemDetail', () => {
expect(within(keyValueWithLink).getByText(item.barcode)).toBeInTheDocument();
});
});

describe('when DCB transaction request on virtual item', () => {
const request = {
...defaultRequest,
instanceId: INVALID_REQUEST_HARDCODED_ID,
holdingsRecordId: INVALID_REQUEST_HARDCODED_ID,
};

beforeEach(() => {
render(
<ItemDetail
{...defaultProps}
request={request}
/>
);
});

it('should render "item barcode" without link', () => {
const keyValueWithLink = screen.getByTestId(testIds.itemBarcodeLink);
const link = within(keyValueWithLink).queryByRole('link');

expect(link).not.toBeInTheDocument();
expect(within(keyValueWithLink).getByText(item.barcode)).toBeInTheDocument();
});
});
});
41 changes: 25 additions & 16 deletions src/ViewRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import {
getTlrSettings,
generateUserName,
isValidRequest,
isVirtualItem,
isVirtualPatron,
} from './utils';
import urls from './routes/urls';

Expand Down Expand Up @@ -473,6 +475,7 @@ class ViewRequest extends React.Component {
const {
requestLevel,
item,
requester
} = request;

const getPickupServicePointName = this.getPickupServicePointName(request);
Expand All @@ -482,6 +485,7 @@ class ViewRequest extends React.Component {
const isRequestOpen = requestStatus.startsWith('Open');
const cancellationReasonMap = keyBy(cancellationReasons, 'id');
const isRequestValid = isValidRequest(request);
const isDCBTransaction = isVirtualPatron(requester?.personal?.lastName) || isVirtualItem(request?.instanceId, request?.holdingsRecordId);

let deliveryAddressDetail;
let selectedDelivery = false;
Expand Down Expand Up @@ -519,18 +523,22 @@ class ViewRequest extends React.Component {

return (
<IfPermission perm="ui-requests.create">
<Button
id="duplicate-request"
onClick={() => {
onToggle();
this.props.onDuplicate(request);
}}
buttonStyle="dropdownItem"
>
<Icon icon="duplicate">
<FormattedMessage id="ui-requests.actions.duplicateRequest" />
</Icon>
</Button>
{
!isDCBTransaction && (
<Button
id="duplicate-request"
onClick={() => {
onToggle();
this.props.onDuplicate(request);
}}
buttonStyle="dropdownItem"
>
<Icon icon="duplicate">
<FormattedMessage id="ui-requests.actions.duplicateRequest" />
</Icon>
</Button>
)
}
</IfPermission>
);
}
Expand All @@ -539,7 +547,7 @@ class ViewRequest extends React.Component {
<>
<IfPermission perm="ui-requests.edit">
{
isRequestValid &&
isRequestValid && !isDCBTransaction &&
<Button
buttonStyle="dropdownItem"
id="clickable-edit-request"
Expand Down Expand Up @@ -568,7 +576,7 @@ class ViewRequest extends React.Component {
</Button>
</IfPermission>
{
isRequestValid &&
isRequestValid && !isDCBTransaction &&
<IfPermission perm="ui-requests.create">
<Button
id="duplicate-request"
Expand All @@ -584,7 +592,7 @@ class ViewRequest extends React.Component {
</Button>
</IfPermission>
}
{item && isRequestNotFilled && isRequestValid &&
{item && isRequestNotFilled && isRequestValid && !isDCBTransaction &&
<IfPermission perm="ui-requests.moveRequest">
<Button
id="move-request"
Expand All @@ -599,7 +607,7 @@ class ViewRequest extends React.Component {
</Icon>
</Button>
</IfPermission> }
{isRequestOpen && isRequestValid &&
{isRequestOpen && isRequestValid && !isDCBTransaction &&
<IfPermission perm="ui-requests.reorderQueue">
<Button
id="reorder-queue"
Expand Down Expand Up @@ -670,6 +678,7 @@ class ViewRequest extends React.Component {
>
<TitleInformation
instanceId={request.instanceId}
holdingsRecordId={request.holdingsRecordId}
titleLevelRequestsCount={request.titleRequestCount}
title={request.instance.title}
contributors={request.instance.contributorNames}
Expand Down
Loading
Loading