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

Add error if filter index pattern is missing #66979

Merged
merged 36 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
666aa4b
add error if filter index pattern is gone
May 19, 2020
21f662e
docs change - why?
May 19, 2020
3e4d0f1
Merge branch 'master' of github.com:elastic/kibana into bug/missing-i…
May 20, 2020
fceecd1
Fix i18n
May 20, 2020
75764a9
Added a functional test for broken filters (field + index pattern)
May 20, 2020
6f9ba3b
Clarify readme
lizozom May 20, 2020
a33a037
Moved readme
May 20, 2020
1018766
New warning status
May 21, 2020
45881b7
Merge branch 'bug/missing-index-pattern-filter' of github.com:lizozom…
May 21, 2020
ed2f9e9
Remove getAll
May 21, 2020
129fc90
Merge commit 'dcfa4850098972b6b00fe869048e61602aea4683' into bug/miss…
May 27, 2020
7bf4315
git pull upstream master
May 27, 2020
ceb4fca
Merge branch 'master' of github.com:elastic/kibana into bug/missing-i…
May 27, 2020
448539b
Fix translation files
May 27, 2020
65e0526
Fix merge
May 27, 2020
ae6735b
added filterbar texts
May 27, 2020
4a7322e
disabled correction
May 27, 2020
886477f
Disable check in maps test until #64861 is resolved
May 27, 2020
4af37a8
Fix tests, warning state is not disabled.
May 27, 2020
ddaa338
Merge remote-tracking branch 'upstream/master' into bug/missing-index…
May 27, 2020
e007ac2
Adjust warning filter - ignore filters from "foreign" index pattern, …
May 28, 2020
fc58070
Merge branch 'master' of github.com:elastic/kibana into bug/missing-i…
May 28, 2020
2d85783
Add an additional unrelaeted filter test
May 28, 2020
cccae76
Update src/plugins/data/public/ui/filter_bar/_global_filter_item.scss
lizozom May 28, 2020
7cd51cb
Update src/plugins/data/public/ui/filter_bar/_global_filter_item.scss
lizozom May 28, 2020
cf9cada
Fixed test data
May 31, 2020
84cbd04
Merge branch 'master' of github.com:elastic/kibana into bug/missing-i…
May 31, 2020
61e2eda
Merge branch 'bug/missing-index-pattern-filter' of github.com:lizozom…
May 31, 2020
2756099
Revert mapping
May 31, 2020
67f418a
Update data with missing test
May 31, 2020
0bc2fbd
Update test to match data
May 31, 2020
10a3441
Merge branch 'master' into bug/missing-index-pattern-filter
elasticmachine Jun 1, 2020
49605a0
Merge branch 'master' of github.com:elastic/kibana into bug/missing-i…
Jun 2, 2020
da75691
Merge branch 'bug/missing-index-pattern-filter' of github.com:lizozom…
Jun 2, 2020
fbd22ce
Code review
Jun 2, 2020
f25a7fb
Merge branch 'master' into bug/missing-index-pattern-filter
elasticmachine Jun 2, 2020
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
4 changes: 2 additions & 2 deletions src/plugins/data/common/es_query/filters/get_display_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Filter } from '../filters';

function getValueFormatter(indexPattern?: IIndexPattern, key?: string) {
if (!indexPattern || !key) return;

let format = get(indexPattern, ['fields', 'byName', key, 'format']);
if (!format && (indexPattern.fields as any).getByName) {
// TODO: Why is indexPatterns sometimes a map and sometimes an array?
Expand All @@ -43,9 +44,8 @@ function getValueFormatter(indexPattern?: IIndexPattern, key?: string) {
}

export function getDisplayValueFromFilter(filter: Filter, indexPatterns: IIndexPattern[]): string {
const indexPattern = getIndexPatternFromFilter(filter, indexPatterns);

if (typeof filter.meta.value === 'function') {
const indexPattern = getIndexPatternFromFilter(filter, indexPatterns);
const valueFormatter: any = getValueFormatter(indexPattern, filter.meta.key);
return filter.meta.value(valueFormatter);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { defaults, isEqual, omit, map } from 'lodash';
import { FilterMeta, Filter } from '../../es_query';

export interface FilterCompareOptions {
index?: boolean;
disabled?: boolean;
negate?: boolean;
state?: boolean;
Expand All @@ -31,6 +32,7 @@ export interface FilterCompareOptions {
* Include disabled, negate and store when comparing filters
*/
export const COMPARE_ALL_OPTIONS: FilterCompareOptions = {
index: true,
disabled: true,
negate: true,
state: true,
Expand All @@ -44,6 +46,7 @@ const mapFilter = (
) => {
const cleaned: FilterMeta = omit(filter, excludedAttributes);

if (comparators.index) cleaned.index = filter.meta?.index;
lizozom marked this conversation as resolved.
Show resolved Hide resolved
if (comparators.negate) cleaned.negate = filter.meta && Boolean(filter.meta.negate);
if (comparators.disabled) cleaned.disabled = filter.meta && Boolean(filter.meta.disabled);
if (comparators.alias) cleaned.alias = filter.meta?.alias;
Expand Down Expand Up @@ -81,6 +84,7 @@ export const compareFilters = (
const excludedAttributes: string[] = ['$$hashKey', 'meta'];

comparators = defaults(comparatorOptions || {}, {
index: false,
state: false,
negate: false,
disabled: false,
Expand Down
15 changes: 13 additions & 2 deletions src/plugins/data/public/ui/filter_bar/_global_filter_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,26 @@
font-style: italic;
}

.globalFilterItem-isInvalid {
.globalFilterItem-isError, .globalFilterItem-isWarning {
text-decoration: none;

.globalFilterLabel__value {
color: $euiColorDanger;
font-weight: $euiFontWeightBold;
}
}

.globalFilterItem-isError {
.globalFilterLabel__value {
color: makeHighContrastColor($euiColorDangerText, $euiColorLightShade);
}
}

.globalFilterItem-isWarning {
.globalFilterLabel__value {
color: makeHighContrastColor($euiColorWarningText, $euiColorLightShade);
}
}

.globalFilterItem-isPinned {
position: relative;

Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/ui/filter_bar/filter_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function FilterBarUI(props: Props) {
<EuiFlexItem key={i} grow={false} className="globalFilterBar__flexItem">
<FilterItem
id={`${i}`}
intl={props.intl}
filter={filter}
onUpdate={(newFilter) => onUpdate(i, newFilter)}
onRemove={() => onRemove(i)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,14 @@ class FilterEditorUI extends Component<Props, State> {
if (
this.props.indexPatterns.length <= 1 &&
this.props.indexPatterns.find(
(indexPattern) => indexPattern === this.state.selectedIndexPattern
(indexPattern) => indexPattern === this.getIndexPatternFromFilter()
)
) {
/**
* Don't render the index pattern index pattern selector if thre's just one \ zero index patterns
* and if the index pattern the filter was LOADED with is in the indexPatterns list.
**/
lizozom marked this conversation as resolved.
Show resolved Hide resolved

return '';
}
const { selectedIndexPattern } = this.state;
Expand Down
Loading