mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* Edits to filter's custom label are ignored (#59169) * Fix filter alias field * Test for alias comparison Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> * Fix types * Clean up fix Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
4f672d5d4f
commit
0522b39706
2 changed files with 28 additions and 0 deletions
|
@ -212,5 +212,29 @@ describe('filter manager utilities', () => {
|
|||
|
||||
expect(compareFilters([f1], [f2], COMPARE_ALL_OPTIONS)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should compare alias with COMPARE_ALL_OPTIONS', () => {
|
||||
const f1 = {
|
||||
$state: { store: esFilters.FilterStateStore.GLOBAL_STATE },
|
||||
...esFilters.buildQueryFilter(
|
||||
{ _type: { match: { query: 'apache', type: 'phrase' } } },
|
||||
'index',
|
||||
''
|
||||
),
|
||||
};
|
||||
const f2 = {
|
||||
$state: { store: esFilters.FilterStateStore.GLOBAL_STATE },
|
||||
...esFilters.buildQueryFilter(
|
||||
{ _type: { match: { query: 'apache', type: 'phrase' } } },
|
||||
'index',
|
||||
''
|
||||
),
|
||||
};
|
||||
|
||||
f2.meta.alias = 'wassup';
|
||||
f2.meta.alias = 'dog';
|
||||
|
||||
expect(compareFilters([f1], [f2], COMPARE_ALL_OPTIONS)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@ export interface FilterCompareOptions {
|
|||
disabled?: boolean;
|
||||
negate?: boolean;
|
||||
state?: boolean;
|
||||
alias?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +34,7 @@ export const COMPARE_ALL_OPTIONS: FilterCompareOptions = {
|
|||
disabled: true,
|
||||
negate: true,
|
||||
state: true,
|
||||
alias: true,
|
||||
};
|
||||
|
||||
const mapFilter = (
|
||||
|
@ -44,6 +46,7 @@ const mapFilter = (
|
|||
|
||||
if (comparators.negate) cleaned.negate = filter.meta && Boolean(filter.meta.negate);
|
||||
if (comparators.disabled) cleaned.disabled = filter.meta && Boolean(filter.meta.disabled);
|
||||
if (comparators.disabled) cleaned.alias = filter.meta?.alias;
|
||||
|
||||
return cleaned;
|
||||
};
|
||||
|
@ -81,6 +84,7 @@ export const compareFilters = (
|
|||
state: false,
|
||||
negate: false,
|
||||
disabled: false,
|
||||
alias: false,
|
||||
});
|
||||
|
||||
if (!comparators.state) excludedAttributes.push('$state');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue