浏览代码

HUE-5857 [editor] Prevent blinking of the risk alert

Also:
- Only the icon is clickable
- Allow syntax check for Impala and Hive only
- Better initialization without check icon and only one time
Romain Rigaux 8 年之前
父节点
当前提交
35797a2afe

+ 9 - 10
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -813,7 +813,7 @@ var EditorViewModel = (function() {
     });
 
     self.suggestion = ko.observable(typeof snippet.complexity != "undefined" && snippet.complexity != null ? snippet.complexity : '');
-    self.hasSuggestion = ko.observable(false);
+    self.hasSuggestion = ko.observable(null);
 
     self.complexityCheckRunning = ko.observable(false);
     self.compatibilityCheckRunning = ko.observable(false);
@@ -864,17 +864,17 @@ var EditorViewModel = (function() {
         });
       };
 
-      self.delayedStatement.subscribe(function () {
-        if (self.type() === 'hive') {
+      if (self.type() === 'hive' || self.type() === 'impala') {
+        self.delayedStatement.subscribe(function () {
           self.checkComplexity();
           self.queryCompatibility();
+        });
+        if (self.statement_raw()) {
+          window.setTimeout(function(){
+            self.checkComplexity();
+            self.queryCompatibility();
+          }, 2000);
         }
-      });
-      if (self.statement_raw()) {
-        window.setTimeout(function(){
-          self.checkComplexity();
-          self.queryCompatibility();
-        }, 2000);
       }
     }
 
@@ -1171,7 +1171,6 @@ var EditorViewModel = (function() {
 
       logGA('compatibility');
       self.compatibilityCheckRunning(targetPlatform != self.type());
-      self.hasSuggestion(false);
 
       self.compatibilityTarget(targetPlatform);
 

+ 8 - 8
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1026,18 +1026,18 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
 <script type="text/html" id="code-editor-snippet-body">
   <!-- ko if: HAS_OPTIMIZER -->
-  <div data-bind="click: function(){ showOptimizer(!showOptimizer()) }, css: { 'active': showOptimizer }, attr: { 'title': showOptimizer() ? '${ _ko('Close Query Validator') }' : '${ _ko('Open Query Validator') }'}">
+  <div data-bind="css: { 'active': showOptimizer }, attr: { 'title': showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
     <div class="round-icon empty">&nbsp;</div>
-    <!-- ko if: !hasSuggestion() || compatibilityCheckRunning() -->
+    <!-- ko if: hasSuggestion() == null || compatibilityCheckRunning() -->
     <div class="round-icon idle">
-      <i class="fa fa-check" data-bind="css: {'fa-spinner fa-spin': compatibilityCheckRunning}"></i>
+      <i class="fa" data-bind="css: {'fa-spinner fa-spin': compatibilityCheckRunning}"></i>
     </div>
     <!-- /ko -->
 
     <!-- ko if: hasSuggestion() -->
         <!-- ko with: suggestion() -->
           <!-- ko if: parseError -->
-            <div class="round-icon error">
+            <div class="round-icon error" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }">
               <i class="fa fa-exclamation"></i>
             </div>
             <!-- ko if: $parent.showOptimizer -->
@@ -1046,7 +1046,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
           <!-- /ko -->
           <!-- ko if: !parseError() && $parent.compatibilityTarget() != $parent.type() -->
             <!-- ko if: queryError.encounteredString().length == 0 -->
-              <div class="round-icon success">
+              <div class="round-icon success" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }">
                 <i class="fa fa-check"></i>
               </div>
               <!-- ko if: $parent.showOptimizer -->
@@ -1054,7 +1054,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
               <!-- /ko -->
             <!-- /ko -->
             <!-- ko ifnot: queryError.encounteredString().length == 0 -->
-              <div class="round-icon warning">
+              <div class="round-icon warning" data-bind="click: function(){ $parent.showOptimizer(! $parent.showOptimizer()) }">
                 <i class="fa fa-exclamation"></i>
               </div>
               <!-- ko if: $parent.showOptimizer -->
@@ -1066,7 +1066,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
     <!-- /ko -->
     <!-- ko if: hasComplexity() && hasSuggestion() && compatibilityTarget() === type() && suggestion() && !suggestion().parseError() -->
       <!-- ko if: complexity() && complexity().risk() && (complexity().risk().length === 0 || complexity().risk() === 'low') -->
-        <div class="round-icon success">
+        <div class="round-icon success" data-bind="click: function(){ $root.showOptimizer(! $root.showOptimizer()) }">
           <i class="fa fa-check"></i>
         </div>
         <!-- ko if: showOptimizer -->
@@ -1074,7 +1074,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         <!-- /ko -->
       <!-- /ko -->
       <!-- ko if: complexity() && complexity().risk() && complexity().risk() === 'high' -->
-        <div class="round-icon error">
+        <div class="round-icon error" data-bind="click: function(){ $root.showOptimizer(! $root.showOptimizer()) }">
           <i class="fa fa-exclamation"></i>
         </div>
         <!-- ko if: showOptimizer -->