Skip to content
Closed
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
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 searching requests. Refs UIREQ-1312.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better to move it down to visualize that it was made last in this release (after * When creating or viewing a request, show whether the a loan on the item would be use-at-location. Fixes UIREQ-1327.).

* *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
17 changes: 15 additions & 2 deletions src/deprecated/routes/RequestsRoute/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ export const urls = {
},
};

function userFormatter(id, user) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Could you please move it to to src/utils.js for reuse in all places?
  2. As I understand it, we only need to show anonymized when the user id is null. Could you add a function to src/utils.js, for example:
export const isAnonymizedUser = (id) => {
  return id === null;
};

and use it in this function.
Just for example:

  if (user) {
    return getFullName(user);
  }

  if (isAnonymizedUser(id)) {
    return <FormattedMessage id="ui-requests.requestMeta.anonymized" />;
  }

  return <NoValue />;

With this approach it will be clearer what is happening. We correctly check that id === null and it will be clear why we are doing this.

if (user) {
return getFullName(user);
}

if (id) {
// User has been deleted
return <NoValue />;
}

return <FormattedMessage id="ui-requests.requestMeta.anonymized" />;
}

export const getListFormatter = (
{
getRowURL,
Expand All @@ -241,13 +254,13 @@ export const getListFormatter = (
/>),
'itemBarcode': rq => (rq?.item?.barcode || <NoValue />),
'position': rq => (rq.position || <NoValue />),
'proxy': rq => (rq.proxy ? getFullName(rq.proxy) : <NoValue />),
'proxy': rq => userFormatter(rq.proxyUserId, rq.proxy),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From https://folio-org.atlassian.net/browse/UXPROD-4302
And, if they exist, the proxy.lastName, proxy.firstName, proxy.barcode, and proxyUserId are removed from the request record
In story we do not have clear scenarios and difficult to understand correct behavior for current case.
How i understood if a requester has been anonymized then the requesterId and proxyUserId will be null.
Could you please double check do we need we show anonymized for proxy or NoValue?

'requestDate': rq => (
<AppIcon size="small" app="requests">
<FormattedTime value={rq.requestDate} day="numeric" month="numeric" year="numeric" />
</AppIcon>
),
'requester': rq => (rq.requester ? getFullName(rq.requester) : <NoValue />),
'requester': rq => userFormatter(rq.requesterId, rq.requester),
'singlePrint': rq => {
const singlePrintButtonProps = {
request: rq,
Expand Down
20 changes: 18 additions & 2 deletions src/deprecated/routes/RequestsRoute/RequestsRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const testIds = {
singlePrintButton: 'singlePrintButton',
rowCheckbox: 'rowCheckbox',
selectRequestCheckbox: 'selectRequestCheckbox',
anonymized: 'ui-requests.requestMeta.anonymized',
};

const intlCache = createIntlCache();
Expand Down Expand Up @@ -231,6 +232,7 @@ const labelIds = {
titleWithSearch: 'ui-requests.documentTitle.search',
defaultTitle: 'ui-requests.meta.title',
recordsSelected: 'ui-requests.rows.recordsSelected',
anonymized: 'ui-requests.requestMeta.anonymized',
};
const mockedRequest = {
requestLevel: REQUEST_LEVEL_TYPES.ITEM,
Expand Down Expand Up @@ -1268,9 +1270,16 @@ describe('RequestsRoute', () => {
expect(listFormatter.proxy(requestWithData)).toBe(mockProxy);
});

it('should trigger NoValue component', () => {
it('should render Anonymized', () => {
render(listFormatter.proxy(requestWithoutData));

expect(screen.getByText(labelIds.anonymized)).toBeInTheDocument();
});

it('should trigger NoValue component', () => {
const req = { ...requestWithoutData, proxyUserId: 'deleted proxy user' };
render(listFormatter.proxy(req));

expect(NoValue).toHaveBeenCalled();
});
});
Expand Down Expand Up @@ -1305,9 +1314,16 @@ describe('RequestsRoute', () => {
expect(listFormatter.requester(requestWithData)).toBe(mockRequester);
});

it('should trigger NoValue component', () => {
it('should render Anonymized', () => {
render(listFormatter.requester(requestWithoutData));

expect(screen.getByText(labelIds.anonymized)).toBeInTheDocument();
});

it('should trigger NoValue component', () => {
const req = { ...requestWithoutData, requesterId: 'deleted requester' };
render(listFormatter.requester(req));

expect(NoValue).toHaveBeenCalled();
});
});
Expand Down
17 changes: 15 additions & 2 deletions src/routes/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@ export const urls = {
},
};

function userFormatter(id, user) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please take a look on comment above for userFormatter?

if (user) {
return getFullName(user);
}

if (id) {
// User has been deleted
return <NoValue />;
}

return <FormattedMessage id="ui-requests.requestMeta.anonymized" />;
}

export const getListFormatter = (
{
getRowURL,
Expand Down Expand Up @@ -259,13 +272,13 @@ export const getListFormatter = (
/>),
'itemBarcode': rq => (rq?.item?.barcode || <NoValue />),
'position': rq => (rq.position || <NoValue />),
...(isProxyAvailable ? { 'proxy': rq => (rq.proxy ? getFullName(rq.proxy) : <NoValue />) } : {}),
...(isProxyAvailable ? { 'proxy': rq => userFormatter(rq.proxyUserId, rq.proxy) } : {}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please take a look on comment above for 'proxy'?

'requestDate': rq => (
<AppIcon size="small" app="requests">
<FormattedTime value={rq.requestDate} day="numeric" month="numeric" year="numeric" />
</AppIcon>
),
'requester': rq => (rq.requester ? getFullName(rq.requester) : <NoValue />),
'requester': rq => userFormatter(rq.requesterId, rq.requester),
'singlePrint': rq => {
const singlePrintButtonProps = {
request: rq,
Expand Down
19 changes: 17 additions & 2 deletions src/routes/RequestsRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ const labelIds = {
titleWithSearch: 'ui-requests.documentTitle.search',
defaultTitle: 'ui-requests.meta.title',
recordsSelected: 'ui-requests.rows.recordsSelected',
anonymized: 'ui-requests.requestMeta.anonymized',
};
const mockedRequest = {
requestLevel: REQUEST_LEVEL_TYPES.ITEM,
Expand Down Expand Up @@ -1422,9 +1423,16 @@ describe('RequestsRoute', () => {
expect(listFormatter.proxy(requestWithData)).toBe(mockProxy);
});

it('should trigger NoValue component', () => {
it('should render Anonymized', () => {
render(listFormatter.proxy(requestWithoutData));

expect(screen.getByText(labelIds.anonymized)).toBeInTheDocument();
});

it('should trigger NoValue component', () => {
const req = { ...requestWithoutData, proxyUserId: 'deleted proxy user' };
render(listFormatter.proxy(req));

expect(NoValue).toHaveBeenCalled();
});
});
Expand Down Expand Up @@ -1459,9 +1467,16 @@ describe('RequestsRoute', () => {
expect(listFormatter.requester(requestWithData)).toBe(mockRequester);
});

it('should trigger NoValue component', () => {
it('should trigger Anonymized component', () => {
render(listFormatter.requester(requestWithoutData));

expect(screen.getByText(labelIds.anonymized)).toBeInTheDocument();
});

it('should trigger NoValue component', () => {
const req = { ...requestWithoutData, requesterId: 'deleted requester' };
render(listFormatter.requester(req));

expect(NoValue).toHaveBeenCalled();
});
});
Expand Down