diff --git a/src/ui/public/index_patterns/__tests__/_index_pattern.js b/src/ui/public/index_patterns/__tests__/_index_pattern.js index 6b8a9fddcc602..3a7426fb49d54 100644 --- a/src/ui/public/index_patterns/__tests__/_index_pattern.js +++ b/src/ui/public/index_patterns/__tests__/_index_pattern.js @@ -103,11 +103,20 @@ describe('index pattern', function () { expect(indexPattern).to.have.property('toString'); expect(indexPattern).to.have.property('toJSON'); expect(indexPattern).to.have.property('save'); + expect(indexPattern).to.have.property('title'); + expect(indexPattern).to.have.property('id'); // properties expect(indexPattern).to.have.property('fields'); }); }); + + it('should have a title when there is no saved title', function () { + const id = 'foo'; + return create(id, {}).then(function (indexPattern) { + expect(indexPattern.title).to.be(id); + }); + }); }); describe('init', function () { diff --git a/src/ui/public/index_patterns/_index_pattern.js b/src/ui/public/index_patterns/_index_pattern.js index 51c0d9648cf99..2648410702829 100644 --- a/src/ui/public/index_patterns/_index_pattern.js +++ b/src/ui/public/index_patterns/_index_pattern.js @@ -89,6 +89,12 @@ export function IndexPatternProvider(Private, $http, config, kbnIndex, Promise, // give index pattern all of the values in _source _.assign(indexPattern, response._source); + // older kibana indices reference the index pattern by _id and may not have the pattern + // saved in title + // if the title doesn't exist, it's an old format and we can use the id instead + if (!indexPattern.title) { + indexPattern.title = indexPattern.id; + } return indexFields(indexPattern); }