mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
do not allow registation of undefined indexpatterns in dashboard state (#12628)
This commit is contained in:
parent
580e0d2964
commit
4bb759cde2
2 changed files with 25 additions and 1 deletions
|
@ -11,6 +11,7 @@ describe('DashboardState', function () {
|
|||
let timefilter;
|
||||
let quickTimeRanges;
|
||||
let dashboardConfig;
|
||||
const mockIndexPattern = { id: 'index1' };
|
||||
|
||||
function initDashboardState() {
|
||||
dashboardState = new DashboardState(savedDashboard, AppState, dashboardConfig);
|
||||
|
@ -78,4 +79,25 @@ describe('DashboardState', function () {
|
|||
expect(timefilter.time.from).to.equal(savedDashboard.timeFrom);
|
||||
});
|
||||
});
|
||||
|
||||
describe('panelIndexPatternMapping', function () {
|
||||
it('registers index pattern', function () {
|
||||
const state = new DashboardState(savedDashboard, AppState, dashboardConfig);
|
||||
state.registerPanelIndexPatternMap('panel1', mockIndexPattern);
|
||||
expect(state.getPanelIndexPatterns().length).to.equal(1);
|
||||
});
|
||||
|
||||
it('registers unique index patterns', function () {
|
||||
const state = new DashboardState(savedDashboard, AppState, dashboardConfig);
|
||||
state.registerPanelIndexPatternMap('panel1', mockIndexPattern);
|
||||
state.registerPanelIndexPatternMap('panel2', mockIndexPattern);
|
||||
expect(state.getPanelIndexPatterns().length).to.equal(1);
|
||||
});
|
||||
|
||||
it('does not register undefined index pattern for panels with no index pattern', function () {
|
||||
const state = new DashboardState(savedDashboard, AppState, dashboardConfig);
|
||||
state.registerPanelIndexPatternMap('markdownPanel1', undefined);
|
||||
expect(state.getPanelIndexPatterns().length).to.equal(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -94,7 +94,9 @@ export class DashboardState {
|
|||
}
|
||||
|
||||
registerPanelIndexPatternMap(panelIndex, indexPattern) {
|
||||
this.panelIndexPatternMapping[panelIndex] = indexPattern;
|
||||
if (indexPattern) {
|
||||
this.panelIndexPatternMapping[panelIndex] = indexPattern;
|
||||
}
|
||||
}
|
||||
|
||||
getPanelIndexPatterns() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue