Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function isFieldFiltered(
const scriptedOrMissing =
!filterState.missing ||
field.type === '_source' ||
field.type === 'unknown_selected' ||
field.scripted ||
fieldCounts[field.name] > 0;
const needle = filterState.name ? filterState.name.toLowerCase() : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ describe('group_fields', function () {
]);
});

it('should filter fields by a given name', function () {
const fieldFilterState = { ...getDefaultFieldFilter(), ...{ name: 'curr' } };

const actual1 = groupFields(
fields as IndexPatternField[],
['customer_birth_date', 'currency', 'unknown'],
5,
fieldCounts,
fieldFilterState,
false
);
expect(actual1.selected.map((field) => field.name)).toEqual(['currency']);
});

it('excludes unmapped fields if showUnmappedFields set to false', function () {
const fieldFilterState = getDefaultFieldFilter();
const fieldsWithUnmappedField = [...fields];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ export function groupFields(
}
}
}
// add columns, that are not part of the index pattern, to be removeable
// add selected columns, that are not part of the index pattern, to be removeable
for (const column of columns) {
if (!result.selected.find((field) => field.name === column)) {
result.selected.push({ name: column, displayName: column } as IndexPatternField);
const tmpField = {
name: column,
displayName: column,
type: 'unknown_selected',
} as IndexPatternField;
if (
!result.selected.find((field) => field.name === column) &&
isFieldFiltered(tmpField, fieldFilterState, fieldCounts)
) {
result.selected.push(tmpField);
}
}
result.selected.sort((a, b) => {
Expand Down