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

UIU-3119: Pronoun Field - User Record Edit #2848

Merged
merged 3 commits into from
Jan 30, 2025
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-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.
Expand All @@ -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.
* *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)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/users",
"version": "11.0.9",
"version": "12.0.0",
"description": "User management",
"repository": "folio-org/ui-users",
"publishConfig": {
Expand Down Expand Up @@ -29,7 +29,7 @@
}
],
"okapiInterfaces": {
"users": "16.3",
"users": "16.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping support for an interface version is a breaking change. You must update the major version of this package in package.json or surround this new functionality with an <IfInterface> conditional that specifies the minimum version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @zburke. Could you please check if it's correct?

"configuration": "2.0",
"permissions": "5.7",
"login": "7.3",
Expand Down
9 changes: 9 additions & 0 deletions src/components/EditSections/EditUserInfo/EditUserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,15 @@ class EditUserInfo extends React.Component {
</OnChange>
</Field>
</Col>
<Col xs={12} md={3}>
<Field
label={<FormattedMessage id="ui-users.information.pronouns" />}
name="personal.pronouns"
id="adduser_pronouns"
component={TextField}
fullWidth
/>
</Col>
</Row>

</Accordion>
Expand Down
6 changes: 6 additions & 0 deletions src/components/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/components/util/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
isAffiliationsEnabled,
isDcbItem,
isAValidImageUrl,
getFormattedPronouns,
} from './util';

const STRIPES = {
Expand Down Expand Up @@ -538,3 +539,9 @@ describe('isAValidImageUrl', () => {
});
});

describe('getFormattedPronouns', () => {
it('returns formatted pronouns', () => {
expect(getFormattedPronouns({ personal: { pronouns: 'e2/e2' } })).toEqual('(e2/e2)');
});
});

11 changes: 11 additions & 0 deletions src/views/UserEdit/UserForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 4 additions & 1 deletion src/views/UserEdit/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
? <FormattedMessage id="ui-users.edit" />
: <FormattedMessage id="ui-users.crud.createUser" />;
Expand Down Expand Up @@ -373,9 +374,11 @@ class UserForm extends React.Component {
<Headline
size="xx-large"
tag="h2"
className={css.NameContainer}
data-test-header-title
>
{fullName}
{pronouns && <span className={css.Pronouns}>{pronouns}</span>}
</Headline>
)}
<AccordionStatus ref={this.accordionStatusRef}>
Expand Down
21 changes: 20 additions & 1 deletion src/views/UserEdit/UserForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('UserForm', () => {
});


describe('renders accordions', () => {
describe('renders accordions and other values', () => {
const props = {
formData: {
patronGroups: [],
Expand Down Expand Up @@ -207,6 +207,25 @@ describe('UserForm', () => {

expect(screen.queryByText('EditUserRoles accordion')).toBeInTheDocument();
});

it('renders pronouns', () => {
renderWithRouter(
<UserForm
{...props}
initialValues={
{
...props.initialValues,
personal: {
...props.initialValues.personal,
pronouns: 'r2/d2',
},
}
}
/>
);

expect(screen.getByText('(r2/d2)')).toBeInTheDocument();
});
});

// this fails:
Expand Down
1 change: 1 addition & 0 deletions translations/ui-users/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading