Skip to content

Commit

Permalink
refactor: copy
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Sep 10, 2020
1 parent 871ec5b commit 5cf7490
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function BucketNestingEditor({
values: { field: fieldName },
}),
filters: i18n.translate('xpack.lens.indexPattern.groupingOverallFilters', {
defaultMessage: 'Search query overall',
defaultMessage: 'Top values for each custom query',
}),
date_histogram: i18n.translate('xpack.lens.indexPattern.groupingOverallDateHistogram', {
defaultMessage: 'Top values for each {field}',
Expand All @@ -83,7 +83,7 @@ export function BucketNestingEditor({
values: { target: target.fieldName },
}),
filters: i18n.translate('xpack.lens.indexPattern.groupingSecondFilters', {
defaultMessage: 'Search query for each {target}',
defaultMessage: 'Overall top {target}',
values: { target: target.fieldName },
}),
date_histogram: i18n.translate('xpack.lens.indexPattern.groupingSecondDateHistogram', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ const QueryInput = ({
placeholder={
inputValue.language === 'kuery'
? i18n.translate('xpack.lens.indexPattern.filters.queryPlaceholderKql', {
defaultMessage: 'Example: {example}',
defaultMessage: '{example}',
values: { example: 'method : "GET" or status : "404"' },
})
: i18n.translate('xpack.lens.indexPattern.filters.queryPlaceholderLucene', {
defaultMessage: 'Example: {example}',
defaultMessage: '{example}',
values: { example: 'method:GET OR status:404' },
})
}
dataTestSubj="transformQueryInput"
dataTestSubj="lns-indexPattern-searchQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('filters', () => {
columnOrder: ['col1', 'col2'],
columns: {
col1: {
label: 'Search query',
label: 'Custom query',
dataType: 'document',
operationType: 'filters',
scale: 'ordinal',
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('filters', () => {
});
});

describe('Modify search query', () => {
describe('Modify custom query', () => {
it('should correctly show existing filters ', () => {
const setStateSpy = jest.fn();
const instance = mount(
Expand All @@ -236,7 +236,7 @@ describe('filters', () => {
).toEqual('src : 2');
});

it('should remove search query', () => {
it('should remove custom query', () => {
const setStateSpy = jest.fn();
const instance = mount(
<InlineOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export interface FilterValue {
id: string;
}

const searchQueryLabel = i18n.translate('xpack.lens.indexPattern.searchQuery', {
defaultMessage: 'Search query',
const customQueryLabel = i18n.translate('xpack.lens.indexPattern.customQuery', {
defaultMessage: 'Custom query',
});

export const defaultLabel = i18n.translate('xpack.lens.indexPattern.filters.label.placeholder', {
Expand Down Expand Up @@ -87,7 +87,7 @@ export interface FiltersIndexPatternColumn extends FieldBasedIndexPatternColumn

export const filtersOperation: OperationDefinition<FiltersIndexPatternColumn> = {
type: 'filters',
displayName: searchQueryLabel,
displayName: customQueryLabel,
priority: 3, // Higher than any metric
getPossibleOperationForField: ({ type }) => {
if (type === 'document') {
Expand Down Expand Up @@ -116,12 +116,10 @@ export const filtersOperation: OperationDefinition<FiltersIndexPatternColumn> =
},
],
};
} else if (previousColumn?.operationType === 'filters' && previousColumn.params?.filters) {
params = previousColumn.params;
}

return {
label: searchQueryLabel,
label: customQueryLabel,
dataType: 'string',
operationType: 'filters',
scale: 'ordinal',
Expand Down Expand Up @@ -163,12 +161,7 @@ export const filtersOperation: OperationDefinition<FiltersIndexPatternColumn> =
);

return (
<EuiFormRow
label={i18n.translate('xpack.lens.indexPattern.filters.queries', {
defaultMessage: 'Queries',
})}
labelType="legend"
>
<EuiFormRow>
<FilterList
filters={filters}
setFilters={setFilters}
Expand Down Expand Up @@ -241,7 +234,7 @@ export const FilterList = ({

return (
<>
<EuiDragDropContext onDragEnd={onDragEnd}>
<EuiDragDropContext onDragEnd={onDragEnd} onDragStart={() => setIsOpenByCreation(false)}>
<EuiDroppable droppableId="FILTERS_DROPPABLE_AREA" spacing="s">
{localFilters?.map((filter: FilterValue, idx: number) => {
const { input, label, id } = filter;
Expand Down Expand Up @@ -312,9 +305,9 @@ export const FilterList = ({
onRemoveFilter(filter.id);
}}
aria-label={i18n.translate(
'xpack.lens.indexPattern.filters.removeSearchQuery',
'xpack.lens.indexPattern.filters.removeCustomQuery',
{
defaultMessage: 'Remove search query',
defaultMessage: 'Remove custom query',
}
)}
title={i18n.translate('xpack.lens.indexPattern.filters.remove', {
Expand All @@ -339,8 +332,8 @@ export const FilterList = ({
setIsOpenByCreation(true);
}}
>
{i18n.translate('xpack.lens.indexPattern.filters.addSearchQuery', {
defaultMessage: 'Add a search query',
{i18n.translate('xpack.lens.indexPattern.filters.addCustomQuery', {
defaultMessage: 'Add a custom query',
})}
</EuiButtonEmpty>
</>
Expand Down

0 comments on commit 5cf7490

Please sign in to comment.