stackriver: use type for state

This commit is contained in:
Erik Sundell
2018-10-31 13:43:07 +01:00
parent e0c0dc1453
commit e9e20224d4
2 changed files with 15 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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 }>;
}