Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 9, 2023
Merged
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: 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);
});
});
});
Loading