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-1134: Migrate from mod-circulation endpoint to mod-circulation-bff for form #1221

Merged
merged 6 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change history for ui-requests

## IN PROGRESS
## 11.0.0 (IN PROGRESS)
* Use settings/entries endpoint to get settings information. Refs UIREQ-1062.
* Requests app.: Editing requests (ECS with mod-tlr enabled). Refs UIREQ-1088.
* Requests app.: Cancelling request (ECS with mod-tlr enabled). Refs UIREQ-1090.
Expand All @@ -16,6 +16,7 @@
* Add `tlr.settings.get` permission. Refs UIREQ-1169.
* Add `mod-settings.global.read.circulation` permission. Refs UIREQ-1170.
* Add `mod-settings.entries.collection.get` permission. Refs UIREQ-1177.
* *BREAKING* Migrate to new `mod-circulation-bff` endpoints. Refs UIREQ-1134.

## [10.0.0] (https://github.com/folio-org/ui-requests/tree/v10.0.0) (2024-10-31)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v9.1.2...v10.0.0)
Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/requests",
"version": "10.0.0",
"version": "11.0.0",
"description": "Requests manager",
"repository": "folio-org/ui-requests",
"publishConfig": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"pick-slips": "0.1",
"search-slips": "0.1",
"automated-patron-blocks": "0.1",
"instance-items": "0.1"
"circulation-bff-requests": "1.0"
},
"permissionSets": [
{
Expand All @@ -58,7 +58,7 @@
"subPermissions": [
"circulation.requests.queue.collection.get",
"circulation.requests.queue.reorder.collection.post",
"circulation.requests.allowed-service-points.get",
"circulation-bff.requests.allowed-service-points.get",
"circulation.rules.request-policy.get"
]
},
Expand Down Expand Up @@ -122,18 +122,16 @@
"subPermissions": [
"ui-requests.view",
"automated-patron-blocks.collection.get",
"circulation.requests.item.post",
"circulation.requests.allowed-service-points.get",
"circulation-bff.requests.allowed-service-points.get",
"circulation-storage.requests.item.post",
"circulation-storage.request-preferences.collection.get",
"circulation-storage.staff-slips.collection.get",
"circulation.pick-slips.get",
"circulation.search-slips.get",
"circulation.print-events-entry.item.post",
"inventory-storage.locations.item.get",
"circulation.items-by-instance.get",
"tlr.ecs-tlr-allowed-service-points.get",
"tlr.ecs-tlr.post"
"circulation-bff.requests.search-instances.get",
"circulation-bff.requests.post"
],
"visible": true
},
Expand All @@ -145,7 +143,7 @@
"circulation.pick-slips.get",
"circulation.search-slips.get",
"circulation.requests.item.put",
"circulation.requests.allowed-service-points.get",
"circulation-bff.requests.allowed-service-points.get",
"circulation.print-events-entry.item.post",
"circulation-storage.staff-slips.collection.get",
"circulation-storage.requests.collection.delete",
Expand Down
2 changes: 1 addition & 1 deletion src/ItemsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ ItemsDialog.manifest = {
items: {
type: 'okapi',
records: 'items',
path: 'circulation/items-by-instance',
path: 'circulation-bff/requests/search-instances',
accumulate: true,
fetch: false,
},
Expand Down
2 changes: 1 addition & 1 deletion src/MoveRequestManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class MoveRequestManager extends React.Component {
token: stripes.store.getState().okapi.token,
})
};
const url = `${stripes.okapi.url}/circulation/requests/allowed-service-points?requestId=${request.id}&itemId=${selectedItem.id}&operation=${REQUEST_OPERATIONS.MOVE}`;
const url = `${stripes.okapi.url}/circulation-bff/requests/allowed-service-points?requestId=${request.id}&itemId=${selectedItem.id}&operation=${REQUEST_OPERATIONS.MOVE}`;

this.setState({
isRequestTypesLoading: true,
Expand Down
2 changes: 1 addition & 1 deletion src/MoveRequestManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('MoveRequestManager', () => {
});

it('should trigger fetch with correct argument', () => {
const expectedUrl = `${basicProps.stripes.okapi.url}/circulation/requests/allowed-service-points?requestId=${basicProps.request.id}&itemId=${selectedItem.id}&operation=${REQUEST_OPERATIONS.MOVE}`;
const expectedUrl = `${basicProps.stripes.okapi.url}/circulation-bff/requests/allowed-service-points?requestId=${basicProps.request.id}&itemId=${selectedItem.id}&operation=${REQUEST_OPERATIONS.MOVE}`;

expect(global.fetch).toHaveBeenCalledWith(expectedUrl, {});
});
Expand Down
15 changes: 0 additions & 15 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,3 @@ export const SETTINGS_SCOPES = {
export const SETTINGS_KEYS = {
GENERAL_TLR: 'generalTlr',
};

export const REQUEST_ACTION_NAMES = {
CREATE_REQUEST: 'CREATE_REQUEST',
GET_SERVICE_POINTS: 'GET_SERVICE_POINTS',
};

export const SINGLE_TENANT_URLS = {
[REQUEST_ACTION_NAMES.CREATE_REQUEST]: 'circulation/requests',
[REQUEST_ACTION_NAMES.GET_SERVICE_POINTS]: 'circulation/requests/allowed-service-points',
};

export const CENTRAL_TENANT_URLS = {
[REQUEST_ACTION_NAMES.CREATE_REQUEST]: 'tlr/ecs-tlr',
[REQUEST_ACTION_NAMES.GET_SERVICE_POINTS]: 'tlr/allowed-service-points',
};
34 changes: 9 additions & 25 deletions src/routes/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
isEmpty,
isArray,
size,
unset,
cloneDeep,
} from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -70,8 +69,6 @@ import {
SETTINGS_SCOPES,
SETTINGS_KEYS,
ITEM_QUERIES,
REQUEST_ACTION_NAMES,
CENTRAL_TENANT_URLS,
PRINT_DETAILS_COLUMNS,
RESOURCE_TYPES,
requestFilterTypes,
Expand All @@ -89,7 +86,6 @@ import {
getSelectedSlipDataMulti,
selectedRowsNonPrintable,
getNextSelectedRowsState,
getRequestUrl,
isMultiDataTenant,
} from '../utils';
import packageInfo from '../../package';
Expand Down Expand Up @@ -167,12 +163,12 @@ export const urls = {

query = stringify({ query });

return `circulation/items-by-instance?${query}`;
return `circulation-bff/requests/search-instances?${query}`;
},
instance: (value) => {
const query = stringify({ query: getInstanceQueryString(value) });

return `circulation/items-by-instance?${query}`;
return `circulation-bff/requests/search-instances?${query}`;
},
loan: (value) => {
const query = stringify({ query: `(itemId=="${value}") and status.name==Open` });
Expand Down Expand Up @@ -208,14 +204,12 @@ export const urls = {
instanceId,
requestId,
operation,
}, idType, stripes) => {
const url = getRequestUrl(REQUEST_ACTION_NAMES.GET_SERVICE_POINTS, stripes);

}) => {
if (requestId) {
return `${url}?operation=${operation}&requestId=${requestId}`;
return `circulation-bff/requests/allowed-service-points?operation=${operation}&requestId=${requestId}`;
}

let requestUrl = `${url}?requesterId=${requesterId}&operation=${operation}`;
let requestUrl = `circulation-bff/requests/allowed-service-points?requesterId=${requesterId}&operation=${operation}`;

if (itemId) {
requestUrl = `${requestUrl}&itemId=${itemId}`;
Expand Down Expand Up @@ -369,9 +363,9 @@ class RequestsRoute extends React.Component {
staticFallback: { params: {} },
},
},
ecsTlrRecords: {
circulationRequests: {
type: 'okapi',
path: CENTRAL_TENANT_URLS[REQUEST_ACTION_NAMES.CREATE_REQUEST],
path: 'circulation-bff/requests',
fetch: false,
throwErrors: false,
},
Expand Down Expand Up @@ -514,7 +508,7 @@ class RequestsRoute extends React.Component {
GET: PropTypes.func,
POST: PropTypes.func,
}),
ecsTlrRecords: PropTypes.shape({
circulationRequests: PropTypes.shape({
POST: PropTypes.func,
}),
reportRecords: PropTypes.shape({
Expand Down Expand Up @@ -1109,21 +1103,11 @@ class RequestsRoute extends React.Component {
};

create = (requestData) => {
const { stripes } = this.props;
const userPersonalData = cloneDeep(requestData?.requester?.personal);
let mutator = this.props.mutator.records;

if (isMultiDataTenant(stripes) && checkIfUserInCentralTenant(stripes)) {
unset(requestData, 'item');
unset(requestData, 'requester');

mutator = this.props.mutator.ecsTlrRecords;
}

const query = new URLSearchParams(this.props.location.search);
const mode = query.get('mode');

return mutator.POST(requestData)
return this.props.mutator.circulationRequests.POST(requestData)
.then((res) => {
const {
match: {
Expand Down
22 changes: 11 additions & 11 deletions src/routes/RequestsRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ const testIds = {
rowCheckbox: 'rowCheckbox',
selectRequestCheckbox: 'selectRequestCheckbox',
};
const requestUrl = 'url';

const intlCache = createIntlCache();
const intl = createIntl(
{
Expand Down Expand Up @@ -117,7 +115,6 @@ jest.mock('../utils', () => ({
extractPickSlipRequestIds: jest.fn(),
isMultiDataTenant: jest.fn(),
generateUserName: jest.fn(),
getRequestUrl: jest.fn(() => requestUrl),
}));
jest.mock('./utils', () => ({
...jest.requireActual('./utils'),
Expand Down Expand Up @@ -444,6 +441,9 @@ describe('RequestsRoute', () => {
GET: jest.fn(),
POST: jest.fn().mockResolvedValue(),
},
circulationRequests: {
POST: jest.fn().mockResolvedValue(),
},
reportRecords: {
GET: jest.fn().mockReturnValueOnce(mockRecordValues).mockRejectedValue(),
reset: jest.fn(),
Expand Down Expand Up @@ -704,8 +704,7 @@ describe('RequestsRoute', () => {
...defaultProps,
mutator: {
...defaultProps.mutator,
records: {
...defaultProps.mutator.records,
circulationRequests: {
POST: jest.fn().mockResolvedValue(response),
},
},
Expand All @@ -721,7 +720,7 @@ describe('RequestsRoute', () => {

fireEvent.click(createRequestButton);

expect(props.mutator.records.POST).toHaveBeenCalledWith(userData);
expect(props.mutator.circulationRequests.POST).toHaveBeenCalledWith(userData);
});

it('should redirect to details page', async () => {
Expand Down Expand Up @@ -756,7 +755,7 @@ describe('RequestsRoute', () => {
...defaultProps,
mutator: {
...defaultProps.mutator,
ecsTlrRecords: {
circulationRequests: {
POST: jest.fn().mockResolvedValue(response),
},
},
Expand Down Expand Up @@ -801,7 +800,7 @@ describe('RequestsRoute', () => {

fireEvent.click(createRequestButton);

expect(props.mutator.ecsTlrRecords.POST).toHaveBeenCalledWith(userData);
expect(props.mutator.circulationRequests.POST).toHaveBeenCalledWith(userData);
});
});

Expand Down Expand Up @@ -1662,7 +1661,7 @@ describe('RequestsRoute', () => {
});

it('should return correct url', () => {
const expectedResult = `circulation/items-by-instance?${mockedQueryValue}`;
const expectedResult = `circulation-bff/requests/search-instances?${mockedQueryValue}`;

expect(queryString).toBe(expectedResult);
});
Expand All @@ -1685,7 +1684,7 @@ describe('RequestsRoute', () => {
});

it('should return correct url', () => {
const expectedResult = `circulation/items-by-instance?${mockedQueryValue}`;
const expectedResult = `circulation-bff/requests/search-instances?${mockedQueryValue}`;

expect(queryString).toBe(expectedResult);
});
Expand Down Expand Up @@ -1715,7 +1714,7 @@ describe('RequestsRoute', () => {
});

it('should return correct url', () => {
const expectedResult = `circulation/items-by-instance?${mockedQueryValue}`;
const expectedResult = `circulation-bff/requests/search-instances?${mockedQueryValue}`;

expect(queryString).toBe(expectedResult);
});
Expand Down Expand Up @@ -1832,6 +1831,7 @@ describe('RequestsRoute', () => {
const operation = REQUEST_OPERATIONS.CREATE;
const itemId = 'itemIdUrl';
const instanceId = 'instanceIdUrl';
const requestUrl = 'circulation-bff/requests/allowed-service-points';

it('should return url with "itemId"', () => {
const expectedResult = `${requestUrl}?requesterId=${requesterId}&operation=${operation}&itemId=${itemId}`;
Expand Down
14 changes: 0 additions & 14 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
Row,
NoValue,
} from '@folio/stripes/components';
import { checkIfUserInCentralTenant } from '@folio/stripes/core';

import {
requestTypeOptionMap,
Expand All @@ -38,8 +37,6 @@ import {
DCB_USER,
SLIPS_TYPE,
REQUEST_ERROR_MESSAGE_TRANSLATION_KEYS,
CENTRAL_TENANT_URLS,
SINGLE_TENANT_URLS,
} from './constants';

import css from './requests.css';
Expand Down Expand Up @@ -531,14 +528,3 @@ export const getRequester = (proxy, selectedUser) => {

return selectedUser;
};

export const getRequestUrl = (actionName, stripes) => {
const isMultiTenant = isMultiDataTenant(stripes);
const isUserInCentralTenant = checkIfUserInCentralTenant(stripes);

if (isMultiTenant && isUserInCentralTenant) {
return CENTRAL_TENANT_URLS[actionName];
}

return SINGLE_TENANT_URLS[actionName];
};
Loading
Loading