From 3ccaf0443717514f1b7dc0c4bc62f67425a2b67d Mon Sep 17 00:00:00 2001 From: Jason Bulicek Date: Sat, 23 Feb 2019 13:10:11 -0800 Subject: [PATCH] fix break that occured when a whitelisted key had a period in it --- .../searchBar/stores/searchBarUiStateStore.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/universalSearch/searchBar/stores/searchBarUiStateStore.js b/src/components/universalSearch/searchBar/stores/searchBarUiStateStore.js index 214d3f05..4d79e9d3 100644 --- a/src/components/universalSearch/searchBar/stores/searchBarUiStateStore.js +++ b/src/components/universalSearch/searchBar/stores/searchBarUiStateStore.js @@ -54,15 +54,22 @@ export class SearchBarUiStateStore { @action setStateFromSearch(search) { // construct observables from search - this.chips = []; + this.chips = {}; Object.keys(search).forEach((key) => { if (key === 'time') { this.timeWindow = {startTime: search[key].from, endTime: search[key].to, timePreset: search[key].preset}; } else if (key === 'tabId') { this.tabId = search[key]; // url query keys that we don't want as chips - } else if (key !== 'type' && key !== 'useExpressionTree' && key !== 'spanLevelFilters') { - this.chips[key] = search[key]; + } else if (key !== 'type' && key !== 'useExpressionTree' && key !== 'spanLevelFilters' && key !== 'interval') { + // check for objects that have a period in key, e.g. app.region + // todo: come up with more elegant solution + if (typeof search[key] === 'object' && !key.includes('nested')) { + const keyInsideObject = Object.keys(search[key])[0]; + this.chips[`${key}.${keyInsideObject}`] = search[key][keyInsideObject]; + } else { + this.chips[key] = search[key]; + } } }); this.serviceName = search.serviceName;