mirror of
https://github.com/grafana/grafana.git
synced 2025-01-02 12:17:01 -06:00
CloudMonitoring: Prevent resource type variable function from crashing (#30901)
* check if label response has resource type prop * use nullish coalescing operator
This commit is contained in:
parent
e2e61878ba
commit
60b5e6ca95
@ -112,7 +112,7 @@ export default class CloudMonitoringMetricFindQuery {
|
|||||||
}
|
}
|
||||||
const refId = 'handleResourceTypeQueryQueryType';
|
const refId = 'handleResourceTypeQueryQueryType';
|
||||||
const labels = await this.datasource.getLabels(selectedMetricType, refId, projectName);
|
const labels = await this.datasource.getLabels(selectedMetricType, refId, projectName);
|
||||||
return labels['resource.type'].map(this.toFindQueryResult);
|
return labels['resource.type']?.map(this.toFindQueryResult) ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleAlignersQuery({ selectedMetricType, projectName }: CloudMonitoringVariableQuery) {
|
async handleAlignersQuery({ selectedMetricType, projectName }: CloudMonitoringVariableQuery) {
|
||||||
|
@ -150,7 +150,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
|
|||||||
selectedMetricType,
|
selectedMetricType,
|
||||||
...(await this.getLabels(selectedMetricType, this.state.projectName)),
|
...(await this.getLabels(selectedMetricType, this.state.projectName)),
|
||||||
};
|
};
|
||||||
this.setState(state);
|
this.setState(state, () => this.onPropsChange());
|
||||||
}
|
}
|
||||||
|
|
||||||
async onMetricTypeChange(metricType: string) {
|
async onMetricTypeChange(metricType: string) {
|
||||||
@ -158,7 +158,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
|
|||||||
selectedMetricType: metricType,
|
selectedMetricType: metricType,
|
||||||
...(await this.getLabels(metricType, this.state.projectName)),
|
...(await this.getLabels(metricType, this.state.projectName)),
|
||||||
};
|
};
|
||||||
this.setState(state);
|
this.setState(state, () => this.onPropsChange());
|
||||||
}
|
}
|
||||||
|
|
||||||
onLabelKeyChange(labelKey: string) {
|
onLabelKeyChange(labelKey: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user