mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[index patterns] Fallback to id if title does not exist (#14302)
* [index patterns] Fallback to id if title does not exist * [tests] browser index patterns should always have id and title * [tests] add regression test for no saved title
This commit is contained in:
parent
6819311ec8
commit
6e2c2f0305
2 changed files with 15 additions and 0 deletions
|
@ -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 () {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue