diff --git a/public/app/plugins/datasource/stackdriver/angular_wrappers.ts b/public/app/plugins/datasource/stackdriver/angular_wrappers.ts index 683eceac904..6549135790c 100644 --- a/public/app/plugins/datasource/stackdriver/angular_wrappers.ts +++ b/public/app/plugins/datasource/stackdriver/angular_wrappers.ts @@ -4,7 +4,8 @@ import { QueryEditor } from './components/QueryEditor'; export function registerAngularDirectives() { react2AngularDirective('queryEditor', QueryEditor, [ 'target', - 'onChange', + 'onQueryChange', + 'onExecuteQuery', ['uiSegmentSrv', { watchDepth: 'reference' }], ['datasource', { watchDepth: 'reference' }], ['templateSrv', { watchDepth: 'reference' }], diff --git a/public/app/plugins/datasource/stackdriver/components/AggregationPicker.tsx b/public/app/plugins/datasource/stackdriver/components/AggregationPicker.tsx index e357fd0ae2e..0a41a093d8f 100644 --- a/public/app/plugins/datasource/stackdriver/components/AggregationPicker.tsx +++ b/public/app/plugins/datasource/stackdriver/components/AggregationPicker.tsx @@ -39,7 +39,7 @@ export class AggregationPicker extends React.Component { } componentDidMount() { - this.setAggOptions(); + this.setAggOptions(this.props); } componentWillReceiveProps(nextProps: Props) { @@ -49,17 +49,21 @@ export class AggregationPicker extends React.Component { nextProps.metricKind !== metricKind || nextProps.aggregation.groupBys !== aggregation.groupBys ) { - this.setAggOptions(); + this.setAggOptions(nextProps); } } - setAggOptions() { - const { valueType, metricKind, aggregation, templateSrv } = this.props; + setAggOptions({ valueType, metricKind, aggregation }) { + const { templateSrv } = this.props; let aggregations = getAggregationOptionsByMetric(valueType, metricKind).map(a => ({ ...a, label: a.text, })); - if (!aggregations.find(o => o.value === templateSrv.replace(aggregation.crossSeriesReducer))) { + + if ( + aggregations.length > 0 && + !aggregations.find(o => o.value === templateSrv.replace(aggregation.crossSeriesReducer)) + ) { this.deselectAggregationOption('REDUCE_NONE'); } @@ -67,15 +71,7 @@ export class AggregationPicker extends React.Component { aggregations = aggregations.filter(o => o.value !== 'REDUCE_NONE'); this.deselectAggregationOption('REDUCE_NONE'); } - this.setState({ - aggOptions: [ - this.getTemplateVariablesGroup(), - { - label: 'Aggregations', - options: aggregations, - }, - ], - }); + this.setState({ aggOptions: aggregations }); } deselectAggregationOption(notValidOptionValue: string) { @@ -86,17 +82,6 @@ export class AggregationPicker extends React.Component { handleAggregationChange(value) { this.props.onChange(value); - // this.$scope.refresh(); - } - - getTemplateVariablesGroup() { - return { - label: 'Template Variables', - options: this.props.templateSrv.variables.map(v => ({ - label: `$${v.name}`, - value: `$${v.name}`, - })), - }; } render() { @@ -108,16 +93,15 @@ export class AggregationPicker extends React.Component {
-
- this.handleAggregationChange(value)} - selected={aggregation.crossSeriesReducer} - options={aggOptions} - searchable={true} - placeholder="Select Aggregation" - className="width-15" - /> -
+ this.handleAggregationChange(value)} + selected={aggregation.crossSeriesReducer} + options={aggOptions} + searchable={true} + placeholder="Select Aggregation" + className="width-15" + groupName="Aggregations" + />