From aa28fdfbf48e3711a0952502deea180ddad0cf6d Mon Sep 17 00:00:00 2001 From: nikolai Date: Wed, 29 Jan 2025 10:49:00 +0400 Subject: [PATCH 1/3] UIU-3119: Pronoun Field - User Record Edit --- CHANGELOG.md | 1 + package.json | 2 +- .../EditSections/EditUserInfo/EditUserInfo.js | 9 ++++++++ src/components/util/util.js | 6 ++++++ src/components/util/util.test.js | 7 +++++++ src/views/UserEdit/UserForm.css | 11 ++++++++++ src/views/UserEdit/UserForm.js | 5 ++++- src/views/UserEdit/UserForm.test.js | 21 ++++++++++++++++++- translations/ui-users/en.json | 1 + 9 files changed, 60 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abd8b0dbd..089d87995 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Change import of `exportToCsv` from `stripes-util` to `stripes-components`. Refs UIU-3202. * Provide `itemToString` to create unique `key` attributes. Refs UIU-3312. * Return appropriate error message when item for manual fee/fine can't be found. Refs UIU-2701. +* Add `pronouns` field to user edit form. Refs UIU-3119. ## [11.0.11](https://github.com/folio-org/ui-users/tree/v11.0.11) (2025-01-15) [Full Changelog](https://github.com/folio-org/ui-users/compare/v11.0.10...v11.0.11) diff --git a/package.json b/package.json index 384debb01..b54f37b6b 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ } ], "okapiInterfaces": { - "users": "16.3", + "users": "16.4", "configuration": "2.0", "permissions": "5.7", "login": "7.3", diff --git a/src/components/EditSections/EditUserInfo/EditUserInfo.js b/src/components/EditSections/EditUserInfo/EditUserInfo.js index 9cca030ee..41ccb3118 100644 --- a/src/components/EditSections/EditUserInfo/EditUserInfo.js +++ b/src/components/EditSections/EditUserInfo/EditUserInfo.js @@ -429,6 +429,15 @@ class EditUserInfo extends React.Component { + + } + name="personal.pronouns" + id="adduser_pronouns" + component={TextField} + fullWidth + /> + diff --git a/src/components/util/util.js b/src/components/util/util.js index d968dea6f..ba1244b55 100644 --- a/src/components/util/util.js +++ b/src/components/util/util.js @@ -36,6 +36,12 @@ export function getFullName(user) { return fullName; } +export function getFormattedPronouns(user) { + const pronouns = user?.personal?.pronouns; + + return pronouns ? `(${pronouns})` : undefined; +} + export const formatActionDescription = (action) => { return action.typeAction + (action.paymentMethod diff --git a/src/components/util/util.test.js b/src/components/util/util.test.js index 66f256065..a340fb3eb 100644 --- a/src/components/util/util.test.js +++ b/src/components/util/util.test.js @@ -29,6 +29,7 @@ import { isAffiliationsEnabled, isDcbItem, isAValidImageUrl, + getFormattedPronouns, } from './util'; const STRIPES = { @@ -538,3 +539,9 @@ describe('isAValidImageUrl', () => { }); }); +describe('getFormattedPronouns', () => { + it('returns formatted pronouns', () => { + expect(getFormattedPronouns({ personal: { pronouns: 'e2/e2' } })).toEqual('(e2/e2)'); + }); +}); + diff --git a/src/views/UserEdit/UserForm.css b/src/views/UserEdit/UserForm.css index c627b3850..0b9b3e4ad 100644 --- a/src/views/UserEdit/UserForm.css +++ b/src/views/UserEdit/UserForm.css @@ -6,3 +6,14 @@ .UserFormEditIcon { display: inline-block; } + +.NameContainer { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; +} + +.Pronouns { + font-weight: normal; + word-wrap: break-word; +} diff --git a/src/views/UserEdit/UserForm.js b/src/views/UserEdit/UserForm.js index 5cb0118e2..3229f3a18 100644 --- a/src/views/UserEdit/UserForm.js +++ b/src/views/UserEdit/UserForm.js @@ -36,7 +36,7 @@ import { EditReadingRoomAccess, EditUserRoles, } from '../../components/EditSections'; -import { getFullName } from '../../components/util'; +import { getFormattedPronouns, getFullName } from '../../components/util'; import RequestFeeFineBlockButtons from '../../components/RequestFeeFineBlockButtons'; import { addressTypesShape } from '../../shapes'; import getProxySponsorWarning from '../../components/util/getProxySponsorWarning'; @@ -340,6 +340,7 @@ class UserForm extends React.Component { const firstMenu = this.getAddFirstMenu(); const footer = this.getPaneFooter(); const fullName = getFullName(initialValues); + const pronouns = getFormattedPronouns(initialValues); const paneTitle = initialValues.id ? : ; @@ -373,9 +374,11 @@ class UserForm extends React.Component { {fullName} + {pronouns && {pronouns}} )} diff --git a/src/views/UserEdit/UserForm.test.js b/src/views/UserEdit/UserForm.test.js index c0ad277f7..222fa00f9 100644 --- a/src/views/UserEdit/UserForm.test.js +++ b/src/views/UserEdit/UserForm.test.js @@ -158,7 +158,7 @@ describe('UserForm', () => { }); - describe('renders accordions', () => { + describe('renders accordions and other values', () => { const props = { formData: { patronGroups: [], @@ -207,6 +207,25 @@ describe('UserForm', () => { expect(screen.queryByText('EditUserRoles accordion')).toBeInTheDocument(); }); + + it('renders pronouns', () => { + renderWithRouter( + + ); + + expect(screen.getByText('(r2/d2)')).toBeTruthy(); + }); }); // this fails: diff --git a/translations/ui-users/en.json b/translations/ui-users/en.json index 5312347ae..253ad921f 100644 --- a/translations/ui-users/en.json +++ b/translations/ui-users/en.json @@ -309,6 +309,7 @@ "contact.addressTypes": "Address Types", "contact.addressType": "Address Type", "contact.addresses": "Addresses", + "information.pronouns": "Pronouns", "information.userInformation": "User information", "information.userDetails": "User details", "information.name": "Name", From 772ba6d6e3d24503d834b06b89f4113146c17f25 Mon Sep 17 00:00:00 2001 From: nikolai Date: Wed, 29 Jan 2025 13:56:33 +0400 Subject: [PATCH 2/3] adjust unit test check --- src/views/UserEdit/UserForm.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/UserEdit/UserForm.test.js b/src/views/UserEdit/UserForm.test.js index 222fa00f9..fcb39affc 100644 --- a/src/views/UserEdit/UserForm.test.js +++ b/src/views/UserEdit/UserForm.test.js @@ -224,7 +224,7 @@ describe('UserForm', () => { /> ); - expect(screen.getByText('(r2/d2)')).toBeTruthy(); + expect(screen.getByText('(r2/d2)')).toBeInTheDocument(); }); }); From 99b2ecb31b22d314fa56b037ed75143263bb3759 Mon Sep 17 00:00:00 2001 From: nikolai Date: Wed, 29 Jan 2025 20:25:55 +0400 Subject: [PATCH 3/3] convert to a breaking change --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 089d87995..0dfab2d29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change history for ui-users -## [11.1.0] In progress +## [12.0.0] In progress * `useUserTenantRoles` supplies `tenantId` in all its queries. Refs UIU-3279. * Leverage API supported sorting of columns on pre-registrations records list. Refs UIU-3249. * Fix issue with `Proxy borrower` field value. Refs UIU-3290. @@ -12,7 +12,7 @@ * Change import of `exportToCsv` from `stripes-util` to `stripes-components`. Refs UIU-3202. * Provide `itemToString` to create unique `key` attributes. Refs UIU-3312. * Return appropriate error message when item for manual fee/fine can't be found. Refs UIU-2701. -* Add `pronouns` field to user edit form. Refs UIU-3119. +* *BREAKING* Add `pronouns` field to user edit form. Refs UIU-3119. ## [11.0.11](https://github.com/folio-org/ui-users/tree/v11.0.11) (2025-01-15) [Full Changelog](https://github.com/folio-org/ui-users/compare/v11.0.10...v11.0.11) diff --git a/package.json b/package.json index b54f37b6b..7de7389ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@folio/users", - "version": "11.0.9", + "version": "12.0.0", "description": "User management", "repository": "folio-org/ui-users", "publishConfig": {