Просмотр исходного кода

Fix for no metrics panels, now goes to viz tab and does not show queries tab

Torkel Ödegaard 7 лет назад
Родитель
Сommit
38b5d7862f

+ 14 - 2
public/app/features/dashboard/dashgrid/PanelEditor.tsx

@@ -72,14 +72,26 @@ export class PanelEditor extends PureComponent<PanelEditorProps> {
 
   render() {
     const { plugin } = this.props;
-    const activeTab = store.getState().location.query.tab || 'queries';
+    let activeTab = store.getState().location.query.tab || 'queries';
 
-    const tabs = [
+    const tabs: PanelEditorTab[] = [
       { id: 'queries', text: 'Queries' },
       { id: 'visualization', text: 'Visualization' },
       { id: 'advanced', text: 'Panel Options' },
     ];
 
+    // handle panels that do not have queries tab
+    if (plugin.exports.PanelCtrl) {
+      if (!plugin.exports.PanelCtrl.prototype.onDataReceived) {
+        // remove queries tab
+        tabs.shift();
+        // switch tab
+        if (activeTab === 'queries') {
+          activeTab = 'visualization';
+        }
+      }
+    }
+
     if (config.alertingEnabled && plugin.id === 'graph') {
       tabs.push({
         id: 'alert',

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

@@ -7,6 +7,8 @@ const defaultContent = `
 
 For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)
 
+
+
 `;
 
 export class TextPanelCtrl extends PanelCtrl {