mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackriver: use type for state
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user