mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #14603 from grafana/minor-angular-editmode-fix
Fixes undefined issue with angular panels and editorTabs
This commit is contained in:
commit
2325c5dbed
@ -106,6 +106,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const panelCtrl = scope.$$childHead.ctrl;
|
const panelCtrl = scope.$$childHead.ctrl;
|
||||||
|
panelCtrl.initEditMode();
|
||||||
|
|
||||||
let template = '';
|
let template = '';
|
||||||
for (let i = 0; i < panelCtrl.editorTabs.length; i++) {
|
for (let i = 0; i < panelCtrl.editorTabs.length; i++) {
|
||||||
|
@ -30,8 +30,6 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|||||||
constructor($scope, $injector) {
|
constructor($scope, $injector) {
|
||||||
super($scope, $injector);
|
super($scope, $injector);
|
||||||
|
|
||||||
// make metrics tab the default
|
|
||||||
this.editorTabIndex = 1;
|
|
||||||
this.$q = $injector.get('$q');
|
this.$q = $injector.get('$q');
|
||||||
this.contextSrv = $injector.get('contextSrv');
|
this.contextSrv = $injector.get('contextSrv');
|
||||||
this.datasourceSrv = $injector.get('datasourceSrv');
|
this.datasourceSrv = $injector.get('datasourceSrv');
|
||||||
|
@ -18,7 +18,6 @@ export class PanelCtrl {
|
|||||||
panel: any;
|
panel: any;
|
||||||
error: any;
|
error: any;
|
||||||
dashboard: any;
|
dashboard: any;
|
||||||
editorTabIndex: number;
|
|
||||||
pluginName: string;
|
pluginName: string;
|
||||||
pluginId: string;
|
pluginId: string;
|
||||||
editorTabs: any;
|
editorTabs: any;
|
||||||
@ -39,7 +38,7 @@ export class PanelCtrl {
|
|||||||
this.$location = $injector.get('$location');
|
this.$location = $injector.get('$location');
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$timeout = $injector.get('$timeout');
|
this.$timeout = $injector.get('$timeout');
|
||||||
this.editorTabIndex = 0;
|
this.editorTabs = [];
|
||||||
this.events = this.panel.events;
|
this.events = this.panel.events;
|
||||||
this.timing = {};
|
this.timing = {};
|
||||||
|
|
||||||
@ -90,11 +89,11 @@ export class PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initEditMode() {
|
initEditMode() {
|
||||||
this.editorTabs = [];
|
if (!this.editModeInitiated) {
|
||||||
|
|
||||||
this.editModeInitiated = true;
|
this.editModeInitiated = true;
|
||||||
this.events.emit('init-edit-mode', null);
|
this.events.emit('init-edit-mode', null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addEditorTab(title, directiveFn, index?, icon?) {
|
addEditorTab(title, directiveFn, index?, icon?) {
|
||||||
const editorTab = { title, directiveFn, icon };
|
const editorTab = { title, directiveFn, icon };
|
||||||
@ -212,11 +211,6 @@ export class PanelCtrl {
|
|||||||
this.containerHeight = $(window).height();
|
this.containerHeight = $(window).height();
|
||||||
}
|
}
|
||||||
|
|
||||||
// hacky solution
|
|
||||||
if (this.panel.isEditing && !this.editModeInitiated) {
|
|
||||||
this.initEditMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.height = this.containerHeight - (PANEL_BORDER + PANEL_HEADER_HEIGHT);
|
this.height = this.containerHeight - (PANEL_BORDER + PANEL_HEADER_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,6 @@ class DashListCtrl extends PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onInitEditMode() {
|
onInitEditMode() {
|
||||||
this.editorTabIndex = 1;
|
|
||||||
this.modes = ['starred', 'search', 'recently viewed'];
|
this.modes = ['starred', 'search', 'recently viewed'];
|
||||||
this.addEditorTab('Options', 'public/app/plugins/panel/dashlist/editor.html');
|
this.addEditorTab('Options', 'public/app/plugins/panel/dashlist/editor.html');
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ class PluginListCtrl extends PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onInitEditMode() {
|
onInitEditMode() {
|
||||||
this.editorTabIndex = 1;
|
|
||||||
this.addEditorTab('Options', 'public/app/plugins/panel/pluginlist/editor.html');
|
this.addEditorTab('Options', 'public/app/plugins/panel/pluginlist/editor.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ export class TextPanelCtrl extends PanelCtrl {
|
|||||||
|
|
||||||
onInitEditMode() {
|
onInitEditMode() {
|
||||||
this.addEditorTab('Options', 'public/app/plugins/panel/text/editor.html');
|
this.addEditorTab('Options', 'public/app/plugins/panel/text/editor.html');
|
||||||
this.editorTabIndex = 1;
|
|
||||||
|
|
||||||
if (this.panel.mode === 'text') {
|
if (this.panel.mode === 'text') {
|
||||||
this.panel.mode = 'markdown';
|
this.panel.mode = 'markdown';
|
||||||
|
Loading…
Reference in New Issue
Block a user