diff --git a/CHANGELOG.md b/CHANGELOG.md index b967855..f1b93f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ * Add PULL_REQUEST_TEMPLATE.md file to the repository. Refs UIPFU-68. * Update Node.js to v18 in GitHub Actions. Refs. UIPFU-73. * Fix selected users length. Refs UIPFU-75. -* ECS - Do not display shadow users in search results. Refs UIPFU-76. * Support fetch users from different tenants. Refs UIPFU-74. * *BREAKING* bump `react-intl` to `v6.4.4`. Refs UIPFU-79. diff --git a/src/UserSearchContainer.js b/src/UserSearchContainer.js index 8d6b69a..55dcbeb 100644 --- a/src/UserSearchContainer.js +++ b/src/UserSearchContainer.js @@ -8,7 +8,6 @@ import { StripesConnectedSource, } from '@folio/stripes/smart-components'; -import { NOT_SHADOW_USER_CQL } from './constants'; import filterConfig from './filterConfig'; const INITIAL_RESULT_COUNT = 30; @@ -33,27 +32,6 @@ const compileQuery = template( { interpolate: /%{([\s\S]+?)}/g } ); -export function buildQuery(queryParams, pathComponents, resourceData, logger, props) { - const mainQuery = makeQueryFunction( - 'cql.allRecords=1', - (_parsedQuery, _props, localProps) => localProps.query.query.trim().split(/\s+/).map(query => compileQuery({ query })).join(' and '), - { - // the keys in this object must match those passed to - // SearchAndSort's columnMapping prop - 'active': 'active', - 'name': 'personal.lastName personal.firstName', - 'patronGroup': 'patronGroup.group', - 'username': 'username', - 'barcode': 'barcode', - 'email': 'personal.email', - }, - filterConfig, - 2, - )(queryParams, pathComponents, resourceData, logger, props); - - return mainQuery && `${NOT_SHADOW_USER_CQL} and ${mainQuery}`; -} - class UserSearchContainer extends React.Component { static manifest = Object.freeze({ initializedFilterConfig: { initialValue: false }, @@ -68,7 +46,24 @@ class UserSearchContainer extends React.Component { perRequest: 100, path: 'users', GET: { - params: { query: buildQuery }, + params: { + query: makeQueryFunction( + 'cql.allRecords=1', + (parsedQuery, props, localProps) => localProps.query.query.trim().split(/\s+/).map(query => compileQuery({ query })).join(' and '), + { + // the keys in this object must match those passed to + // SearchAndSort's columnMapping prop + 'active': 'active', + 'name': 'personal.lastName personal.firstName', + 'patronGroup': 'patronGroup.group', + 'username': 'username', + 'barcode': 'barcode', + 'email': 'personal.email', + }, + filterConfig, + 2, + ), + }, staticFallback: { params: {} }, }, }, diff --git a/src/constants.js b/src/constants.js deleted file mode 100644 index 907b3df..0000000 --- a/src/constants.js +++ /dev/null @@ -1,7 +0,0 @@ -export const USER_TYPES = { - PATRON: 'patron', - SHADOW: 'shadow', - STAFF: 'staff', -}; - -export const NOT_SHADOW_USER_CQL = `((cql.allRecords=1 NOT type ="") or type<>"${USER_TYPES.SHADOW}")`; diff --git a/test/bigtest/tests/findUser-test.js b/test/bigtest/tests/findUser-test.js index ea49fd2..1d6cc8d 100644 --- a/test/bigtest/tests/findUser-test.js +++ b/test/bigtest/tests/findUser-test.js @@ -3,8 +3,6 @@ import { describe, beforeEach, it } from '@bigtest/mocha'; import { expect } from 'chai'; import PropTypes from 'prop-types'; -import { NOT_SHADOW_USER_CQL } from '../../../src/constants'; -import { buildQuery } from '../../../src/UserSearchContainer'; import setupApplication, { mount } from '../helpers/helpers'; import PluginHarness from '../helpers/PluginHarness'; import FindUserInteractor from '../interactors/findUser'; @@ -260,23 +258,4 @@ describe('UsersShape PropTypes', () => { ); expect(result).to.equal(undefined); }); - - describe('buildQuery', () => { - const queryParams = { - filters: 'active.active', - query: 'Joe', - sort: 'name', - }; - const pathComponents = {}; - const resourceData = { - query: queryParams, - }; - const logger = { - log: () => {}, - }; - - it('should exclude shadow users when building CQL query', () => { - expect(buildQuery(queryParams, pathComponents, resourceData, logger)).contain(NOT_SHADOW_USER_CQL); - }); - }); });