Skip to content

Commit

Permalink
UIU-2988 - Disable open loan action buttons and hide open loan record…
Browse files Browse the repository at this point in the history
… action menu items for DCB Lending library
  • Loading branch information
Terala-Priyanka committed Nov 20, 2023
1 parent 705b58e commit e0dcbac
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Also support `feesfines` interface version `19.0`. Refs UIU-2960.
* Disable validation for shadow user. Refs UIU-3000.
* Disable open loan actions for virtual patron. Refs UIU-2964.
* Open loan page modifications for a virtual patron. Refs UIU-2988.

## [10.0.4](https://github.com/folio-org/ui-users/tree/v10.0.4) (2023-11-10)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.0.3...v10.0.4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
getChargeFineToLoanPath,
getOpenRequestsPath,
checkUserActive,
isDcbUser,
isDCBItem,
} from '../../../../util';

import { itemStatuses } from '../../../../../constants';
Expand Down Expand Up @@ -54,20 +56,26 @@ class ActionsDropdown extends React.Component {
const loanPolicyLink = `/settings/circulation/loan-policies/${loan.loanPolicyId}`;
const buttonDisabled = !stripes.hasPerm('ui-users.feesfines.actions.all');
const isUserActive = checkUserActive(user);
const isVirtualUser = isDcbUser(user);
const isVirtualItem = isDCBItem(loan?.item);

return (
<DropdownMenu data-role="menu">
<IfPermission perm="inventory.items.item.get">
<Button
buttonStyle="dropdownItem"
to={itemDetailsLink}
disabled={!loan?.item}
>
<FormattedMessage id="ui-users.itemDetails" />
</Button>
{
!isVirtualItem && (
<Button
buttonStyle="dropdownItem"
to={itemDetailsLink}
disabled={!loan?.item}
>
<FormattedMessage id="ui-users.itemDetails" />
</Button>
)
}
</IfPermission>
<IfPermission perm="ui-users.loans.renew">
{ isUserActive && itemStatusName !== itemStatuses.CLAIMED_RETURNED &&
{ isUserActive && !isVirtualUser && itemStatusName !== itemStatuses.CLAIMED_RETURNED &&
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-renew-button
Expand All @@ -81,7 +89,7 @@ class ActionsDropdown extends React.Component {
}
</IfPermission>
<IfPermission perm="ui-users.loans.claim-item-returned">
{ itemStatusName !== itemStatuses.CLAIMED_RETURNED &&
{ itemStatusName !== itemStatuses.CLAIMED_RETURNED && !isVirtualUser &&
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-claim-returned-button
Expand All @@ -98,6 +106,7 @@ class ActionsDropdown extends React.Component {
{ itemStatusName !== itemStatuses.DECLARED_LOST &&
itemStatusName !== itemStatuses.CLAIMED_RETURNED &&
itemStatusName !== itemStatuses.AGED_TO_LOST &&
!isVirtualUser &&
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-change-due-date-button
Expand All @@ -111,7 +120,7 @@ class ActionsDropdown extends React.Component {
}
</IfPermission>
<IfPermission perm="ui-users.loans.declare-item-lost">
{ itemStatusName !== itemStatuses.DECLARED_LOST &&
{ itemStatusName !== itemStatuses.DECLARED_LOST && !isVirtualUser &&
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-declare-lost-button
Expand All @@ -125,7 +134,7 @@ class ActionsDropdown extends React.Component {
}
</IfPermission>
<IfPermission perm="ui-users.loans.declare-claimed-returned-item-as-missing">
{ itemStatusName === itemStatuses.CLAIMED_RETURNED &&
{ itemStatusName === itemStatuses.CLAIMED_RETURNED && !isVirtualUser &&
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-mark-as-missing-button
Expand All @@ -139,34 +148,46 @@ class ActionsDropdown extends React.Component {
}
</IfPermission>
<IfPermission perm="circulation-storage.loan-policies.item.get">
<Button
buttonStyle="dropdownItem"
to={loanPolicyLink}
>
<FormattedMessage id="ui-users.loans.details.loanPolicy" />
</Button>
{
!isVirtualUser && (
<Button
buttonStyle="dropdownItem"
to={loanPolicyLink}
>
<FormattedMessage id="ui-users.loans.details.loanPolicy" />
</Button>
)
}
</IfPermission>
<IfPermission perm="ui-users.feesfines.actions.all">
<Button
buttonStyle="dropdownItem"
disabled={buttonDisabled}
to={getChargeFineToLoanPath(params.id, loan.id)}
>
<FormattedMessage id="ui-users.loans.newFeeFine" />
</Button>
{
!isVirtualUser && (
<Button
buttonStyle="dropdownItem"
disabled={buttonDisabled}
to={getChargeFineToLoanPath(params.id, loan.id)}
>
<FormattedMessage id="ui-users.loans.newFeeFine" />
</Button>
)
}
</IfPermission>
<IfPermission perm="ui-users.feesfines.view">
<Button
buttonStyle="dropdownItem"
disabled={disableFeeFineDetails}
onClick={() => {
handleOptionsChange({ loan, action: 'feefineDetails' });
}}
>
<FormattedMessage id="ui-users.loans.feeFineDetails" />
</Button>
{
!isVirtualUser && (
<Button
buttonStyle="dropdownItem"
disabled={disableFeeFineDetails}
onClick={() => {
handleOptionsChange({ loan, action: 'feefineDetails' });
}}
>
<FormattedMessage id="ui-users.loans.feeFineDetails" />
</Button>
)
}
</IfPermission>
{requestQueue && stripes.hasPerm('ui-requests.all') &&
{requestQueue && stripes.hasPerm('ui-requests.all') && !isVirtualUser &&
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-request-queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
hasAnyLoanItemStatus,
getRenewalPatronBlocksFromPatronBlocks,
checkUserActive,
isDcbUser,
} from '../../../../util';

import css from './OpenLoansSubHeader.css';
Expand Down Expand Up @@ -121,6 +122,7 @@ const OpenLoansSubHeader = ({
const onlyClaimedReturnedItemsSelected = hasEveryLoanItemStatus(checkedLoans, itemStatuses.CLAIMED_RETURNED);
const onlyLostyItemsSelected = hasAnyLoanItemStatus(checkedLoans, lostItemStatuses);
const isUserActive = checkUserActive(user);
const isVirtualUser = isDcbUser(user);

return (
<ActionsBar
Expand Down Expand Up @@ -158,45 +160,47 @@ const OpenLoansSubHeader = ({
</span>
}
contentEnd={
<span>
<IfPermission perm="ui-users.loans.renew">
<Button
marginBottom0
id="renew-all"
disabled={noSelectedLoans || onlyClaimedReturnedItemsSelected || !isUserActive}
onClick={!isEmpty(countRenews)
? openPatronBlockedModal
: () => renewSelected()
!isVirtualUser && (
<span>
<IfPermission perm="ui-users.loans.renew">
<Button
marginBottom0
id="renew-all"
disabled={noSelectedLoans || onlyClaimedReturnedItemsSelected || !isUserActive}
onClick={!isEmpty(countRenews)
? openPatronBlockedModal
: () => renewSelected()
}
>
{intl.formatMessage({ id: 'ui-users.renew' })}
</Button>
</IfPermission>
<IfPermission perm="ui-users.loans.claim-item-returned">
<Button
marginBottom0
id="bulk-claim-returned"
disabled={noSelectedLoans || onlyClaimedReturnedItemsSelected}
onClick={openBulkClaimReturnedModal}
>
{intl.formatMessage({ id: 'ui-users.loans.claimReturned' })}
</Button>
</IfPermission>
<IfPermission perm="ui-users.loans.change-due-date">
<Button
marginBottom0
id="change-due-date-all"
disabled={noSelectedLoans || onlyLostyItemsSelected}
onClick={showChangeDueDateDialog}
>
{intl.formatMessage({ id: 'stripes-smart-components.cddd.changeDueDate' })}
</Button>
</IfPermission>
<ExportCsv
data={recordsToCSV}
onlyFields={columnHeadersMap}
/>
</span>
>
{intl.formatMessage({ id: 'ui-users.renew' })}
</Button>
</IfPermission>
<IfPermission perm="ui-users.loans.claim-item-returned">
<Button
marginBottom0
id="bulk-claim-returned"
disabled={noSelectedLoans || onlyClaimedReturnedItemsSelected}
onClick={openBulkClaimReturnedModal}
>
{intl.formatMessage({ id: 'ui-users.loans.claimReturned' })}
</Button>
</IfPermission>
<IfPermission perm="ui-users.loans.change-due-date">
<Button
marginBottom0
id="change-due-date-all"
disabled={noSelectedLoans || onlyLostyItemsSelected}
onClick={showChangeDueDateDialog}
>
{intl.formatMessage({ id: 'stripes-smart-components.cddd.changeDueDate' })}
</Button>
</IfPermission>
<ExportCsv
data={recordsToCSV}
onlyFields={columnHeadersMap}
/>
</span>
)
}
/>
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
USER_TYPES,
requestStatuses,
sortTypes,
DCB_INSTANCE_ID,
DCB_HOLDINGS_RECORD_ID,
} from '../../constants';

/**
Expand Down Expand Up @@ -208,3 +210,5 @@ export const isStaffUser = (user) => user?.type === USER_TYPES.STAFF;
export const isAffiliationsEnabled = (user) => {
return !isPatronUser(user) && !isDcbUser(user);
};

export const isDCBItem = (item) => item.instanceId === DCB_INSTANCE_ID && item.holdingsRecordId === DCB_HOLDINGS_RECORD_ID;
3 changes: 3 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ export const USER_TYPES = {
SYSTEM: 'system',
DCB: 'dcb',
};

export const DCB_INSTANCE_ID = '9d1b77e4-f02e-4b7f-b296-3f2042ddac54';
export const DCB_HOLDINGS_RECORD_ID = '10cd3a5a-d36f-4c7a-bc4f-e1ae3cf820c9';
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"@aashutoshrathi/word-wrap@^1.2.3", "@aashutoshrathi/word-wrap@^1.2.6", "word-wrap@npm:@aashutoshrathi/word-wrap@^1.2.6":
name word-wrap
version "1.2.6"
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==
Expand Down Expand Up @@ -9449,7 +9450,7 @@ postcss-calc@^9.0.1:
postcss-selector-parser "^6.0.11"
postcss-value-parser "^4.2.0"

"postcss-color-function@github:folio-org/postcss-color-function":
postcss-color-function@folio-org/postcss-color-function:
version "4.1.0"
resolved "https://codeload.github.com/folio-org/postcss-color-function/tar.gz/c128aad740ae740fb571c4b6493f467dd51efe85"
dependencies:
Expand Down

0 comments on commit e0dcbac

Please sign in to comment.