|
|
@@ -19,6 +19,19 @@ export interface State {
|
|
|
field: string;
|
|
|
}
|
|
|
|
|
|
+// Helper function for determining if a collection of pairs are valid
|
|
|
+// where a valid pair is either fully defined, or not defined at all, but not partially defined
|
|
|
+export function pairsAreValid(pairs: KeyValuePair[]) {
|
|
|
+ return (
|
|
|
+ !pairs ||
|
|
|
+ pairs.every(pair => {
|
|
|
+ const allDefined = !!(pair.key && pair.operator && pair.value);
|
|
|
+ const allEmpty = pair.key === undefined && pair.operator === undefined && pair.value === undefined;
|
|
|
+ return allDefined || allEmpty;
|
|
|
+ })
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
export class InfluxLogsQueryField extends React.PureComponent<Props, State> {
|
|
|
templateSrv: TemplateSrv = new TemplateSrv();
|
|
|
state: State = { measurements: [], measurement: null, field: null };
|
|
|
@@ -77,6 +90,11 @@ export class InfluxLogsQueryField extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
|
|
|
this.props.onChange(queryModel.target);
|
|
|
+
|
|
|
+ // Only run the query if measurement & field are set, and there are no invalid pairs
|
|
|
+ if (measurement && field && pairsAreValid(pairs)) {
|
|
|
+ this.props.onRunQuery();
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
render() {
|