Browse Source

Fixes undefined issue with angular panels and editorTabs

Torkel Ödegaard 7 years ago
parent
commit
5b83f6d49d

+ 1 - 0
public/app/features/dashboard/dashgrid/VisualizationTab.tsx

@@ -106,6 +106,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
     }
 
     const panelCtrl = scope.$$childHead.ctrl;
+    panelCtrl.initEditMode();
 
     let template = '';
     for (let i = 0; i < panelCtrl.editorTabs.length; i++) {

+ 0 - 2
public/app/features/panel/metrics_panel_ctrl.ts

@@ -30,8 +30,6 @@ class MetricsPanelCtrl extends PanelCtrl {
   constructor($scope, $injector) {
     super($scope, $injector);
 
-    // make metrics tab the default
-    this.editorTabIndex = 1;
     this.$q = $injector.get('$q');
     this.contextSrv = $injector.get('contextSrv');
     this.datasourceSrv = $injector.get('datasourceSrv');

+ 5 - 11
public/app/features/panel/panel_ctrl.ts

@@ -18,7 +18,6 @@ export class PanelCtrl {
   panel: any;
   error: any;
   dashboard: any;
-  editorTabIndex: number;
   pluginName: string;
   pluginId: string;
   editorTabs: any;
@@ -39,7 +38,7 @@ export class PanelCtrl {
     this.$location = $injector.get('$location');
     this.$scope = $scope;
     this.$timeout = $injector.get('$timeout');
-    this.editorTabIndex = 0;
+    this.editorTabs = [];
     this.events = this.panel.events;
     this.timing = {};
 
@@ -90,10 +89,10 @@ export class PanelCtrl {
   }
 
   initEditMode() {
-    this.editorTabs = [];
-
-    this.editModeInitiated = true;
-    this.events.emit('init-edit-mode', null);
+    if (!this.editModeInitiated) {
+      this.editModeInitiated = true;
+      this.events.emit('init-edit-mode', null);
+    }
   }
 
   addEditorTab(title, directiveFn, index?, icon?) {
@@ -212,11 +211,6 @@ export class PanelCtrl {
       this.containerHeight = $(window).height();
     }
 
-    // hacky solution
-    if (this.panel.isEditing && !this.editModeInitiated) {
-      this.initEditMode();
-    }
-
     this.height = this.containerHeight - (PANEL_BORDER + PANEL_HEADER_HEIGHT);
   }
 

+ 0 - 1
public/app/plugins/panel/dashlist/module.ts

@@ -60,7 +60,6 @@ class DashListCtrl extends PanelCtrl {
   }
 
   onInitEditMode() {
-    this.editorTabIndex = 1;
     this.modes = ['starred', 'search', 'recently viewed'];
     this.addEditorTab('Options', 'public/app/plugins/panel/dashlist/editor.html');
   }

+ 0 - 1
public/app/plugins/panel/pluginlist/module.ts

@@ -29,7 +29,6 @@ class PluginListCtrl extends PanelCtrl {
   }
 
   onInitEditMode() {
-    this.editorTabIndex = 1;
     this.addEditorTab('Options', 'public/app/plugins/panel/pluginlist/editor.html');
   }
 

+ 0 - 1
public/app/plugins/panel/text/module.ts

@@ -43,7 +43,6 @@ export class TextPanelCtrl extends PanelCtrl {
 
   onInitEditMode() {
     this.addEditorTab('Options', 'public/app/plugins/panel/text/editor.html');
-    this.editorTabIndex = 1;
 
     if (this.panel.mode === 'text') {
       this.panel.mode = 'markdown';