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

[App Search] Hide Value and Functional boosts for geolocation #93683

Merged
merged 1 commit into from
Mar 4, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -64,6 +64,20 @@ describe('Boosts', () => {
expect(select.prop('options').map((o: any) => o.value)).toEqual(['add-boost', 'value']);
});

it('will not render functional or value options if "type" prop is "geolocation"', () => {
const wrapper = shallow(
<Boosts
{...{
...props,
type: 'geolocation' as SchemaTypes,
}}
/>
);

const select = wrapper.find(EuiSuperSelect);
expect(select.prop('options').map((o: any) => o.value)).toEqual(['add-boost', 'proximity']);
});

it('will add a boost of the selected type when a selection is made', () => {
const wrapper = shallow(<Boosts {...props} />);

Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiTitle, EuiSuperSelect } from '@

import { i18n } from '@kbn/i18n';

import { TEXT } from '../../../../shared/constants/field_types';
import { GEOLOCATION, TEXT } from '../../../../shared/constants/field_types';
import { SchemaTypes } from '../../../../shared/types';

import { BoostIcon } from '../boost_icon';
@@ -68,6 +68,8 @@ const BASE_OPTIONS = [
const filterInvalidOptions = (value: BoostType, type: SchemaTypes) => {
// Proximity and Functional boost types are not valid for text fields
if (type === TEXT && [BoostType.Proximity, BoostType.Functional].includes(value)) return false;
// Value and Functional boost types are not valid for geolocation fields
if (type === GEOLOCATION && [BoostType.Functional, BoostType.Value].includes(value)) return false;
return true;
};