Browse Source

HUE-6077 [editor] Reset the history if the type of the editor changed

If not, if default editor is hive and we open http://127.0.0.1:8000/hue/editor/?type=impala,
the Hive history will stay instead of the Impala one.
Romain Rigaux 8 years ago
parent
commit
7db098b

+ 1 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1753,7 +1753,7 @@ var EditorViewModel = (function() {
     if (self.dependentsCoordinator().length > 0 && ! self.coordinatorUuid()) {
       self.coordinatorUuid(self.dependentsCoordinator()[0].uuid());
     }
-    self.history = ko.observableArray(vm.selectedNotebook() && vm.selectedNotebook().type() == self.type() ? vm.selectedNotebook().history() : []);
+    self.history = ko.observableArray(vm.selectedNotebook() && vm.selectedNotebook().history().length > 0 && vm.selectedNotebook().history()[0].type == self.type() ? vm.selectedNotebook().history() : []);
     self.history.subscribe(function(val) {
       if (self.id() == null && val.length == 0 && self.historyFilter() === '' && ! vm.isNotificationManager()) {
         self.snippets()[0].currentQueryTab('savedQueries');