Browse Source

stackriver: use type for state

Erik Sundell 7 years ago
parent
commit
e9e20224d4

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

@@ -3,9 +3,9 @@ import SimpleDropdown from './SimpleDropdown';
 import { TemplateQueryProps } from 'app/types/plugins';
 import { getMetricTypes, extractServicesFromMetricDescriptors } from '../functions';
 import defaultsDeep from 'lodash/defaultsDeep';
-import { MetricFindQueryTypes } from '../types';
+import { MetricFindQueryTypes, TemplateQueryComponentState } from '../types';
 
-export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQueryProps, any> {
+export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQueryProps, TemplateQueryComponentState> {
   queryTypes: Array<{ value: string; name: string }> = [
     { value: MetricFindQueryTypes.Services, name: 'Services' },
     { value: MetricFindQueryTypes.MetricTypes, name: 'Metric Types' },
@@ -17,7 +17,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
     { value: MetricFindQueryTypes.AlignmentPeriods, name: 'Alignment Periods' },
   ];
 
-  defaults = {
+  defaults: TemplateQueryComponentState = {
     selectedQueryType: '',
     metricDescriptors: [],
     selectedService: '',
@@ -95,7 +95,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
   }
 
   componentDidUpdate() {
-    const { metricDescriptors, metricLabels, resourceLabels, ...queryModel } = this.state;
+    const { metricDescriptors, labels, ...queryModel } = this.state;
     this.props.onChange(queryModel);
   }
 

+ 11 - 0
public/app/plugins/datasource/stackdriver/types.ts

@@ -8,3 +8,14 @@ export enum MetricFindQueryTypes {
   Alignerns = 'alignerns',
   AlignmentPeriods = 'alignmentPeriods',
 }
+
+export interface TemplateQueryComponentState {
+  selectedQueryType: string;
+  metricDescriptors: any[];
+  selectedService: string;
+  selectedMetricType: string;
+  labels: string[];
+  labelKey: string;
+  metricTypes: Array<{ value: string; name: string }>;
+  services: Array<{ value: string; name: string }>;
+}