Skip to content

Commit

Permalink
names changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Jan 12, 2024
1 parent a2f1311 commit 5dec780
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import { EuiTextColor } from '@elastic/eui';
import type { Filter } from '@kbn/es-query';
import { FILTERS } from '@kbn/es-query';
import { existsOperator, isOneOfOperator } from '../../filter_bar/filter_editor';
import { existsOperator, oneOfOperator } from '../../filter_bar/filter_editor';
import { strings } from '../i18n';

const FilterValue = ({ value }: { value: string | number }) => {
Expand Down Expand Up @@ -71,7 +71,7 @@ export function FilterContent({ filter, valueLabel, fieldLabel, hideAlias }: Fil
return (
<>
<FilterField filter={filter} fieldLabel={fieldLabel} />
<FilterValue value={`${isOneOfOperator.message} ${valueLabel}`} />
<FilterValue value={`${oneOfOperator.message} ${valueLabel}`} />
</>
);
case FILTERS.QUERY_STRING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export {
getOperatorOptions,
validateParams,
isFilterValid,
isOperator,
isNotOperator,
isOneOfOperator,
isNotOneOfOperator,
isBetweenOperator,
isNotBetweenOperator,
equalsOperator,
doesNotEqualOperator,
oneOfOperator,
notOneOfOperator,
betweenOperator,
notBetweenOperator,
existsOperator,
doesNotExistOperator,
FILTER_OPERATORS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
isFilterValid,
} from './filter_editor_utils';

import { existsOperator, isBetweenOperator, isOneOfOperator, isOperator } from './filter_operators';
import { existsOperator, betweenOperator, oneOfOperator, equalsOperator } from './filter_operators';

describe('Filter editor utils', () => {
describe('getFieldFromFilter', () => {
Expand Down Expand Up @@ -134,12 +134,12 @@ describe('Filter editor utils', () => {

describe('isFilterValid', () => {
it('should return false if index pattern is not provided', () => {
const isValid = isFilterValid(undefined, stubFields[0], isOperator, 'foo');
const isValid = isFilterValid(undefined, stubFields[0], equalsOperator, 'foo');
expect(isValid).toBe(false);
});

it('should return false if field is not provided', () => {
const isValid = isFilterValid(stubIndexPattern, undefined, isOperator, 'foo');
const isValid = isFilterValid(stubIndexPattern, undefined, equalsOperator, 'foo');
expect(isValid).toBe(false);
});

Expand All @@ -149,45 +149,45 @@ describe('Filter editor utils', () => {
});

it('should return false for phrases filter without phrases', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isOneOfOperator, []);
const isValid = isFilterValid(stubIndexPattern, stubFields[0], oneOfOperator, []);
expect(isValid).toBe(false);
});

it('should return true for phrases filter with phrases', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isOneOfOperator, ['foo']);
const isValid = isFilterValid(stubIndexPattern, stubFields[0], oneOfOperator, ['foo']);
expect(isValid).toBe(true);
});

it('should return false for range filter without range', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isBetweenOperator, undefined);
const isValid = isFilterValid(stubIndexPattern, stubFields[0], betweenOperator, undefined);
expect(isValid).toBe(false);
});

it('should return true for range filter with from', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isBetweenOperator, {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], betweenOperator, {
from: 'foo',
});
expect(isValid).toBe(true);
});

it('should return true for range filter with from/to', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isBetweenOperator, {
const isValid = isFilterValid(stubIndexPattern, stubFields[0], betweenOperator, {
from: 'foo',
to: 'goo',
});
expect(isValid).toBe(true);
});

it('should return false for date range filter with bad from', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[4], isBetweenOperator, {
const isValid = isFilterValid(stubIndexPattern, stubFields[4], betweenOperator, {
from: 'foo',
to: 'now',
});
expect(isValid).toBe(false);
});

it('should return false for date range filter with bad to', () => {
const isValid = isFilterValid(stubIndexPattern, stubFields[4], isBetweenOperator, {
const isValid = isFilterValid(stubIndexPattern, stubFields[4], betweenOperator, {
from: '2020-01-01',
to: 'mau',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ import { ES_FIELD_TYPES } from '@kbn/field-types';
import { DataViewField } from '@kbn/data-views-plugin/common';

export const strings = {
getIsOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.isOperatorOptionLabel', {
defaultMessage: 'is',
getEqualsOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.equalsOperatorOptionLabel', {
defaultMessage: 'equals',
}),
getIsNotOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.isNotOperatorOptionLabel', {
defaultMessage: 'is not',
getDoesNotEqualOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.doesNotEqualOperatorOptionLabel', {
defaultMessage: 'does not equal',
}),
getIsOneOfOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.isOneOfOperatorOptionLabel', {
defaultMessage: 'is one of',
getOneOfOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.oneOfOperatorOptionLabel', {
defaultMessage: 'one of',
}),
getIsNotOneOfOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.isNotOneOfOperatorOptionLabel', {
defaultMessage: 'is not one of',
getNotOneOfOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.notOneOfOperatorOptionLabel', {
defaultMessage: 'not one of',
}),
getIsBetweenOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.isBetweenOperatorOptionLabel', {
defaultMessage: 'is between',
getBetweenOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.betweenOperatorOptionLabel', {
defaultMessage: 'between',
}),
getIsGreaterOrEqualOperatorOptionLabel: () =>
getGreaterOrEqualOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.greaterThanOrEqualOptionLabel', {
defaultMessage: 'greater or equal',
}),
getLessThanOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.lessThanOrEqualOptionLabel', {
defaultMessage: 'less than',
}),
getIsNotBetweenOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.isNotBetweenOperatorOptionLabel', {
defaultMessage: 'is not between',
getNotBetweenOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.notBetweenOperatorOptionLabel', {
defaultMessage: 'not between',
}),
getExistsOperatorOptionLabel: () =>
i18n.translate('unifiedSearch.filter.filterEditor.existsOperatorOptionLabel', {
Expand All @@ -58,11 +58,11 @@ export enum OPERATORS {
LESS = 'less',
GREATER_OR_EQUAL = 'greater_or_equal',
BETWEEN = 'between',
IS = 'is',
EQUALS = 'equals',
NOT_BETWEEN = 'not_between',
IS_NOT = 'is_not',
IS_ONE_OF = 'is_one_of',
IS_NOT_ONE_OF = 'is_not_one_of',
DOES_NOT_EQUAL = 'does_not_equal',
ONE_OF = 'one_of',
NOT_ONE_OF = 'not_one_of',
EXISTS = 'exists',
DOES_NOT_EXIST = 'does_not_exist',
}
Expand All @@ -85,34 +85,34 @@ export interface Operator {
field?: (field: DataViewField) => boolean;
}

export const isOperator = {
message: strings.getIsOperatorOptionLabel(),
export const equalsOperator = {
message: strings.getEqualsOperatorOptionLabel(),
type: FILTERS.PHRASE,
negate: false,
id: OPERATORS.IS,
id: OPERATORS.EQUALS,
};

export const isNotOperator = {
message: strings.getIsNotOperatorOptionLabel(),
export const doesNotEqualOperator = {
message: strings.getDoesNotEqualOperatorOptionLabel(),
type: FILTERS.PHRASE,
negate: true,
id: OPERATORS.IS_NOT,
id: OPERATORS.DOES_NOT_EQUAL,
};

export const isOneOfOperator = {
message: strings.getIsOneOfOperatorOptionLabel(),
export const oneOfOperator = {
message: strings.getOneOfOperatorOptionLabel(),
type: FILTERS.PHRASES,
negate: false,
fieldTypes: ['string', 'number', 'date', 'ip', 'geo_point', 'geo_shape'],
id: OPERATORS.IS_ONE_OF,
id: OPERATORS.ONE_OF,
};

export const isNotOneOfOperator = {
message: strings.getIsNotOneOfOperatorOptionLabel(),
export const notOneOfOperator = {
message: strings.getNotOneOfOperatorOptionLabel(),
type: FILTERS.PHRASES,
negate: true,
fieldTypes: ['string', 'number', 'date', 'ip', 'geo_point', 'geo_shape'],
id: OPERATORS.IS_NOT_ONE_OF,
id: OPERATORS.NOT_ONE_OF,
};

const rangeOperatorsSharedProps = {
Expand All @@ -127,30 +127,30 @@ const rangeOperatorsSharedProps = {
},
};

export const isBetweenOperator = {
export const betweenOperator = {
...rangeOperatorsSharedProps,
message: strings.getIsBetweenOperatorOptionLabel(),
message: strings.getBetweenOperatorOptionLabel(),
id: OPERATORS.BETWEEN,
negate: false,
};

export const isLessThanOperator = {
export const lessThanOperator = {
...rangeOperatorsSharedProps,
message: strings.getLessThanOperatorOptionLabel(),
id: OPERATORS.LESS,
negate: false,
};

export const isGreaterOrEqualOperator = {
export const greaterOrEqualOperator = {
...rangeOperatorsSharedProps,
message: strings.getIsGreaterOrEqualOperatorOptionLabel(),
message: strings.getGreaterOrEqualOperatorOptionLabel(),
id: OPERATORS.GREATER_OR_EQUAL,
negate: false,
};

export const isNotBetweenOperator = {
export const notBetweenOperator = {
...rangeOperatorsSharedProps,
message: strings.getIsNotBetweenOperatorOptionLabel(),
message: strings.getNotBetweenOperatorOptionLabel(),
negate: true,
id: OPERATORS.NOT_BETWEEN,
};
Expand All @@ -170,14 +170,14 @@ export const doesNotExistOperator = {
};

export const FILTER_OPERATORS: Operator[] = [
isOperator,
isNotOperator,
isOneOfOperator,
isNotOneOfOperator,
isGreaterOrEqualOperator,
isLessThanOperator,
isBetweenOperator,
isNotBetweenOperator,
equalsOperator,
doesNotEqualOperator,
oneOfOperator,
notOneOfOperator,
greaterOrEqualOperator,
lessThanOperator,
betweenOperator,
notBetweenOperator,
existsOperator,
doesNotExistOperator,
];
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
export { getFieldValidityAndErrorMessage } from './helpers';
export type { Operator } from './filter_operators';
export {
isOperator,
isNotOperator,
isOneOfOperator,
isNotOneOfOperator,
isBetweenOperator,
isNotBetweenOperator,
equalsOperator,
doesNotEqualOperator,
oneOfOperator,
notOneOfOperator,
betweenOperator,
notBetweenOperator,
existsOperator,
doesNotExistOperator,
FILTER_OPERATORS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ interface ParamsEditorInputProps {
suggestionsAbstraction?: SuggestionsAbstraction;
}

const getPlaceholderText = (isFieldSelected: boolean, isOperatorSelected: boolean) => {
const getPlaceholderText = (isFieldSelected: boolean, equalsOperatorSelected: boolean) => {
if (!isFieldSelected) {
return strings.getSelectFieldPlaceholderLabel();
}

if (!isOperatorSelected) {
if (!equalsOperatorSelected) {
return strings.getSelectOperatorPlaceholderLabel();
}

Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -6321,12 +6321,6 @@
"unifiedSearch.filter.filterEditor.existsOperatorOptionLabel": "existe",
"unifiedSearch.filter.filterEditor.experimentalLabel": "Version d'évaluation technique",
"unifiedSearch.filter.filterEditor.falseOptionLabel": "faux",
"unifiedSearch.filter.filterEditor.isBetweenOperatorOptionLabel": "est entre",
"unifiedSearch.filter.filterEditor.isNotBetweenOperatorOptionLabel": "n'est pas entre",
"unifiedSearch.filter.filterEditor.isNotOneOfOperatorOptionLabel": "n'est pas l'une des options suivantes",
"unifiedSearch.filter.filterEditor.isNotOperatorOptionLabel": "n'est pas",
"unifiedSearch.filter.filterEditor.isOneOfOperatorOptionLabel": "est l'une des options suivantes",
"unifiedSearch.filter.filterEditor.isOperatorOptionLabel": "est",
"unifiedSearch.filter.filterEditor.queryDslAriaLabel": "Éditeur Query DSL d'Elasticsearch",
"unifiedSearch.filter.filterEditor.queryDslDocsLinkLabel": "En savoir plus sur la syntaxe Query DSL",
"unifiedSearch.filter.filterEditor.queryDslLabel": "Query DSL d'Elasticsearch",
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -6336,12 +6336,6 @@
"unifiedSearch.filter.filterEditor.existsOperatorOptionLabel": "存在する",
"unifiedSearch.filter.filterEditor.experimentalLabel": "テクニカルプレビュー",
"unifiedSearch.filter.filterEditor.falseOptionLabel": "false",
"unifiedSearch.filter.filterEditor.isBetweenOperatorOptionLabel": "is between",
"unifiedSearch.filter.filterEditor.isNotBetweenOperatorOptionLabel": "is not between",
"unifiedSearch.filter.filterEditor.isNotOneOfOperatorOptionLabel": "is not one of",
"unifiedSearch.filter.filterEditor.isNotOperatorOptionLabel": "is not",
"unifiedSearch.filter.filterEditor.isOneOfOperatorOptionLabel": "is one of",
"unifiedSearch.filter.filterEditor.isOperatorOptionLabel": "は",
"unifiedSearch.filter.filterEditor.queryDslAriaLabel": "ElasticsearchクエリDSLエディター",
"unifiedSearch.filter.filterEditor.queryDslDocsLinkLabel": "クエリDSL構文の詳細",
"unifiedSearch.filter.filterEditor.queryDslLabel": "Elasticsearch クエリ DSL",
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -6429,12 +6429,6 @@
"unifiedSearch.filter.filterEditor.existsOperatorOptionLabel": "存在",
"unifiedSearch.filter.filterEditor.experimentalLabel": "技术预览",
"unifiedSearch.filter.filterEditor.falseOptionLabel": "false",
"unifiedSearch.filter.filterEditor.isBetweenOperatorOptionLabel": "介于",
"unifiedSearch.filter.filterEditor.isNotBetweenOperatorOptionLabel": "不介于",
"unifiedSearch.filter.filterEditor.isNotOneOfOperatorOptionLabel": "不属于",
"unifiedSearch.filter.filterEditor.isNotOperatorOptionLabel": "不是",
"unifiedSearch.filter.filterEditor.isOneOfOperatorOptionLabel": "属于",
"unifiedSearch.filter.filterEditor.isOperatorOptionLabel": "是",
"unifiedSearch.filter.filterEditor.queryDslAriaLabel": "Elasticsearch 查询 DSL 编辑器",
"unifiedSearch.filter.filterEditor.queryDslDocsLinkLabel": "了解查询 DSL 语法",
"unifiedSearch.filter.filterEditor.queryDslLabel": "Elasticsearch 查询 DSL",
Expand Down

0 comments on commit 5dec780

Please sign in to comment.