浏览代码

HUE-9000 [editor] Properly position result headers after query tab switching

Johan Ahlen 6 年之前
父节点
当前提交
217792fb92

+ 9 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.snippetResults.js

@@ -29,6 +29,7 @@ import { EXECUTABLE_UPDATED_EVENT, EXECUTION_STATUS } from 'apps/notebook2/execu
 import { RESULT_TYPE, RESULT_UPDATED_EVENT } from 'apps/notebook2/execution/executionResult';
 import { attachTracker } from 'apps/notebook2/components/executableStateHandler';
 import { defer } from 'utils/hueUtils';
+import { CURRENT_QUERY_TAB_SWITCHED_EVENT } from 'apps/notebook2/snippet';
 
 export const NAME = 'snippet-results';
 
@@ -160,6 +161,14 @@ class SnippetResults extends DisposableComponent {
     this.hasMore = ko.observable();
     this.hasResultSet = ko.observable();
 
+    this.subscribe(CURRENT_QUERY_TAB_SWITCHED_EVENT, queryTab => {
+      if (queryTab === 'queryResults') {
+        defer(() => {
+          huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+        });
+      }
+    });
+
     this.executing = ko.pureComputed(() => this.status() === EXECUTION_STATUS.running);
 
     this.hasSomeResult = ko.pureComputed(() => this.data().length);

+ 3 - 2
desktop/core/src/desktop/js/apps/notebook2/snippet.js

@@ -45,6 +45,8 @@ import { EXECUTE_ACTIVE_EXECUTABLE_EVENT } from 'apps/notebook2/components/ko.ex
 window.SqlExecutable = SqlExecutable;
 window.Executor = Executor;
 
+export const CURRENT_QUERY_TAB_SWITCHED_EVENT = 'current.query.tab.switched';
+
 const TYPE = {
   hive: 'hive',
   impala: 'impala',
@@ -308,8 +310,7 @@ export default class Snippet {
 
     this.lastQueriesPage = 1;
     this.currentQueryTab.subscribe(newValue => {
-      huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-      huePubSub.publish('current.query.tab.switched', newValue);
+      huePubSub.publish(CURRENT_QUERY_TAB_SWITCHED_EVENT, newValue);
       if (
         newValue === 'savedQueries' &&
         (this.queries().length === 0 || this.lastQueriesPage !== this.queriesCurrentPage())