Skip to content

Commit

Permalink
Handle missing index pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jun 6, 2018
1 parent a342b31 commit 789d6cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/ui/public/index_patterns/static_utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function isFilterable(field) {
}

export function getFromSavedObject(savedObject) {
if (!savedObject) {
return null;
}

return {
fields: JSON.parse(savedObject.attributes.fields),
title: savedObject.attributes.title,
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/apm/public/components/shared/KueryBar/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class KueryBarView extends Component {
};

render() {
if (!this.state.indexPattern) {
return null;
}

return (
<Container>
<Typeahead
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/apm/public/services/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import 'isomorphic-fetch';
import { camelizeKeys } from 'humps';
import { kfetch } from 'ui/kfetch';
import { memoize, isEmpty, first, startsWith } from 'lodash';
import { memoize, first, startsWith } from 'lodash';
import chrome from 'ui/chrome';
import { convertKueryToEsQuery } from './kuery';
import { getFromSavedObject } from 'ui/index_patterns/static_utils';
Expand Down Expand Up @@ -49,10 +49,6 @@ export const getAPMIndexPattern = memoize(async () => {
}
});

if (isEmpty(res.savedObjects)) {
return {};
}

const apmIndexPattern = chrome.getInjected('apmIndexPattern');
const apmSavedObject = first(
res.savedObjects.filter(
Expand Down

0 comments on commit 789d6cb

Please sign in to comment.