浏览代码

Influx: Reset logs query field on clear all and clear row in explore (#17549)

Resets influx logs query field when hitting clear all and clear row 
in explore logs mode.

Fixes #17506
Marcus Efraimsson 6 年之前
父节点
当前提交
d168057fc6
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      public/app/plugins/datasource/influxdb/components/InfluxLogsQueryField.tsx

+ 7 - 1
public/app/plugins/datasource/influxdb/components/InfluxLogsQueryField.tsx

@@ -63,6 +63,12 @@ export class InfluxLogsQueryField extends React.PureComponent<Props, State> {
     this.setState({ measurements });
     this.setState({ measurements });
   }
   }
 
 
+  componentDidUpdate(prevProps: Props) {
+    if (prevProps.query.measurement && !this.props.query.measurement) {
+      this.setState({ measurement: null, field: null });
+    }
+  }
+
   onMeasurementsChange = async (values: string[]) => {
   onMeasurementsChange = async (values: string[]) => {
     const { query } = this.props;
     const { query } = this.props;
     const measurement = values[0];
     const measurement = values[0];
@@ -105,7 +111,7 @@ export class InfluxLogsQueryField extends React.PureComponent<Props, State> {
     return (
     return (
       <div className="gf-form-inline gf-form-inline--nowrap">
       <div className="gf-form-inline gf-form-inline--nowrap">
         <div className="gf-form flex-shrink-0">
         <div className="gf-form flex-shrink-0">
-          <Cascader options={measurements} onChange={this.onMeasurementsChange}>
+          <Cascader options={measurements} value={[measurement, field]} onChange={this.onMeasurementsChange}>
             <button className="gf-form-label gf-form-label--btn">
             <button className="gf-form-label gf-form-label--btn">
               {cascadeText} <i className="fa fa-caret-down" />
               {cascadeText} <i className="fa fa-caret-down" />
             </button>
             </button>