瀏覽代碼

QueryEditors: Fixes flakey text edit mode toggle (#18335)

Closes #18037
kay delaney 6 年之前
父節點
當前提交
9b5890cc62
共有 1 個文件被更改,包括 1 次插入7 次删除
  1. 1 7
      public/app/features/dashboard/panel_editor/QueryEditorRow.tsx

+ 1 - 7
public/app/features/dashboard/panel_editor/QueryEditorRow.tsx

@@ -83,7 +83,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
     this.setState({
       datasource,
       loadedDataSourceValue: this.props.dataSourceValue,
-      hasTextEditMode: false,
+      hasTextEditMode: _.has(datasource, 'components.QueryCtrl.prototype.toggleEditorMode'),
     });
   }
 
@@ -122,14 +122,8 @@ export class QueryEditorRow extends PureComponent<Props, State> {
     const loader = getAngularLoader();
     const template = '<plugin-component type="query-ctrl" />';
     const scopeProps = { ctrl: this.getAngularQueryComponentScope() };
-
     this.angularQueryEditor = loader.load(this.element, scopeProps, template);
     this.angularScope = scopeProps.ctrl;
-
-    // give angular time to compile
-    setTimeout(() => {
-      this.setState({ hasTextEditMode: !!this.angularScope.toggleEditorMode });
-    }, 100);
   }
 
   onToggleCollapse = () => {