Skip to content

Commit

Permalink
UIPFU-76 Revert - ECS - 'Do not display shadow users in search results'
Browse files Browse the repository at this point in the history
  • Loading branch information
usavkov-epam committed Oct 6, 2023
1 parent ba7bb49 commit 49e33f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 46 deletions.
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
2 changes: 0 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ export const USER_TYPES = {
SHADOW: 'shadow',
STAFF: 'staff',
};

export const NOT_SHADOW_USER_CQL = `((cql.allRecords=1 NOT type ="") or type<>"${USER_TYPES.SHADOW}")`;
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 49e33f9

Please sign in to comment.