From f8b0417fb9000dde689d514761217f68e7a7f1b9 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Tue, 21 Nov 2023 19:15:12 +0100 Subject: [PATCH] fix(ui): filter keys conflcit with metadata, path analysis 4 col --- .../Filters/FilterAutoComplete/FilterAutoComplete.tsx | 8 +++++++- frontend/app/duck/customField.js | 6 +++--- frontend/app/mstore/types/widget.ts | 5 +++-- frontend/app/types/filter/newFilter.js | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/frontend/app/components/shared/Filters/FilterAutoComplete/FilterAutoComplete.tsx b/frontend/app/components/shared/Filters/FilterAutoComplete/FilterAutoComplete.tsx index 6f058fb86..e9ef6116f 100644 --- a/frontend/app/components/shared/Filters/FilterAutoComplete/FilterAutoComplete.tsx +++ b/frontend/app/components/shared/Filters/FilterAutoComplete/FilterAutoComplete.tsx @@ -144,8 +144,14 @@ function FilterAutoComplete(props: Props) { }, [value]) const loadOptions = (inputValue: string, callback: (options: []) => void) => { + // remove underscore from params + const _params = Object.keys(params).reduce((acc: any, key: string) => { + acc[key] = params[key].replace('_', ''); + return acc; + }, {}); + new APIClient() - [method?.toLocaleLowerCase()](endpoint, { ...params, q: inputValue }) + [method?.toLocaleLowerCase()](endpoint, { ..._params, q: inputValue }) .then((response: any) => { return response.json(); }) diff --git a/frontend/app/duck/customField.js b/frontend/app/duck/customField.js index 9320dc5bc..d92df59ef 100644 --- a/frontend/app/duck/customField.js +++ b/frontend/app/duck/customField.js @@ -43,9 +43,9 @@ const reducer = (state = initialState, action = {}) => { case FETCH_LIST_ACTIVE_SUCCESS: clearMetaFilters(); action.data.forEach((item) => { - addElementToFiltersMap(FilterCategory.METADATA, item.key); - addElementToLiveFiltersMap(FilterCategory.METADATA, item.key); - addElementToFlagConditionsMap(FilterCategory.METADATA, item.key) + addElementToFiltersMap(FilterCategory.METADATA, '_' + item.key); + addElementToLiveFiltersMap(FilterCategory.METADATA, '_' + item.key); + addElementToFlagConditionsMap(FilterCategory.METADATA, '_' + item.key) }); return state.set('list', List(action.data).map(CustomField)) diff --git a/frontend/app/mstore/types/widget.ts b/frontend/app/mstore/types/widget.ts index e12211545..3cd2c2241 100644 --- a/frontend/app/mstore/types/widget.ts +++ b/frontend/app/mstore/types/widget.ts @@ -215,12 +215,13 @@ export default class Widget { config: { ...this.config, col: - this.metricType === 'funnel' || + this.metricType === FUNNEL || this.metricOf === FilterKey.ERRORS || this.metricOf === FilterKey.SESSIONS || this.metricOf === FilterKey.SLOWEST_RESOURCES || this.metricOf === FilterKey.MISSING_RESOURCES || - this.metricOf === FilterKey.PAGES_RESPONSE_TIME_DISTRIBUTION + this.metricOf === FilterKey.PAGES_RESPONSE_TIME_DISTRIBUTION || + this.metricType === USER_PATH ? 4 : this.metricType === WEB_VITALS ? 1 diff --git a/frontend/app/types/filter/newFilter.js b/frontend/app/types/filter/newFilter.js index 5457cafc9..13544afdd 100644 --- a/frontend/app/types/filter/newFilter.js +++ b/frontend/app/types/filter/newFilter.js @@ -604,7 +604,8 @@ export const addElementToFiltersMap = ( key, type, category, - label: capitalize(key), + // remove _ from key + label: key.replace(/^_/, '').charAt(0).toUpperCase() + key.slice(2), operator: operator, operatorOptions, icon,