From 7e348fba0e59336a1a921acf9c52944c02f86f1f Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Wed, 18 Oct 2023 12:51:47 +0400 Subject: [PATCH 1/3] UIU-2970 Make the `username` field required for users with the `staff` type in "ECS" mode (#2571) * UIU-2970 Make the 'username' field required for users with the 'staff' type in ECS mode * add unit tests --- CHANGELOG.md | 1 + .../EditExtendedInfo/EditExtendedInfo.js | 14 ++++- .../EditExtendedInfo/EditExtendedInfo.test.js | 53 ++++++++++++++++++- src/components/util/util.js | 1 + src/views/UserEdit/UserForm.js | 1 + 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6798acea..f767bc131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [10.1.0] IN PROGRESS * Don't display affiliations of users with types `patron` or `dcb`. Refs UIU-2967. +* Make the `username` field required for users with the `staff` type in ECS mode. Refs UIU-2970. ## [10.0.0](https://github.com/folio-org/ui-users/tree/v10.0.0) (2023-10-13) [Full Changelog](https://github.com/folio-org/ui-users/compare/v9.0.3...v10.0.0) diff --git a/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.js b/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.js index 8829ce510..dd98c3e5a 100644 --- a/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.js +++ b/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.js @@ -12,7 +12,10 @@ import { Datepicker, Headline, } from '@folio/stripes/components'; -import { IfPermission } from '@folio/stripes/core'; +import { + IfPermission, + stripesShape, +} from '@folio/stripes/core'; import { withFormValues } from '../../Wrappers'; import asyncValidateField from '../../validators/asyncValidateField'; @@ -21,6 +24,10 @@ import { addressTypesShape, departmentsShape, } from '../../../shapes'; +import { + isConsortiumEnabled, + isStaffUser, +} from '../../util'; import CreateResetPasswordControl from './CreateResetPasswordControl'; import RequestPreferencesEdit from './RequestPreferencesEdit'; @@ -41,6 +48,7 @@ class EditExtendedInfo extends Component { values: PropTypes.object, uniquenessValidator: PropTypes.object, disabled: PropTypes.bool, + stripes: stripesShape, }; buildAccordionHeader = () => { @@ -85,6 +93,8 @@ class EditExtendedInfo extends Component { change, uniquenessValidator, disabled, + values, + stripes, } = this.props; const accordionHeader = this.buildAccordionHeader(); @@ -92,6 +102,7 @@ class EditExtendedInfo extends Component { const addresses = this.getAddresses(); const defaultDeliveryAddressTypeId = this.getDefaultDeliveryAddressTypeId(); const deliveryAvailable = this.isDeliveryAvailable(); + const isUsernameFieldRequired = isConsortiumEnabled(stripes) && isStaffUser(values); return ( diff --git a/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js b/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js index 37cb243c6..20553a94b 100644 --- a/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js +++ b/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js @@ -2,7 +2,9 @@ import { screen } from '@folio/jest-config-stripes/testing-library/react'; import { Form } from 'react-final-form'; import PropTypes from 'prop-types'; +import buildStripes from '__mock__/stripes.mock'; import renderWithRouter from 'helpers/renderWithRouter'; +import { USER_TYPES } from '../../../constants'; import EditExtendedInfo from './EditExtendedInfo'; jest.unmock('@folio/stripes/components'); @@ -22,7 +24,7 @@ const arrayMutators = { update: jest.fn() }; -const renderEditExtendedInfo = (props) => { +const renderEditExtendedInfo = (props, initialValues) => { const component = () => ( <> @@ -35,6 +37,7 @@ const renderEditExtendedInfo = (props) => { mutators={{ ...arrayMutators }} + initialValues={initialValues} onSubmit={onSubmit} render={component} /> @@ -67,6 +70,7 @@ const props = { }], values: {}, uniquenessValidator: {}, + stripes: buildStripes(), }; const DepartmentsName = ({ departments }) => { return departments.map((dep) => { @@ -125,4 +129,51 @@ describe('Render Extended User Information component', () => { renderEditExtendedInfo({ ...props, disabled: true }); expect(screen.getAllByRole('textbox')[0]).toBeDisabled(); }); + + describe('Username field', () => { + it('should be required for users with the \'staff\' type in ECS mode', () => { + renderEditExtendedInfo( + { + ...props, + stripes: { + ...props.stripes, + hasInterface: () => true, + }, + }, + { type: USER_TYPES.STAFF } + ); + + expect(screen.getByRole('textbox', { name: 'ui-users.information.username' })).toBeRequired(); + }); + + it('should NOT be required if user type is other than \'staff\' in ECS mode', () => { + renderEditExtendedInfo( + { + ...props, + stripes: { + ...props.stripes, + hasInterface: () => true, + }, + }, + { type: USER_TYPES.PATRON } + ); + + expect(screen.getByRole('textbox', { name: 'ui-users.information.username' })).not.toBeRequired(); + }); + + it('should NOT be required in default mode (non ECS)', () => { + renderEditExtendedInfo( + { + ...props, + stripes: { + ...props.stripes, + hasInterface: (i) => i !== 'consortia', + }, + }, + { type: USER_TYPES.STAFF } + ); + + expect(screen.getByRole('textbox', { name: 'ui-users.information.username' })).not.toBeRequired(); + }); + }); }); diff --git a/src/components/util/util.js b/src/components/util/util.js index aa4d1ce03..64bcf990c 100644 --- a/src/components/util/util.js +++ b/src/components/util/util.js @@ -203,6 +203,7 @@ export const getRequestUrl = (barcode, userId) => { export const isPatronUser = (user) => user?.type === USER_TYPES.PATRON; export const isDcbUser = (user) => user?.type === USER_TYPES.DCB; +export const isStaffUser = (user) => user?.type === USER_TYPES.STAFF; export const isAffiliationsEnabled = (user) => { return !isPatronUser(user) && !isDcbUser(user); diff --git a/src/views/UserEdit/UserForm.js b/src/views/UserEdit/UserForm.js index f96fb888f..98c5d75b2 100644 --- a/src/views/UserEdit/UserForm.js +++ b/src/views/UserEdit/UserForm.js @@ -369,6 +369,7 @@ class UserForm extends React.Component { departments={formData.departments} uniquenessValidator={uniquenessValidator} disabled={isShadowUser} + stripes={stripes} /> Date: Wed, 18 Oct 2023 15:26:50 +0400 Subject: [PATCH 2/3] Update the changelog to reflect the v10.0.1 release (#2575) --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f767bc131..fd588b3ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [10.1.0] IN PROGRESS +## [10.0.1](https://github.com/folio-org/ui-users/tree/v10.0.1) (2023-10-18) +[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.0.0...v10.0.1) + * Don't display affiliations of users with types `patron` or `dcb`. Refs UIU-2967. * Make the `username` field required for users with the `staff` type in ECS mode. Refs UIU-2970. From 1f640dc8a949e4042460c0928606b05eb3139627 Mon Sep 17 00:00:00 2001 From: Dmitriy-Litvinenko Date: Tue, 17 Oct 2023 17:58:34 +0300 Subject: [PATCH 3/3] UIU-2960: Also support feesfines interface version 19.0 --- CHANGELOG.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd588b3ff..b10311053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change history for ui-users ## [10.1.0] IN PROGRESS +* Also support `feesfines` interface version `19.0`. Refs UIU-2960. ## [10.0.1](https://github.com/folio-org/ui-users/tree/v10.0.1) (2023-10-18) [Full Changelog](https://github.com/folio-org/ui-users/compare/v10.0.0...v10.0.1) diff --git a/package.json b/package.json index ff6c1c89b..aaaa2d4c5 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "automated-patron-blocks": "0.1", "circulation": "9.0 10.0 11.0 12.0 13.0 14.0", "consortia": "1.0", - "feesfines": "16.1 17.0 18.0", + "feesfines": "16.1 17.0 18.0 19.0", "loan-policy-storage": "1.0 2.0", "loan-storage": "4.0 5.0 6.0 7.0", "notes": "2.0 3.0",