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

+ 10 - 4
public/app/features/dashboard/dashgrid/QueriesTab.tsx

@@ -21,15 +21,21 @@ export class QueriesTab extends React.Component<Props, any> {
       return;
     }
 
+    const { panel, dashboard } = this.props;
+
+    // make sure the panel has datasource & queries properties
+    panel.datasource = panel.datasource || null;
+    panel.targets = panel.targets || [{}];
+
     const loader = getAngularLoader();
     const template = '<metrics-tab />';
     const scopeProps = {
       ctrl: {
-        panel: this.props.panel,
-        dashboard: this.props.dashboard,
+        panel: panel,
+        dashboard: dashboard,
         panelCtrl: {
-          panel: this.props.panel,
-          dashboard: this.props.dashboard,
+          panel: panel,
+          dashboard: dashboard,
         },
       },
     };

+ 0 - 2
public/app/features/dashboard/panel_model.ts

@@ -52,8 +52,6 @@ export class PanelModel {
 
     // defaults
     this.gridPos = this.gridPos || { x: 0, y: 0, h: 3, w: 6 };
-    this.datasource = this.datasource || null;
-    this.targets = this.targets || [{}];
   }
 
   getSaveModel() {

+ 1 - 0
public/app/features/dashboard/specs/viewstate_srv.test.ts

@@ -11,6 +11,7 @@ describe('when updating view state', () => {
   };
 
   const $scope = {
+    appEvent: jest.fn(),
     onAppEvent: jest.fn(() => {}),
     dashboard: new DashboardModel({
       panels: [{ id: 1 }],