Disable submenu when autopanels is enabled

This commit is contained in:
Tobias Skarhed 2018-08-03 12:19:41 +02:00 committed by Torkel Ödegaard
parent 36c406eefb
commit 4b84a58575
3 changed files with 21 additions and 1 deletions

View File

@ -91,7 +91,7 @@ export class DashboardCtrl implements PanelContainer {
);
//Consider navbar and submenu controls, padding and margin
let availableHeight = window.innerHeight - 80;
let availableHeight = window.innerHeight - 40;
let availableRows = Math.floor(availableHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
let scaleFactor = maxRows / availableRows;
@ -99,6 +99,8 @@ export class DashboardCtrl implements PanelContainer {
panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1;
panel.gridPos.h = Math.round(panel.gridPos.h / scaleFactor) || 1;
});
this.dashboard.meta.autofitpanels = true;
console.log(this.dashboard);
}
}

View File

@ -9,6 +9,7 @@ import sortByKeys from 'app/core/utils/sort_by_keys';
import { PanelModel } from './panel_model';
import { DashboardMigrator } from './dashboard_migration';
import { tickStep } from '../../core/utils/ticks';
export class DashboardModel {
id: any;
@ -591,6 +592,10 @@ export class DashboardModel {
updateSubmenuVisibility() {
this.meta.submenuEnabled = (() => {
if (this.meta.autofitpanels) {
return false;
}
if (this.links.length > 0) {
return true;
}

View File

@ -305,6 +305,19 @@ describe('DashboardModel', function() {
});
});
describe('updateSubmenuVisibility with autofitpanels enabled', function() {
var model;
beforeEach(function() {
model = new DashboardModel({}, { autofitpanels: true });
model.updateSubmenuVisibility();
});
it('should not enable submmenu', function() {
expect(model.meta.submenuEnabled).toBe(false);
});
});
describe('updateSubmenuVisibility with hidden annotation toggle', function() {
var dashboard;