@ -57,14 +57,12 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
constructor ( props : Props ) {
super ( props ) ;
this . state = Object . assign (
this . defaults ,
{ projectName : this.props.datasource.getDefaultProject ( ) } ,
this . props . query
) ;
this . state = Object . assign ( this . defaults , this . props . query ) ;
}
async componentDidMount() {
await this . props . datasource . ensureGCEDefaultProject ( ) ;
const projectName = this . props . datasource . getDefaultProject ( ) ;
const projects = ( await this . props . datasource . getProjects ( ) ) as MetricDescriptor [ ] ;
const metricDescriptors = await this . props . datasource . getMetricTypes (
this . props . query . projectName || this . props . datasource . getDefaultProject ( )
@ -88,7 +86,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
getTemplateSrv ( ) . replace ( selectedService )
) ;
const sloServices = await this . props . datasource . getSLOServices ( this . state . projectName ) ;
const sloServices = await this . props . datasource . getSLOServices ( projectName ) ;
const state : any = {
services ,
@ -97,9 +95,10 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
selectedMetricType ,
metricDescriptors ,
projects ,
. . . ( await this . getLabels ( selectedMetricType , this . state . projectName ) ) ,
. . . ( await this . getLabels ( selectedMetricType , projectName ) ) ,
sloServices ,
loading : false ,
projectName ,
} ;
this . setState ( state , ( ) = > this . onPropsChange ( ) ) ;
}