diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a06339f..07f0d1d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
* 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.
+* Hide Actions menu on closed request of DCB Transaction. Refs UIREQ-1040.
## [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)
diff --git a/src/ViewRequest.js b/src/ViewRequest.js
index a6477b27..3e929326 100644
--- a/src/ViewRequest.js
+++ b/src/ViewRequest.js
@@ -513,32 +513,28 @@ class ViewRequest extends React.Component {
const showActionMenu = stripes.hasPerm('ui-requests.create')
|| stripes.hasPerm('ui-requests.edit')
|| stripes.hasPerm('ui-requests.moveRequest')
- || stripes.hasPerm('ui-requests.reorderQueue');
+ || stripes.hasPerm('ui-requests.reorderQueue') || !isDCBTransaction;
const actionMenu = ({ onToggle }) => {
if (isRequestClosed) {
- if (!isRequestValid || (requestLevel === REQUEST_LEVEL_TYPES.TITLE && !titleLevelRequestsFeatureEnabled)) {
+ if (!isRequestValid || (requestLevel === REQUEST_LEVEL_TYPES.TITLE && !titleLevelRequestsFeatureEnabled) || isDCBTransaction) {
return null;
}
return (
- {
- !isDCBTransaction && (
-
- )
- }
+
);
}
diff --git a/src/ViewRequest.test.js b/src/ViewRequest.test.js
index 9f12b608..19816559 100644
--- a/src/ViewRequest.test.js
+++ b/src/ViewRequest.test.js
@@ -133,14 +133,37 @@ describe('ViewRequest', () => {
},
},
};
+ const defaultDCBLendingProps = {
+ ...defaultProps,
+ resources: {
+ selectedRequest: {
+ hasLoaded: true,
+ records: [
+ mockedRequestWithDCBUser,
+ ],
+ },
+ }
+ };
+ const defaultDCBBorrowingProps = {
+ ...defaultProps,
+ resources: {
+ selectedRequest: {
+ hasLoaded: true,
+ records: [
+ mockedRequestWithVirtualItem,
+ ],
+ },
+ }
+ };
+ const renderViewRequest = (props) => render(
+
+
+
+ );
describe('Non DCB Transactions', () => {
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(defaultProps);
});
afterEach(() => {
@@ -212,11 +235,7 @@ describe('ViewRequest', () => {
};
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(props);
});
it('should not render "Duplicate" button', () => {
@@ -243,11 +262,7 @@ describe('ViewRequest', () => {
};
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(props);
});
it('actions menu should show all possible actions', () => {
@@ -277,11 +292,7 @@ describe('ViewRequest', () => {
};
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(props);
});
it('should render action menu with only "Cancel request" button', () => {
@@ -314,54 +325,37 @@ describe('ViewRequest', () => {
});
describe('when virtual patron-DCB Lending flow', () => {
- const alteredProps = {
- ...defaultProps,
- resources: {
- selectedRequest: {
- hasLoaded: true,
- records: [
- mockedRequestWithDCBUser,
- ],
- },
- }
- };
-
describe('when in request detail', () => {
beforeAll(() => {
mockedLocation.search = null;
});
- describe('when current lending request is closed', () => {
- const openValidRequest = {
+ describe("when current lending request status starts with 'Closed'", () => {
+ const closedStatuses = [requestStatuses.FILLED, requestStatuses.CANCELLED, requestStatuses.PICKUP_EXPIRED, requestStatuses.UNFILLED];
+ const closedRequests = closedStatuses.map(cStatus => ({
...mockedRequestWithDCBUser,
- status: requestStatuses.FILLED,
- };
-
- const props = {
- ...alteredProps,
+ status: cStatus,
+ }));
+ const closedRequestsProps = closedRequests.map(cReq => ({
+ ...defaultDCBLendingProps,
resources: {
selectedRequest: {
hasLoaded: true,
records: [
{
- ...alteredProps.resources.selectedRequest.records,
- ...openValidRequest,
+ ...defaultDCBLendingProps.resources.selectedRequest.records,
+ ...cReq,
},
],
},
- },
- };
-
- beforeEach(() => {
- render(
-
-
-
- );
- });
+ }
+ }));
- it('should not render "Duplicate" button', () => {
- expect(screen.queryByText(labelIds.duplicateRequest)).not.toBeInTheDocument();
+ closedRequestsProps.forEach(props => {
+ it(`should not render action menu when request status is ${props?.resources?.selectedRequest?.records[0]?.status}`, () => {
+ renderViewRequest(props);
+ expect(screen.queryByRole('button', { name: 'Actions' })).toBeNull();
+ });
});
});
@@ -372,13 +366,13 @@ describe('ViewRequest', () => {
};
const props = {
- ...alteredProps,
+ ...defaultDCBLendingProps,
resources: {
selectedRequest: {
hasLoaded: true,
records: [
{
- ...alteredProps.resources.selectedRequest.records,
+ ...defaultDCBLendingProps.resources.selectedRequest.records,
...openValidRequest,
},
],
@@ -387,11 +381,7 @@ describe('ViewRequest', () => {
};
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(props);
});
it('should render action menu with only "Cancel request" button', () => {
@@ -406,11 +396,7 @@ describe('ViewRequest', () => {
describe('Keyboard shortcuts', () => {
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(defaultDCBLendingProps);
});
it('should check permission when duplicating', () => {
duplicateRecordShortcut(document.body);
@@ -425,71 +411,53 @@ describe('ViewRequest', () => {
});
describe('when virtual item-DCB Borrowing flow', () => {
- const alteredProps = {
- ...defaultProps,
- resources: {
- selectedRequest: {
- hasLoaded: true,
- records: [
- mockedRequestWithVirtualItem,
- ],
- },
- }
- };
-
describe('when in request detail', () => {
beforeAll(() => {
mockedLocation.search = null;
});
- describe('when current lending request is closed', () => {
- const openValidRequest = {
+ describe('when current borrowing request status starts with "Closed"', () => {
+ const closedStatuses = [requestStatuses.FILLED, requestStatuses.CANCELLED, requestStatuses.PICKUP_EXPIRED, requestStatuses.UNFILLED];
+ const closedRequests = closedStatuses.map(cStatus => ({
...mockedRequestWithDCBUser,
- status: requestStatuses.FILLED,
- };
-
- const props = {
- ...alteredProps,
+ status: cStatus,
+ }));
+ const closedRequestsProps = closedRequests.map(cReq => ({
+ ...defaultDCBBorrowingProps,
resources: {
selectedRequest: {
hasLoaded: true,
records: [
{
- ...alteredProps.resources.selectedRequest.records,
- ...openValidRequest,
+ ...defaultDCBBorrowingProps.resources.selectedRequest.records,
+ ...cReq,
},
],
},
- },
- };
-
- beforeEach(() => {
- render(
-
-
-
- );
- });
-
- it('should not render "Duplicate" button', () => {
- expect(screen.queryByText(labelIds.duplicateRequest)).not.toBeInTheDocument();
+ }
+ }));
+ closedRequestsProps.forEach(props => {
+ it(`should not render action menu when request status is ${props?.resources?.selectedRequest?.records[0]?.status}`, () => {
+ renderViewRequest(props);
+ expect(screen.queryByRole('button', { name: 'Actions' })).toBeNull();
+ });
});
});
- describe('when current lending request is open', () => {
+ describe('when current borrowing request is open', () => {
const openValidRequest = {
...mockedRequestWithDCBUser,
status: requestStatuses.NOT_YET_FILLED,
};
const props = {
- ...alteredProps,
+ ...defaultDCBBorrowingProps,
resources: {
selectedRequest: {
hasLoaded: true,
records: [
{
- ...alteredProps.resources.selectedRequest.records,
+ ...defaultDCBBorrowingProps.resources.selectedRequest.records,
...openValidRequest,
},
],
@@ -498,11 +466,7 @@ describe('ViewRequest', () => {
};
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(props);
});
it('should render action menu with only "Cancel request" button', () => {
@@ -517,11 +481,7 @@ describe('ViewRequest', () => {
describe('Keyboard shortcuts', () => {
beforeEach(() => {
- render(
-
-
-
- );
+ renderViewRequest(defaultDCBBorrowingProps);
});
it('should check permission when duplicating', () => {
duplicateRecordShortcut(document.body);