From 9d36366771ada365ef3b5e314b313047235bc271 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Wed, 4 Oct 2017 10:52:45 -0500 Subject: [PATCH 1/3] [index patterns] Fallback to id if title does not exist --- src/ui/public/index_patterns/_index_pattern.js | 6 ++++++ 1 file changed, 6 insertions(+) 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); } From 55d3828fa935c8636464360f31b52da2869a0929 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Wed, 4 Oct 2017 13:24:45 -0500 Subject: [PATCH 2/3] [tests] browser index patterns should always have id and title --- src/ui/public/index_patterns/__tests__/_index_pattern.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ui/public/index_patterns/__tests__/_index_pattern.js b/src/ui/public/index_patterns/__tests__/_index_pattern.js index 6b8a9fddcc602..94fc2f87b2a48 100644 --- a/src/ui/public/index_patterns/__tests__/_index_pattern.js +++ b/src/ui/public/index_patterns/__tests__/_index_pattern.js @@ -103,6 +103,8 @@ 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'); From 23e5a0ff429f737a177dd3899a284db569423679 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Wed, 4 Oct 2017 13:40:59 -0500 Subject: [PATCH 3/3] [tests] add regression test for no saved title --- src/ui/public/index_patterns/__tests__/_index_pattern.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/public/index_patterns/__tests__/_index_pattern.js b/src/ui/public/index_patterns/__tests__/_index_pattern.js index 94fc2f87b2a48..3a7426fb49d54 100644 --- a/src/ui/public/index_patterns/__tests__/_index_pattern.js +++ b/src/ui/public/index_patterns/__tests__/_index_pattern.js @@ -110,6 +110,13 @@ describe('index pattern', function () { 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 () {