diff --git a/CHANGELOG.md b/CHANGELOG.md index c28266d25..0da3ff55f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change history for ui-users +## [11.0.6](https://github.com/folio-org/ui-users/tree/v11.0.6) (2024-11-28) +[Full Changelog](https://github.com/folio-org/ui-users/compare/v11.0.5...v11.0.6) + +* `useUserTenantRoles` supplies `tenantId` in all its queries. Refs UIU-3279. +* Leverage API supported sorting of columns on pre-registrations records list. Refs UIU-3249. +* Show all patron notice print jobs (not just ten random ones), in correct order. Fixes UIU-3269. + ## [11.0.5](https://github.com/folio-org/ui-users/tree/v11.0.5) (2024-11-20) [Full Changelog](https://github.com/folio-org/ui-users/compare/v11.0.3...v11.0.5) diff --git a/package.json b/package.json index edf87a041..b86e1b429 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@folio/users", - "version": "11.0.5", + "version": "11.0.6", "description": "User management", "repository": "folio-org/ui-users", "publishConfig": { diff --git a/src/hooks/useUserTenantRoles/useUserTenantRoles.js b/src/hooks/useUserTenantRoles/useUserTenantRoles.js index ca2460ec2..bcfa686fc 100644 --- a/src/hooks/useUserTenantRoles/useUserTenantRoles.js +++ b/src/hooks/useUserTenantRoles/useUserTenantRoles.js @@ -71,6 +71,7 @@ const useUserTenantRoles = ( ids, queryEnabled: isSuccess, reduceFunction: chunkedRolesReducer, + tenantId, }); return { diff --git a/src/hooks/useUserTenantRoles/useUserTenantRoles.test.js b/src/hooks/useUserTenantRoles/useUserTenantRoles.test.js index ac8ffe0b8..c620f8e8c 100644 --- a/src/hooks/useUserTenantRoles/useUserTenantRoles.test.js +++ b/src/hooks/useUserTenantRoles/useUserTenantRoles.test.js @@ -1,6 +1,6 @@ import { QueryClient, QueryClientProvider } from 'react-query'; -import { act, renderHook } from '@folio/jest-config-stripes/testing-library/react'; - +import { renderHook } from '@folio/jest-config-stripes/testing-library/react'; +import { act } from 'react'; import { useChunkedCQLFetch, useOkapiKy, @@ -73,11 +73,17 @@ describe('useUserTenantRoles', () => { }); it('fetches roles assigned to a user', async () => { - const { result } = renderHook(() => useUserTenantRoles({ userId: 'u', tenantId: 't' }), { wrapper }); + const props = { userId: 'u', tenantId: 't' }; + const { result } = renderHook(() => useUserTenantRoles(props), { wrapper }); await act(() => !result.current.isFetching); expect(result.current.isLoading).toBe(false); expect(result.current.userRoles).toEqual(roleData); + expect(useChunkedCQLFetch).toHaveBeenCalledWith(expect.objectContaining({ + tenantId: props.tenantId, + ids: expect.any(Array), + reduceFunction: expect.any(Function), + })); }); }); @@ -92,71 +98,3 @@ describe('chunkedRolesReducer', () => { expect(result.length).toBe(6); }); }); - - - -// import { renderHook, waitFor } from '@folio/jest-config-stripes/testing-library/react'; -// import { -// QueryClient, -// QueryClientProvider, -// } from 'react-query'; - -// import { useOkapiKy, useStripes } from '@folio/stripes/core'; - -// import roles from 'fixtures/roles'; -// import useUserTenantRoles from './useUserTenantRoles'; - -// const queryClient = new QueryClient(); - -// // eslint-disable-next-line react/prop-types -// const wrapper = ({ children }) => ( -// -// {children} -// -// ); - -// const response = { -// roles, -// totalRecords: roles.length, -// }; - -// describe('useUserTenantRoles', () => { -// const getMock = jest.fn(() => ({ -// json: () => Promise.resolve(response), -// })); -// const setHeaderMock = jest.fn(); -// const kyMock = { -// extend: jest.fn(({ hooks: { beforeRequest } }) => { -// beforeRequest.forEach(handler => handler({ headers: { set: setHeaderMock } })); - -// return { -// get: getMock, -// }; -// }), -// }; - -// beforeEach(() => { -// getMock.mockClear(); - -// useStripes.mockClear().mockReturnValue({ -// okapi: {}, -// config: { -// maxUnpagedResourceCount: 1000, -// } -// }); -// useOkapiKy.mockClear().mockReturnValue(kyMock); -// }); - -// it('should fetch user roles for specified tenant', async () => { -// const options = { -// userId: 'userId', -// tenantId: 'tenantId', -// }; -// const { result } = renderHook(() => useUserTenantRoles(options), { wrapper }); - -// await waitFor(() => !result.current.isLoading); - -// expect(setHeaderMock).toHaveBeenCalledWith('X-Okapi-Tenant', options.tenantId); -// expect(getMock).toHaveBeenCalledWith('roles/users', expect.objectContaining({})); -// }); -// }); diff --git a/src/routes/PatronNoticePrintJobsContainer.js b/src/routes/PatronNoticePrintJobsContainer.js index dd9250af6..6abdffbcc 100644 --- a/src/routes/PatronNoticePrintJobsContainer.js +++ b/src/routes/PatronNoticePrintJobsContainer.js @@ -35,8 +35,8 @@ PatronNoticePrintJobsContainer.manifest = { type: 'okapi', path: 'print/entries', params: { - query: 'type="BATCH"', - sortby: 'created/sort.descending' + query: 'type="BATCH" sortby created/sort.descending', + limit: '100', }, records: 'items', throwErrors: false, diff --git a/src/views/PatronNoticePrintJobs/PatronNoticePrintJobs.js b/src/views/PatronNoticePrintJobs/PatronNoticePrintJobs.js index 9119c2f23..2695c0531 100644 --- a/src/views/PatronNoticePrintJobs/PatronNoticePrintJobs.js +++ b/src/views/PatronNoticePrintJobs/PatronNoticePrintJobs.js @@ -1,5 +1,4 @@ -import { orderBy } from 'lodash'; import { Button, Pane, MenuSection, MultiColumnList, Checkbox, FormattedDate, FormattedTime, TextLink } from '@folio/stripes/components'; import { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; @@ -72,7 +71,7 @@ const PatronNoticePrintJobs = (props) => { useEffect(() => { const updatedRecords = - orderBy(records, (item) => item.created, sortOrder === DESC ? 'desc' : 'asc') + records .map(record => ({ ...record, selected: !!record.selected, diff --git a/src/views/PatronsPreRegistrationListContainer/PatronsPreRegistrationList.js b/src/views/PatronsPreRegistrationListContainer/PatronsPreRegistrationList.js index 09a85568b..22a60e883 100644 --- a/src/views/PatronsPreRegistrationListContainer/PatronsPreRegistrationList.js +++ b/src/views/PatronsPreRegistrationListContainer/PatronsPreRegistrationList.js @@ -1,6 +1,5 @@ -import { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; -import { get, orderBy } from 'lodash'; +import { get } from 'lodash'; import { useIntl, FormattedMessage, @@ -18,34 +17,22 @@ import { COLUMNS_NAME, } from './constants'; import { useNewRecordHandler } from './hooks'; -import { sortTypes } from '../../constants'; const PatronsPreRegistrationList = ({ data, isEmptyMessage, totalCount, - onNeedMoreData + onNeedMoreData, + onSort, + sortOrder, }) => { const intl = useIntl(); - const sortInitialState = { - data: [], - order: '', - direction: sortTypes.ASC, - }; - const [sortedRecordsDetails, setSortedRecordsDetails] = useState(sortInitialState); const { handle, isLoading, } = useNewRecordHandler(); - useEffect(() => { - setSortedRecordsDetails(prev => ({ - ...prev, - data: orderBy(data, prev.order, prev.direction) - })); - }, [data]); - const renderActionColumn = (user) => (