mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
QueryEditor: Don't use _.defaults as it mutates the query prop directly (#37965)
* QueryEditor: Don't use _.defaults as it mutates the query prop directly * QueryEditor: Update the query type on mount if none exists * QueryEditor: Mutate in the constructor instead of render * Apply defaults immutably in render
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
import { defaults } from 'lodash';
|
|
||||||
|
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { InlineField, Select, Alert, Input } from '@grafana/ui';
|
import { InlineField, Select, Alert, Input } from '@grafana/ui';
|
||||||
import { QueryEditorProps, SelectableValue, dataFrameFromJSON, rangeUtil } from '@grafana/data';
|
import { QueryEditorProps, SelectableValue, dataFrameFromJSON, rangeUtil } from '@grafana/data';
|
||||||
@@ -245,7 +243,11 @@ export class QueryEditor extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const query = defaults(this.props.query, defaultQuery);
|
const query = {
|
||||||
|
...defaultQuery,
|
||||||
|
...this.props.query,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="gf-form">
|
<div className="gf-form">
|
||||||
|
|||||||
Reference in New Issue
Block a user