Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4ed2b0d
Replace link tests with ones for the whole highlight box
brycekbargar Oct 9, 2025
cd31006
Componentize the UserHighlightBox and tests
brycekbargar Oct 9, 2025
5aef902
Refactor UserDetail to use the new component
brycekbargar Oct 9, 2025
20c7cba
Refactor UserForm to use new component
brycekbargar Oct 10, 2025
6db5850
Create new components for barcode/requester links based on existing
brycekbargar Oct 10, 2025
a09b44b
Refactor usage of RequesterLink
brycekbargar Oct 10, 2025
1cc9d3c
Remove now unused RequestLink component
brycekbargar Oct 10, 2025
426a6bf
Actually test the full name link is doing what it says
brycekbargar Oct 10, 2025
4de1122
Replace the internals in UserHighlightBox with new components
brycekbargar Oct 10, 2025
b0da428
Remove last usage of util highlight link function
brycekbargar Oct 10, 2025
3627722
Remove now unused request utils
brycekbargar Oct 10, 2025
d987692
Remove uneeded getFullName usages
brycekbargar Oct 10, 2025
b7eb6d1
Remove unused utils test imports
brycekbargar Oct 10, 2025
4ac8bfd
Change the message from unknown to anonymized
brycekbargar Oct 10, 2025
d4ba1a3
Add to changelog
brycekbargar Oct 10, 2025
61b975d
Update deprecated component referred record and handle nulls
brycekbargar Oct 15, 2025
0d5d90a
Address formatting issues from code review
brycekbargar Oct 22, 2025
709d279
Split requester links into two component files
brycekbargar Oct 22, 2025
6c46cf0
Properly render unknown/anonymized for requester
brycekbargar Oct 22, 2025
24d2ef3
Invert full name link conditions
brycekbargar Oct 22, 2025
2d70285
WIP: Refactoring callers to actual pass in the requests requesterId
brycekbargar Oct 22, 2025
51b0bcb
Re-implement UserForm and tests to get back to original behavior
brycekbargar Oct 22, 2025
b295009
Re-implement UserDetail and tests to get back to original behavior
brycekbargar Oct 22, 2025
f8ce490
Fix view test
brycekbargar Oct 22, 2025
8e23de0
Fix unknown user translation id
brycekbargar Oct 22, 2025
5dc06ca
Add back accidentally deleted translation
brycekbargar Oct 27, 2025
cfadfa5
Remove stray getFullName
brycekbargar Oct 27, 2025
c660213
Fix failing test around unknown text
brycekbargar Oct 28, 2025
be0543f
Fixes for UIREQ-1313 code review
brycekbargar Nov 13, 2025
92a7d46
Move CHANGELOG addition to end of unreleased features
brycekbargar Nov 21, 2025
87786e7
Add a utility function checking for anonymized users
brycekbargar Nov 21, 2025
7d28677
Use jsdoc format for fullnamelink comment
brycekbargar Nov 21, 2025
359d24c
Organize userhighlightbox import statements
brycekbargar Nov 21, 2025
d9f2eb7
Update referredrecord tests with correct props format
brycekbargar Nov 21, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Display loan type on the Request Detail page, as well as New Request page. Refs UIREQ-1328.
* When creating or viewing a request, show whether the a loan on the item would be use-at-location. Fixes UIREQ-1327.
* Added global permissions for get read-access to values such as tenant’s locale, timezone, and currency. Refs UIREQ-1341.
* Display Anonymized when viewing a requester/proxy for a single anonymized loan. Refs UIREQ-1313.

## [12.0.4] (https://github.com/folio-org/ui-requests/tree/v12.0.4) (2025-10-29)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v12.0.3...v12.0.4)
Expand Down
21 changes: 11 additions & 10 deletions src/UserDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import {
NoValue,
} from '@folio/stripes/components';

import UserHighlightBox from './components/UserHighlightBox';
import {
getFullName,
userHighlightBox,
getPatronGroup,
isProxyFunctionalityAvailable,
} from './utils';
Expand Down Expand Up @@ -61,26 +60,28 @@ class UserDetail extends React.Component {
} = this.props;

const id = user?.id ?? request.requesterId;
const name = getFullName(user);
const barcode = user ? user.barcode : '';
const patronGroup = getPatronGroup(user, patronGroups) || {};

let proxyName;
let proxyBarcode;
let proxyId;
if (isProxyFunctionalityAvailable(isEcsTlrSettingEnabled) && proxy) {
proxyName = getFullName(proxy);
proxyBarcode = proxy?.barcode || <NoValue />;
proxyId = proxy.id || request.proxyUserId;
}

const proxySection = proxyId
? userHighlightBox(<FormattedMessage id="ui-requests.requester.proxy" />, proxyName, proxyId, proxyBarcode)
? <UserHighlightBox
title={<FormattedMessage id="ui-requests.requester.proxy" />}
userId={proxyId}
user={proxy}
/>
: null;

return (
<div>
{userHighlightBox(<FormattedMessage id="ui-requests.requester.requester" />, name, id, barcode)}
<UserHighlightBox
title={<FormattedMessage id="ui-requests.requester.requester" />}
userId={id}
user={user}
/>
<Row>
<Col xs={4}>
<KeyValue
Expand Down
59 changes: 39 additions & 20 deletions src/UserDetail.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MemoryRouter } from 'react-router-dom';
import {
render,
screen,
Expand All @@ -7,9 +8,9 @@ import {
import { NoValue } from '@folio/stripes/components';

import UserDetail from './UserDetail';
import * as UserHighlightBox from './components/UserHighlightBox/UserHighlightBox';
import {
getFullName,
userHighlightBox,
getPatronGroup,
} from './utils';

Expand Down Expand Up @@ -46,28 +47,30 @@ const labelIds = {

jest.mock('./utils', () => ({
getFullName: jest.fn((user) => user.lastName),
userHighlightBox: jest.fn((label, name, id, barcode) => (
<>
<div>{label}</div>
<div>{barcode}</div>
</>
)),
getPatronGroup: jest.fn(() => ({
group: 'testPatronGroup',
})),
isProxyFunctionalityAvailable: jest.fn(() => true),
}));

describe('UserDetail', () => {
let userHighlightBoxSpy;
beforeEach(() => {
userHighlightBoxSpy = jest.spyOn(UserHighlightBox, 'default');
});

afterEach(() => {
NoValue.mockClear();
userHighlightBoxSpy.mockClear();
cleanup();
});

describe('when all data provided', () => {
beforeEach(() => {
render(
<UserDetail {...basicProps} />
<MemoryRouter>
<UserDetail {...basicProps} />
</MemoryRouter>
);
});

Expand All @@ -83,14 +86,14 @@ describe('UserDetail', () => {
expect(getPatronGroup).toHaveBeenCalledWith(basicProps.user, basicProps.patronGroups);
});

it('should trigger "userHighlightBox" with correct arguments', () => {
it('should trigger "UserHighlightBox" with correct arguments', () => {
const expectedArgs = [
[expect.anything(), basicProps.proxy.lastName, basicProps.proxy.id, basicProps.proxy.barcode],
[expect.anything(), basicProps.user.lastName, basicProps.user.id, basicProps.user.barcode],
{ title: expect.anything(), userId:basicProps.user.id, user:basicProps.user },
{ title: expect.anything(), userId:basicProps.proxy.id, user:basicProps.proxy },
];

expectedArgs.forEach((user, index) => {
expect(userHighlightBox).toHaveBeenNthCalledWith(index + 1, ...user);
expect(userHighlightBoxSpy).toHaveBeenNthCalledWith(index + 1, user, {});
});
});

Expand Down Expand Up @@ -139,7 +142,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand All @@ -156,7 +161,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand All @@ -182,7 +189,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand All @@ -202,7 +211,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand All @@ -215,7 +226,9 @@ describe('UserDetail', () => {
beforeEach(() => {
getPatronGroup.mockReturnValueOnce(undefined);
render(
<UserDetail {...basicProps} />
<MemoryRouter>
<UserDetail {...basicProps} />
</MemoryRouter>
);
});

Expand All @@ -232,7 +245,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand All @@ -258,7 +273,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand All @@ -280,7 +297,9 @@ describe('UserDetail', () => {

beforeEach(() => {
render(
<UserDetail {...props} />
<MemoryRouter>
<UserDetail {...props} />
</MemoryRouter>
);
});

Expand Down
27 changes: 16 additions & 11 deletions src/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
} from '@folio/stripes/components';
import { ProxyManager } from '@folio/stripes/smart-components';

import UserHighlightBox from './components/UserHighlightBox';
import {
getFullName,
userHighlightBox,
isProxyFunctionalityAvailable,
} from './utils';

Expand Down Expand Up @@ -59,27 +58,33 @@ class UserForm extends React.Component {
} = 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 (isProxyAvailable && proxy) {
proxyName = getFullName(proxy);
proxyBarcode = proxy?.barcode || '-';
proxyId = proxy.id;
}

const proxySection = proxyId && proxyId !== id
? userHighlightBox(<FormattedMessage id="ui-requests.requester.proxy" />, name, id, barcode)
? <UserHighlightBox
title={<FormattedMessage id="ui-requests.requester.proxy" />}
userId={id}
user={user}
/>
: null;

const userSection = proxyId
? userHighlightBox(<FormattedMessage id="ui-requests.requester.requester" />, proxyName, proxyId, proxyBarcode)
: userHighlightBox(<FormattedMessage id="ui-requests.requester.requester" />, name, id, barcode);
? <UserHighlightBox
title={<FormattedMessage id="ui-requests.requester.requester" />}
userId={proxyId}
user={proxy}
/>
: <UserHighlightBox
title={<FormattedMessage id="ui-requests.requester.requester" />}
userId={id}
user={user}
/>;

return (
<div>
Expand Down
Loading