Skip to content

Commit

Permalink
UICHKIN-403 - Hide “Item details” option in Actions menu when item is…
Browse files Browse the repository at this point in the history
… virtual (#608)

* UICHKIN-403 - refinement

* UICHKIN-403 - fix test failures

* UICHKIN-403 - Conditional hide scanned record action menu options for DCB borrowing and Pickup roles.
  • Loading branch information
Terala-Priyanka authored Dec 5, 2023
1 parent 8874366 commit 2060677
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 9.1.0 IN PROGRESS
* Also support `feesfines` interface version `19.0`. Refs UICHKIN-401.
* Hide fee/fine action menu items when requester is virtual user. Refs UICHKIN-398.
* Hide “Item details” option in Actions menu when item is virtual. Refs UICHKIN-403.

## [9.0.1] (https://github.com/folio-org/ui-checkin/tree/v9.0.1) (2023-10-23)
[Full Changelog](https://github.com/folio-org/ui-checkin/compare/v9.0.0...v9.0.1)
Expand Down
23 changes: 15 additions & 8 deletions src/CheckIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
convertToSlipData,
getCheckinSettings,
isDcbUser,
isDCBItem,
} from './util';

import styles from './checkin.css';
Expand Down Expand Up @@ -304,12 +305,14 @@ class CheckIn extends React.Component {
timezone,
locale,
},
scannedItems,
} = this.props;

const isCheckInNote = element => element.noteType === 'Check in';
const checkinNotePresent = get(loan.item, ['circulationNotes'], []).some(isCheckInNote);
const loanOpenRequest = loan?.staffSlipContext?.request ?? {};
const isVirtualUser = isDcbUser(loan?.borrower);
const isVirtualItem = isDCBItem(get(scannedItems, [0, 'item']));

const trigger = ({ getTriggerProps, triggerRef }) => (
<IconButton
Expand Down Expand Up @@ -372,14 +375,18 @@ class CheckIn extends React.Component {
</Button>
</div>}
<div data-test-item-details>
<Button
role="menuitem"
buttonStyle="dropdownItem"
href={`/inventory/view/${loan.item.instanceId}/${loan.item.holdingsRecordId}/${loan.item.id}`}
onClick={(e) => this.handleOptionsChange({ loan, action: 'showItemDetails' }, e)}
>
<FormattedMessage id="ui-checkin.itemDetails" />
</Button>
{
!isVirtualItem && (
<Button
role="menuitem"
buttonStyle="dropdownItem"
href={`/inventory/view/${loan.item.instanceId}/${loan.item.holdingsRecordId}/${loan.item.id}`}
onClick={(e) => this.handleOptionsChange({ loan, action: 'showItemDetails' }, e)}
>
<FormattedMessage id="ui-checkin.itemDetails" />
</Button>
)
}
</div>
{!isEmpty(loanOpenRequest) &&
<div data-test-request-details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { account as accountFixture } from '../../../test/jest/fixtures/account';
import { loan as loanFixture } from '../../../test/jest/fixtures/loan';
import FeeFineDetailsButton from './FeeFineDetailsButton';
import { DCB_USER } from '../../consts';
import { DCB_USER_LASTNAME } from '../../consts';

const mockedQueryUpdate = jest.fn();
const labelIds = {
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('FeeFineDetailsButton', () => {
...loanFixture.loan,
borrower: {
...loanFixture.loan.borrower,
lastName: DCB_USER.lastName,
lastName: DCB_USER_LASTNAME,
}
}
};
Expand Down
7 changes: 6 additions & 1 deletion src/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export const cancelFeeClaimReturned = {

export const MAX_RECORDS = '1000';

export const DCB_USER_LASTNAME = 'DcbSystem';

export const DCB_USER = {
lastName: 'DcbSystem',
lastName: DCB_USER_LASTNAME,
};

export const DCB_INSTANCE_ID = '9d1b77e4-f02e-4b7f-b296-3f2042ddac54';
export const DCB_HOLDINGS_RECORD_ID = '10cd3a5a-d36f-4c7a-bc4f-e1ae3cf820c9';
4 changes: 4 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
import {
DCB_USER,
statuses,
DCB_INSTANCE_ID,
DCB_HOLDINGS_RECORD_ID,
} from './consts';

export const escapeValue = (val) => {
Expand Down Expand Up @@ -169,4 +171,6 @@ export function shouldConfirmStatusModalBeShown(item) {

export const isDcbUser = (user) => user?.lastName === DCB_USER.lastName;

export const isDCBItem = (item) => item.instanceId === DCB_INSTANCE_ID && item.holdingsRecordId === DCB_HOLDINGS_RECORD_ID;

export default {};
41 changes: 38 additions & 3 deletions src/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import {
getCheckinSettings,
shouldConfirmStatusModalBeShown,
isDcbUser,
isDCBItem,
} from './util';

import {
DCB_USER,
DCB_INSTANCE_ID,
DCB_HOLDINGS_RECORD_ID,
statuses,
} from './consts';

Expand Down Expand Up @@ -323,9 +326,7 @@ describe('shouldConfirmStatusModalBeShown', () => {

describe('isDcbUser', () => {
it('should return true when user has lastName as "DcbSystem"', () => {
const user = {
lastName: DCB_USER.lastName,
};
const user = DCB_USER;

expect(isDcbUser(user)).toBeTruthy();
});
Expand All @@ -338,3 +339,37 @@ describe('isDcbUser', () => {
expect(isDcbUser(user)).toBeFalsy();
});
});

describe('isDCBItem ', () => {
it('should return true when both item instance id and item holdings record id are DCB_INSTANCE_ID and DCB_HOLDINGS_RECORD_ID respectively', () => {
const item = {
instanceId: DCB_INSTANCE_ID,
holdingsRecordId: DCB_HOLDINGS_RECORD_ID,
};
expect(isDCBItem(item)).toBeTruthy();
});

it('should return false when item instance id is DCB_INSTANCE_ID and item holdings record id is not DCB_HOLDINGS_RECORD_ID', () => {
const item = {
instanceId: DCB_INSTANCE_ID,
holdingsRecordId: 'test',
};
expect(isDCBItem(item)).toBeFalsy();
});

it('should return false when item instance id is not DCB_INSTANCE_ID and item holdings record id is DCB_HOLDINGS_RECORD_ID', () => {
const item = {
instanceId: 'test',
holdingsRecordId: DCB_HOLDINGS_RECORD_ID,
};
expect(isDCBItem(item)).toBeFalsy();
});

it('should return false when item instance id is not DCB_INSTANCE_ID and item holdings record id is not DCB_HOLDINGS_RECORD_ID', () => {
const item = {
instanceId: 'test',
holdingsRecordId: 'test',
};
expect(isDCBItem(item)).toBeFalsy();
});
});

0 comments on commit 2060677

Please sign in to comment.