Skip to content

Commit

Permalink
Hide proxy functionality for ECS with mod-tlr enabled (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-blazhko authored Nov 22, 2024
1 parent eef6ca8 commit e996115
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* Add `mod-settings.entries.collection.get` permission. Refs UIREQ-1177.
* *BREAKING* Migrate to new `mod-circulation-bff` endpoints. Refs UIREQ-1134.
* Implement feature toggle for ECS and not ECS envs. Refs UIREQ-1171.

* Update permission checks of ui-users. Refs UIREQ-1187.
* Hide proxy functionality for ECS with mod-tlr enabled. Refs UIREQ-1185.

## [10.0.1] (https://github.com/folio-org/ui-requests/tree/v10.0.1) (2024-11-13)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v10.0.0...v10.0.1)
Expand Down
21 changes: 16 additions & 5 deletions src/RequestForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {
isFormEditing,
resetFieldState,
getRequester,
isProxyFunctionalityAvailable,
} from './utils';

import css from './requests.css';
Expand Down Expand Up @@ -159,6 +160,7 @@ class RequestForm extends React.Component {
onSetSelectedInstance: PropTypes.func.isRequired,
onSetBlocked: PropTypes.func.isRequired,
onSetIsPatronBlocksOverridden: PropTypes.func.isRequired,
isEcsTlrSettingEnabled: PropTypes.bool.isRequired,
};

static defaultProps = {
Expand Down Expand Up @@ -472,7 +474,9 @@ class RequestForm extends React.Component {
}

async hasProxies(user) {
if (!user) {
const { isEcsTlrSettingEnabled } = this.props;

if (!user || !isProxyFunctionalityAvailable(isEcsTlrSettingEnabled)) {
this.setState({ isAwaitingForProxySelection: false });

return null;
Expand Down Expand Up @@ -509,6 +513,7 @@ class RequestForm extends React.Component {
onSetIsPatronBlocksOverridden,
onSetSelectedUser,
onSetBlocked,
isEcsTlrSettingEnabled,
} = this.props;

this.setState({
Expand All @@ -535,7 +540,9 @@ class RequestForm extends React.Component {

return findResource(RESOURCE_TYPES.USER, value, fieldName)
.then((result) => {
this.setState({ isAwaitingForProxySelection: true });
if (isProxyFunctionalityAvailable(isEcsTlrSettingEnabled)) {
this.setState({ isAwaitingForProxySelection: true });
}

if (result.totalRecords === 1) {
const blocks = onGetPatronManualBlocks(parentResources);
Expand Down Expand Up @@ -759,6 +766,7 @@ class RequestForm extends React.Component {
form,
onSetSelectedItem,
selectedUser,
isEcsTlrSettingEnabled,
} = this.props;
const { proxy } = this.state;

Expand Down Expand Up @@ -815,7 +823,7 @@ class RequestForm extends React.Component {
})
.then(item => {
if (item && selectedUser?.id) {
const requester = getRequester(proxy, selectedUser);
const requester = getRequester(proxy, selectedUser, isEcsTlrSettingEnabled);
this.findRequestTypes(item.id, requester.id, ID_TYPE_MAP.ITEM_ID);
}

Expand Down Expand Up @@ -848,6 +856,7 @@ class RequestForm extends React.Component {
form,
onSetSelectedInstance,
selectedUser,
isEcsTlrSettingEnabled,
} = this.props;
const { proxy } = this.state;

Expand Down Expand Up @@ -897,7 +906,7 @@ class RequestForm extends React.Component {
})
.then(instance => {
if (instance && selectedUser?.id) {
const requester = getRequester(proxy, selectedUser);
const requester = getRequester(proxy, selectedUser, isEcsTlrSettingEnabled);
this.findRequestTypes(instance.id, requester.id, ID_TYPE_MAP.INSTANCE_ID);
}

Expand Down Expand Up @@ -1111,6 +1120,7 @@ class RequestForm extends React.Component {
onSetSelectedItem,
onSetSelectedInstance,
metadataDisplay,
isEcsTlrSettingEnabled,
} = this.props;

const {
Expand Down Expand Up @@ -1139,7 +1149,7 @@ class RequestForm extends React.Component {
const automatedPatronBlocks = onGetAutomatedPatronBlocks(parentResources);
const isEditForm = isFormEditing(request);
const selectedProxy = getProxy(request, proxy);
const requester = getRequester(selectedProxy, selectedUser);
const requester = getRequester(selectedProxy, selectedUser, isEcsTlrSettingEnabled);
let deliveryLocations;
let deliveryLocationsDetail = [];
let addressDetail;
Expand Down Expand Up @@ -1331,6 +1341,7 @@ class RequestForm extends React.Component {
handleCloseProxy={this.handleCloseProxy}
findUser={this.findUser}
triggerUserBarcodeValidation={this.triggerUserBarcodeValidation}
isEcsTlrSettingEnabled={isEcsTlrSettingEnabled}
/>
</div>
</Accordion>
Expand Down
1 change: 1 addition & 0 deletions src/RequestForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jest.mock('./utils', () => ({
isFormEditing: jest.fn(),
getFulfillmentPreference: jest.fn(),
getRequester: jest.fn((proxy, selectedUser) => selectedUser),
isProxyFunctionalityAvailable: jest.fn(() => true),
}));
jest.mock('./components/FulfilmentPreference', () => jest.fn(({
changeDeliveryAddress,
Expand Down
3 changes: 3 additions & 0 deletions src/RequestFormContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const RequestFormContainer = ({
parentResources,
request,
onSubmit,
isEcsTlrSettingEnabled,
...rest
}) => {
const {
Expand Down Expand Up @@ -182,6 +183,7 @@ const RequestFormContainer = ({
onSetSelectedInstance={setInstance}
onSetIsPatronBlocksOverridden={setStateIsPatronBlocksOverridden}
onSubmit={handleSubmit}
isEcsTlrSettingEnabled={isEcsTlrSettingEnabled}
/>
);
};
Expand All @@ -190,6 +192,7 @@ RequestFormContainer.propTypes = {
request: PropTypes.object,
parentResources: PropTypes.object,
onSubmit: PropTypes.func.isRequired,
isEcsTlrSettingEnabled: PropTypes.bool.isRequired,
};

export default RequestFormContainer;
5 changes: 4 additions & 1 deletion src/UserDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getFullName,
userHighlightBox,
getPatronGroup,
isProxyFunctionalityAvailable,
} from './utils';

class UserDetail extends React.Component {
Expand All @@ -23,6 +24,7 @@ class UserDetail extends React.Component {
proxy: PropTypes.object,
request: PropTypes.object.isRequired,
user: PropTypes.object.isRequired,
isEcsTlrSettingEnabled: PropTypes.bool.isRequired,
selectedDelivery: PropTypes.bool,
};

Expand All @@ -41,6 +43,7 @@ class UserDetail extends React.Component {
deliveryAddress,
pickupServicePoint,
selectedDelivery,
isEcsTlrSettingEnabled,
} = this.props;

const id = user?.id ?? request.requesterId;
Expand All @@ -51,7 +54,7 @@ class UserDetail extends React.Component {
let proxyName;
let proxyBarcode;
let proxyId;
if (proxy) {
if (isProxyFunctionalityAvailable(isEcsTlrSettingEnabled) && proxy) {
proxyName = getFullName(proxy);
proxyBarcode = proxy?.barcode || <NoValue />;
proxyId = proxy.id || request.proxyUserId;
Expand Down
2 changes: 2 additions & 0 deletions src/UserDetail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const basicProps = {
lastName: 'userLastName',
},
selectedDelivery: true,
isEcsTlrSettingEnabled: false,
};
const labelIds = {
proxy: 'ui-requests.requester.proxy',
Expand All @@ -54,6 +55,7 @@ jest.mock('./utils', () => ({
getPatronGroup: jest.fn(() => ({
group: 'testPatronGroup',
})),
isProxyFunctionalityAvailable: jest.fn(() => true),
}));

describe('UserDetail', () => {
Expand Down
10 changes: 7 additions & 3 deletions src/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ProxyManager } from '@folio/stripes/smart-components';
import {
getFullName,
userHighlightBox,
isProxyFunctionalityAvailable,
} from './utils';

class UserForm extends React.Component {
Expand All @@ -24,6 +25,7 @@ class UserForm extends React.Component {
proxy: PropTypes.object,
stripes: PropTypes.object.isRequired,
user: PropTypes.object.isRequired,
isEcsTlrSettingEnabled: PropTypes.bool.isRequired,
request: PropTypes.object,
};

Expand All @@ -43,17 +45,19 @@ class UserForm extends React.Component {
proxy,
patronGroup,
request,
isEcsTlrSettingEnabled,
} = this.props;

const isProxyAvailable = isProxyFunctionalityAvailable(isEcsTlrSettingEnabled);
const id = user?.id ?? request.requesterId;
const name = getFullName(user);
const barcode = user.barcode;
const isEditable = !!request;
const isProxyManagerAvailable = isProxyAvailable && !isEditable;

let proxyName;
let proxyBarcode;
let proxyId;
if (proxy) {
if (isProxyAvailable && proxy) {
proxyName = getFullName(proxy);
proxyBarcode = proxy?.barcode || '-';
proxyId = proxy.id;
Expand All @@ -78,7 +82,7 @@ class UserForm extends React.Component {

{proxySection}

{ !isEditable &&
{isProxyManagerAvailable &&
<this.connectedProxyManager
patron={user}
proxy={proxy}
Expand Down
2 changes: 2 additions & 0 deletions src/UserForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const basicProps = {
barcode: 'userBarcode',
id: 'userId',
},
isEcsTlrSettingEnabled: false,
};
const labelIds = {
proxyTitle: 'ui-requests.requester.proxy',
Expand All @@ -38,6 +39,7 @@ jest.mock('./utils', () => ({
<span>{barcode}</span>
</>
)),
isProxyFunctionalityAvailable: jest.fn(() => true),
}));

describe('UserForm', () => {
Expand Down
10 changes: 10 additions & 0 deletions src/ViewRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import {
isVirtualPatron,
getRequestErrorMessage,
isMultiDataTenant,
isProxyFunctionalityAvailable,
} from './utils';
import urls from './routes/urls';

Expand Down Expand Up @@ -230,6 +231,7 @@ class ViewRequest extends React.Component {
}

update(record) {
const { isEcsTlrSettingEnabled } = this.props;
const requestFromProps = this.getRequestFromProps() || {};
const updatedRecord = {
...requestFromProps,
Expand All @@ -251,6 +253,11 @@ class ViewRequest extends React.Component {
delete updatedRecord.numberOfReorderableRequests;
delete updatedRecord.holdShelfExpirationTime;

if (!isProxyFunctionalityAvailable(isEcsTlrSettingEnabled)) {
delete updatedRecord.proxy;
delete updatedRecord.proxyUserId;
}

this.props.mutator.selectedRequest.PUT(updatedRecord).then(() => {
this.props.onCloseEdit();
this.callout.current.sendCallout({
Expand Down Expand Up @@ -381,6 +388,7 @@ class ViewRequest extends React.Component {
findResource,
patronGroups,
parentMutator,
isEcsTlrSettingEnabled,
} = this.props;
const {
titleLevelRequestsFeatureEnabled,
Expand Down Expand Up @@ -425,6 +433,7 @@ class ViewRequest extends React.Component {
parentMutator={parentMutator}
findResource={findResource}
isTlrEnabledOnEditPage={titleLevelRequestsFeatureEnabled}
isEcsTlrSettingEnabled={isEcsTlrSettingEnabled}
/>
</Layer>
) }
Expand Down Expand Up @@ -821,6 +830,7 @@ class ViewRequest extends React.Component {
selectedDelivery={selectedDelivery}
deliveryAddress={deliveryAddressDetail}
pickupServicePoint={getPickupServicePointName}
isEcsTlrSettingEnabled={isEcsTlrSettingEnabled}
/>
</Accordion>
<NotesSmartAccordion
Expand Down
3 changes: 3 additions & 0 deletions src/components/RequesterInformation/RequesterInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RequesterInformation extends Component {
handleCloseProxy: PropTypes.func.isRequired,
findUser: PropTypes.func.isRequired,
triggerUserBarcodeValidation: PropTypes.func.isRequired,
isEcsTlrSettingEnabled: PropTypes.bool.isRequired,
stripes: stripesShape.isRequired,
selectedUser: PropTypes.object,
isLoading: PropTypes.bool,
Expand Down Expand Up @@ -210,6 +211,7 @@ class RequesterInformation extends Component {
onSelectProxy,
handleCloseProxy,
isLoading,
isEcsTlrSettingEnabled,
} = this.props;
const {
isUserClicked,
Expand Down Expand Up @@ -293,6 +295,7 @@ class RequesterInformation extends Component {
proxy={selectedProxy}
onSelectProxy={onSelectProxy}
onCloseProxy={handleCloseProxy}
isEcsTlrSettingEnabled={isEcsTlrSettingEnabled}
/>
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const basicProps = {
},
isLoading: false,
submitting: false,
isEcsTlrSettingEnabled: false,
};
const labelIds = {
selectUserError: 'ui-requests.errors.selectUser',
Expand Down Expand Up @@ -246,6 +247,7 @@ describe('RequesterInformation', () => {
proxy: basicProps.selectedProxy,
onSelectProxy: basicProps.onSelectProxy,
onCloseProxy: basicProps.handleCloseProxy,
isEcsTlrSettingEnabled: basicProps.isEcsTlrSettingEnabled,
};

render(
Expand Down
9 changes: 7 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ export const PRINT_DETAILS_COLUMNS = {
PRINTED: 'printDetails.lastPrintedDetails',
};

export const PROXY_COLUMNS = {
NAME: 'proxy.name',
BARCODE: 'proxy.barcode',
};

export const reportHeaders = [
'requestType',
'status',
Expand Down Expand Up @@ -203,8 +208,8 @@ export const reportHeaders = [
'fulfillmentPreference',
'pickupServicePoint.name',
'deliveryAddress',
'proxy.name',
'proxy.barcode',
PROXY_COLUMNS.NAME,
PROXY_COLUMNS.BARCODE,
'tags.tagList',
'patronComments',
PRINT_DETAILS_COLUMNS.COPIES,
Expand Down
6 changes: 4 additions & 2 deletions src/deprecated/components/RequestForm/RequestForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ import {
isSubmittingButtonDisabled,
isFormEditing,
resetFieldState,
getRequester,
} from '../../../utils';
import { getTlrSettings } from '../../utils';
import {
getTlrSettings,
getRequester,
} from '../../utils';

import css from './RequestForm.css';

Expand Down
Loading

0 comments on commit e996115

Please sign in to comment.