prevent undefined filterQuery error (#113522) (#113818)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Sergi Massaneda <sergi.massaneda@elastic.co>
This commit is contained in:
Kibana Machine 2021-10-04 16:22:14 -04:00 committed by GitHub
parent a5acdf5371
commit dad2009acd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -228,14 +228,13 @@ export const getCombinedFilterQuery = ({
to, to,
filters, filters,
...combineQueriesParams ...combineQueriesParams
}: CombineQueries & { from: string; to: string }): string => { }: CombineQueries & { from: string; to: string }): string =>
return replaceStatusField( replaceStatusField(
combineQueries({ combineQueries({
...combineQueriesParams, ...combineQueriesParams,
filters: [...filters, buildTimeRangeFilter(from, to)], filters: [...filters, buildTimeRangeFilter(from, to)],
})!.filterQuery })?.filterQuery
); );
};
/** /**
* This function is a temporary patch to prevent queries using old `signal.status` field. * This function is a temporary patch to prevent queries using old `signal.status` field.
@ -243,8 +242,8 @@ export const getCombinedFilterQuery = ({
* must be replaced by `ALERT_WORKFLOW_STATUS` field name constant * must be replaced by `ALERT_WORKFLOW_STATUS` field name constant
* @deprecated * @deprecated
*/ */
const replaceStatusField = (query: string): string => const replaceStatusField = (filterQuery?: string): string =>
query.replaceAll('signal.status', ALERT_WORKFLOW_STATUS); filterQuery?.replaceAll('signal.status', ALERT_WORKFLOW_STATUS) ?? '';
/** /**
* The CSS class name of a "stateful event", which appears in both * The CSS class name of a "stateful event", which appears in both