Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
00b0e82
Replace link tests with ones for the whole highlight box
brycekbargar Oct 9, 2025
b197a39
Componentize the UserHighlightBox and tests
brycekbargar Oct 9, 2025
9372ec3
Refactor UserDetail to use the new component
brycekbargar Oct 9, 2025
96acf55
Refactor UserForm to use new component
brycekbargar Oct 10, 2025
be51027
Create new components for barcode/requester links based on existing
brycekbargar Oct 10, 2025
bdd92f1
Refactor usage of RequesterLink
brycekbargar Oct 10, 2025
2311525
Remove now unused RequestLink component
brycekbargar Oct 10, 2025
0329630
Actually test the full name link is doing what it says
brycekbargar Oct 10, 2025
6682b23
Replace the internals in UserHighlightBox with new components
brycekbargar Oct 10, 2025
ac45dcd
Remove last usage of util highlight link function
brycekbargar Oct 10, 2025
32f2479
Remove now unused request utils
brycekbargar Oct 10, 2025
9e71d35
Remove uneeded getFullName usages
brycekbargar Oct 10, 2025
4965a0d
Remove unused utils test imports
brycekbargar Oct 10, 2025
22a7712
Change the message from unknown to anonymized
brycekbargar Oct 10, 2025
f65b371
Add to changelog
brycekbargar Oct 10, 2025
d57285d
Update deprecated component referred record and handle nulls
brycekbargar Oct 15, 2025
62df1fd
Address formatting issues from code review
brycekbargar Oct 22, 2025
1f6a3e9
Split requester links into two component files
brycekbargar Oct 22, 2025
5df290f
Properly render unknown/anonymized for requester
brycekbargar Oct 22, 2025
d365255
Invert full name link conditions
brycekbargar Oct 22, 2025
2e8a4dc
WIP: Refactoring callers to actual pass in the requests requesterId
brycekbargar Oct 22, 2025
5280437
Re-implement UserForm and tests to get back to original behavior
brycekbargar Oct 22, 2025
721bc03
Re-implement UserDetail and tests to get back to original behavior
brycekbargar Oct 22, 2025
c89d997
Fix view test
brycekbargar Oct 22, 2025
e091b49
Fix unknown user translation id
brycekbargar Oct 22, 2025
603095d
Add back accidentally deleted translation
brycekbargar Oct 27, 2025
51cb580
Remove stray getFullName
brycekbargar Oct 27, 2025
88fc2dd
Fix failing test around unknown text
brycekbargar Oct 28, 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 @@ -2,6 +2,7 @@

## 13.0.0 IN PROGRESS

* Display Anonymized when viewing a requester/proxy for a single anonymized loan. Refs UIREQ-1313.
* *BREAKING* Use `convertToSlipData` and supporting functions from `stripes-util`. Refs UIREQ-1263.
* Replace moment with day.js. Refs UIREQ-1291.
* Reduce count of eslint errors after update eslint-config-stripes. Refs UIREQ-1289.
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
Loading