Skip to content

Commit

Permalink
fix break that occured when a whitelisted key had a period in it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Bulicek committed Feb 23, 2019
1 parent a0dc022 commit 3ccaf04
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3ccaf04

Please sign in to comment.