Commit 21940c2c by Erik Sundell

stackdriver: revert refactoring

parent 2780ef27
......@@ -105,7 +105,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
async getLabels(selectedMetricType, selectedQueryType = this.state.selectedQueryType) {
let result = { labels: this.state.labels, labelKey: this.state.labelKey };
if (this.isLabelQuery(selectedQueryType)) {
if (selectedMetricType && this.isLabelQuery(selectedQueryType)) {
const refId = 'StackdriverTemplateQueryComponent';
const response = await this.props.datasource.getLabels(selectedMetricType, refId);
const labels = Object.keys(response.meta[selectedQueryType]);
......@@ -115,7 +115,10 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
return result;
}
servicePicker = (
renderQueryTypeSwitch(queryType) {
switch (queryType) {
case MetricFindQueryTypes.MetricTypes:
return (
<SimpleSelect
value={this.state.selectedService}
options={this.state.services}
......@@ -123,47 +126,53 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
label="Services"
/>
);
metricTypesPicker = (
case MetricFindQueryTypes.MetricLabels:
case MetricFindQueryTypes.ResourceLabels:
case MetricFindQueryTypes.ResourceTypes:
return (
<React.Fragment>
<SimpleSelect
value={this.state.selectedService}
options={this.state.services}
onValueChange={this.onServiceChange}
label="Services"
/>
<SimpleSelect
value={this.state.selectedMetricType}
options={this.state.metricTypes}
onValueChange={this.onMetricTypeChange}
label="Metric Types"
/>
);
labelPicker = (
{queryType !== MetricFindQueryTypes.ResourceTypes && (
<SimpleSelect
value={this.state.labelKey}
options={this.state.labels.map(l => ({ value: l, name: l }))}
onValueChange={this.onLabelKeyChange}
label={
this.state.selectedQueryType === MetricFindQueryTypes.ResourceLabels ? 'Resource Label Key' : 'Metric Label Key'
this.state.selectedQueryType === MetricFindQueryTypes.ResourceLabels
? 'Resource Label Key'
: 'Metric Label Key'
}
/>
);
renderQueryTypeSwitch(queryType) {
switch (queryType) {
case MetricFindQueryTypes.MetricTypes:
return this.servicePicker;
case MetricFindQueryTypes.MetricLabels:
case MetricFindQueryTypes.ResourceLabels:
case MetricFindQueryTypes.ResourceTypes:
return (
<React.Fragment>
{this.servicePicker}
{this.metricTypesPicker}
{queryType !== MetricFindQueryTypes.ResourceTypes && this.labelPicker}
)}
</React.Fragment>
);
case MetricFindQueryTypes.Alignerns:
case MetricFindQueryTypes.Aggregations:
return (
<React.Fragment>
{this.servicePicker}
{this.metricTypesPicker}
<SimpleSelect
value={this.state.selectedService}
options={this.state.services}
onValueChange={this.onServiceChange}
label="Services"
/>
<SimpleSelect
value={this.state.selectedMetricType}
options={this.state.metricTypes}
onValueChange={this.onMetricTypeChange}
label="Metric Types"
/>
</React.Fragment>
);
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment