Skip to content

Commit

Permalink
UIPFU-76 Revert - ECS - 'Do not display shadow users in search result…
Browse files Browse the repository at this point in the history
…s' (#244)

* UIPFU-76 Revert - ECS - 'Do not display shadow users in search results'

* remove the record from the changelog

* remove unused const
  • Loading branch information
usavkov-epam authored Oct 9, 2023
1 parent ba7bb49 commit 87d27da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 52 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
41 changes: 18 additions & 23 deletions src/UserSearchContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 },
Expand All @@ -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: {} },
},
},
Expand Down
7 changes: 0 additions & 7 deletions src/constants.js

This file was deleted.

21 changes: 0 additions & 21 deletions test/bigtest/tests/findUser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit 87d27da

Please sign in to comment.