From f95ebdfb31fe3d154797c2617fff534f63325370 Mon Sep 17 00:00:00 2001 From: GitStart <1501599+gitstart@users.noreply.github.com> Date: Fri, 21 Apr 2023 17:02:58 +0300 Subject: [PATCH] [Synthetics] Filtering - location filter counts are off when filter is applied (#155437) Co-authored-by: Anjola Adeuyi <57623705+anjola-adeuyi@users.noreply.github.com> Co-authored-by: gitstart_bot Co-authored-by: shahzad31 --- .../common/monitor_filters/filter_group.tsx | 13 ++++++++++++- .../common/monitor_filters/use_filters.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/filter_group.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/filter_group.tsx index 7e19abbf758ced..a59a26613a427a 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/filter_group.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/filter_group.tsx @@ -61,7 +61,18 @@ export const FilterGroup = ({ label: LOCATION_LABEL, field: 'locations', values: getSyntheticsFilterDisplayValues( - mixUrlValues(data.locations, urlParams.locations), + mixUrlValues( + data.locations.map((locationData) => { + const matchingLocation = locations.find( + (location) => location.id === locationData.label + ); + return { + label: matchingLocation ? matchingLocation.label : locationData.label, + count: locationData.count, + }; + }), + urlParams.locations + ), 'locations', locations ), diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/use_filters.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/use_filters.ts index 014966f31bbc0a..0e3fe38566f346 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/use_filters.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/common/monitor_filters/use_filters.ts @@ -132,7 +132,7 @@ export const useFilters = (): FiltersList => { })) ?? [], schedules: schedules?.buckets?.map(({ key, doc_count: count }) => ({ - label: key, + label: String(key), count, })) ?? [], };