Jelajahi Sumber

stackdriver: converts some variables from any to types

Daniel Lee 7 tahun lalu
induk
melakukan
7b1aed6caf

+ 3 - 1
public/app/plugins/datasource/stackdriver/annotations_query_ctrl.ts

@@ -1,7 +1,9 @@
+import { TemplateSrv } from 'app/features/templating/template_srv';
+
 export class StackdriverAnnotationsQueryCtrl {
   static templateUrl = 'partials/annotations.editor.html';
   annotation: any;
-  templateSrv: any;
+  templateSrv: TemplateSrv;
 
   /** @ngInject */
   constructor(templateSrv) {

+ 2 - 1
public/app/plugins/datasource/stackdriver/components/Aggregations.test.tsx

@@ -3,10 +3,11 @@ import renderer from 'react-test-renderer';
 import { Aggregations, Props } from './Aggregations';
 import { shallow } from 'enzyme';
 import { ValueTypes, MetricKind } from '../constants';
+import { TemplateSrvStub } from 'test/specs/helpers';
 
 const props: Props = {
   onChange: () => {},
-  templateSrv: {},
+  templateSrv: new TemplateSrvStub(),
   metricDescriptor: {
     valueType: '',
     metricKind: '',

+ 2 - 1
public/app/plugins/datasource/stackdriver/components/Aggregations.tsx

@@ -3,10 +3,11 @@ import _ from 'lodash';
 
 import { MetricSelect } from 'app/core/components/Select/MetricSelect';
 import { getAggregationOptionsByMetric } from '../functions';
+import { TemplateSrv } from 'app/features/templating/template_srv';
 
 export interface Props {
   onChange: (metricDescriptor) => void;
-  templateSrv: any;
+  templateSrv: TemplateSrv;
   metricDescriptor: {
     valueType: string;
     metricKind: string;

+ 2 - 1
public/app/plugins/datasource/stackdriver/components/AlignmentPeriods.tsx

@@ -4,10 +4,11 @@ import _ from 'lodash';
 import kbn from 'app/core/utils/kbn';
 import { MetricSelect } from 'app/core/components/Select/MetricSelect';
 import { alignmentPeriods, alignOptions } from '../constants';
+import { TemplateSrv } from 'app/features/templating/template_srv';
 
 export interface Props {
   onChange: (alignmentPeriod) => void;
-  templateSrv: any;
+  templateSrv: TemplateSrv;
   alignmentPeriod: string;
   perSeriesAligner: string;
   usedAlignmentPeriod: string;

+ 4 - 2
public/app/plugins/datasource/stackdriver/components/Alignments.tsx

@@ -2,11 +2,13 @@ import React, { SFC } from 'react';
 import _ from 'lodash';
 
 import { MetricSelect } from 'app/core/components/Select/MetricSelect';
+import { TemplateSrv } from 'app/features/templating/template_srv';
+import { SelectOptionItem } from '@grafana/ui';
 
 export interface Props {
   onChange: (perSeriesAligner) => void;
-  templateSrv: any;
-  alignOptions: any[];
+  templateSrv: TemplateSrv;
+  alignOptions: SelectOptionItem[];
   perSeriesAligner: string;
 }
 

+ 4 - 2
public/app/plugins/datasource/stackdriver/components/Filter.tsx

@@ -4,16 +4,18 @@ import appEvents from 'app/core/app_events';
 
 import { QueryMeta } from '../types';
 import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
+import { TemplateSrv } from 'app/features/templating/template_srv';
+import StackdriverDatasource from '../datasource';
 import '../query_filter_ctrl';
 
 export interface Props {
   filtersChanged: (filters: string[]) => void;
   groupBysChanged?: (groupBys: string[]) => void;
   metricType: string;
-  templateSrv: any;
+  templateSrv: TemplateSrv;
   groupBys?: string[];
   filters: string[];
-  datasource: any;
+  datasource: StackdriverDatasource;
   refId: string;
   hideGroupBys: boolean;
 }

+ 2 - 1
public/app/plugins/datasource/stackdriver/components/Metrics.tsx

@@ -5,10 +5,11 @@ import StackdriverDatasource from '../datasource';
 import appEvents from 'app/core/app_events';
 import { MetricDescriptor } from '../types';
 import { MetricSelect } from 'app/core/components/Select/MetricSelect';
+import { TemplateSrv } from 'app/features/templating/template_srv';
 
 export interface Props {
   onChange: (metricDescriptor: MetricDescriptor) => void;
-  templateSrv: any;
+  templateSrv: TemplateSrv;
   datasource: StackdriverDatasource;
   defaultProject: string;
   metricType: string;

+ 1 - 1
public/app/plugins/datasource/stackdriver/components/QueryEditor.test.tsx

@@ -11,7 +11,7 @@ const props: Props = {
   datasource: {
     getDefaultProject: () => Promise.resolve('project'),
     getMetricTypes: () => Promise.resolve([]),
-  },
+  } as any,
   templateSrv: new TemplateSrv(),
 };
 

+ 4 - 2
public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx

@@ -12,18 +12,20 @@ import { AliasBy } from './AliasBy';
 import { Help } from './Help';
 import { Target, MetricDescriptor } from '../types';
 import { getAlignmentPickerData } from '../functions';
+import StackdriverDatasource from '../datasource';
+import { SelectOptionItem } from '@grafana/ui';
 
 export interface Props {
   onQueryChange: (target: Target) => void;
   onExecuteQuery: () => void;
   target: Target;
   events: any;
-  datasource: any;
+  datasource: StackdriverDatasource;
   templateSrv: TemplateSrv;
 }
 
 interface State extends Target {
-  alignOptions: any[];
+  alignOptions: SelectOptionItem[];
   lastQuery: string;
   lastQueryError: string;
   [key: string]: any;

+ 2 - 2
public/app/plugins/datasource/stackdriver/components/__snapshots__/QueryEditor.test.tsx.snap

@@ -436,9 +436,9 @@ Array [
       onClick={[Function]}
     >
       <label
-        className="gf-form-label query-keyword"
+        className="gf-form-label query-keyword pointer"
       >
-        Show Help
+        Show Help 
         <i
           className="fa fa-caret-right"
         />

+ 2 - 1
public/app/plugins/datasource/stackdriver/query_ctrl.ts

@@ -2,10 +2,11 @@ import _ from 'lodash';
 
 import { QueryCtrl } from 'app/plugins/sdk';
 import { Target } from './types';
+import { TemplateSrv } from 'app/features/templating/template_srv';
 
 export class StackdriverQueryCtrl extends QueryCtrl {
   static templateUrl = 'partials/query.editor.html';
-  templateSrv: any;
+  templateSrv: TemplateSrv;
 
   /** @ngInject */
   constructor($scope, $injector, templateSrv) {