From dad2009acd8f57c6ddc3082e1ddd012697271c24 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 4 Oct 2021 16:22:14 -0400 Subject: [PATCH] prevent undefined filterQuery error (#113522) (#113818) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Sergi Massaneda --- .../timelines/public/components/t_grid/helpers.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/timelines/public/components/t_grid/helpers.tsx b/x-pack/plugins/timelines/public/components/t_grid/helpers.tsx index 5fe766077a74..02c3d10a7605 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/helpers.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/helpers.tsx @@ -228,14 +228,13 @@ export const getCombinedFilterQuery = ({ to, filters, ...combineQueriesParams -}: CombineQueries & { from: string; to: string }): string => { - return replaceStatusField( +}: CombineQueries & { from: string; to: string }): string => + replaceStatusField( combineQueries({ ...combineQueriesParams, filters: [...filters, buildTimeRangeFilter(from, to)], - })!.filterQuery + })?.filterQuery ); -}; /** * 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 * @deprecated */ -const replaceStatusField = (query: string): string => - query.replaceAll('signal.status', ALERT_WORKFLOW_STATUS); +const replaceStatusField = (filterQuery?: string): string => + filterQuery?.replaceAll('signal.status', ALERT_WORKFLOW_STATUS) ?? ''; /** * The CSS class name of a "stateful event", which appears in both