Ver código fonte

HUE-9101 [editor] Refresh the history after execution in notebook 2

Johan Ahlen 6 anos atrás
pai
commit
dd6e5307cc

+ 3 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.queryHistory.js

@@ -28,6 +28,7 @@ import huePubSub from 'utils/huePubSub';
 
 export const NAME = 'query-history';
 export const HISTORY_CLEARED_EVENT = 'query.history.cleared';
+export const UPDATE_HISTORY_EVENT = 'query.history.update';
 
 // prettier-ignore
 const TEMPLATE = `
@@ -191,6 +192,8 @@ class QueryHistory extends DisposableComponent {
 
     this.subscribe(this.historyCurrentPage, throttledFetch);
 
+    this.subscribe(UPDATE_HISTORY_EVENT, throttledFetch);
+
     throttledFetch();
   }
 

+ 8 - 0
desktop/core/src/desktop/js/apps/notebook2/snippet.js

@@ -41,6 +41,7 @@ import {
   REFRESH_STATEMENT_LOCATIONS_EVENT
 } from 'ko/bindings/ace/aceLocationHandler';
 import { EXECUTE_ACTIVE_EXECUTABLE_EVENT } from 'apps/notebook2/components/ko.executableActions';
+import { UPDATE_HISTORY_EVENT } from 'apps/notebook2/components/ko.queryHistory';
 
 // TODO: Remove for ENABLE_NOTEBOOK_2. Temporary here for debug
 window.SqlExecutable = SqlExecutable;
@@ -1053,6 +1054,13 @@ export default class Snippet {
 
   updateFromExecutable(executable) {
     if (executable) {
+      if (
+        executable.status === EXECUTION_STATUS.available ||
+        executable.status === EXECUTION_STATUS.failed ||
+        executable.status === EXECUTION_STATUS.success
+      ) {
+        huePubSub.publish(UPDATE_HISTORY_EVENT);
+      }
       this.status(executable.status);
       if (executable.result) {
         this.currentQueryTab('queryResults');