Ver Fonte

[editor] Separate the editor v2 from the notebook

This introduces a new webpack entrypoint for the editor v2 and it moves the feature flag test to the backend. If the flag is enabled it will return editor2.mako, for the editor and the old notebook.mako for the notebook.

This gives us full control of the editor v2 page layout without interfering with editor v1 and the notebook functionality.

Notebook will keep using editor v1.
Johan Ahlen há 5 anos atrás
pai
commit
0a9a8a7c20
99 ficheiros alterados com 2276 adições e 2394 exclusões
  1. 4 6
      desktop/core/src/desktop/js/apps/editor/EditorViewModel.js
  2. 0 0
      desktop/core/src/desktop/js/apps/editor/api.ts
  3. 843 0
      desktop/core/src/desktop/js/apps/editor/app.js
  4. 1 1
      desktop/core/src/desktop/js/apps/editor/components/EditorResizer.vue
  5. 1 1
      desktop/core/src/desktop/js/apps/editor/components/EditorResizerKoBridge.vue
  6. 2 2
      desktop/core/src/desktop/js/apps/editor/components/ExecutableActions.test.ts
  7. 4 4
      desktop/core/src/desktop/js/apps/editor/components/ExecutableActions.vue
  8. 1 1
      desktop/core/src/desktop/js/apps/editor/components/ExecutableActionsKoBridge.vue
  9. 0 0
      desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ExecutableActions.test.ts.snap
  10. 0 0
      desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ko.paginator.test.js.snap
  11. 0 0
      desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ko.queryHistory.test.js.snap
  12. 0 0
      desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ko.savedQueries.test.js.snap
  13. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceAnchoredRange.ts
  14. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.scss
  15. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.test.ts
  16. 2 2
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.vue
  17. 1 1
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditorKoBridge.vue
  18. 3 3
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceGutterHandler.ts
  19. 1 1
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceLocationHandler.ts
  20. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/QueryEditorWebComponent.ts
  21. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/__snapshots__/AceEditor.test.ts.snap
  22. 1 1
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AceAutocomplete.vue
  23. 2 2
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AutocompleteResults.ts
  24. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/CatalogEntryDetailsPanel.vue
  25. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/Category.ts
  26. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/MatchedText.vue
  27. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/OptionDetailsPanel.vue
  28. 1 1
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/SqlAutocompleter.ts
  29. 0 0
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/UdfDetailsPanel.vue
  30. 1 1
      desktop/core/src/desktop/js/apps/editor/components/executableStateHandler.js
  31. 3 3
      desktop/core/src/desktop/js/apps/editor/components/ko.executableLogs.js
  32. 1 1
      desktop/core/src/desktop/js/apps/editor/components/ko.executableProgressBar.js
  33. 1 1
      desktop/core/src/desktop/js/apps/editor/components/ko.executableProgressBar.test.js
  34. 0 0
      desktop/core/src/desktop/js/apps/editor/components/ko.paginator.js
  35. 0 0
      desktop/core/src/desktop/js/apps/editor/components/ko.paginator.test.js
  36. 1 1
      desktop/core/src/desktop/js/apps/editor/components/ko.queryHistory.js
  37. 0 0
      desktop/core/src/desktop/js/apps/editor/components/ko.queryHistory.test.js
  38. 0 0
      desktop/core/src/desktop/js/apps/editor/components/ko.savedQueries.js
  39. 0 0
      desktop/core/src/desktop/js/apps/editor/components/ko.savedQueries.test.js
  40. 1 1
      desktop/core/src/desktop/js/apps/editor/components/ko.snippetEditorActions.js
  41. 8 8
      desktop/core/src/desktop/js/apps/editor/components/ko.snippetResults.js
  42. 3 3
      desktop/core/src/desktop/js/apps/editor/components/result/ExecutionResults.vue
  43. 1 1
      desktop/core/src/desktop/js/apps/editor/components/result/ExecutionResultsKoBridge.vue
  44. 2 2
      desktop/core/src/desktop/js/apps/editor/components/result/ResultGrid.vue
  45. 1 4
      desktop/core/src/desktop/js/apps/editor/components/resultChart/chartTransformers.js
  46. 2 2
      desktop/core/src/desktop/js/apps/editor/components/resultChart/ko.resultChart.js
  47. 1 1
      desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.resultDownloadActions.js
  48. 0 0
      desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.resultDownloadModal.js
  49. 2 2
      desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.resultGrid.js
  50. 3 3
      desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.simpleResultGrid.js
  51. 0 0
      desktop/core/src/desktop/js/apps/editor/events.js
  52. 2 5
      desktop/core/src/desktop/js/apps/editor/execution/api.ts
  53. 6 6
      desktop/core/src/desktop/js/apps/editor/execution/executable.ts
  54. 1 1
      desktop/core/src/desktop/js/apps/editor/execution/executionLogs.ts
  55. 1 1
      desktop/core/src/desktop/js/apps/editor/execution/executionResult.ts
  56. 4 4
      desktop/core/src/desktop/js/apps/editor/execution/executor.ts
  57. 0 0
      desktop/core/src/desktop/js/apps/editor/execution/sessionManager.test.ts
  58. 1 1
      desktop/core/src/desktop/js/apps/editor/execution/sessionManager.ts
  59. 1 1
      desktop/core/src/desktop/js/apps/editor/execution/sqlExecutable.test.ts
  60. 4 4
      desktop/core/src/desktop/js/apps/editor/execution/sqlExecutable.ts
  61. 2 2
      desktop/core/src/desktop/js/apps/editor/execution/utils.test.ts
  62. 3 3
      desktop/core/src/desktop/js/apps/editor/execution/utils.ts
  63. 4 4
      desktop/core/src/desktop/js/apps/editor/notebook.js
  64. 1 1
      desktop/core/src/desktop/js/apps/editor/notebook.test.js
  65. 11 11
      desktop/core/src/desktop/js/apps/editor/snippet.js
  66. 1 1
      desktop/core/src/desktop/js/apps/editor/snippet.test.js
  67. 1 1
      desktop/core/src/desktop/js/apps/editor/variableSubstitution.ts
  68. 2 4
      desktop/core/src/desktop/js/apps/notebook/NotebookViewModel.js
  69. 1294 1308
      desktop/core/src/desktop/js/apps/notebook/app.js
  70. 1 1
      desktop/core/src/desktop/js/apps/notebook/snippet.js
  71. 0 848
      desktop/core/src/desktop/js/apps/notebook2/app.js
  72. 1 1
      desktop/core/src/desktop/js/catalog/api.ts
  73. 1 1
      desktop/core/src/desktop/js/components/SqlText.vue
  74. 2 7
      desktop/core/src/desktop/js/hue.js
  75. 1 1
      desktop/core/src/desktop/js/jest/jest.init.js
  76. 1 1
      desktop/core/src/desktop/js/ko/bindings/ace/aceGutterHandler.js
  77. 4 10
      desktop/core/src/desktop/js/ko/bindings/ace/aceLocationHandler.js
  78. 7 18
      desktop/core/src/desktop/js/ko/bindings/ace/ko.aceEditor.js
  79. 1 1
      desktop/core/src/desktop/js/ko/components/assist/ko.rightAssistPanel.js
  80. 4 4
      desktop/core/src/desktop/js/ko/components/contextPopover/ko.quickQueryContext.js
  81. 2 2
      desktop/core/src/desktop/js/ko/components/ko.historyPanel.js
  82. 1 1
      desktop/core/src/desktop/js/ko/components/ko.sessionAuthModal.js
  83. 1 1
      desktop/core/src/desktop/js/ko/components/ko.sessionAuthModal.test.js
  84. 1 1
      desktop/core/src/desktop/js/ko/components/ko.sessionPanel.js
  85. 1 1
      desktop/core/src/desktop/js/ko/components/ko.sessionPanel.test.js
  86. 1 1
      desktop/core/src/desktop/js/sidePanelViewModel.js
  87. 2 2
      desktop/core/src/desktop/js/sql/autocompleteResults.js
  88. 1 1
      desktop/core/src/desktop/js/sql/sqlUtils.ts
  89. 0 24
      desktop/core/src/desktop/static/desktop/js/ko.editor.js
  90. 0 24
      desktop/core/src/desktop/static/desktop/js/ko.metastore.js
  91. 0 3
      desktop/core/src/desktop/templates/hue.mako
  92. 1 1
      desktop/libs/indexer/src/indexer/templates/importer.mako
  93. 1 1
      desktop/libs/indexer/src/indexer/templates/indexer.mako
  94. 0 16
      desktop/libs/notebook/src/notebook/templates/editor.mako
  95. 1 1
      desktop/libs/notebook/src/notebook/templates/editor2.mako
  96. 1 1
      desktop/libs/notebook/src/notebook/templates/editor_m.mako
  97. 0 1
      desktop/libs/notebook/src/notebook/templates/notebook.mako
  98. 1 0
      webpack.config.js
  99. 1 1
      webpack.config.npm.js

+ 4 - 6
desktop/core/src/desktop/js/apps/notebook2/editorViewModel.js → desktop/core/src/desktop/js/apps/editor/EditorViewModel.js

@@ -23,11 +23,11 @@ import ChartTransformers from 'apps/notebook/chartTransformers';
 import huePubSub from 'utils/huePubSub';
 import hueUtils from 'utils/hueUtils';
 
-import Notebook from 'apps/notebook2/notebook';
+import Notebook from 'apps/editor/notebook';
 import {
   ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT,
   GET_ACTIVE_SNIPPET_CONNECTOR_EVENT
-} from 'apps/notebook2/events';
+} from 'apps/editor/events';
 import {
   CONFIG_REFRESHED_EVENT,
   GET_KNOWN_CONFIG_EVENT,
@@ -36,10 +36,10 @@ import {
 } from 'utils/hueConfig';
 import { getFromLocalStorage, setInLocalStorage } from 'utils/storageUtils';
 
-class EditorViewModel {
+export default class EditorViewModel {
   constructor(editorId, notebooks, options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
     // eslint-disable-next-line no-restricted-syntax
-    console.log('Notebook 2 enabled.');
+    console.log('Editor v2 enabled.');
 
     this.editorId = editorId;
     this.snippetViewSettings = options.snippetViewSettings;
@@ -519,5 +519,3 @@ class EditorViewModel {
     }
   }
 }
-
-export default EditorViewModel;

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/api.ts → desktop/core/src/desktop/js/apps/editor/api.ts


+ 843 - 0
desktop/core/src/desktop/js/apps/editor/app.js

@@ -0,0 +1,843 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import * as ko from 'knockout';
+import $ from 'jquery';
+import Clipboard from 'clipboard';
+import 'jquery-mousewheel';
+import 'ext/bootstrap-datepicker.min';
+import 'ext/jquery.hotkeys';
+import 'jquery/plugins/jquery.hdfstree';
+
+import huePubSub from 'utils/huePubSub';
+import hueUtils from 'utils/hueUtils';
+import I18n from 'utils/i18n';
+import sqlWorkerHandler from 'sql/sqlWorkerHandler';
+
+import {
+  HIDE_FIXED_HEADERS_EVENT,
+  REDRAW_FIXED_HEADERS_EVENT,
+  SHOW_GRID_SEARCH_EVENT,
+  SHOW_NORMAL_RESULT_EVENT,
+  REDRAW_CHART_EVENT,
+  IGNORE_NEXT_UNLOAD_EVENT
+} from './events';
+import EditorViewModel from './EditorViewModel';
+import { DIALECT } from './snippet';
+import { SHOW_LEFT_ASSIST_EVENT } from 'ko/components/assist/events';
+
+window.Clipboard = Clipboard;
+
+const HUE_PUB_SUB_EDITOR_ID = 'editor';
+
+huePubSub.subscribe('app.dom.loaded', app => {
+  if (app === 'editor') {
+    window.MAIN_SCROLLABLE = '.page-content';
+
+    let isLeftNavOpen = false;
+    huePubSub.subscribe(
+      'left.nav.open.toggle',
+      val => {
+        isLeftNavOpen = val;
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'split.panel.resized',
+      () => {
+        huePubSub.publish('recalculate.name.description.width');
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    const showHoverMsg = e => {
+      let dt = null;
+      if (e) {
+        dt = e.dataTransfer;
+      }
+      if (
+        !isLeftNavOpen &&
+        (!dt ||
+          (dt.types &&
+            (dt.types.indexOf ? dt.types.indexOf('Files') !== -1 : dt.types.contains('Files'))))
+      ) {
+        $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').removeClass('hide');
+      }
+    };
+
+    const hideHoverMsg = vm => {
+      if (vm.editorMode()) {
+        $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverText').html(I18n('Drop a SQL file here'));
+      } else {
+        $(window.EDITOR_BINDABLE_ELEMENT)
+          .find('.hoverText')
+          .html(I18n('Drop iPython/Zeppelin notebooks here'));
+      }
+      $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').addClass('hide');
+    };
+
+    if (ko.options) {
+      ko.options.deferUpdates = true;
+    }
+
+    let viewModel;
+
+    const replaceAce = content => {
+      const snip = viewModel.selectedNotebook().snippets()[0];
+      if (snip) {
+        snip.statement_raw(content);
+        snip.result.statements_count(1);
+        snip.ace().setValue(content, 1);
+        snip.result.statement_range({
+          start: {
+            row: 0,
+            column: 0
+          },
+          end: {
+            row: 0,
+            column: 0
+          }
+        });
+        snip.ace()._emit('focus');
+      }
+      hideHoverMsg(viewModel);
+      huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+    };
+    window.replaceAce = replaceAce;
+
+    // Drag and drop iPython / Zeppelin notebooks
+    if (window.FileReader) {
+      let aceChecks = 0;
+
+      const addAce = (content, snippetType) => {
+        const snip = viewModel
+          .selectedNotebook()
+          .addSnippet({ type: snippetType, result: {} }, true);
+        snip.statement_raw(content);
+        aceChecks++;
+        snip.checkForAce = window.setInterval(() => {
+          if (snip.ace()) {
+            window.clearInterval(snip.checkForAce);
+            aceChecks--;
+            if (aceChecks === 0) {
+              hideHoverMsg(viewModel);
+              huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+            }
+          }
+        }, 100);
+      };
+
+      const addMarkdown = content => {
+        const snip = viewModel
+          .selectedNotebook()
+          .addSnippet({ type: 'markdown', result: {} }, true);
+        snip.statement_raw(content);
+      };
+
+      const addPySpark = content => {
+        addAce(content, 'pyspark');
+      };
+
+      const addSql = content => {
+        addAce(content, 'hive');
+      };
+
+      const addScala = content => {
+        addAce(content, 'spark');
+      };
+
+      const parseExternalJSON = raw => {
+        try {
+          if (viewModel.editorMode()) {
+            replaceAce(raw);
+          } else {
+            const loaded = typeof raw == 'string' ? JSON.parse(raw) : raw;
+            if (loaded.nbformat) {
+              //ipython
+              let cells = [];
+              if (loaded.nbformat === 3) {
+                cells = loaded.worksheets[0].cells;
+              } else if (loaded.nbformat === 4) {
+                cells = loaded.cells;
+              }
+              cells.forEach((cell, cellCnt) => {
+                window.setTimeout(() => {
+                  if (cell.cell_type === 'code') {
+                    if (loaded.nbformat === 3) {
+                      addPySpark($.isArray(cell.input) ? cell.input.join('') : cell.input);
+                    } else {
+                      addPySpark($.isArray(cell.source) ? cell.source.join('') : cell.source);
+                    }
+                  }
+                  if (cell.cell_type === 'heading') {
+                    let heading = $.isArray(cell.source) ? cell.source.join('') : cell.source;
+                    if (cell.level === 1) {
+                      heading += '\n====================';
+                    } else if (cell.level === 2) {
+                      heading += '\n--------------------';
+                    } else {
+                      heading = '### ' + heading;
+                    }
+                    addMarkdown(heading);
+                  }
+                  if (cell.cell_type === 'markdown') {
+                    addMarkdown($.isArray(cell.source) ? cell.source.join('') : cell.source);
+                  }
+                  if (cellCnt === cells.length - 1 && aceChecks === 0) {
+                    hideHoverMsg(viewModel);
+                  }
+                }, 10);
+              });
+            }
+
+            if (loaded.paragraphs) {
+              //zeppelin
+              if (loaded.name) {
+                viewModel.selectedNotebook().name(loaded.name);
+              }
+              loaded.paragraphs.forEach(paragraph => {
+                if (paragraph.text) {
+                  const content = paragraph.text.split('\n');
+                  if (content[0].indexOf('%md') > -1) {
+                    content.shift();
+                    addMarkdown(content.join('\n'));
+                  } else if (content[0].indexOf('%sql') > -1 || content[0].indexOf('%hive') > -1) {
+                    content.shift();
+                    addSql(content.join('\n'));
+                  } else if (content[0].indexOf('%pyspark') > -1) {
+                    content.shift();
+                    addPySpark(content.join('\n'));
+                  } else {
+                    if (content[0].indexOf('%spark') > -1) {
+                      content.shift();
+                    }
+                    addScala(content.join('\n'));
+                  }
+                }
+              });
+            }
+          }
+        } catch (e) {
+          hideHoverMsg(viewModel);
+          replaceAce(raw);
+        }
+      };
+
+      const handleFileSelect = evt => {
+        evt.stopPropagation();
+        evt.preventDefault();
+        const dt = evt.dataTransfer;
+        const files = dt.files;
+        if (files.length > 0) {
+          showHoverMsg();
+        } else {
+          hideHoverMsg(viewModel);
+        }
+
+        for (let i = 0, f; (f = files[i]); i++) {
+          const reader = new FileReader();
+          reader.onload = (function (file) {
+            return function (e) {
+              $('.hoverText').html("<i class='fa fa-spinner fa-spin'></i>");
+              parseExternalJSON(e.target.result);
+            };
+          })(f);
+          reader.readAsText(f);
+        }
+      };
+
+      const handleDragOver = function (evt) {
+        evt.stopPropagation();
+        evt.preventDefault();
+        evt.dataTransfer.dropEffect = 'copy';
+      };
+
+      const dropZone = $(window.EDITOR_BINDABLE_ELEMENT)[0];
+      dropZone.addEventListener('dragenter', showHoverMsg, false);
+      dropZone.addEventListener('dragover', handleDragOver, false);
+      dropZone.addEventListener('drop', handleFileSelect, false);
+
+      let isDraggingOverText = false;
+
+      $(window.EDITOR_BINDABLE_ELEMENT)
+        .find('.hoverText')
+        .on('dragenter', e => {
+          e.preventDefault();
+          e.stopPropagation();
+          e.stopImmediatePropagation();
+          isDraggingOverText = true;
+        });
+
+      $(window.EDITOR_BINDABLE_ELEMENT)
+        .find('.hoverText')
+        .on('dragleave', e => {
+          e.preventDefault();
+          e.stopPropagation();
+          e.stopImmediatePropagation();
+          isDraggingOverText = false;
+        });
+
+      $(window.EDITOR_BINDABLE_ELEMENT)
+        .find('.hoverMsg')
+        .on('dragleave', e => {
+          if (!isDraggingOverText) {
+            hideHoverMsg(viewModel);
+          }
+        });
+    }
+
+    if (window.EDITOR_ENABLE_QUERY_SCHEDULING) {
+      viewModel = new EditorViewModel(
+        window.EDITOR_ID,
+        window.NOTEBOOKS_JSON,
+        window.EDITOR_VIEW_MODEL_OPTIONS,
+        window.CoordinatorEditorViewModel,
+        window.RunningCoordinatorModel
+      );
+    } else {
+      viewModel = new EditorViewModel(
+        window.EDITOR_ID,
+        window.NOTEBOOKS_JSON,
+        window.EDITOR_VIEW_MODEL_OPTIONS
+      );
+    }
+    ko.applyBindings(viewModel, $(window.EDITOR_BINDABLE_ELEMENT)[0]);
+    viewModel.init();
+
+    sqlWorkerHandler.registerWorkers();
+
+    viewModel.selectedNotebook.subscribe(newVal => {
+      huePubSub.publish('selected.notebook.changed', newVal);
+    });
+
+    let wasResultFullScreenMode = false;
+    let isAssistAvailable = viewModel.assistAvailable();
+    let wasLeftPanelVisible = viewModel.isLeftPanelVisible();
+    let wasRightPanelVisible = viewModel.isRightPanelVisible();
+
+    const exitPlayerMode = () => {
+      if (!wasResultFullScreenMode) {
+        viewModel.selectedNotebook().isPresentationMode(false);
+      } else {
+        viewModel.isResultFullScreenMode(false);
+      }
+      wasResultFullScreenMode = false;
+    };
+
+    viewModel.isResultFullScreenMode.subscribe(newValue => {
+      wasResultFullScreenMode = newValue;
+      huePubSub.publish('editor.presentation.operate.toggle', newValue);
+    });
+
+    viewModel.isLeftPanelVisible.subscribe(value => {
+      huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+    });
+
+    let ignoreNextUnload = false;
+
+    huePubSub.subscribe(IGNORE_NEXT_UNLOAD_EVENT, () => {
+      ignoreNextUnload = true;
+    });
+
+    // Close the notebook snippets when leaving the page
+    window.onbeforeunload = function (e) {
+      if (ignoreNextUnload) {
+        ignoreNextUnload = false;
+        return;
+      }
+      if (!viewModel.selectedNotebook().avoidClosing) {
+        viewModel.selectedNotebook().close();
+      }
+    };
+    $(window).data('beforeunload', window.onbeforeunload);
+
+    $('.preview-sample').css('right', 10 + hueUtils.scrollbarWidth() + 'px');
+
+    const saveKeyHandler = () => {
+      if (viewModel.canSave()) {
+        viewModel.saveNotebook();
+      } else {
+        $('#saveAsModal' + window.EDITOR_SUFFIX).modal('show');
+      }
+    };
+
+    const newKeyHandler = () => {
+      if (!viewModel.editorMode()) {
+        viewModel.selectedNotebook().newSnippet();
+      } else {
+        viewModel.newNotebook(
+          viewModel.editorType(),
+          null,
+          viewModel.selectedNotebook()
+            ? viewModel.selectedNotebook().snippets()[0].currentQueryTab()
+            : null
+        );
+      }
+    };
+
+    const initKeydownBindings = () => {
+      $(window).bind('keydown.editor', 'ctrl+s alt+s meta+s', e => {
+        e.preventDefault();
+        saveKeyHandler();
+        return false;
+      });
+      $(window).bind('keydown.editor', 'ctrl+shift+p alt+shift+p meta+shift+p', e => {
+        e.preventDefault();
+        huePubSub.publish('editor.presentation.toggle');
+        return false;
+      });
+      $(window).bind('keydown.editor', 'ctrl+e alt+e meta+e', e => {
+        e.preventDefault();
+        newKeyHandler();
+        return false;
+      });
+    };
+
+    if (document.location.href.indexOf('editor') >= 0) {
+      initKeydownBindings();
+    }
+
+    $(document).bind('keyup', e => {
+      if (
+        e.keyCode === 191 &&
+        e.shiftKey &&
+        !$(e.target).is('input') &&
+        !$(e.target).is('textarea')
+      ) {
+        $('#helpModal' + window.EDITOR_SUFFIX).modal('show');
+      }
+
+      if (
+        e.keyCode === 191 &&
+        !e.shiftKey &&
+        !$(e.target).is('input') &&
+        !$(e.target).is('textarea')
+      ) {
+        if (
+          viewModel.editorMode() &&
+          viewModel.selectedNotebook().snippets()[0].currentQueryTab() === 'queryResults'
+        ) {
+          e.preventDefault();
+          huePubSub.publish(SHOW_GRID_SEARCH_EVENT);
+          return false;
+        }
+      }
+    });
+
+    let initialResizePosition = 100;
+
+    const draggableHelper = (el, e, ui, setSize) => {
+      const _snippet = ko.dataFor(el.parents('.snippet')[0]);
+      const _cm = $('#snippet_' + _snippet.id()).data('editor');
+      const _newSize = _snippet.aceSize() + (ui.offset.top - initialResizePosition);
+      _cm.setSize('99%', _newSize);
+      if (setSize) {
+        _snippet.aceSize(_newSize);
+      }
+    };
+
+    const getDraggableOptions = minY => {
+      return {
+        axis: 'y',
+        start: function (e, ui) {
+          initialResizePosition = ui.offset.top;
+          huePubSub.publish(HIDE_FIXED_HEADERS_EVENT);
+        },
+        drag: function (e, ui) {
+          draggableHelper($(this), e, ui);
+        },
+        stop: function (e, ui) {
+          draggableHelper($(this), e, ui, true);
+          huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+          ui.helper.first().removeAttr('style');
+        },
+        containment: [0, minY, 4000, minY + 400]
+      };
+    };
+
+    $('.resize-panel a').each(function () {
+      $(this).draggable(getDraggableOptions($(this).parents('.snippet').offset().top + 128));
+    });
+
+    // ======== PubSub ========
+
+    let splitDraggableTimeout = -1;
+    huePubSub.subscribe(
+      'split.draggable.position',
+      () => {
+        window.clearTimeout(splitDraggableTimeout);
+        splitDraggableTimeout = window.setTimeout(() => {
+          huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+        }, 200);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'app.gained.focus',
+      app => {
+        if (app === 'editor') {
+          huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+          huePubSub.publish('hue.scrollleft.show');
+          viewModel.notifyDialectChange(
+            viewModel.editorType(),
+            viewModel.getSnippetViewSettings(viewModel.editorType()).sqlDialect
+          );
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'current.query.tab.switched',
+      tab => {
+        if (tab !== 'queryResults') {
+          $('.hue-datatable-search').hide();
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_EDITOR_ID);
+
+    if (viewModel.isOptimizerEnabled()) {
+      if (window.OPTIMIZER_AUTO_UPLOAD_QUERIES) {
+        huePubSub.subscribe(
+          'editor.upload.query',
+          query_id => {
+            viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
+          },
+          HUE_PUB_SUB_EDITOR_ID
+        );
+      }
+
+      if (window.OPTIMIZER_AUTO_UPLOAD_DDL) {
+        huePubSub.subscribe(
+          'editor.upload.table.stats',
+          options => {
+            viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
+          },
+          HUE_PUB_SUB_EDITOR_ID
+        );
+      }
+
+      if (window.OPTIMIZER_QUERY_HISTORY_UPLOAD_LIMIT !== 0) {
+        huePubSub.subscribe(
+          'editor.upload.history',
+          () => {
+            viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
+          },
+          HUE_PUB_SUB_EDITOR_ID
+        );
+      }
+    }
+
+    huePubSub.subscribe(
+      'get.selected.notebook',
+      () => {
+        huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      SHOW_LEFT_ASSIST_EVENT,
+      () => {
+        if (!viewModel.isLeftPanelVisible() && viewModel.assistAvailable()) {
+          viewModel.isLeftPanelVisible(true);
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'assist.set.manual.visibility',
+      () => {
+        wasLeftPanelVisible = viewModel.isLeftPanelVisible();
+        wasRightPanelVisible = viewModel.isRightPanelVisible();
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.presentation.operate.toggle',
+      value => {
+        viewModel.isEditing(!viewModel.isEditing());
+        if (value) {
+          $('.jHueNotify').remove();
+          isAssistAvailable = viewModel.assistAvailable();
+          wasLeftPanelVisible = viewModel.isLeftPanelVisible();
+          wasRightPanelVisible = viewModel.isRightPanelVisible();
+
+          if (wasResultFullScreenMode) {
+            huePubSub.publish('both.assists.hide', true);
+          } else {
+            huePubSub.publish('right.assist.hide', true);
+          }
+
+          viewModel.assistWithoutStorage(true);
+          viewModel.assistAvailable(false);
+          viewModel.isLeftPanelVisible(true);
+          viewModel.isRightPanelVisible(false);
+          window.setTimeout(() => {
+            viewModel.assistWithoutStorage(false);
+          }, 0);
+          $('.navigator').hide();
+          $('.add-snippet').hide();
+
+          if (window.BANNER_TOP_HTML) {
+            $('.main-content').attr('style', 'top: 31px !important');
+          } else {
+            $('.main-content').css('top', '1px');
+          }
+          window.setTimeout(() => {
+            huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+          }, 200);
+          $(window).bind('keydown', 'esc', exitPlayerMode);
+        } else {
+          huePubSub.publish(HIDE_FIXED_HEADERS_EVENT);
+          huePubSub.publish('both.assists.show', true);
+          viewModel.assistWithoutStorage(true);
+          viewModel.isLeftPanelVisible(wasLeftPanelVisible);
+          viewModel.isRightPanelVisible(wasRightPanelVisible);
+          viewModel.assistAvailable(isAssistAvailable);
+          window.setTimeout(() => {
+            viewModel.assistWithoutStorage(false);
+          }, 0);
+          $('.navigator').show();
+          $('.add-snippet').show();
+          if (window.BANNER_TOP_HTML) {
+            $('.main-content').css('top', '112px');
+          } else {
+            $('.main-content').css('top', '74px');
+          }
+          window.setTimeout(() => {
+            huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+          }, 200);
+          $(window).unbind('keydown', exitPlayerMode);
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'show.retry.modal',
+      data => {
+        $('#retryModal' + window.EDITOR_SUFFIX).modal('show');
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'hide.retry.modal',
+      data => {
+        $('#retryModal' + window.EDITOR_SUFFIX).modal('hide');
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'open.link',
+      link => {
+        $(window).unbind('keydown.editor');
+        if (link.indexOf('editor') >= 0) {
+          initKeydownBindings();
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.presentation.toggle',
+      () => {
+        viewModel.selectedNotebook().isPresentationMode(!viewModel.isPresentationMode());
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_EDITOR_ID);
+
+    huePubSub.subscribe(
+      'render.jqcron',
+      () => {
+        if (typeof window.renderJqCron !== 'undefined') {
+          window.renderJqCron();
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'submit.popup.return',
+      data => {
+        viewModel.selectedNotebook().viewSchedulerId(data.job_id);
+        $('.submit-modal-editor').modal('hide');
+        huePubSub.publish('show.jobs.panel', { id: data.job_id, interface: data.type });
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'jobbrowser.data',
+      jobs => {
+        viewModel.withActiveSnippet(snippet => {
+          if (!snippet || snippet.dialect() === DIALECT.impala) {
+            return;
+          }
+          if (jobs.length > 0) {
+            let progress = 0;
+            let parent;
+            jobs.forEach(job => {
+              const id = job.shortId || job.id;
+              const el = $('.jobs-overlay li:contains(' + id + ')');
+              if (!el.length) {
+                return;
+              }
+              const context = ko.contextFor(el[0]);
+              parent = context.$parent;
+              const _job = context.$data;
+              progress = parseInt(job.mapsPercentComplete);
+              if (isNaN(progress)) {
+                progress = parseInt(job.progress);
+              }
+              if (!isNaN(progress)) {
+                _job.percentJob(progress);
+              } else {
+                progress = 0;
+              }
+            });
+            if (parent && parent.jobs().length === 1) {
+              parent.progress(Math.max(progress, parent.progress()));
+            }
+          }
+        });
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.get.active.risks',
+      callback => {
+        const result = {
+          editor: undefined,
+          risks: {}
+        };
+        if (viewModel.selectedNotebook()) {
+          if (viewModel.selectedNotebook().snippets().length === 1) {
+            result.editor = viewModel.selectedNotebook().snippets()[0].ace();
+            result.risks = viewModel.selectedNotebook().snippets()[0].complexity() || {};
+          } else {
+            viewModel
+              .selectedNotebook()
+              .snippets()
+              .every(snippet => {
+                if (snippet.inFocus()) {
+                  result.editor = snippet.ace();
+                  result.risks = snippet.complexity() || {};
+                  return false;
+                }
+                return true;
+              });
+          }
+        }
+        callback(result);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'recalculate.name.description.width',
+      () => {
+        hueUtils.waitForRendered(
+          '.editorComponents .hue-title-bar .query-name',
+          el => {
+            return el.is(':visible');
+          },
+          () => {
+            let cumulativeWidth = 0;
+            $('.editorComponents .hue-title-bar ul li:not(.skip-width-calculation)').each(
+              function () {
+                cumulativeWidth += $(this).outerWidth();
+              }
+            );
+            $('.notebook-name-desc').css(
+              'max-width',
+              ($('.editorComponents .hue-title-bar').width() -
+                cumulativeWidth -
+                $('.editorComponents .hue-title-bar .pull-right').width() -
+                120) /
+                2 +
+                'px'
+            );
+          }
+        );
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    $(document).on('updateResultHeaders', e => {
+      huePubSub.publish(HIDE_FIXED_HEADERS_EVENT);
+      window.setTimeout(() => {
+        huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
+      }, 200);
+    });
+
+    $(document).on('showAuthModal', (e, data) => {
+      viewModel.authSessionUsername(window.LOGGED_USERNAME);
+      viewModel.authSessionMessage(data['message']);
+      viewModel.authSessionPassword('');
+      viewModel.authSessionType(data['type']);
+      viewModel.authSessionCallback(data['callback']);
+      $('#authModal' + window.EDITOR_SUFFIX).modal('show');
+    });
+
+    $(document).on('hideHistoryModal', e => {
+      $('#clearHistoryModal' + window.EDITOR_SUFFIX).modal('hide');
+    });
+
+    $(document).on('editorSizeChanged', () => {
+      window.setTimeout(() => {
+        huePubSub.publish(REDRAW_CHART_EVENT);
+      }, 50);
+    });
+
+    $(document).on('redrawResults', () => {
+      window.setTimeout(() => {
+        huePubSub.publish(REDRAW_CHART_EVENT);
+      }, 50);
+    });
+
+    $(document).on('renderDataError', (e, options) => {
+      huePubSub.publish(SHOW_NORMAL_RESULT_EVENT);
+    });
+
+    let hideTimeout = -1;
+    $(document).on('hideAutocomplete', () => {
+      window.clearTimeout(hideTimeout);
+      hideTimeout = window.setTimeout(() => {
+        const $aceAutocomplete = $('.ace_editor.ace_autocomplete');
+        if ($aceAutocomplete.is(':visible')) {
+          $aceAutocomplete.hide();
+        }
+      }, 100);
+    });
+
+    $(window).on('resize', () => {
+      huePubSub.publish('recalculate.name.description.width');
+    });
+  }
+});

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/EditorResizer.vue → desktop/core/src/desktop/js/apps/editor/components/EditorResizer.vue

@@ -25,7 +25,7 @@
   import Component from 'vue-class-component';
   import { Prop } from 'vue-property-decorator';
 
-  import { HIDE_FIXED_HEADERS_EVENT, REDRAW_FIXED_HEADERS_EVENT } from 'apps/notebook2/events';
+  import { HIDE_FIXED_HEADERS_EVENT, REDRAW_FIXED_HEADERS_EVENT } from 'apps/editor/events';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
   import { Ace } from 'ext/ace';
   import huePubSub from 'utils/huePubSub';

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/EditorResizerKoBridge.vue → desktop/core/src/desktop/js/apps/editor/components/EditorResizerKoBridge.vue

@@ -27,7 +27,7 @@
   import { Prop } from 'vue-property-decorator';
   import { wrap } from 'vue/webComponentWrapper';
 
-  import EditorResizer from 'apps/notebook2/components/EditorResizer.vue';
+  import EditorResizer from 'apps/editor/components/EditorResizer.vue';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
 
   @Component({

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/ExecutableActions.test.ts → desktop/core/src/desktop/js/apps/editor/components/ExecutableActions.test.ts

@@ -17,8 +17,8 @@
 import huePubSub from 'utils/huePubSub';
 import Vue from 'vue';
 import { mount, shallowMount } from '@vue/test-utils';
-import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/notebook2/execution/executable';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/editor/execution/executable';
+import sessionManager from 'apps/editor/execution/sessionManager';
 import ExecutableActions from './ExecutableActions.vue';
 
 /* eslint-disable @typescript-eslint/no-empty-function */

+ 4 - 4
desktop/core/src/desktop/js/apps/notebook2/components/ExecutableActions.vue → desktop/core/src/desktop/js/apps/editor/components/ExecutableActions.vue

@@ -72,7 +72,7 @@
 </template>
 
 <script lang="ts">
-  import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
+  import SqlExecutable from 'apps/editor/execution/sqlExecutable';
   import HueButton from 'components/HueButton.vue';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
   import huePubSub from 'utils/huePubSub';
@@ -81,9 +81,9 @@
   import Component from 'vue-class-component';
   import { Prop, Watch } from 'vue-property-decorator';
 
-  import { Session } from 'apps/notebook2/execution/api';
-  import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/notebook2/execution/executable';
-  import sessionManager from 'apps/notebook2/execution/sessionManager';
+  import { Session } from 'apps/editor/execution/api';
+  import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/editor/execution/executable';
+  import sessionManager from 'apps/editor/execution/sessionManager';
 
   export const EXECUTE_ACTIVE_EXECUTABLE_EVENT = 'executable.active.executable';
   const WHITE_SPACE_REGEX = /^\s*$/;

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ExecutableActionsKoBridge.vue → desktop/core/src/desktop/js/apps/editor/components/ExecutableActionsKoBridge.vue

@@ -26,7 +26,7 @@
 
 <script lang="ts">
   import ExecutableActions from './ExecutableActions.vue';
-  import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
+  import SqlExecutable from 'apps/editor/execution/sqlExecutable';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
   import Vue from 'vue';
   import Component from 'vue-class-component';

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/__snapshots__/ExecutableActions.test.ts.snap → desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ExecutableActions.test.ts.snap


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/__snapshots__/ko.paginator.test.js.snap → desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ko.paginator.test.js.snap


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/__snapshots__/ko.queryHistory.test.js.snap → desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ko.queryHistory.test.js.snap


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/__snapshots__/ko.savedQueries.test.js.snap → desktop/core/src/desktop/js/apps/editor/components/__snapshots__/ko.savedQueries.test.js.snap


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceAnchoredRange.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceAnchoredRange.ts


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceEditor.scss → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.scss


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceEditor.test.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.test.ts


+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceEditor.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.vue

@@ -39,8 +39,8 @@
   import AceAutocomplete from './autocomplete/AceAutocomplete.vue';
   import AceGutterHandler from './AceGutterHandler';
   import AceLocationHandler from './AceLocationHandler';
-  import { formatSql } from 'apps/notebook2/api';
-  import Executor from 'apps/notebook2/execution/executor';
+  import { formatSql } from 'apps/editor/api';
+  import Executor from 'apps/editor/execution/executor';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
   import {
     AutocompleteParser,

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceEditorKoBridge.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditorKoBridge.vue

@@ -42,7 +42,7 @@
   import { wrap } from 'vue/webComponentWrapper';
 
   import AceEditor from './AceEditor.vue';
-  import Executor from 'apps/notebook2/execution/executor';
+  import Executor from 'apps/editor/execution/executor';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
   import sqlParserRepository from 'parse/sql/sqlParserRepository';
 

+ 3 - 3
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceGutterHandler.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceGutterHandler.ts

@@ -18,9 +18,9 @@ import { Ace } from 'ext/ace';
 
 import AceAnchoredRange from './AceAnchoredRange';
 import { ACTIVE_STATEMENT_CHANGED_EVENT } from './AceLocationHandler';
-import { EXECUTABLE_UPDATED_EVENT } from 'apps/notebook2/execution/executable';
-import Executor from 'apps/notebook2/execution/executor';
-import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
+import { EXECUTABLE_UPDATED_EVENT } from 'apps/editor/execution/executable';
+import Executor from 'apps/editor/execution/executor';
+import SqlExecutable from 'apps/editor/execution/sqlExecutable';
 import SubscriptionTracker, { Disposable } from 'components/utils/SubscriptionTracker';
 import { ParsedSqlStatement } from 'parse/sqlStatementsParser';
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceLocationHandler.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceLocationHandler.ts

@@ -17,7 +17,7 @@
 import { Ace } from 'ext/ace';
 import ace from 'ext/aceHelper';
 
-import Executor from 'apps/notebook2/execution/executor';
+import Executor from 'apps/editor/execution/executor';
 import DataCatalogEntry, { TableSourceMeta } from 'catalog/DataCatalogEntry';
 import SubscriptionTracker, { Disposable } from 'components/utils/SubscriptionTracker';
 import AssistStorageEntry from 'ko/components/assist/assistStorageEntry';

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/QueryEditorWebComponent.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/QueryEditorWebComponent.ts


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/__snapshots__/AceEditor.test.ts.snap → desktop/core/src/desktop/js/apps/editor/components/aceEditor/__snapshots__/AceEditor.test.ts.snap


+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/AceAutocomplete.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AceAutocomplete.vue

@@ -87,7 +87,7 @@
   import { Prop, Watch } from 'vue-property-decorator';
 
   import { Category, CategoryId, CategoryInfo, extractCategories } from './Category';
-  import Executor from 'apps/notebook2/execution/executor';
+  import Executor from 'apps/editor/execution/executor';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
   import sqlUtils, { SortOverride } from 'sql/sqlUtils';
   import huePubSub from 'utils/huePubSub';

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/AutocompleteResults.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AutocompleteResults.ts

@@ -15,8 +15,8 @@
 // limitations under the License.
 
 import { CancellablePromise } from 'api/cancellablePromise';
-import { Category, CategoryInfo } from 'apps/notebook2/components/aceEditor/autocomplete/Category';
-import Executor from 'apps/notebook2/execution/executor';
+import { Category, CategoryInfo } from 'apps/editor/components/aceEditor/autocomplete/Category';
+import Executor from 'apps/editor/execution/executor';
 import DataCatalogEntry, {
   FieldSample,
   FieldSourceMeta,

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/CatalogEntryDetailsPanel.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/CatalogEntryDetailsPanel.vue


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/Category.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/Category.ts


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/MatchedText.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/MatchedText.vue


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/OptionDetailsPanel.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/OptionDetailsPanel.vue


+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/SqlAutocompleter.ts → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/SqlAutocompleter.ts

@@ -20,7 +20,7 @@ import {
   GET_ACTIVE_LOCATIONS_EVENT,
   REFRESH_STATEMENT_LOCATIONS_EVENT
 } from '../AceLocationHandler';
-import Executor from 'apps/notebook2/execution/executor';
+import Executor from 'apps/editor/execution/executor';
 import SubscriptionTracker, { Disposable } from 'components/utils/SubscriptionTracker';
 import { Ace } from 'ext/ace';
 import { ParsedSqlStatement } from 'parse/sqlStatementsParser';

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/autocomplete/UdfDetailsPanel.vue → desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/UdfDetailsPanel.vue


+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/executableStateHandler.js → desktop/core/src/desktop/js/apps/editor/components/executableStateHandler.js

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import * as ko from 'knockout';
-import { RESULT_UPDATED_EVENT } from 'apps/notebook2/execution/executionResult';
+import { RESULT_UPDATED_EVENT } from 'apps/editor/execution/executionResult';
 import huePubSub from 'utils/huePubSub';
 
 export const trackResult = (activeExecutable, onChange) => {

+ 3 - 3
desktop/core/src/desktop/js/apps/notebook2/components/ko.executableLogs.js → desktop/core/src/desktop/js/apps/editor/components/ko.executableLogs.js

@@ -19,11 +19,11 @@ import * as ko from 'knockout';
 import 'ko/bindings/ko.publish';
 
 import componentUtils from 'ko/components/componentUtils';
-import { EXECUTABLE_UPDATED_EVENT } from 'apps/notebook2/execution/executable';
+import { EXECUTABLE_UPDATED_EVENT } from 'apps/editor/execution/executable';
 import DisposableComponent from 'ko/components/DisposableComponent';
 import I18n from 'utils/i18n';
-import { RESULT_UPDATED_EVENT } from 'apps/notebook2/execution/executionResult';
-import { LOGS_UPDATED_EVENT } from 'apps/notebook2/execution/executionLogs';
+import { RESULT_UPDATED_EVENT } from 'apps/editor/execution/executionResult';
+import { LOGS_UPDATED_EVENT } from 'apps/editor/execution/executionLogs';
 
 export const NAME = 'executable-logs';
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.executableProgressBar.js → desktop/core/src/desktop/js/apps/editor/components/ko.executableProgressBar.js

@@ -20,7 +20,7 @@ import * as ko from 'knockout';
 import 'ko/bindings/ko.publish';
 
 import componentUtils from 'ko/components/componentUtils';
-import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/notebook2/execution/executable';
+import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/editor/execution/executable';
 import DisposableComponent from 'ko/components/DisposableComponent';
 import { sleep } from 'utils/hueUtils';
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.executableProgressBar.test.js → desktop/core/src/desktop/js/apps/editor/components/ko.executableProgressBar.test.js

@@ -17,7 +17,7 @@
 import huePubSub from 'utils/huePubSub';
 import { koSetup } from 'jest/koTestUtils';
 import { NAME } from './ko.executableProgressBar';
-import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/notebook2/execution/executable';
+import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/editor/execution/executable';
 
 describe('ko.executableProgressBar.js', () => {
   const setup = koSetup();

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.paginator.js → desktop/core/src/desktop/js/apps/editor/components/ko.paginator.js


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.paginator.test.js → desktop/core/src/desktop/js/apps/editor/components/ko.paginator.test.js


+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.queryHistory.js → desktop/core/src/desktop/js/apps/editor/components/ko.queryHistory.js

@@ -21,7 +21,7 @@ import apiHelper from 'api/apiHelper';
 import componentUtils from 'ko/components/componentUtils';
 import DisposableComponent from 'ko/components/DisposableComponent';
 import I18n from 'utils/i18n';
-import { ExecutionStatus } from 'apps/notebook2/execution/executable';
+import { ExecutionStatus } from 'apps/editor/execution/executable';
 import { sleep } from 'utils/hueUtils';
 import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.queryHistory.test.js → desktop/core/src/desktop/js/apps/editor/components/ko.queryHistory.test.js


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.savedQueries.js → desktop/core/src/desktop/js/apps/editor/components/ko.savedQueries.js


+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/ko.savedQueries.test.js → desktop/core/src/desktop/js/apps/editor/components/ko.savedQueries.test.js


+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.snippetEditorActions.js → desktop/core/src/desktop/js/apps/editor/components/ko.snippetEditorActions.js

@@ -24,7 +24,7 @@ import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 import { SHOW_EVENT as SHOW_GIST_MODAL_EVENT } from 'ko/components/ko.shareGistModal';
-import { DIALECT, STATUS } from 'apps/notebook2/snippet';
+import { DIALECT, STATUS } from 'apps/editor/snippet';
 
 const TEMPLATE = `
 <div class="snippet-editor-actions">

+ 8 - 8
desktop/core/src/desktop/js/apps/notebook2/components/ko.snippetResults.js → desktop/core/src/desktop/js/apps/editor/components/ko.snippetResults.js

@@ -21,15 +21,15 @@ import DisposableComponent from 'ko/components/DisposableComponent';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 
-import { RESULT_CHART_COMPONENT } from 'apps/notebook2/components/resultChart/ko.resultChart';
-import { RESULT_GRID_COMPONENT } from 'apps/notebook2/components/resultGrid/ko.resultGrid';
-import { REDRAW_FIXED_HEADERS_EVENT } from 'apps/notebook2/events';
-import { REDRAW_CHART_EVENT } from 'apps/notebook2/events';
-import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/notebook2/execution/executable';
-import { RESULT_TYPE, RESULT_UPDATED_EVENT } from 'apps/notebook2/execution/executionResult';
-import { attachTracker } from 'apps/notebook2/components/executableStateHandler';
+import { RESULT_CHART_COMPONENT } from 'apps/editor/components/resultChart/ko.resultChart';
+import { RESULT_GRID_COMPONENT } from 'apps/editor/components/resultGrid/ko.resultGrid';
+import { REDRAW_FIXED_HEADERS_EVENT } from 'apps/editor/events';
+import { REDRAW_CHART_EVENT } from 'apps/editor/events';
+import { EXECUTABLE_UPDATED_EVENT, ExecutionStatus } from 'apps/editor/execution/executable';
+import { RESULT_TYPE, RESULT_UPDATED_EVENT } from 'apps/editor/execution/executionResult';
+import { attachTracker } from 'apps/editor/components/executableStateHandler';
 import { defer } from 'utils/hueUtils';
-import { CURRENT_QUERY_TAB_SWITCHED_EVENT } from 'apps/notebook2/snippet';
+import { CURRENT_QUERY_TAB_SWITCHED_EVENT } from 'apps/editor/snippet';
 
 export const NAME = 'snippet-results';
 

+ 3 - 3
desktop/core/src/desktop/js/apps/notebook2/components/result/ExecutionResults.vue → desktop/core/src/desktop/js/apps/editor/components/result/ExecutionResults.vue

@@ -26,16 +26,16 @@
   import { Prop, Watch } from 'vue-property-decorator';
 
   import ResultGrid from './ResultGrid.vue';
-  import { ResultMeta } from 'apps/notebook2/execution/api';
+  import { ResultMeta } from 'apps/editor/execution/api';
   import Executable, {
     EXECUTABLE_UPDATED_EVENT,
     ExecutionStatus
-  } from 'apps/notebook2/execution/executable';
+  } from 'apps/editor/execution/executable';
   import ExecutionResult, {
     RESULT_UPDATED_EVENT,
     ResultRow,
     ResultType
-  } from 'apps/notebook2/execution/executionResult';
+  } from 'apps/editor/execution/executionResult';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
 
   @Component({

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/result/ExecutionResultsKoBridge.vue → desktop/core/src/desktop/js/apps/editor/components/result/ExecutionResultsKoBridge.vue

@@ -27,7 +27,7 @@
   import { wrap } from 'vue/webComponentWrapper';
 
   import ExecutionResults from './ExecutionResults.vue';
-  import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
+  import SqlExecutable from 'apps/editor/execution/sqlExecutable';
   import SubscriptionTracker from 'components/utils/SubscriptionTracker';
 
   @Component({

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/result/ResultGrid.vue → desktop/core/src/desktop/js/apps/editor/components/result/ResultGrid.vue

@@ -21,8 +21,8 @@
 </template>
 
 <script lang="ts">
-  import { ResultMeta } from 'apps/notebook2/execution/api';
-  import { ResultRow } from 'apps/notebook2/execution/executionResult';
+  import { ResultMeta } from 'apps/editor/execution/api';
+  import { ResultRow } from 'apps/editor/execution/executionResult';
   import { Column, Row } from 'components/HueTable';
   import HueTable from 'components/HueTable.vue';
   import Vue from 'vue';

+ 1 - 4
desktop/core/src/desktop/js/apps/notebook2/components/resultChart/chartTransformers.js → desktop/core/src/desktop/js/apps/editor/components/resultChart/chartTransformers.js

@@ -18,10 +18,7 @@ import $ from 'jquery';
 
 import HueColors from 'utils/hueColors';
 import { html2text } from 'utils/hueUtils';
-import {
-  CHART_MAP_TYPE,
-  CHART_SORTING
-} from 'apps/notebook2/components/resultChart/ko.resultChart';
+import { CHART_MAP_TYPE, CHART_SORTING } from 'apps/editor/components/resultChart/ko.resultChart';
 
 // The leaflet map can freeze the browser with numbers outside the map
 const MIN_LAT = -90;

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/resultChart/ko.resultChart.js → desktop/core/src/desktop/js/apps/editor/components/resultChart/ko.resultChart.js

@@ -30,8 +30,8 @@ import {
 } from './chartTransformers';
 import $ from 'jquery';
 import { UUID } from 'utils/hueUtils';
-import { REDRAW_CHART_EVENT } from 'apps/notebook2/events';
-import { attachTracker } from 'apps/notebook2/components/executableStateHandler';
+import { REDRAW_CHART_EVENT } from 'apps/editor/events';
+import { attachTracker } from 'apps/editor/components/executableStateHandler';
 
 export const RESULT_CHART_COMPONENT = 'result-chart';
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/resultGrid/ko.resultDownloadActions.js → desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.resultDownloadActions.js

@@ -22,7 +22,7 @@ import DisposableComponent from 'ko/components/DisposableComponent';
 import I18n from 'utils/i18n';
 import huePubSub from 'utils/huePubSub';
 import hueUtils from 'utils/hueUtils';
-import { SHOW_DOWNLOAD_RESULT_MODAL_EVENT } from 'apps/notebook2/components/resultGrid/ko.resultDownloadModal';
+import { SHOW_DOWNLOAD_RESULT_MODAL_EVENT } from 'apps/editor/components/resultGrid/ko.resultDownloadModal';
 
 export const NAME = 'result-download-actions';
 

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/components/resultGrid/ko.resultDownloadModal.js → desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.resultDownloadModal.js


+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/resultGrid/ko.resultGrid.js → desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.resultGrid.js

@@ -29,9 +29,9 @@ import {
   REDRAW_FIXED_HEADERS_EVENT,
   SHOW_GRID_SEARCH_EVENT,
   SHOW_NORMAL_RESULT_EVENT
-} from 'apps/notebook2/events';
+} from 'apps/editor/events';
 
-import { attachTracker } from 'apps/notebook2/components/executableStateHandler';
+import { attachTracker } from 'apps/editor/components/executableStateHandler';
 
 export const RESULT_GRID_COMPONENT = 'result-grid';
 

+ 3 - 3
desktop/core/src/desktop/js/apps/notebook2/components/resultGrid/ko.simpleResultGrid.js → desktop/core/src/desktop/js/apps/editor/components/resultGrid/ko.simpleResultGrid.js

@@ -28,9 +28,9 @@ import {
   REDRAW_FIXED_HEADERS_EVENT,
   SHOW_GRID_SEARCH_EVENT,
   SHOW_NORMAL_RESULT_EVENT
-} from 'apps/notebook2/events';
-import { trackResult } from 'apps/notebook2/components/executableStateHandler';
-import { ExecutionStatus } from 'apps/notebook2/execution/executable';
+} from 'apps/editor/events';
+import { trackResult } from 'apps/editor/components/executableStateHandler';
+import { ExecutionStatus } from 'apps/editor/execution/executable';
 
 export const SIMPLE_RESULT_GRID_COMPONENT = 'simple-result-grid';
 

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/events.js → desktop/core/src/desktop/js/apps/editor/events.js


+ 2 - 5
desktop/core/src/desktop/js/apps/notebook2/execution/api.ts → desktop/core/src/desktop/js/apps/editor/execution/api.ts

@@ -15,11 +15,8 @@
 // limitations under the License.
 
 import { extractErrorMessage, post, successResponseIsError } from 'api/utils';
-import Executable, {
-  ExecutableContext,
-  ExecutionStatus
-} from 'apps/notebook2/execution/executable';
-import { ResultType } from 'apps/notebook2/execution/executionResult';
+import Executable, { ExecutableContext, ExecutionStatus } from 'apps/editor/execution/executable';
+import { ResultType } from 'apps/editor/execution/executionResult';
 
 type SessionPropertyValue = string | number | boolean | null | undefined;
 

+ 6 - 6
desktop/core/src/desktop/js/apps/notebook2/execution/executable.ts → desktop/core/src/desktop/js/apps/editor/execution/executable.ts

@@ -23,18 +23,18 @@ import {
   ExecuteApiResponse,
   ExecutionHandle,
   ExecutionHistory
-} from 'apps/notebook2/execution/api';
-import ExecutionResult from 'apps/notebook2/execution/executionResult';
+} from 'apps/editor/execution/api';
+import ExecutionResult from 'apps/editor/execution/executionResult';
 import { hueWindow } from 'types/types';
 import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 import ExecutionLogs, {
   ExecutionError,
   ExecutionLogsRaw
-} from 'apps/notebook2/execution/executionLogs';
+} from 'apps/editor/execution/executionLogs';
 import hueUtils, { UUID } from 'utils/hueUtils';
-import Executor from 'apps/notebook2/execution/executor';
+import Executor from 'apps/editor/execution/executor';
 
 /**
  *
@@ -68,7 +68,7 @@ export interface ExecutableRaw {
   lost: boolean;
   observerState: { [key: string]: unknown };
   progress: number;
-  status: string;
+  status: ExecutionStatus;
   type: string;
 }
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/executionLogs.ts → desktop/core/src/desktop/js/apps/editor/execution/executionLogs.ts

@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import { ExecutionJob, fetchLogs } from 'apps/notebook2/execution/api';
+import { ExecutionJob, fetchLogs } from 'apps/editor/execution/api';
 import huePubSub from 'utils/huePubSub';
 import Executable, { ExecutionStatus } from './executable';
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/executionResult.ts → desktop/core/src/desktop/js/apps/editor/execution/executionResult.ts

@@ -20,7 +20,7 @@ import {
   ResultApiResponse,
   ResultMeta,
   ResultSizeApiResponse
-} from 'apps/notebook2/execution/api';
+} from 'apps/editor/execution/api';
 import { Observable } from 'knockout';
 import * as ko from 'knockout';
 

+ 4 - 4
desktop/core/src/desktop/js/apps/notebook2/execution/executor.ts → desktop/core/src/desktop/js/apps/editor/execution/executor.ts

@@ -14,10 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import Snippet from 'apps/notebook2/snippet';
-import Executable, { ExecutableRaw } from 'apps/notebook2/execution/executable';
-import { syncSqlExecutables } from 'apps/notebook2/execution/utils';
-import { VariableSubstitutionHandler } from 'apps/notebook2/variableSubstitution';
+import Snippet from 'apps/editor/snippet';
+import Executable, { ExecutableRaw } from 'apps/editor/execution/executable';
+import { syncSqlExecutables } from 'apps/editor/execution/utils';
+import { VariableSubstitutionHandler } from 'apps/editor/variableSubstitution';
 import { StatementDetails } from 'parse/types';
 import { Compute, Connector, Namespace } from 'types/config';
 

+ 0 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/sessionManager.test.ts → desktop/core/src/desktop/js/apps/editor/execution/sessionManager.test.ts


+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/sessionManager.ts → desktop/core/src/desktop/js/apps/editor/execution/sessionManager.ts

@@ -20,7 +20,7 @@ import {
   createSession,
   Session,
   SessionProperty
-} from 'apps/notebook2/execution/api';
+} from 'apps/editor/execution/api';
 import huePubSub from 'utils/huePubSub';
 
 class SessionManager {

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/sqlExecutable.test.ts → desktop/core/src/desktop/js/apps/editor/execution/sqlExecutable.test.ts

@@ -17,7 +17,7 @@
 import { CancellablePromise } from 'api/cancellablePromise';
 import { CHECK_STATUS_API, CREATE_SESSION_API, EXECUTE_API_PREFIX, GET_LOGS_API } from 'api/urls';
 
-import Executor from 'apps/notebook2/execution/executor';
+import Executor from 'apps/editor/execution/executor';
 import SqlExecutable from './sqlExecutable';
 import { ExecutionStatus } from './executable';
 import sessionManager from './sessionManager';

+ 4 - 4
desktop/core/src/desktop/js/apps/notebook2/execution/sqlExecutable.ts → desktop/core/src/desktop/js/apps/editor/execution/sqlExecutable.ts

@@ -14,10 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import { ExecuteApiResponse, executeStatement } from 'apps/notebook2/execution/api';
-import Executable, { ExecutableRaw } from 'apps/notebook2/execution/executable';
-import { ExecutionError } from 'apps/notebook2/execution/executionLogs';
-import Executor from 'apps/notebook2/execution/executor';
+import { ExecuteApiResponse, executeStatement } from 'apps/editor/execution/api';
+import Executable, { ExecutableRaw } from 'apps/editor/execution/executable';
+import { ExecutionError } from 'apps/editor/execution/executionLogs';
+import Executor from 'apps/editor/execution/executor';
 import { ParsedSqlStatement } from 'parse/sqlStatementsParser';
 
 const BATCHABLE_STATEMENT_TYPES = /ALTER|WITH|REFRESH|CREATE|DELETE|DROP|GRANT|INSERT|INVALIDATE|LOAD|SET|TRUNCATE|UPDATE|UPSERT|USE/i;

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/execution/utils.test.ts → desktop/core/src/desktop/js/apps/editor/execution/utils.test.ts

@@ -14,8 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import Executor from 'apps/notebook2/execution/executor';
-import { syncSqlExecutables } from 'apps/notebook2/execution/utils';
+import Executor from 'apps/editor/execution/executor';
+import { syncSqlExecutables } from 'apps/editor/execution/utils';
 import sqlStatementsParser from 'parse/sqlStatementsParser';
 
 const mockExecutor = (mock: unknown): Executor => mock as Executor;

+ 3 - 3
desktop/core/src/desktop/js/apps/notebook2/execution/utils.ts → desktop/core/src/desktop/js/apps/editor/execution/utils.ts

@@ -14,9 +14,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import Executable from 'apps/notebook2/execution/executable';
-import Executor from 'apps/notebook2/execution/executor';
-import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
+import Executable from 'apps/editor/execution/executable';
+import Executor from 'apps/editor/execution/executor';
+import SqlExecutable from 'apps/editor/execution/sqlExecutable';
 import { StatementDetails } from 'parse/types';
 
 export interface SyncSqlExecutablesResult {

+ 4 - 4
desktop/core/src/desktop/js/apps/notebook2/notebook.js → desktop/core/src/desktop/js/apps/editor/notebook.js

@@ -22,11 +22,11 @@ import apiHelper from 'api/apiHelper';
 import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';
 import hueUtils from 'utils/hueUtils';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 
-import Snippet, { STATUS as SNIPPET_STATUS } from 'apps/notebook2/snippet';
-import { HISTORY_CLEARED_EVENT } from 'apps/notebook2/components/ko.queryHistory';
-import { UPDATE_SAVED_QUERIES_EVENT } from 'apps/notebook2/components/ko.savedQueries';
+import Snippet, { STATUS as SNIPPET_STATUS } from 'apps/editor/snippet';
+import { HISTORY_CLEARED_EVENT } from 'apps/editor/components/ko.queryHistory';
+import { UPDATE_SAVED_QUERIES_EVENT } from 'apps/editor/components/ko.savedQueries';
 import SqlExecutable from './execution/sqlExecutable';
 import {
   ASSIST_DB_PANEL_IS_READY_EVENT,

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/notebook.test.js → desktop/core/src/desktop/js/apps/editor/notebook.test.js

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import Notebook from './notebook';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 import * as hueConfig from 'utils/hueConfig';
 
 describe('notebook.js', () => {

+ 11 - 11
desktop/core/src/desktop/js/apps/notebook2/snippet.js → desktop/core/src/desktop/js/apps/editor/snippet.js

@@ -19,11 +19,11 @@ import * as ko from 'knockout';
 import komapping from 'knockout.mapping';
 import { markdown } from 'markdown';
 
-import 'apps/notebook2/components/ko.executableLogs';
-import 'apps/notebook2/components/ko.executableProgressBar';
-import 'apps/notebook2/components/ko.snippetEditorActions';
-import 'apps/notebook2/components/ko.snippetResults';
-import 'apps/notebook2/components/ko.queryHistory';
+import 'apps/editor/components/ko.executableLogs';
+import 'apps/editor/components/ko.executableProgressBar';
+import 'apps/editor/components/ko.snippetEditorActions';
+import 'apps/editor/components/ko.snippetResults';
+import 'apps/editor/components/ko.queryHistory';
 
 import './components/ExecutableActionsKoBridge.vue';
 import './components/EditorResizerKoBridge.vue';
@@ -32,26 +32,26 @@ import './components/result/ExecutionResultsKoBridge.vue';
 
 import AceAutocompleteWrapper from 'apps/notebook/aceAutocompleteWrapper';
 import apiHelper from 'api/apiHelper';
-import Executor from 'apps/notebook2/execution/executor';
+import Executor from 'apps/editor/execution/executor';
 import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';
 import { defer, UUID } from 'utils/hueUtils';
 import { getFromLocalStorage, setInLocalStorage } from 'utils/storageUtils';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
-import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
-import { HIDE_FIXED_HEADERS_EVENT, REDRAW_FIXED_HEADERS_EVENT } from 'apps/notebook2/events';
+import sessionManager from 'apps/editor/execution/sessionManager';
+import SqlExecutable from 'apps/editor/execution/sqlExecutable';
+import { HIDE_FIXED_HEADERS_EVENT, REDRAW_FIXED_HEADERS_EVENT } from 'apps/editor/events';
 import {
   EXECUTABLE_STATUS_TRANSITION_EVENT,
   EXECUTABLE_UPDATED_EVENT,
   ExecutionStatus
-} from 'apps/notebook2/execution/executable';
+} from 'apps/editor/execution/executable';
 import {
   ACTIVE_STATEMENT_CHANGED_EVENT,
   CURSOR_POSITION_CHANGED_EVENT,
   REFRESH_STATEMENT_LOCATIONS_EVENT
 } from 'ko/bindings/ace/aceLocationHandler';
 import { EXECUTE_ACTIVE_EXECUTABLE_EVENT } from './components/ExecutableActions.vue';
-import { ADD_TO_HISTORY_EVENT } from 'apps/notebook2/components/ko.queryHistory';
+import { ADD_TO_HISTORY_EVENT } from 'apps/editor/components/ko.queryHistory';
 import { findEditorConnector, getLastKnownConfig } from 'utils/hueConfig';
 import { cancelActiveRequest } from 'api/apiUtils';
 import { getOptimizer } from 'catalog/optimizer/optimizer';

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/snippet.test.js → desktop/core/src/desktop/js/apps/editor/snippet.test.js

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import Notebook from './notebook';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 import * as hueConfig from 'utils/hueConfig';
 
 describe('snippet.js', () => {

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/variableSubstitution.ts → desktop/core/src/desktop/js/apps/editor/variableSubstitution.ts

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import { Cancellable } from 'api/cancellablePromise';
-import { DIALECT } from 'apps/notebook2/snippet';
+import { DIALECT } from 'apps/editor/snippet';
 import DataCatalogEntry, { FieldSourceMeta, SourceMeta } from 'catalog/DataCatalogEntry';
 import ko, { PureComputed } from 'knockout';
 import { Observable, ObservableArray } from 'knockout';

+ 2 - 4
desktop/core/src/desktop/js/apps/notebook/editorViewModel.js → desktop/core/src/desktop/js/apps/notebook/NotebookViewModel.js

@@ -28,11 +28,11 @@ import Snippet from 'apps/notebook/snippet';
 import {
   ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT,
   GET_ACTIVE_SNIPPET_CONNECTOR_EVENT
-} from 'apps/notebook2/events';
+} from 'apps/editor/events';
 import { CONFIG_REFRESHED_EVENT, findEditorConnector, getLastKnownConfig } from 'utils/hueConfig';
 import { getFromLocalStorage, setInLocalStorage } from 'utils/storageUtils';
 
-class EditorViewModel {
+export default class NotebookViewModel {
   constructor(editor_id, notebooks, options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
     const self = this;
 
@@ -705,5 +705,3 @@ class EditorViewModel {
     }
   }
 }
-
-export default EditorViewModel;

+ 1294 - 1308
desktop/core/src/desktop/js/apps/notebook/app.js

@@ -26,1445 +26,1431 @@ import huePubSub from 'utils/huePubSub';
 import hueUtils from 'utils/hueUtils';
 import I18n from 'utils/i18n';
 import sqlWorkerHandler from 'sql/sqlWorkerHandler';
-import { initNotebook2 } from 'apps/notebook2/app';
+import NotebookViewModel from './NotebookViewModel';
 import {
   ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT,
   IGNORE_NEXT_UNLOAD_EVENT
-} from 'apps/notebook2/events';
+} from 'apps/editor/events';
 import { SHOW_LEFT_ASSIST_EVENT } from 'ko/components/assist/events';
 
-if (window.ENABLE_NOTEBOOK_2) {
-  initNotebook2();
-} else {
-  window.Clipboard = Clipboard;
+window.Clipboard = Clipboard;
 
-  const HUE_PUB_SUB_EDITOR_ID =
-    window.location.pathname.indexOf('notebook') > -1 ? 'notebook' : 'editor';
+const HUE_PUB_SUB_EDITOR_ID =
+  window.location.pathname.indexOf('notebook') > -1 ? 'notebook' : 'editor';
 
-  huePubSub.subscribe('app.dom.loaded', app => {
-    if (app === 'editor' || app === 'notebook') {
-      window.MAIN_SCROLLABLE = '.page-content';
+huePubSub.subscribe('app.dom.loaded', app => {
+  if ((app === 'editor' && !window.ENABLE_NOTEBOOK_2) || app === 'notebook') {
+    window.MAIN_SCROLLABLE = '.page-content';
 
-      let isLeftNavOpen = false;
-      huePubSub.subscribe(
-        'left.nav.open.toggle',
-        val => {
-          isLeftNavOpen = val;
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'split.panel.resized',
-        () => {
-          huePubSub.publish('recalculate.name.description.width');
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      const showHoverMsg = e => {
-        let dt = null;
-        if (e) {
-          dt = e.dataTransfer;
-        }
-        if (
-          !isLeftNavOpen &&
-          (!dt ||
-            (dt.types &&
-              (dt.types.indexOf ? dt.types.indexOf('Files') !== -1 : dt.types.contains('Files'))))
-        ) {
-          $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').removeClass('hide');
-        }
-      };
-
-      const hideHoverMsg = vm => {
-        if (vm.editorMode()) {
-          $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverText').html(I18n('Drop a SQL file here'));
-        } else {
-          $(window.EDITOR_BINDABLE_ELEMENT)
-            .find('.hoverText')
-            .html(I18n('Drop iPython/Zeppelin notebooks here'));
-        }
-        $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').addClass('hide');
-      };
+    let isLeftNavOpen = false;
+    huePubSub.subscribe(
+      'left.nav.open.toggle',
+      val => {
+        isLeftNavOpen = val;
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
 
-      const createHueDatatable = (el, snippet, vm) => {
-        let DATATABLES_MAX_HEIGHT = 330;
-        let invisibleRows = 10;
-        if (snippet.result && snippet.result.data() && snippet.result.data().length) {
-          const cols = snippet.result.data()[0].length;
-          invisibleRows = cols > 200 ? 10 : cols > 30 ? 50 : 100;
-        }
-        const _dt = $(el).hueDataTable({
-          i18n: {
-            NO_RESULTS: I18n('No results found.'),
-            OF: I18n('of')
-          },
-          fnDrawCallback: function (oSettings) {
-            if (vm.editorMode()) {
-              $('#queryResults').removeAttr('style');
-              DATATABLES_MAX_HEIGHT = $(window).height() - $(el).parent().offset().top - 40;
-              $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
-              $(el).jHueHorizontalScrollbar();
-              $(el).parents('.dataTables_wrapper').jHueScrollLeft();
-            } else if ($(el).data('fnDraws') === 1) {
-              $(el).parents('.dataTables_wrapper').jHueTableScroller({
-                maxHeight: DATATABLES_MAX_HEIGHT,
-                heightAfterCorrection: 0
-              });
-            }
-          },
-          scrollable:
-            vm.editorMode() && !vm.isPresentationMode()
-              ? window.MAIN_SCROLLABLE
-              : '.dataTables_wrapper',
-          contained: !vm.editorMode() || vm.isPresentationMode(),
-          forceInvisible: invisibleRows
-        });
+    huePubSub.subscribe(
+      'split.panel.resized',
+      () => {
+        huePubSub.publish('recalculate.name.description.width');
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    const showHoverMsg = e => {
+      let dt = null;
+      if (e) {
+        dt = e.dataTransfer;
+      }
+      if (
+        !isLeftNavOpen &&
+        (!dt ||
+          (dt.types &&
+            (dt.types.indexOf ? dt.types.indexOf('Files') !== -1 : dt.types.contains('Files'))))
+      ) {
+        $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').removeClass('hide');
+      }
+    };
 
-        window.setTimeout(() => {
+    const hideHoverMsg = vm => {
+      if (vm.editorMode()) {
+        $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverText').html(I18n('Drop a SQL file here'));
+      } else {
+        $(window.EDITOR_BINDABLE_ELEMENT)
+          .find('.hoverText')
+          .html(I18n('Drop iPython/Zeppelin notebooks here'));
+      }
+      $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').addClass('hide');
+    };
+
+    const createHueDatatable = (el, snippet, vm) => {
+      let DATATABLES_MAX_HEIGHT = 330;
+      let invisibleRows = 10;
+      if (snippet.result && snippet.result.data() && snippet.result.data().length) {
+        const cols = snippet.result.data()[0].length;
+        invisibleRows = cols > 200 ? 10 : cols > 30 ? 50 : 100;
+      }
+      const _dt = $(el).hueDataTable({
+        i18n: {
+          NO_RESULTS: I18n('No results found.'),
+          OF: I18n('of')
+        },
+        fnDrawCallback: function (oSettings) {
           if (vm.editorMode()) {
+            $('#queryResults').removeAttr('style');
+            DATATABLES_MAX_HEIGHT = $(window).height() - $(el).parent().offset().top - 40;
             $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
-            const bannerTopHeight = window.BANNER_TOP_HTML ? 30 : 2;
-            $(el).jHueTableExtender2({
-              mainScrollable: window.MAIN_SCROLLABLE,
-              fixedFirstColumn: vm.editorMode(),
-              stickToTopPosition: 48 + bannerTopHeight,
-              parentId: 'snippet_' + snippet.id(),
-              clonedContainerPosition: 'fixed',
-              app: 'editor'
-            });
             $(el).jHueHorizontalScrollbar();
-          } else {
-            $(el).jHueTableExtender2({
-              mainScrollable: $(el).parents('.dataTables_wrapper')[0],
-              fixedFirstColumn: vm.editorMode(),
-              parentId: 'snippet_' + snippet.id(),
-              clonedContainerPosition: 'absolute',
-              app: 'editor'
+            $(el).parents('.dataTables_wrapper').jHueScrollLeft();
+          } else if ($(el).data('fnDraws') === 1) {
+            $(el).parents('.dataTables_wrapper').jHueTableScroller({
+              maxHeight: DATATABLES_MAX_HEIGHT,
+              heightAfterCorrection: 0
             });
           }
-        }, 0);
-
-        return _dt;
-      };
+        },
+        scrollable:
+          vm.editorMode() && !vm.isPresentationMode()
+            ? window.MAIN_SCROLLABLE
+            : '.dataTables_wrapper',
+        contained: !vm.editorMode() || vm.isPresentationMode(),
+        forceInvisible: invisibleRows
+      });
 
-      const createDatatable = (el, snippet, vm) => {
-        const parent = $(el).parent();
-        // When executing few columns -> many columns -> few columns we have to clear the style
-        $(el).removeAttr('style');
-        if ($(el).hasClass('table-huedatatable')) {
-          $(el).removeClass('table-huedatatable');
-          if (parent.hasClass('dataTables_wrapper')) {
-            $(el).unwrap();
-          }
+      window.setTimeout(() => {
+        if (vm.editorMode()) {
+          $(el).parents('.dataTables_wrapper').css('overflow-x', 'hidden');
+          const bannerTopHeight = window.BANNER_TOP_HTML ? 30 : 2;
+          $(el).jHueTableExtender2({
+            mainScrollable: window.MAIN_SCROLLABLE,
+            fixedFirstColumn: vm.editorMode(),
+            stickToTopPosition: 48 + bannerTopHeight,
+            parentId: 'snippet_' + snippet.id(),
+            clonedContainerPosition: 'fixed',
+            app: 'editor'
+          });
+          $(el).jHueHorizontalScrollbar();
+        } else {
+          $(el).jHueTableExtender2({
+            mainScrollable: $(el).parents('.dataTables_wrapper')[0],
+            fixedFirstColumn: vm.editorMode(),
+            parentId: 'snippet_' + snippet.id(),
+            clonedContainerPosition: 'absolute',
+            app: 'editor'
+          });
+        }
+      }, 0);
+
+      return _dt;
+    };
+
+    const createDatatable = (el, snippet, vm) => {
+      const parent = $(el).parent();
+      // When executing few columns -> many columns -> few columns we have to clear the style
+      $(el).removeAttr('style');
+      if ($(el).hasClass('table-huedatatable')) {
+        $(el).removeClass('table-huedatatable');
+        if (parent.hasClass('dataTables_wrapper')) {
+          $(el).unwrap();
         }
-        $(el).addClass('dt');
+      }
+      $(el).addClass('dt');
 
-        const _dt = createHueDatatable(el, snippet, vm);
+      const _dt = createHueDatatable(el, snippet, vm);
 
-        const dataTableEl = $(el).parents('.dataTables_wrapper');
+      const dataTableEl = $(el).parents('.dataTables_wrapper');
 
-        if (!vm.editorMode()) {
-          dataTableEl.bind('mousewheel DOMMouseScroll wheel', function (e) {
-            if ($(el).closest('.results').css('overflow') === 'hidden') {
-              return;
-            }
-            const _e = e.originalEvent,
-              _deltaX = _e.wheelDeltaX || -_e.deltaX,
-              _deltaY = _e.wheelDeltaY || -_e.deltaY;
-            this.scrollTop += -_deltaY / 2;
-            this.scrollLeft += -_deltaX / 2;
-
-            if (this.scrollTop === 0) {
-              $('body')[0].scrollTop += -_deltaY / 3;
-              $('html')[0].scrollTop += -_deltaY / 3; // for firefox
-            }
-            e.preventDefault();
-          });
-        }
+      if (!vm.editorMode()) {
+        dataTableEl.bind('mousewheel DOMMouseScroll wheel', function (e) {
+          if ($(el).closest('.results').css('overflow') === 'hidden') {
+            return;
+          }
+          const _e = e.originalEvent,
+            _deltaX = _e.wheelDeltaX || -_e.deltaX,
+            _deltaY = _e.wheelDeltaY || -_e.deltaY;
+          this.scrollTop += -_deltaY / 2;
+          this.scrollLeft += -_deltaX / 2;
+
+          if (this.scrollTop === 0) {
+            $('body')[0].scrollTop += -_deltaY / 3;
+            $('html')[0].scrollTop += -_deltaY / 3; // for firefox
+          }
+          e.preventDefault();
+        });
+      }
 
-        let _scrollTimeout = -1;
+      let _scrollTimeout = -1;
 
-        let scrollElement = dataTableEl;
-        if (vm.editorMode()) {
-          scrollElement = $(window.MAIN_SCROLLABLE);
-        }
+      let scrollElement = dataTableEl;
+      if (vm.editorMode()) {
+        scrollElement = $(window.MAIN_SCROLLABLE);
+      }
 
-        if (scrollElement.data('scrollFnDtCreation')) {
-          scrollElement.off('scroll', scrollElement.data('scrollFnDtCreation'));
-        }
+      if (scrollElement.data('scrollFnDtCreation')) {
+        scrollElement.off('scroll', scrollElement.data('scrollFnDtCreation'));
+      }
 
-        let resultFollowTimeout = -1;
-        const dataScroll = function () {
-          if (vm.editorMode()) {
-            const snippetEl = $('#snippet_' + snippet.id());
-            if (snippetEl.find('.dataTables_wrapper').length > 0 && snippet.showGrid()) {
-              window.clearTimeout(resultFollowTimeout);
-              resultFollowTimeout = window.setTimeout(() => {
-                const topCoord = vm.isPresentationMode() || vm.isResultFullScreenMode() ? 50 : 73;
-                let offsetTop = 0;
-                if (
-                  snippetEl.find('.dataTables_wrapper').length > 0 &&
-                  snippetEl.find('.dataTables_wrapper').offset()
-                ) {
-                  offsetTop = (snippetEl.find('.dataTables_wrapper').offset().top - topCoord) * -1;
-                }
-                let margin = Math.max(offsetTop, 0);
-                if (window.BANNER_TOP_HTML) {
-                  margin += 31;
-                }
-                if (snippet.isResultSettingsVisible()) {
-                  snippetEl.find('.snippet-grid-settings').css({
-                    height:
-                      vm.isPresentationMode() || !vm.editorMode()
-                        ? '330px'
-                        : Math.max(
-                            100,
-                            Math.ceil(
-                              $(window).height() -
-                                Math.max($('#queryResults').offset().top, topCoord)
-                            )
-                          ) + 'px'
-                  });
-                  snippetEl.find('.result-settings').css({
-                    marginTop: margin
-                  });
-                }
-                snippetEl.find('.snippet-actions').css({
-                  marginTop: margin + 25
-                });
-              }, 100);
-            }
-          }
-          if (
-            !vm.editorMode() ||
-            (vm.editorMode() && snippet.currentQueryTab() === 'queryResults' && snippet.showGrid())
-          ) {
-            let _lastScrollPosition =
-              scrollElement.data('scrollPosition') != null
-                ? scrollElement.data('scrollPosition')
-                : 0;
-            window.clearTimeout(_scrollTimeout);
-            scrollElement.data('scrollPosition', scrollElement.scrollTop());
-            _scrollTimeout = window.setTimeout(() => {
-              if (vm.editorMode()) {
-                _lastScrollPosition--; //hack for forcing fetching
-              }
+      let resultFollowTimeout = -1;
+      const dataScroll = function () {
+        if (vm.editorMode()) {
+          const snippetEl = $('#snippet_' + snippet.id());
+          if (snippetEl.find('.dataTables_wrapper').length > 0 && snippet.showGrid()) {
+            window.clearTimeout(resultFollowTimeout);
+            resultFollowTimeout = window.setTimeout(() => {
+              const topCoord = vm.isPresentationMode() || vm.isResultFullScreenMode() ? 50 : 73;
+              let offsetTop = 0;
               if (
-                _lastScrollPosition !== scrollElement.scrollTop() &&
-                scrollElement.scrollTop() + scrollElement.outerHeight() + 20 >=
-                  scrollElement[0].scrollHeight &&
-                _dt &&
-                snippet.result.hasMore()
+                snippetEl.find('.dataTables_wrapper').length > 0 &&
+                snippetEl.find('.dataTables_wrapper').offset()
               ) {
-                huePubSub.publish('editor.snippet.result.gray', snippet);
-                snippet.fetchResult(100, false);
+                offsetTop = (snippetEl.find('.dataTables_wrapper').offset().top - topCoord) * -1;
               }
+              let margin = Math.max(offsetTop, 0);
+              if (window.BANNER_TOP_HTML) {
+                margin += 31;
+              }
+              if (snippet.isResultSettingsVisible()) {
+                snippetEl.find('.snippet-grid-settings').css({
+                  height:
+                    vm.isPresentationMode() || !vm.editorMode()
+                      ? '330px'
+                      : Math.max(
+                          100,
+                          Math.ceil(
+                            $(window).height() - Math.max($('#queryResults').offset().top, topCoord)
+                          )
+                        ) + 'px'
+                });
+                snippetEl.find('.result-settings').css({
+                  marginTop: margin
+                });
+              }
+              snippetEl.find('.snippet-actions').css({
+                marginTop: margin + 25
+              });
             }, 100);
           }
-        };
-        scrollElement.data('scrollFnDtCreation', dataScroll);
-        scrollElement.on('scroll', dataScroll);
-        snippet.isResultSettingsVisible.subscribe(newValue => {
-          if (newValue) {
-            dataScroll();
-          }
-        });
-
-        huePubSub.subscribeOnce('chart.hard.reset', () => {
-          // hard reset once the default opened chart
-          const oldChartX = snippet.chartX();
-          snippet.chartX(null);
-          window.setTimeout(() => {
-            snippet.chartX(oldChartX);
-          }, 0);
-        });
-
-        return _dt;
+        }
+        if (
+          !vm.editorMode() ||
+          (vm.editorMode() && snippet.currentQueryTab() === 'queryResults' && snippet.showGrid())
+        ) {
+          let _lastScrollPosition =
+            scrollElement.data('scrollPosition') != null ? scrollElement.data('scrollPosition') : 0;
+          window.clearTimeout(_scrollTimeout);
+          scrollElement.data('scrollPosition', scrollElement.scrollTop());
+          _scrollTimeout = window.setTimeout(() => {
+            if (vm.editorMode()) {
+              _lastScrollPosition--; //hack for forcing fetching
+            }
+            if (
+              _lastScrollPosition !== scrollElement.scrollTop() &&
+              scrollElement.scrollTop() + scrollElement.outerHeight() + 20 >=
+                scrollElement[0].scrollHeight &&
+              _dt &&
+              snippet.result.hasMore()
+            ) {
+              huePubSub.publish('editor.snippet.result.gray', snippet);
+              snippet.fetchResult(100, false);
+            }
+          }, 100);
+        }
       };
+      scrollElement.data('scrollFnDtCreation', dataScroll);
+      scrollElement.on('scroll', dataScroll);
+      snippet.isResultSettingsVisible.subscribe(newValue => {
+        if (newValue) {
+          dataScroll();
+        }
+      });
 
-      if (ko.options) {
-        ko.options.deferUpdates = true;
-      }
+      huePubSub.subscribeOnce('chart.hard.reset', () => {
+        // hard reset once the default opened chart
+        const oldChartX = snippet.chartX();
+        snippet.chartX(null);
+        window.setTimeout(() => {
+          snippet.chartX(oldChartX);
+        }, 0);
+      });
 
-      let viewModel;
+      return _dt;
+    };
 
-      const hideFixedHeaders = function () {
-        $('.jHueTableExtenderClonedContainer').hide();
-        $('.jHueTableExtenderClonedContainerColumn').hide();
-        $('.jHueTableExtenderClonedContainerCell').hide();
-        $('.fixed-header-row').hide();
-        $('.fixed-first-cell').hide();
-        $('.fixed-first-column').hide();
-      };
+    if (ko.options) {
+      ko.options.deferUpdates = true;
+    }
 
-      window.hideFixedHeaders = hideFixedHeaders;
+    let viewModel;
 
-      let redrawTimeout = -1;
-      const redrawFixedHeaders = function (timeout) {
-        const renderer = function () {
-          if (!viewModel.selectedNotebook()) {
-            return;
-          }
-          viewModel
-            .selectedNotebook()
-            .snippets()
-            .forEach(snippet => {
-              if (snippet.result.meta().length > 0) {
-                const tableExtender = $('#snippet_' + snippet.id() + ' .resultTable').data(
-                  'plugin_jHueTableExtender2'
-                );
-                if (typeof tableExtender !== 'undefined') {
-                  tableExtender.repositionHeader();
-                  tableExtender.drawLockedRows();
-                }
-                $(window.MAIN_SCROLLABLE).data('lastScroll', $(window.MAIN_SCROLLABLE).scrollTop());
-                $(window.MAIN_SCROLLABLE).trigger('scroll');
-              }
-            });
-          $('.jHueTableExtenderClonedContainer').show();
-          $('.jHueTableExtenderClonedContainerColumn').show();
-          $('.jHueTableExtenderClonedContainerCell').show();
-          $('.fixed-header-row').show();
-          $('.fixed-first-cell').show();
-          $('.fixed-first-column').show();
-        };
+    const hideFixedHeaders = function () {
+      $('.jHueTableExtenderClonedContainer').hide();
+      $('.jHueTableExtenderClonedContainerColumn').hide();
+      $('.jHueTableExtenderClonedContainerCell').hide();
+      $('.fixed-header-row').hide();
+      $('.fixed-first-cell').hide();
+      $('.fixed-first-column').hide();
+    };
 
-        if (timeout) {
-          window.clearTimeout(redrawTimeout);
-          redrawTimeout = window.setTimeout(renderer, timeout);
-        } else {
-          renderer();
+    window.hideFixedHeaders = hideFixedHeaders;
+
+    let redrawTimeout = -1;
+    const redrawFixedHeaders = function (timeout) {
+      const renderer = function () {
+        if (!viewModel.selectedNotebook()) {
+          return;
         }
-      };
-      window.redrawFixedHeaders = redrawFixedHeaders;
-
-      const replaceAce = content => {
-        const snip = viewModel.selectedNotebook().snippets()[0];
-        if (snip) {
-          snip.statement_raw(content);
-          snip.result.statements_count(1);
-          snip.ace().setValue(content, 1);
-          snip.result.statement_range({
-            start: {
-              row: 0,
-              column: 0
-            },
-            end: {
-              row: 0,
-              column: 0
+        viewModel
+          .selectedNotebook()
+          .snippets()
+          .forEach(snippet => {
+            if (snippet.result.meta().length > 0) {
+              const tableExtender = $('#snippet_' + snippet.id() + ' .resultTable').data(
+                'plugin_jHueTableExtender2'
+              );
+              if (typeof tableExtender !== 'undefined') {
+                tableExtender.repositionHeader();
+                tableExtender.drawLockedRows();
+              }
+              $(window.MAIN_SCROLLABLE).data('lastScroll', $(window.MAIN_SCROLLABLE).scrollTop());
+              $(window.MAIN_SCROLLABLE).trigger('scroll');
             }
           });
-          snip.ace()._emit('focus');
-        }
-        hideHoverMsg(viewModel);
-        redrawFixedHeaders(200);
+        $('.jHueTableExtenderClonedContainer').show();
+        $('.jHueTableExtenderClonedContainerColumn').show();
+        $('.jHueTableExtenderClonedContainerCell').show();
+        $('.fixed-header-row').show();
+        $('.fixed-first-cell').show();
+        $('.fixed-first-column').show();
       };
-      window.replaceAce = replaceAce;
-
-      // Drag and drop iPython / Zeppelin notebooks
-      if (window.FileReader) {
-        let aceChecks = 0;
-
-        const addAce = (content, snippetType) => {
-          const snip = viewModel
-            .selectedNotebook()
-            .addSnippet({ type: snippetType, result: {} }, true);
-          snip.statement_raw(content);
-          aceChecks++;
-          snip.checkForAce = window.setInterval(() => {
-            if (snip.ace()) {
-              window.clearInterval(snip.checkForAce);
-              aceChecks--;
-              if (aceChecks === 0) {
-                hideHoverMsg(viewModel);
-                redrawFixedHeaders(200);
-              }
+
+      if (timeout) {
+        window.clearTimeout(redrawTimeout);
+        redrawTimeout = window.setTimeout(renderer, timeout);
+      } else {
+        renderer();
+      }
+    };
+    window.redrawFixedHeaders = redrawFixedHeaders;
+
+    const replaceAce = content => {
+      const snip = viewModel.selectedNotebook().snippets()[0];
+      if (snip) {
+        snip.statement_raw(content);
+        snip.result.statements_count(1);
+        snip.ace().setValue(content, 1);
+        snip.result.statement_range({
+          start: {
+            row: 0,
+            column: 0
+          },
+          end: {
+            row: 0,
+            column: 0
+          }
+        });
+        snip.ace()._emit('focus');
+      }
+      hideHoverMsg(viewModel);
+      redrawFixedHeaders(200);
+    };
+    window.replaceAce = replaceAce;
+
+    // Drag and drop iPython / Zeppelin notebooks
+    if (window.FileReader) {
+      let aceChecks = 0;
+
+      const addAce = (content, snippetType) => {
+        const snip = viewModel
+          .selectedNotebook()
+          .addSnippet({ type: snippetType, result: {} }, true);
+        snip.statement_raw(content);
+        aceChecks++;
+        snip.checkForAce = window.setInterval(() => {
+          if (snip.ace()) {
+            window.clearInterval(snip.checkForAce);
+            aceChecks--;
+            if (aceChecks === 0) {
+              hideHoverMsg(viewModel);
+              redrawFixedHeaders(200);
             }
-          }, 100);
-        };
+          }
+        }, 100);
+      };
 
-        const addMarkdown = content => {
-          const snip = viewModel
-            .selectedNotebook()
-            .addSnippet({ type: 'markdown', result: {} }, true);
-          snip.statement_raw(content);
-        };
+      const addMarkdown = content => {
+        const snip = viewModel
+          .selectedNotebook()
+          .addSnippet({ type: 'markdown', result: {} }, true);
+        snip.statement_raw(content);
+      };
 
-        const addPySpark = content => {
-          addAce(content, 'pyspark');
-        };
+      const addPySpark = content => {
+        addAce(content, 'pyspark');
+      };
 
-        const addSql = content => {
-          addAce(content, 'hive');
-        };
+      const addSql = content => {
+        addAce(content, 'hive');
+      };
 
-        const addScala = content => {
-          addAce(content, 'spark');
-        };
+      const addScala = content => {
+        addAce(content, 'spark');
+      };
 
-        const parseExternalJSON = raw => {
-          try {
-            if (viewModel.editorMode()) {
-              replaceAce(raw);
-            } else {
-              const loaded = typeof raw == 'string' ? JSON.parse(raw) : raw;
-              if (loaded.nbformat) {
-                //ipython
-                let cells = [];
-                if (loaded.nbformat === 3) {
-                  cells = loaded.worksheets[0].cells;
-                } else if (loaded.nbformat === 4) {
-                  cells = loaded.cells;
-                }
-                cells.forEach((cell, cellCnt) => {
-                  window.setTimeout(() => {
-                    if (cell.cell_type === 'code') {
-                      if (loaded.nbformat === 3) {
-                        addPySpark($.isArray(cell.input) ? cell.input.join('') : cell.input);
-                      } else {
-                        addPySpark($.isArray(cell.source) ? cell.source.join('') : cell.source);
-                      }
-                    }
-                    if (cell.cell_type === 'heading') {
-                      let heading = $.isArray(cell.source) ? cell.source.join('') : cell.source;
-                      if (cell.level === 1) {
-                        heading += '\n====================';
-                      } else if (cell.level === 2) {
-                        heading += '\n--------------------';
-                      } else {
-                        heading = '### ' + heading;
-                      }
-                      addMarkdown(heading);
-                    }
-                    if (cell.cell_type === 'markdown') {
-                      addMarkdown($.isArray(cell.source) ? cell.source.join('') : cell.source);
+      const parseExternalJSON = raw => {
+        try {
+          if (viewModel.editorMode()) {
+            replaceAce(raw);
+          } else {
+            const loaded = typeof raw == 'string' ? JSON.parse(raw) : raw;
+            if (loaded.nbformat) {
+              //ipython
+              let cells = [];
+              if (loaded.nbformat === 3) {
+                cells = loaded.worksheets[0].cells;
+              } else if (loaded.nbformat === 4) {
+                cells = loaded.cells;
+              }
+              cells.forEach((cell, cellCnt) => {
+                window.setTimeout(() => {
+                  if (cell.cell_type === 'code') {
+                    if (loaded.nbformat === 3) {
+                      addPySpark($.isArray(cell.input) ? cell.input.join('') : cell.input);
+                    } else {
+                      addPySpark($.isArray(cell.source) ? cell.source.join('') : cell.source);
                     }
-                    if (cellCnt === cells.length - 1 && aceChecks === 0) {
-                      hideHoverMsg(viewModel);
+                  }
+                  if (cell.cell_type === 'heading') {
+                    let heading = $.isArray(cell.source) ? cell.source.join('') : cell.source;
+                    if (cell.level === 1) {
+                      heading += '\n====================';
+                    } else if (cell.level === 2) {
+                      heading += '\n--------------------';
+                    } else {
+                      heading = '### ' + heading;
                     }
-                  }, 10);
-                });
-              }
+                    addMarkdown(heading);
+                  }
+                  if (cell.cell_type === 'markdown') {
+                    addMarkdown($.isArray(cell.source) ? cell.source.join('') : cell.source);
+                  }
+                  if (cellCnt === cells.length - 1 && aceChecks === 0) {
+                    hideHoverMsg(viewModel);
+                  }
+                }, 10);
+              });
+            }
 
-              if (loaded.paragraphs) {
-                //zeppelin
-                if (loaded.name) {
-                  viewModel.selectedNotebook().name(loaded.name);
-                }
-                loaded.paragraphs.forEach(paragraph => {
-                  if (paragraph.text) {
-                    const content = paragraph.text.split('\n');
-                    if (content[0].indexOf('%md') > -1) {
-                      content.shift();
-                      addMarkdown(content.join('\n'));
-                    } else if (
-                      content[0].indexOf('%sql') > -1 ||
-                      content[0].indexOf('%hive') > -1
-                    ) {
-                      content.shift();
-                      addSql(content.join('\n'));
-                    } else if (content[0].indexOf('%pyspark') > -1) {
+            if (loaded.paragraphs) {
+              //zeppelin
+              if (loaded.name) {
+                viewModel.selectedNotebook().name(loaded.name);
+              }
+              loaded.paragraphs.forEach(paragraph => {
+                if (paragraph.text) {
+                  const content = paragraph.text.split('\n');
+                  if (content[0].indexOf('%md') > -1) {
+                    content.shift();
+                    addMarkdown(content.join('\n'));
+                  } else if (content[0].indexOf('%sql') > -1 || content[0].indexOf('%hive') > -1) {
+                    content.shift();
+                    addSql(content.join('\n'));
+                  } else if (content[0].indexOf('%pyspark') > -1) {
+                    content.shift();
+                    addPySpark(content.join('\n'));
+                  } else {
+                    if (content[0].indexOf('%spark') > -1) {
                       content.shift();
-                      addPySpark(content.join('\n'));
-                    } else {
-                      if (content[0].indexOf('%spark') > -1) {
-                        content.shift();
-                      }
-                      addScala(content.join('\n'));
                     }
+                    addScala(content.join('\n'));
                   }
-                });
-              }
+                }
+              });
             }
-          } catch (e) {
-            hideHoverMsg(viewModel);
-            replaceAce(raw);
           }
-        };
+        } catch (e) {
+          hideHoverMsg(viewModel);
+          replaceAce(raw);
+        }
+      };
 
-        const handleFileSelect = function (evt) {
-          evt.stopPropagation();
-          evt.preventDefault();
-          const dt = evt.dataTransfer;
-          const files = dt.files;
-          if (files.length > 0) {
-            showHoverMsg();
-          } else {
-            hideHoverMsg(viewModel);
-          }
+      const handleFileSelect = function (evt) {
+        evt.stopPropagation();
+        evt.preventDefault();
+        const dt = evt.dataTransfer;
+        const files = dt.files;
+        if (files.length > 0) {
+          showHoverMsg();
+        } else {
+          hideHoverMsg(viewModel);
+        }
 
-          for (let i = 0, f; (f = files[i]); i++) {
-            const reader = new FileReader();
-            reader.onload = (function (file) {
-              return function (e) {
-                $('.hoverText').html("<i class='fa fa-spinner fa-spin'></i>");
-                parseExternalJSON(e.target.result);
-              };
-            })(f);
-            reader.readAsText(f);
-          }
-        };
+        for (let i = 0, f; (f = files[i]); i++) {
+          const reader = new FileReader();
+          reader.onload = (function (file) {
+            return function (e) {
+              $('.hoverText').html("<i class='fa fa-spinner fa-spin'></i>");
+              parseExternalJSON(e.target.result);
+            };
+          })(f);
+          reader.readAsText(f);
+        }
+      };
 
-        const handleDragOver = function (evt) {
-          evt.stopPropagation();
-          evt.preventDefault();
-          evt.dataTransfer.dropEffect = 'copy';
-        };
+      const handleDragOver = function (evt) {
+        evt.stopPropagation();
+        evt.preventDefault();
+        evt.dataTransfer.dropEffect = 'copy';
+      };
 
-        const dropZone = $(window.EDITOR_BINDABLE_ELEMENT)[0];
-        dropZone.addEventListener('dragenter', showHoverMsg, false);
-        dropZone.addEventListener('dragover', handleDragOver, false);
-        dropZone.addEventListener('drop', handleFileSelect, false);
+      const dropZone = $(window.EDITOR_BINDABLE_ELEMENT)[0];
+      dropZone.addEventListener('dragenter', showHoverMsg, false);
+      dropZone.addEventListener('dragover', handleDragOver, false);
+      dropZone.addEventListener('drop', handleFileSelect, false);
 
-        let isDraggingOverText = false;
+      let isDraggingOverText = false;
 
-        $(window.EDITOR_BINDABLE_ELEMENT)
-          .find('.hoverText')
-          .on('dragenter', e => {
-            e.preventDefault();
-            e.stopPropagation();
-            e.stopImmediatePropagation();
-            isDraggingOverText = true;
-          });
+      $(window.EDITOR_BINDABLE_ELEMENT)
+        .find('.hoverText')
+        .on('dragenter', e => {
+          e.preventDefault();
+          e.stopPropagation();
+          e.stopImmediatePropagation();
+          isDraggingOverText = true;
+        });
 
-        $(window.EDITOR_BINDABLE_ELEMENT)
-          .find('.hoverText')
-          .on('dragleave', e => {
-            e.preventDefault();
-            e.stopPropagation();
-            e.stopImmediatePropagation();
-            isDraggingOverText = false;
-          });
+      $(window.EDITOR_BINDABLE_ELEMENT)
+        .find('.hoverText')
+        .on('dragleave', e => {
+          e.preventDefault();
+          e.stopPropagation();
+          e.stopImmediatePropagation();
+          isDraggingOverText = false;
+        });
 
-        $(window.EDITOR_BINDABLE_ELEMENT)
-          .find('.hoverMsg')
-          .on('dragleave', e => {
-            if (!isDraggingOverText) {
-              hideHoverMsg(viewModel);
-            }
-          });
-      }
+      $(window.EDITOR_BINDABLE_ELEMENT)
+        .find('.hoverMsg')
+        .on('dragleave', e => {
+          if (!isDraggingOverText) {
+            hideHoverMsg(viewModel);
+          }
+        });
+    }
 
-      if (window.EDITOR_ENABLE_QUERY_SCHEDULING) {
-        viewModel = new window.EditorViewModel(
-          window.EDITOR_ID,
-          window.NOTEBOOKS_JSON,
-          window.EDITOR_VIEW_MODEL_OPTIONS,
-          window.CoordinatorEditorViewModel,
-          window.RunningCoordinatorModel
-        );
-      } else {
-        viewModel = new window.EditorViewModel(
-          window.EDITOR_ID,
-          window.NOTEBOOKS_JSON,
-          window.EDITOR_VIEW_MODEL_OPTIONS
-        );
-      }
-      ko.applyBindings(viewModel, $(window.EDITOR_BINDABLE_ELEMENT)[0]);
-      viewModel.init();
+    if (window.EDITOR_ENABLE_QUERY_SCHEDULING) {
+      viewModel = new NotebookViewModel(
+        window.EDITOR_ID,
+        window.NOTEBOOKS_JSON,
+        window.EDITOR_VIEW_MODEL_OPTIONS,
+        window.CoordinatorEditorViewModel,
+        window.RunningCoordinatorModel
+      );
+    } else {
+      viewModel = new NotebookViewModel(
+        window.EDITOR_ID,
+        window.NOTEBOOKS_JSON,
+        window.EDITOR_VIEW_MODEL_OPTIONS
+      );
+    }
+    ko.applyBindings(viewModel, $(window.EDITOR_BINDABLE_ELEMENT)[0]);
+    viewModel.init();
 
-      sqlWorkerHandler.registerWorkers();
+    sqlWorkerHandler.registerWorkers();
 
-      viewModel.selectedNotebook.subscribe(newVal => {
-        huePubSub.publish('selected.notebook.changed', newVal);
-      });
+    viewModel.selectedNotebook.subscribe(newVal => {
+      huePubSub.publish('selected.notebook.changed', newVal);
+    });
 
-      let wasResultFullScreenMode = false;
-      let isAssistAvailable = viewModel.assistAvailable();
-      let wasLeftPanelVisible = viewModel.isLeftPanelVisible();
-      let wasRightPanelVisible = viewModel.isRightPanelVisible();
+    let wasResultFullScreenMode = false;
+    let isAssistAvailable = viewModel.assistAvailable();
+    let wasLeftPanelVisible = viewModel.isLeftPanelVisible();
+    let wasRightPanelVisible = viewModel.isRightPanelVisible();
 
-      const exitPlayerMode = () => {
-        if (!wasResultFullScreenMode) {
-          viewModel.selectedNotebook().isPresentationMode(false);
-        } else {
-          viewModel.isResultFullScreenMode(false);
-        }
-        wasResultFullScreenMode = false;
-      };
+    const exitPlayerMode = () => {
+      if (!wasResultFullScreenMode) {
+        viewModel.selectedNotebook().isPresentationMode(false);
+      } else {
+        viewModel.isResultFullScreenMode(false);
+      }
+      wasResultFullScreenMode = false;
+    };
 
-      viewModel.isResultFullScreenMode.subscribe(newValue => {
-        wasResultFullScreenMode = newValue;
-        huePubSub.publish('editor.presentation.operate.toggle', newValue);
-      });
+    viewModel.isResultFullScreenMode.subscribe(newValue => {
+      wasResultFullScreenMode = newValue;
+      huePubSub.publish('editor.presentation.operate.toggle', newValue);
+    });
 
-      viewModel.isLeftPanelVisible.subscribe(value => {
-        redrawFixedHeaders(200);
-      });
+    viewModel.isLeftPanelVisible.subscribe(value => {
+      redrawFixedHeaders(200);
+    });
 
-      let ignoreNextUnload = false;
+    let ignoreNextUnload = false;
 
-      huePubSub.subscribe(IGNORE_NEXT_UNLOAD_EVENT, () => {
-        ignoreNextUnload = true;
-      });
+    huePubSub.subscribe(IGNORE_NEXT_UNLOAD_EVENT, () => {
+      ignoreNextUnload = true;
+    });
 
-      // Close the notebook snippets when leaving the page
-      window.onbeforeunload = function (e) {
-        if (ignoreNextUnload) {
-          ignoreNextUnload = false;
-          return;
-        }
+    // Close the notebook snippets when leaving the page
+    window.onbeforeunload = function (e) {
+      if (ignoreNextUnload) {
+        ignoreNextUnload = false;
+        return;
+      }
 
-        if (!viewModel.selectedNotebook().avoidClosing) {
-          viewModel.selectedNotebook().close();
-        }
-      };
-      $(window).data('beforeunload', window.onbeforeunload);
+      if (!viewModel.selectedNotebook().avoidClosing) {
+        viewModel.selectedNotebook().close();
+      }
+    };
+    $(window).data('beforeunload', window.onbeforeunload);
 
-      $('.preview-sample').css('right', 10 + hueUtils.scrollbarWidth() + 'px');
+    $('.preview-sample').css('right', 10 + hueUtils.scrollbarWidth() + 'px');
 
-      const saveKeyHandler = () => {
-        if (viewModel.canSave()) {
-          viewModel.saveNotebook();
-        } else {
-          $('#saveAsModal' + window.EDITOR_SUFFIX).modal('show');
-        }
-      };
+    const saveKeyHandler = () => {
+      if (viewModel.canSave()) {
+        viewModel.saveNotebook();
+      } else {
+        $('#saveAsModal' + window.EDITOR_SUFFIX).modal('show');
+      }
+    };
 
-      const newKeyHandler = () => {
-        if (!viewModel.editorMode()) {
-          viewModel.selectedNotebook().newSnippet();
-        } else {
-          viewModel.newNotebook(
-            viewModel.editorType(),
-            null,
-            viewModel.selectedNotebook()
-              ? viewModel.selectedNotebook().snippets()[0].currentQueryTab()
-              : null
-          );
-        }
-      };
+    const newKeyHandler = () => {
+      if (!viewModel.editorMode()) {
+        viewModel.selectedNotebook().newSnippet();
+      } else {
+        viewModel.newNotebook(
+          viewModel.editorType(),
+          null,
+          viewModel.selectedNotebook()
+            ? viewModel.selectedNotebook().snippets()[0].currentQueryTab()
+            : null
+        );
+      }
+    };
 
-      const initKeydownBindings = () => {
-        $(window).bind('keydown.editor', 'ctrl+s alt+s meta+s', e => {
-          e.preventDefault();
-          saveKeyHandler();
-          return false;
-        });
-        $(window).bind('keydown.editor', 'ctrl+shift+p alt+shift+p meta+shift+p', e => {
-          e.preventDefault();
-          huePubSub.publish('editor.presentation.toggle');
-          return false;
-        });
-        $(window).bind('keydown.editor', 'ctrl+e alt+e meta+e', e => {
-          e.preventDefault();
-          newKeyHandler();
-          return false;
-        });
-      };
+    const initKeydownBindings = () => {
+      $(window).bind('keydown.editor', 'ctrl+s alt+s meta+s', e => {
+        e.preventDefault();
+        saveKeyHandler();
+        return false;
+      });
+      $(window).bind('keydown.editor', 'ctrl+shift+p alt+shift+p meta+shift+p', e => {
+        e.preventDefault();
+        huePubSub.publish('editor.presentation.toggle');
+        return false;
+      });
+      $(window).bind('keydown.editor', 'ctrl+e alt+e meta+e', e => {
+        e.preventDefault();
+        newKeyHandler();
+        return false;
+      });
+    };
+
+    if (document.location.href.indexOf('editor') >= 0) {
+      initKeydownBindings();
+    }
 
-      if (document.location.href.indexOf('editor') >= 0) {
-        initKeydownBindings();
+    $(document).bind('keyup', e => {
+      if (
+        e.keyCode === 191 &&
+        e.shiftKey &&
+        !$(e.target).is('input') &&
+        !$(e.target).is('textarea')
+      ) {
+        $('#helpModal' + window.EDITOR_SUFFIX).modal('show');
       }
 
-      $(document).bind('keyup', e => {
+      if (
+        e.keyCode === 191 &&
+        !e.shiftKey &&
+        !$(e.target).is('input') &&
+        !$(e.target).is('textarea')
+      ) {
         if (
-          e.keyCode === 191 &&
-          e.shiftKey &&
-          !$(e.target).is('input') &&
-          !$(e.target).is('textarea')
+          viewModel.editorMode() &&
+          viewModel.selectedNotebook().snippets()[0].currentQueryTab() === 'queryResults'
         ) {
-          $('#helpModal' + window.EDITOR_SUFFIX).modal('show');
-        }
-
-        if (
-          e.keyCode === 191 &&
-          !e.shiftKey &&
-          !$(e.target).is('input') &&
-          !$(e.target).is('textarea')
-        ) {
-          if (
-            viewModel.editorMode() &&
-            viewModel.selectedNotebook().snippets()[0].currentQueryTab() === 'queryResults'
-          ) {
-            e.preventDefault();
-            const $t = $('#snippet_' + viewModel.selectedNotebook().snippets()[0].id()).find(
-              '.resultTable'
-            );
-            $t.hueDataTable().fnShowSearch();
-            return false;
-          }
+          e.preventDefault();
+          const $t = $('#snippet_' + viewModel.selectedNotebook().snippets()[0].id()).find(
+            '.resultTable'
+          );
+          $t.hueDataTable().fnShowSearch();
+          return false;
         }
-      });
+      }
+    });
 
-      let initialResizePosition = 100;
+    let initialResizePosition = 100;
 
-      const draggableHelper = (el, e, ui, setSize) => {
-        const _snippet = ko.dataFor(el.parents('.snippet')[0]);
-        const _cm = $('#snippet_' + _snippet.id()).data('editor');
-        const _newSize = _snippet.aceSize() + (ui.offset.top - initialResizePosition);
-        _cm.setSize('99%', _newSize);
-        if (setSize) {
-          _snippet.aceSize(_newSize);
-        }
-      };
+    const draggableHelper = (el, e, ui, setSize) => {
+      const _snippet = ko.dataFor(el.parents('.snippet')[0]);
+      const _cm = $('#snippet_' + _snippet.id()).data('editor');
+      const _newSize = _snippet.aceSize() + (ui.offset.top - initialResizePosition);
+      _cm.setSize('99%', _newSize);
+      if (setSize) {
+        _snippet.aceSize(_newSize);
+      }
+    };
 
-      const getDraggableOptions = minY => {
-        return {
-          axis: 'y',
-          start: function (e, ui) {
-            initialResizePosition = ui.offset.top;
-          },
-          drag: function (e, ui) {
-            draggableHelper($(this), e, ui);
-            $('.jHueTableExtenderClonedContainer').hide();
-            $('.jHueTableExtenderClonedContainerColumn').hide();
-            $('.jHueTableExtenderClonedContainerCell').hide();
-            $('.fixed-header-row').hide();
-            $('.fixed-first-cell').hide();
-            $('.fixed-first-column').hide();
-          },
-          stop: function (e, ui) {
-            $('.jHueTableExtenderClonedContainer').show();
-            $('.jHueTableExtenderClonedContainerColum').show();
-            $('.jHueTableExtenderClonedContainerCell').show();
-            $('.fixed-header-row').show();
-            $('.fixed-first-cell').show();
-            $('.fixed-first-column').show();
-            draggableHelper($(this), e, ui, true);
-            redrawFixedHeaders();
-            ui.helper.first().removeAttr('style');
-          },
-          containment: [0, minY, 4000, minY + 400]
-        };
+    const getDraggableOptions = minY => {
+      return {
+        axis: 'y',
+        start: function (e, ui) {
+          initialResizePosition = ui.offset.top;
+        },
+        drag: function (e, ui) {
+          draggableHelper($(this), e, ui);
+          $('.jHueTableExtenderClonedContainer').hide();
+          $('.jHueTableExtenderClonedContainerColumn').hide();
+          $('.jHueTableExtenderClonedContainerCell').hide();
+          $('.fixed-header-row').hide();
+          $('.fixed-first-cell').hide();
+          $('.fixed-first-column').hide();
+        },
+        stop: function (e, ui) {
+          $('.jHueTableExtenderClonedContainer').show();
+          $('.jHueTableExtenderClonedContainerColum').show();
+          $('.jHueTableExtenderClonedContainerCell').show();
+          $('.fixed-header-row').show();
+          $('.fixed-first-cell').show();
+          $('.fixed-first-column').show();
+          draggableHelper($(this), e, ui, true);
+          redrawFixedHeaders();
+          ui.helper.first().removeAttr('style');
+        },
+        containment: [0, minY, 4000, minY + 400]
       };
-
-      $('.resize-panel a').each(function () {
-        $(this).draggable(getDraggableOptions($(this).parents('.snippet').offset().top + 128));
-      });
-
-      const resetResultsResizer = snippet => {
-        const $snippet = $('#snippet_' + snippet.id());
+    };
+
+    $('.resize-panel a').each(function () {
+      $(this).draggable(getDraggableOptions($(this).parents('.snippet').offset().top + 128));
+    });
+
+    const resetResultsResizer = snippet => {
+      const $snippet = $('#snippet_' + snippet.id());
+      $snippet
+        .find('.table-results .column-side')
+        .width(hueUtils.bootstrapRatios.span3() + '%')
+        .data('newWidth', hueUtils.bootstrapRatios.span3());
+      if (snippet.isResultSettingsVisible()) {
         $snippet
-          .find('.table-results .column-side')
-          .width(hueUtils.bootstrapRatios.span3() + '%')
-          .data('newWidth', hueUtils.bootstrapRatios.span3());
-        if (snippet.isResultSettingsVisible()) {
-          $snippet
-            .find('.table-results .grid-side')
-            .data('newWidth', hueUtils.bootstrapRatios.span9())
-            .width(hueUtils.bootstrapRatios.span9() + '%');
-        } else {
-          $snippet.find('.table-results .grid-side').data('newWidth', 100).width('100%');
-        }
-        $snippet.find('.resize-bar').css('left', '');
-        try {
-          $snippet.find('.resize-bar').draggable('destroy');
-        } catch (e) {}
+          .find('.table-results .grid-side')
+          .data('newWidth', hueUtils.bootstrapRatios.span9())
+          .width(hueUtils.bootstrapRatios.span9() + '%');
+      } else {
+        $snippet.find('.table-results .grid-side').data('newWidth', 100).width('100%');
+      }
+      $snippet.find('.resize-bar').css('left', '');
+      try {
+        $snippet.find('.resize-bar').draggable('destroy');
+      } catch (e) {}
 
-        let initialPosition = 0;
+      let initialPosition = 0;
 
-        $snippet.find('.resize-bar').draggable({
-          axis: 'x',
-          containment: $snippet.find('.table-results'),
-          create: function () {
-            const $snip = $('#snippet_' + snippet.id());
+      $snippet.find('.resize-bar').draggable({
+        axis: 'x',
+        containment: $snippet.find('.table-results'),
+        create: function () {
+          const $snip = $('#snippet_' + snippet.id());
+          initialPosition = $snip.find('.resize-bar').position().left;
+          $snip
+            .find('.table-results .column-side')
+            .data('newWidth', hueUtils.bootstrapRatios.span3());
+          $snip.find('.meta-filter').width($snip.find('.table-results .column-side').width() - 28);
+        },
+        drag: function (event, ui) {
+          const $snip = $('#snippet_' + snippet.id());
+          if (initialPosition === 0) {
             initialPosition = $snip.find('.resize-bar').position().left;
-            $snip
-              .find('.table-results .column-side')
-              .data('newWidth', hueUtils.bootstrapRatios.span3());
-            $snip
-              .find('.meta-filter')
-              .width($snip.find('.table-results .column-side').width() - 28);
-          },
-          drag: function (event, ui) {
-            const $snip = $('#snippet_' + snippet.id());
-            if (initialPosition === 0) {
-              initialPosition = $snip.find('.resize-bar').position().left;
-            }
-            ui.position.left = Math.max(150, ui.position.left);
-            const newSpan3Width =
-              (ui.position.left * hueUtils.bootstrapRatios.span3()) / initialPosition;
-            const newSpan9Width = 100 - newSpan3Width - hueUtils.bootstrapRatios.margin();
-            $snip
-              .find('.table-results .column-side')
-              .width(newSpan3Width + '%')
-              .data('newWidth', newSpan3Width);
-            $snip
-              .find('.table-results .grid-side')
-              .width(newSpan9Width + '%')
-              .data('newWidth', newSpan9Width);
-            $snip
-              .find('.meta-filter')
-              .width($snip.find('.table-results .column-side').width() - 28);
-          },
-          stop: function () {
-            redrawFixedHeaders();
-            huePubSub.publish('resize.leaflet.map');
           }
-        });
-      };
-
-      const resizeToggleResultSettings = (snippet, initial) => {
-        let _dtElement;
-        const $snip = $('#snippet_' + snippet.id());
-        if (snippet.showGrid()) {
-          _dtElement = $snip.find('.dataTables_wrapper');
-          const topCoord =
-            viewModel.isPresentationMode() || viewModel.isResultFullScreenMode()
-              ? window.BANNER_TOP_HTML
-                ? 31
-                : 1
-              : 73;
-          $snip.find('.snippet-grid-settings').css({
-            height:
-              viewModel.isPresentationMode() || !viewModel.editorMode()
-                ? '330px'
-                : Math.ceil(
-                    $(window).height() -
-                      Math.max(
-                        $('.result-settings').length > 0 ? $('.result-settings').offset().top : 0,
-                        topCoord
-                      )
-                  ) + 'px'
-          });
-        } else {
-          _dtElement = $snip.find('.chart:visible');
-        }
-        if (_dtElement.length === 0) {
-          _dtElement = $snip.find('.table-results');
-        }
-        _dtElement
-          .parents('.snippet-body')
-          .find('.toggle-result-settings')
-          .css({
-            height: _dtElement.height() - 30 + 'px',
-            'line-height': _dtElement.height() - 30 + 'px'
-          });
-        if (initial) {
-          $snip.find('.result-settings').css({
-            marginTop: 0
-          });
-          $snip.find('.snippet-actions').css({
-            marginTop: 0
-          });
+          ui.position.left = Math.max(150, ui.position.left);
+          const newSpan3Width =
+            (ui.position.left * hueUtils.bootstrapRatios.span3()) / initialPosition;
+          const newSpan9Width = 100 - newSpan3Width - hueUtils.bootstrapRatios.margin();
+          $snip
+            .find('.table-results .column-side')
+            .width(newSpan3Width + '%')
+            .data('newWidth', newSpan3Width);
+          $snip
+            .find('.table-results .grid-side')
+            .width(newSpan9Width + '%')
+            .data('newWidth', newSpan9Width);
+          $snip.find('.meta-filter').width($snip.find('.table-results .column-side').width() - 28);
+        },
+        stop: function () {
+          redrawFixedHeaders();
           huePubSub.publish('resize.leaflet.map');
         }
-      };
-
-      const forceChartDraws = initial => {
-        if (viewModel.selectedNotebook()) {
-          viewModel
-            .selectedNotebook()
-            .snippets()
-            .forEach(snippet => {
-              if (snippet.result.data().length > 0) {
-                let _elCheckerInterval = -1;
-                const _el = $('#snippet_' + snippet.id());
-                _elCheckerInterval = window.setInterval(() => {
-                  if (_el.find('.resultTable').length > 0) {
-                    try {
-                      resizeToggleResultSettings(snippet, initial);
-                      resetResultsResizer(snippet);
-                      $(document).trigger('forceChartDraw', snippet);
-                    } catch (e) {}
-                    window.clearInterval(_elCheckerInterval);
-                  }
-                }, 200);
-              }
-            });
-        }
-      };
-
-      forceChartDraws(true);
-
-      // ======== PubSub ========
-
-      let splitDraggableTimeout = -1;
-      huePubSub.subscribe(
-        'split.draggable.position',
-        () => {
-          window.clearTimeout(splitDraggableTimeout);
-          splitDraggableTimeout = window.setTimeout(() => {
-            redrawFixedHeaders(100);
-          }, 200);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'redraw.fixed.headers',
-        () => {
-          hideFixedHeaders();
-          redrawFixedHeaders(200);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'app.gained.focus',
-        app => {
-          if (app === 'editor') {
-            huePubSub.publish('redraw.fixed.headers');
-            huePubSub.publish('hue.scrollleft.show');
-            huePubSub.publish(ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT, viewModel.activeConnector());
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'current.query.tab.switched',
-        tab => {
-          if (tab !== 'queryResults') {
-            $('.hue-datatable-search').hide();
-          }
-          if (tab === 'queryHistory') {
-            hueUtils.waitForRendered(
-              $('#queryHistory .history-table'),
-              el => {
-                return el.is(':visible');
-              },
-              () => {
-                viewModel.selectedNotebook().forceHistoryInitialHeight(true);
-                huePubSub.publish('editor.calculate.history.height');
-              }
-            );
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+      });
+    };
+
+    const resizeToggleResultSettings = (snippet, initial) => {
+      let _dtElement;
+      const $snip = $('#snippet_' + snippet.id());
+      if (snippet.showGrid()) {
+        _dtElement = $snip.find('.dataTables_wrapper');
+        const topCoord =
+          viewModel.isPresentationMode() || viewModel.isResultFullScreenMode()
+            ? window.BANNER_TOP_HTML
+              ? 31
+              : 1
+            : 73;
+        $snip.find('.snippet-grid-settings').css({
+          height:
+            viewModel.isPresentationMode() || !viewModel.editorMode()
+              ? '330px'
+              : Math.ceil(
+                  $(window).height() -
+                    Math.max(
+                      $('.result-settings').length > 0 ? $('.result-settings').offset().top : 0,
+                      topCoord
+                    )
+                ) + 'px'
+        });
+      } else {
+        _dtElement = $snip.find('.chart:visible');
+      }
+      if (_dtElement.length === 0) {
+        _dtElement = $snip.find('.table-results');
+      }
+      _dtElement
+        .parents('.snippet-body')
+        .find('.toggle-result-settings')
+        .css({
+          height: _dtElement.height() - 30 + 'px',
+          'line-height': _dtElement.height() - 30 + 'px'
+        });
+      if (initial) {
+        $snip.find('.result-settings').css({
+          marginTop: 0
+        });
+        $snip.find('.snippet-actions').css({
+          marginTop: 0
+        });
+        huePubSub.publish('resize.leaflet.map');
+      }
+    };
+
+    const forceChartDraws = initial => {
+      if (viewModel.selectedNotebook()) {
+        viewModel
+          .selectedNotebook()
+          .snippets()
+          .forEach(snippet => {
+            if (snippet.result.data().length > 0) {
+              let _elCheckerInterval = -1;
+              const _el = $('#snippet_' + snippet.id());
+              _elCheckerInterval = window.setInterval(() => {
+                if (_el.find('.resultTable').length > 0) {
+                  try {
+                    resizeToggleResultSettings(snippet, initial);
+                    resetResultsResizer(snippet);
+                    $(document).trigger('forceChartDraw', snippet);
+                  } catch (e) {}
+                  window.clearInterval(_elCheckerInterval);
+                }
+              }, 200);
+            }
+          });
+      }
+    };
 
-      huePubSub.subscribe(
-        'detach.scrolls',
-        snippet => {
-          let scrollElement = $('#snippet_' + snippet.id()).find('.dataTables_wrapper');
-          if (viewModel.editorMode()) {
-            scrollElement = $(window.MAIN_SCROLLABLE);
-          }
-          if (scrollElement.data('scrollFnDt')) {
-            scrollElement.off('scroll', scrollElement.data('scrollFnDt'));
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+    forceChartDraws(true);
 
-      huePubSub.subscribe(
-        'editor.calculate.history.height',
-        () => {
-          if (
-            viewModel.editorMode() &&
-            (viewModel.selectedNotebook().historyInitialHeight() === 0 ||
-              viewModel.selectedNotebook().forceHistoryInitialHeight())
-          ) {
-            let h = $('#queryHistory .history-table').height();
-            if (h === 0) {
-              h = viewModel.selectedNotebook().history().length * 32;
-            }
-            viewModel.selectedNotebook().historyInitialHeight(h + 80); // add pagination too
-            viewModel.selectedNotebook().forceHistoryInitialHeight(false);
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+    // ======== PubSub ========
 
-      huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_EDITOR_ID);
+    let splitDraggableTimeout = -1;
+    huePubSub.subscribe(
+      'split.draggable.position',
+      () => {
+        window.clearTimeout(splitDraggableTimeout);
+        splitDraggableTimeout = window.setTimeout(() => {
+          redrawFixedHeaders(100);
+        }, 200);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
 
-      if (viewModel.isOptimizerEnabled()) {
-        if (window.OPTIMIZER_AUTO_UPLOAD_QUERIES) {
-          huePubSub.subscribe(
-            'editor.upload.query',
-            query_id => {
-              viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
-            },
-            HUE_PUB_SUB_EDITOR_ID
-          );
+    huePubSub.subscribe(
+      'redraw.fixed.headers',
+      () => {
+        hideFixedHeaders();
+        redrawFixedHeaders(200);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'app.gained.focus',
+      app => {
+        if (app === 'editor') {
+          huePubSub.publish('redraw.fixed.headers');
+          huePubSub.publish('hue.scrollleft.show');
+          huePubSub.publish(ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT, viewModel.activeConnector());
         }
-
-        if (window.OPTIMIZER_AUTO_UPLOAD_DDL) {
-          huePubSub.subscribe(
-            'editor.upload.table.stats',
-            options => {
-              viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'current.query.tab.switched',
+      tab => {
+        if (tab !== 'queryResults') {
+          $('.hue-datatable-search').hide();
+        }
+        if (tab === 'queryHistory') {
+          hueUtils.waitForRendered(
+            $('#queryHistory .history-table'),
+            el => {
+              return el.is(':visible');
             },
-            HUE_PUB_SUB_EDITOR_ID
+            () => {
+              viewModel.selectedNotebook().forceHistoryInitialHeight(true);
+              huePubSub.publish('editor.calculate.history.height');
+            }
           );
         }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'detach.scrolls',
+      snippet => {
+        let scrollElement = $('#snippet_' + snippet.id()).find('.dataTables_wrapper');
+        if (viewModel.editorMode()) {
+          scrollElement = $(window.MAIN_SCROLLABLE);
+        }
+        if (scrollElement.data('scrollFnDt')) {
+          scrollElement.off('scroll', scrollElement.data('scrollFnDt'));
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
 
-        if (window.OPTIMIZER_QUERY_HISTORY_UPLOAD_LIMIT !== 0) {
-          huePubSub.subscribe(
-            'editor.upload.history',
-            () => {
-              viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
-            },
-            HUE_PUB_SUB_EDITOR_ID
-          );
+    huePubSub.subscribe(
+      'editor.calculate.history.height',
+      () => {
+        if (
+          viewModel.editorMode() &&
+          (viewModel.selectedNotebook().historyInitialHeight() === 0 ||
+            viewModel.selectedNotebook().forceHistoryInitialHeight())
+        ) {
+          let h = $('#queryHistory .history-table').height();
+          if (h === 0) {
+            h = viewModel.selectedNotebook().history().length * 32;
+          }
+          viewModel.selectedNotebook().historyInitialHeight(h + 80); // add pagination too
+          viewModel.selectedNotebook().forceHistoryInitialHeight(false);
         }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_EDITOR_ID);
+
+    if (viewModel.isOptimizerEnabled()) {
+      if (window.OPTIMIZER_AUTO_UPLOAD_QUERIES) {
+        huePubSub.subscribe(
+          'editor.upload.query',
+          query_id => {
+            viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
+          },
+          HUE_PUB_SUB_EDITOR_ID
+        );
       }
 
-      huePubSub.subscribe(
-        'get.selected.notebook',
-        () => {
-          huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+      if (window.OPTIMIZER_AUTO_UPLOAD_DDL) {
+        huePubSub.subscribe(
+          'editor.upload.table.stats',
+          options => {
+            viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
+          },
+          HUE_PUB_SUB_EDITOR_ID
+        );
+      }
 
-      huePubSub.subscribe(
-        SHOW_LEFT_ASSIST_EVENT,
-        () => {
-          if (!viewModel.isLeftPanelVisible() && viewModel.assistAvailable()) {
-            viewModel.isLeftPanelVisible(true);
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+      if (window.OPTIMIZER_QUERY_HISTORY_UPLOAD_LIMIT !== 0) {
+        huePubSub.subscribe(
+          'editor.upload.history',
+          () => {
+            viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
+          },
+          HUE_PUB_SUB_EDITOR_ID
+        );
+      }
+    }
 
-      huePubSub.subscribe(
-        'assist.set.manual.visibility',
-        () => {
+    huePubSub.subscribe(
+      'get.selected.notebook',
+      () => {
+        huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      SHOW_LEFT_ASSIST_EVENT,
+      () => {
+        if (!viewModel.isLeftPanelVisible() && viewModel.assistAvailable()) {
+          viewModel.isLeftPanelVisible(true);
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'assist.set.manual.visibility',
+      () => {
+        wasLeftPanelVisible = viewModel.isLeftPanelVisible();
+        wasRightPanelVisible = viewModel.isRightPanelVisible();
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.presentation.operate.toggle',
+      value => {
+        viewModel.isEditing(!viewModel.isEditing());
+        if (value) {
+          $('.jHueNotify').remove();
+          isAssistAvailable = viewModel.assistAvailable();
           wasLeftPanelVisible = viewModel.isLeftPanelVisible();
           wasRightPanelVisible = viewModel.isRightPanelVisible();
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
 
-      huePubSub.subscribe(
-        'editor.presentation.operate.toggle',
-        value => {
-          viewModel.isEditing(!viewModel.isEditing());
-          if (value) {
-            $('.jHueNotify').remove();
-            isAssistAvailable = viewModel.assistAvailable();
-            wasLeftPanelVisible = viewModel.isLeftPanelVisible();
-            wasRightPanelVisible = viewModel.isRightPanelVisible();
-
-            if (wasResultFullScreenMode) {
-              huePubSub.publish('both.assists.hide', true);
-            } else {
-              huePubSub.publish('right.assist.hide', true);
-            }
-
-            viewModel.assistWithoutStorage(true);
-            viewModel.assistAvailable(false);
-            viewModel.isLeftPanelVisible(true);
-            viewModel.isRightPanelVisible(false);
-            window.setTimeout(() => {
-              viewModel.assistWithoutStorage(false);
-            }, 0);
-            $('.navigator').hide();
-            $('.add-snippet').hide();
-
-            if (window.BANNER_TOP_HTML) {
-              $('.main-content').attr('style', 'top: 31px !important');
-            } else {
-              $('.main-content').css('top', '1px');
-            }
-            redrawFixedHeaders(200);
-            $(window).bind('keydown', 'esc', exitPlayerMode);
+          if (wasResultFullScreenMode) {
+            huePubSub.publish('both.assists.hide', true);
           } else {
-            hideFixedHeaders();
-            huePubSub.publish('both.assists.show', true);
-            viewModel.assistWithoutStorage(true);
-            viewModel.isLeftPanelVisible(wasLeftPanelVisible);
-            viewModel.isRightPanelVisible(wasRightPanelVisible);
-            viewModel.assistAvailable(isAssistAvailable);
-            window.setTimeout(() => {
-              viewModel.assistWithoutStorage(false);
-            }, 0);
-            $('.navigator').show();
-            $('.add-snippet').show();
-            if (window.BANNER_TOP_HTML) {
-              $('.main-content').css('top', '112px');
-            } else {
-              $('.main-content').css('top', '74px');
-            }
-            redrawFixedHeaders(200);
-            $(window).unbind('keydown', exitPlayerMode);
+            huePubSub.publish('right.assist.hide', true);
           }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'show.retry.modal',
-        data => {
-          $('#retryModal' + window.EDITOR_SUFFIX).modal('show');
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
 
-      huePubSub.subscribe(
-        'hide.retry.modal',
-        data => {
-          $('#retryModal' + window.EDITOR_SUFFIX).modal('hide');
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+          viewModel.assistWithoutStorage(true);
+          viewModel.assistAvailable(false);
+          viewModel.isLeftPanelVisible(true);
+          viewModel.isRightPanelVisible(false);
+          window.setTimeout(() => {
+            viewModel.assistWithoutStorage(false);
+          }, 0);
+          $('.navigator').hide();
+          $('.add-snippet').hide();
 
-      huePubSub.subscribe(
-        'open.link',
-        link => {
-          $(window).unbind('keydown.editor');
-          if (link.indexOf('editor') >= 0) {
-            initKeydownBindings();
+          if (window.BANNER_TOP_HTML) {
+            $('.main-content').attr('style', 'top: 31px !important');
+          } else {
+            $('.main-content').css('top', '1px');
           }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.presentation.toggle',
-        () => {
-          viewModel.selectedNotebook().isPresentationMode(!viewModel.isPresentationMode());
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_EDITOR_ID);
-
-      huePubSub.subscribe(
-        'editor.render.data',
-        options => {
-          const $snip = $('#snippet_' + options.snippet.id());
-          const _el = $snip.find('.resultTable');
-          if (options.data.length > 0) {
-            window.setTimeout(() => {
-              let _dt;
-              if (options.initial) {
-                options.snippet.result.meta.notifySubscribers();
-                $('#snippet_' + options.snippet.id())
-                  .find('select')
-                  .trigger('chosen:updated');
-                _dt = createDatatable(_el, options.snippet, viewModel);
-                resetResultsResizer(options.snippet);
-              } else {
-                _dt = _el.hueDataTable();
-              }
-              try {
-                _dt.fnAddData(options.data);
-              } catch (e) {}
-              const _dtElement = $snip.find('.dataTables_wrapper');
-              huePubSub.publish('editor.snippet.result.normal', options.snippet);
-              _dtElement.scrollTop(_dtElement.data('scrollPosition'));
-              redrawFixedHeaders();
-              resizeToggleResultSettings(options.snippet, options.initial);
-            }, 300);
+          redrawFixedHeaders(200);
+          $(window).bind('keydown', 'esc', exitPlayerMode);
+        } else {
+          hideFixedHeaders();
+          huePubSub.publish('both.assists.show', true);
+          viewModel.assistWithoutStorage(true);
+          viewModel.isLeftPanelVisible(wasLeftPanelVisible);
+          viewModel.isRightPanelVisible(wasRightPanelVisible);
+          viewModel.assistAvailable(isAssistAvailable);
+          window.setTimeout(() => {
+            viewModel.assistWithoutStorage(false);
+          }, 0);
+          $('.navigator').show();
+          $('.add-snippet').show();
+          if (window.BANNER_TOP_HTML) {
+            $('.main-content').css('top', '112px');
           } else {
-            huePubSub.publish('editor.snippet.result.normal', options.snippet);
+            $('.main-content').css('top', '74px');
           }
-          $snip.find('select').trigger('chosen:updated');
-          $snip.find('.snippet-grid-settings').scrollLeft(0);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.redraw.data',
-        options => {
-          hueUtils.waitForRendered(
-            '#snippet_' + options.snippet.id() + ' .resultTable',
-            el => {
-              return el.is(':visible');
-            },
-            () => {
-              const $el = $('#snippet_' + options.snippet.id()).find('.resultTable');
-              const dt = createDatatable($el, options.snippet, viewModel);
-              dt.fnAddData(options.snippet.result.data());
+          redrawFixedHeaders(200);
+          $(window).unbind('keydown', exitPlayerMode);
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'show.retry.modal',
+      data => {
+        $('#retryModal' + window.EDITOR_SUFFIX).modal('show');
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'hide.retry.modal',
+      data => {
+        $('#retryModal' + window.EDITOR_SUFFIX).modal('hide');
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'open.link',
+      link => {
+        $(window).unbind('keydown.editor');
+        if (link.indexOf('editor') >= 0) {
+          initKeydownBindings();
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.presentation.toggle',
+      () => {
+        viewModel.selectedNotebook().isPresentationMode(!viewModel.isPresentationMode());
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_EDITOR_ID);
+
+    huePubSub.subscribe(
+      'editor.render.data',
+      options => {
+        const $snip = $('#snippet_' + options.snippet.id());
+        const _el = $snip.find('.resultTable');
+        if (options.data.length > 0) {
+          window.setTimeout(() => {
+            let _dt;
+            if (options.initial) {
+              options.snippet.result.meta.notifySubscribers();
+              $('#snippet_' + options.snippet.id())
+                .find('select')
+                .trigger('chosen:updated');
+              _dt = createDatatable(_el, options.snippet, viewModel);
+              resetResultsResizer(options.snippet);
+            } else {
+              _dt = _el.hueDataTable();
             }
-          );
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.snippet.result.gray',
-        snippet => {
-          const $snippet = $('#snippet_' + snippet.id());
-          $snippet.find('.dataTables_wrapper .fixed-first-column').css({ opacity: '0' });
-          $snippet.find('.dataTables_wrapper .fixed-header-row').css({ opacity: '0' });
-          $snippet.find('.dataTables_wrapper .fixed-first-cell').css({ opacity: '0' });
-          $snippet.find('.dataTables_wrapper .resultTable').css({ opacity: '0.55' });
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.snippet.result.normal',
-        snippet => {
-          const $snippet = $('#snippet_' + snippet.id());
-          $snippet.find('.dataTables_wrapper .fixed-first-column').css({ opacity: '1' });
-          $snippet.find('.dataTables_wrapper .fixed-header-row').css({ opacity: '1' });
-          $snippet.find('.dataTables_wrapper .fixed-first-cell').css({ opacity: '1' });
-          $snippet.find('.dataTables_wrapper .resultTable').css({ opacity: '1' });
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'render.jqcron',
-        () => {
-          if (typeof window.renderJqCron !== 'undefined') {
-            window.renderJqCron();
+            try {
+              _dt.fnAddData(options.data);
+            } catch (e) {}
+            const _dtElement = $snip.find('.dataTables_wrapper');
+            huePubSub.publish('editor.snippet.result.normal', options.snippet);
+            _dtElement.scrollTop(_dtElement.data('scrollPosition'));
+            redrawFixedHeaders();
+            resizeToggleResultSettings(options.snippet, options.initial);
+          }, 300);
+        } else {
+          huePubSub.publish('editor.snippet.result.normal', options.snippet);
+        }
+        $snip.find('select').trigger('chosen:updated');
+        $snip.find('.snippet-grid-settings').scrollLeft(0);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.redraw.data',
+      options => {
+        hueUtils.waitForRendered(
+          '#snippet_' + options.snippet.id() + ' .resultTable',
+          el => {
+            return el.is(':visible');
+          },
+          () => {
+            const $el = $('#snippet_' + options.snippet.id()).find('.resultTable');
+            const dt = createDatatable($el, options.snippet, viewModel);
+            dt.fnAddData(options.snippet.result.data());
           }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'submit.popup.return',
-        data => {
-          viewModel.selectedNotebook().viewSchedulerId(data.job_id);
-          $('.submit-modal-editor').modal('hide');
-          huePubSub.publish('show.jobs.panel', { id: data.job_id, interface: data.type });
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
+        );
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
 
-      huePubSub.subscribe(
-        'jobbrowser.data',
-        jobs => {
-          viewModel.withActiveSnippet(snippet => {
-            if (!snippet || snippet.type() === 'impala') {
-              return;
-            }
-            if (jobs.length > 0) {
-              let progress = 0;
-              let parent;
-              jobs.forEach(job => {
-                const id = job.shortId || job.id;
-                const el = $('.jobs-overlay li:contains(' + id + ')');
-                if (!el.length) {
-                  return;
-                }
-                const context = ko.contextFor(el[0]);
-                parent = context.$parent;
-                const _job = context.$data;
-                progress = parseInt(job.mapsPercentComplete);
-                if (isNaN(progress)) {
-                  progress = parseInt(job.progress);
-                }
-                if (!isNaN(progress)) {
-                  _job.percentJob(progress);
-                } else {
-                  progress = 0;
-                }
-              });
-              if (parent && parent.jobs().length === 1) {
-                parent.progress(Math.max(progress, parent.progress()));
+    huePubSub.subscribe(
+      'editor.snippet.result.gray',
+      snippet => {
+        const $snippet = $('#snippet_' + snippet.id());
+        $snippet.find('.dataTables_wrapper .fixed-first-column').css({ opacity: '0' });
+        $snippet.find('.dataTables_wrapper .fixed-header-row').css({ opacity: '0' });
+        $snippet.find('.dataTables_wrapper .fixed-first-cell').css({ opacity: '0' });
+        $snippet.find('.dataTables_wrapper .resultTable').css({ opacity: '0.55' });
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.snippet.result.normal',
+      snippet => {
+        const $snippet = $('#snippet_' + snippet.id());
+        $snippet.find('.dataTables_wrapper .fixed-first-column').css({ opacity: '1' });
+        $snippet.find('.dataTables_wrapper .fixed-header-row').css({ opacity: '1' });
+        $snippet.find('.dataTables_wrapper .fixed-first-cell').css({ opacity: '1' });
+        $snippet.find('.dataTables_wrapper .resultTable').css({ opacity: '1' });
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'render.jqcron',
+      () => {
+        if (typeof window.renderJqCron !== 'undefined') {
+          window.renderJqCron();
+        }
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'submit.popup.return',
+      data => {
+        viewModel.selectedNotebook().viewSchedulerId(data.job_id);
+        $('.submit-modal-editor').modal('hide');
+        huePubSub.publish('show.jobs.panel', { id: data.job_id, interface: data.type });
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'jobbrowser.data',
+      jobs => {
+        viewModel.withActiveSnippet(snippet => {
+          if (!snippet || snippet.type() === 'impala') {
+            return;
+          }
+          if (jobs.length > 0) {
+            let progress = 0;
+            let parent;
+            jobs.forEach(job => {
+              const id = job.shortId || job.id;
+              const el = $('.jobs-overlay li:contains(' + id + ')');
+              if (!el.length) {
+                return;
               }
-            }
-          });
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.get.active.risks',
-        callback => {
-          const result = {
-            editor: undefined,
-            risks: {}
-          };
-          if (viewModel.selectedNotebook()) {
-            if (viewModel.selectedNotebook().snippets().length === 1) {
-              result.editor = viewModel.selectedNotebook().snippets()[0].ace();
-              result.risks = viewModel.selectedNotebook().snippets()[0].complexity() || {};
-            } else {
-              viewModel
-                .selectedNotebook()
-                .snippets()
-                .every(snippet => {
-                  if (snippet.inFocus()) {
-                    result.editor = snippet.ace();
-                    result.risks = snippet.complexity() || {};
-                    return false;
-                  }
-                  return true;
-                });
+              const context = ko.contextFor(el[0]);
+              parent = context.$parent;
+              const _job = context.$data;
+              progress = parseInt(job.mapsPercentComplete);
+              if (isNaN(progress)) {
+                progress = parseInt(job.progress);
+              }
+              if (!isNaN(progress)) {
+                _job.percentJob(progress);
+              } else {
+                progress = 0;
+              }
+            });
+            if (parent && parent.jobs().length === 1) {
+              parent.progress(Math.max(progress, parent.progress()));
             }
           }
-          callback(result);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.grid.shown',
-        snippet => {
-          hueUtils.waitForRendered(
-            '#snippet_' + snippet.id() + ' .dataTables_wrapper',
-            el => {
-              return el.is(':visible');
-            },
-            () => {
-              resizeToggleResultSettings(snippet, true);
-              forceChartDraws();
-              $('#snippet_' + snippet.id())
-                .find('.snippet-grid-settings')
-                .scrollLeft(0);
-            }
-          );
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.chart.shown',
-        snippet => {
-          resizeToggleResultSettings(snippet, true);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'recalculate.name.description.width',
-        () => {
-          hueUtils.waitForRendered(
-            '.editorComponents .hue-title-bar .query-name',
-            el => {
-              return el.is(':visible');
-            },
-            () => {
-              let cumulativeWidth = 0;
-              $('.editorComponents .hue-title-bar ul li:not(.skip-width-calculation)').each(
-                function () {
-                  cumulativeWidth += $(this).outerWidth();
-                }
-              );
-              $('.notebook-name-desc').css(
-                'max-width',
-                ($('.editorComponents .hue-title-bar').width() -
-                  cumulativeWidth -
-                  $('.editorComponents .hue-title-bar .pull-right').width() -
-                  120) /
-                  2 +
-                  'px'
-              );
-            }
-          );
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      $(document).on('updateResultHeaders', e => {
-        hideFixedHeaders();
-        redrawFixedHeaders(200);
-      });
-
-      $(document).on('showAuthModal', (e, data) => {
-        viewModel.authSessionUsername(window.LOGGED_USERNAME);
-        viewModel.authSessionMessage(data['message']);
-        viewModel.authSessionPassword('');
-        viewModel.authSessionType(data['type']);
-        viewModel.authSessionCallback(data['callback']);
-        $('#authModal' + window.EDITOR_SUFFIX).modal('show');
-      });
-
-      $(document).on('hideHistoryModal', e => {
-        $('#clearHistoryModal' + window.EDITOR_SUFFIX).modal('hide');
-      });
-
-      $(document).on('toggleResultSettings', (e, snippet) => {
-        window.setTimeout(() => {
-          const $snip = $('#snippet_' + snippet.id());
-          $snip.find('.chart').trigger('forceUpdate');
-          $snip.find('.snippet-grid-settings').scrollLeft(0);
-          if (snippet.isResultSettingsVisible()) {
-            $snip
-              .find('.table-results .grid-side')
-              .width(
-                100 -
-                  $snip.find('.table-results .column-side').data('newWidth') -
-                  hueUtils.bootstrapRatios.margin() +
-                  '%'
-              );
+        });
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.get.active.risks',
+      callback => {
+        const result = {
+          editor: undefined,
+          risks: {}
+        };
+        if (viewModel.selectedNotebook()) {
+          if (viewModel.selectedNotebook().snippets().length === 1) {
+            result.editor = viewModel.selectedNotebook().snippets()[0].ace();
+            result.risks = viewModel.selectedNotebook().snippets()[0].complexity() || {};
           } else {
-            $snip.find('.table-results .grid-side').width('100%');
+            viewModel
+              .selectedNotebook()
+              .snippets()
+              .every(snippet => {
+                if (snippet.inFocus()) {
+                  result.editor = snippet.ace();
+                  result.risks = snippet.complexity() || {};
+                  return false;
+                }
+                return true;
+              });
           }
-          redrawFixedHeaders();
-          $(window).trigger('resize');
-        }, 10);
-      });
-
-      $(document).on('editorSizeChanged', () => {
-        window.setTimeout(forceChartDraws, 50);
-      });
-
-      $(document).on('redrawResults', () => {
-        window.setTimeout(forceChartDraws, 50);
-      });
-
-      $(document).on('executeStarted', (e, options) => {
-        const $snip = $('#snippet_' + options.snippet.id());
-        const $el = $snip.find('.resultTable');
-        if (options.vm.editorMode()) {
-          $('#queryResults').css({
-            height: $el.height() + 'px'
-          });
         }
-        $el.data('scrollToCol', null);
-        $el.data('scrollToRow', null);
-        $snip.find('.progress-snippet').animate(
-          {
-            height: '3px'
+        callback(result);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.grid.shown',
+      snippet => {
+        hueUtils.waitForRendered(
+          '#snippet_' + snippet.id() + ' .dataTables_wrapper',
+          el => {
+            return el.is(':visible');
           },
-          100
+          () => {
+            resizeToggleResultSettings(snippet, true);
+            forceChartDraws();
+            $('#snippet_' + snippet.id())
+              .find('.snippet-grid-settings')
+              .scrollLeft(0);
+          }
         );
-        if ($el.hasClass('dt')) {
-          $el.removeClass('dt');
-          $('#eT' + options.snippet.id() + 'jHueTableExtenderClonedContainer').remove();
-          $('#eT' + options.snippet.id() + 'jHueTableExtenderClonedContainerColumn').remove();
-          $('#eT' + options.snippet.id() + 'jHueTableExtenderClonedContainerCell').remove();
-          if ($el.hueDataTable()) {
-            $el.hueDataTable().fnDestroy();
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'editor.chart.shown',
+      snippet => {
+        resizeToggleResultSettings(snippet, true);
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    huePubSub.subscribe(
+      'recalculate.name.description.width',
+      () => {
+        hueUtils.waitForRendered(
+          '.editorComponents .hue-title-bar .query-name',
+          el => {
+            return el.is(':visible');
+          },
+          () => {
+            let cumulativeWidth = 0;
+            $('.editorComponents .hue-title-bar ul li:not(.skip-width-calculation)').each(
+              function () {
+                cumulativeWidth += $(this).outerWidth();
+              }
+            );
+            $('.notebook-name-desc').css(
+              'max-width',
+              ($('.editorComponents .hue-title-bar').width() -
+                cumulativeWidth -
+                $('.editorComponents .hue-title-bar .pull-right').width() -
+                120) /
+                2 +
+                'px'
+            );
           }
-          $el.find('thead tr').empty();
-          $el.data('lockedRows', {});
+        );
+      },
+      HUE_PUB_SUB_EDITOR_ID
+    );
+
+    $(document).on('updateResultHeaders', e => {
+      hideFixedHeaders();
+      redrawFixedHeaders(200);
+    });
+
+    $(document).on('showAuthModal', (e, data) => {
+      viewModel.authSessionUsername(window.LOGGED_USERNAME);
+      viewModel.authSessionMessage(data['message']);
+      viewModel.authSessionPassword('');
+      viewModel.authSessionType(data['type']);
+      viewModel.authSessionCallback(data['callback']);
+      $('#authModal' + window.EDITOR_SUFFIX).modal('show');
+    });
+
+    $(document).on('hideHistoryModal', e => {
+      $('#clearHistoryModal' + window.EDITOR_SUFFIX).modal('hide');
+    });
+
+    $(document).on('toggleResultSettings', (e, snippet) => {
+      window.setTimeout(() => {
+        const $snip = $('#snippet_' + snippet.id());
+        $snip.find('.chart').trigger('forceUpdate');
+        $snip.find('.snippet-grid-settings').scrollLeft(0);
+        if (snippet.isResultSettingsVisible()) {
+          $snip
+            .find('.table-results .grid-side')
+            .width(
+              100 -
+                $snip.find('.table-results .column-side').data('newWidth') -
+                hueUtils.bootstrapRatios.margin() +
+                '%'
+            );
+        } else {
+          $snip.find('.table-results .grid-side').width('100%');
         }
-      });
-
-      $(document).on('renderDataError', (e, options) => {
-        huePubSub.publish('editor.snippet.result.normal', options.snippet);
-      });
-
-      $(document).on('progress', (e, options) => {
-        if (options.data === 100) {
-          window.setTimeout(() => {
-            $('#snippet_' + options.snippet.id())
-              .find('.progress-snippet')
-              .animate(
-                {
-                  height: '0'
-                },
-                100,
-                () => {
-                  options.snippet.progress(0);
-                  redrawFixedHeaders();
-                }
-              );
-          }, 2000);
+        redrawFixedHeaders();
+        $(window).trigger('resize');
+      }, 10);
+    });
+
+    $(document).on('editorSizeChanged', () => {
+      window.setTimeout(forceChartDraws, 50);
+    });
+
+    $(document).on('redrawResults', () => {
+      window.setTimeout(forceChartDraws, 50);
+    });
+
+    $(document).on('executeStarted', (e, options) => {
+      const $snip = $('#snippet_' + options.snippet.id());
+      const $el = $snip.find('.resultTable');
+      if (options.vm.editorMode()) {
+        $('#queryResults').css({
+          height: $el.height() + 'px'
+        });
+      }
+      $el.data('scrollToCol', null);
+      $el.data('scrollToRow', null);
+      $snip.find('.progress-snippet').animate(
+        {
+          height: '3px'
+        },
+        100
+      );
+      if ($el.hasClass('dt')) {
+        $el.removeClass('dt');
+        $('#eT' + options.snippet.id() + 'jHueTableExtenderClonedContainer').remove();
+        $('#eT' + options.snippet.id() + 'jHueTableExtenderClonedContainerColumn').remove();
+        $('#eT' + options.snippet.id() + 'jHueTableExtenderClonedContainerCell').remove();
+        if ($el.hueDataTable()) {
+          $el.hueDataTable().fnDestroy();
         }
-      });
-
-      $(document).on('forceChartDraw', (e, snippet) => {
-        window.setTimeout(() => {
-          snippet.chartX.notifySubscribers();
-          snippet.chartX.valueHasMutated();
-        }, 100);
-      });
+        $el.find('thead tr').empty();
+        $el.data('lockedRows', {});
+      }
+    });
 
-      let hideTimeout = -1;
-      $(document).on('hideAutocomplete', () => {
-        window.clearTimeout(hideTimeout);
-        hideTimeout = window.setTimeout(() => {
-          const $aceAutocomplete = $('.ace_editor.ace_autocomplete');
-          if ($aceAutocomplete.is(':visible')) {
-            $aceAutocomplete.hide();
-          }
-        }, 100);
-      });
+    $(document).on('renderDataError', (e, options) => {
+      huePubSub.publish('editor.snippet.result.normal', options.snippet);
+    });
 
-      let _resizeTimeout = -1;
-      $(window).on('resize', () => {
-        huePubSub.publish('recalculate.name.description.width');
-        window.clearTimeout(_resizeTimeout);
-        _resizeTimeout = window.setTimeout(() => {
-          forceChartDraws();
-        }, 200);
-      });
-    }
-  });
-}
+    $(document).on('progress', (e, options) => {
+      if (options.data === 100) {
+        window.setTimeout(() => {
+          $('#snippet_' + options.snippet.id())
+            .find('.progress-snippet')
+            .animate(
+              {
+                height: '0'
+              },
+              100,
+              () => {
+                options.snippet.progress(0);
+                redrawFixedHeaders();
+              }
+            );
+        }, 2000);
+      }
+    });
+
+    $(document).on('forceChartDraw', (e, snippet) => {
+      window.setTimeout(() => {
+        snippet.chartX.notifySubscribers();
+        snippet.chartX.valueHasMutated();
+      }, 100);
+    });
+
+    let hideTimeout = -1;
+    $(document).on('hideAutocomplete', () => {
+      window.clearTimeout(hideTimeout);
+      hideTimeout = window.setTimeout(() => {
+        const $aceAutocomplete = $('.ace_editor.ace_autocomplete');
+        if ($aceAutocomplete.is(':visible')) {
+          $aceAutocomplete.hide();
+        }
+      }, 100);
+    });
+
+    let _resizeTimeout = -1;
+    $(window).on('resize', () => {
+      huePubSub.publish('recalculate.name.description.width');
+      window.clearTimeout(_resizeTimeout);
+      _resizeTimeout = window.setTimeout(() => {
+        forceChartDraws();
+      }, 200);
+    });
+  }
+});

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook/snippet.js

@@ -31,7 +31,7 @@ import Session from 'apps/notebook/session';
 import sqlStatementsParser from 'parse/sqlStatementsParser';
 import { SHOW_EVENT as SHOW_GIST_MODAL_EVENT } from 'ko/components/ko.shareGistModal';
 import { cancelActiveRequest } from 'api/apiUtils';
-import { ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT } from 'apps/notebook2/events';
+import { ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT } from 'apps/editor/events';
 import { findEditorConnector } from 'utils/hueConfig';
 import {
   ASSIST_GET_DATABASE_EVENT,

+ 0 - 848
desktop/core/src/desktop/js/apps/notebook2/app.js

@@ -1,848 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import * as ko from 'knockout';
-import $ from 'jquery';
-import Clipboard from 'clipboard';
-import 'jquery-mousewheel';
-import 'ext/bootstrap-datepicker.min';
-import 'ext/jquery.hotkeys';
-import 'jquery/plugins/jquery.hdfstree';
-
-import huePubSub from 'utils/huePubSub';
-import hueUtils from 'utils/hueUtils';
-import I18n from 'utils/i18n';
-import sqlWorkerHandler from 'sql/sqlWorkerHandler';
-
-import {
-  HIDE_FIXED_HEADERS_EVENT,
-  REDRAW_FIXED_HEADERS_EVENT,
-  SHOW_GRID_SEARCH_EVENT,
-  SHOW_NORMAL_RESULT_EVENT,
-  REDRAW_CHART_EVENT,
-  IGNORE_NEXT_UNLOAD_EVENT
-} from 'apps/notebook2/events';
-import { DIALECT } from 'apps/notebook2/snippet';
-import { SHOW_LEFT_ASSIST_EVENT } from 'ko/components/assist/events';
-
-export const initNotebook2 = () => {
-  window.Clipboard = Clipboard;
-
-  const HUE_PUB_SUB_EDITOR_ID =
-    window.location.pathname.indexOf('notebook') > -1 ? 'notebook' : 'editor';
-
-  huePubSub.subscribe('app.dom.loaded', app => {
-    if (app === 'editor' || app === 'notebook') {
-      window.MAIN_SCROLLABLE = '.page-content';
-
-      let isLeftNavOpen = false;
-      huePubSub.subscribe(
-        'left.nav.open.toggle',
-        val => {
-          isLeftNavOpen = val;
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'split.panel.resized',
-        () => {
-          huePubSub.publish('recalculate.name.description.width');
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      const showHoverMsg = e => {
-        let dt = null;
-        if (e) {
-          dt = e.dataTransfer;
-        }
-        if (
-          !isLeftNavOpen &&
-          (!dt ||
-            (dt.types &&
-              (dt.types.indexOf ? dt.types.indexOf('Files') !== -1 : dt.types.contains('Files'))))
-        ) {
-          $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').removeClass('hide');
-        }
-      };
-
-      const hideHoverMsg = vm => {
-        if (vm.editorMode()) {
-          $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverText').html(I18n('Drop a SQL file here'));
-        } else {
-          $(window.EDITOR_BINDABLE_ELEMENT)
-            .find('.hoverText')
-            .html(I18n('Drop iPython/Zeppelin notebooks here'));
-        }
-        $(window.EDITOR_BINDABLE_ELEMENT).find('.hoverMsg').addClass('hide');
-      };
-
-      if (ko.options) {
-        ko.options.deferUpdates = true;
-      }
-
-      let viewModel;
-
-      const replaceAce = content => {
-        const snip = viewModel.selectedNotebook().snippets()[0];
-        if (snip) {
-          snip.statement_raw(content);
-          snip.result.statements_count(1);
-          snip.ace().setValue(content, 1);
-          snip.result.statement_range({
-            start: {
-              row: 0,
-              column: 0
-            },
-            end: {
-              row: 0,
-              column: 0
-            }
-          });
-          snip.ace()._emit('focus');
-        }
-        hideHoverMsg(viewModel);
-        huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-      };
-      window.replaceAce = replaceAce;
-
-      // Drag and drop iPython / Zeppelin notebooks
-      if (window.FileReader) {
-        let aceChecks = 0;
-
-        const addAce = (content, snippetType) => {
-          const snip = viewModel
-            .selectedNotebook()
-            .addSnippet({ type: snippetType, result: {} }, true);
-          snip.statement_raw(content);
-          aceChecks++;
-          snip.checkForAce = window.setInterval(() => {
-            if (snip.ace()) {
-              window.clearInterval(snip.checkForAce);
-              aceChecks--;
-              if (aceChecks === 0) {
-                hideHoverMsg(viewModel);
-                huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-              }
-            }
-          }, 100);
-        };
-
-        const addMarkdown = content => {
-          const snip = viewModel
-            .selectedNotebook()
-            .addSnippet({ type: 'markdown', result: {} }, true);
-          snip.statement_raw(content);
-        };
-
-        const addPySpark = content => {
-          addAce(content, 'pyspark');
-        };
-
-        const addSql = content => {
-          addAce(content, 'hive');
-        };
-
-        const addScala = content => {
-          addAce(content, 'spark');
-        };
-
-        const parseExternalJSON = raw => {
-          try {
-            if (viewModel.editorMode()) {
-              replaceAce(raw);
-            } else {
-              const loaded = typeof raw == 'string' ? JSON.parse(raw) : raw;
-              if (loaded.nbformat) {
-                //ipython
-                let cells = [];
-                if (loaded.nbformat === 3) {
-                  cells = loaded.worksheets[0].cells;
-                } else if (loaded.nbformat === 4) {
-                  cells = loaded.cells;
-                }
-                cells.forEach((cell, cellCnt) => {
-                  window.setTimeout(() => {
-                    if (cell.cell_type === 'code') {
-                      if (loaded.nbformat === 3) {
-                        addPySpark($.isArray(cell.input) ? cell.input.join('') : cell.input);
-                      } else {
-                        addPySpark($.isArray(cell.source) ? cell.source.join('') : cell.source);
-                      }
-                    }
-                    if (cell.cell_type === 'heading') {
-                      let heading = $.isArray(cell.source) ? cell.source.join('') : cell.source;
-                      if (cell.level === 1) {
-                        heading += '\n====================';
-                      } else if (cell.level === 2) {
-                        heading += '\n--------------------';
-                      } else {
-                        heading = '### ' + heading;
-                      }
-                      addMarkdown(heading);
-                    }
-                    if (cell.cell_type === 'markdown') {
-                      addMarkdown($.isArray(cell.source) ? cell.source.join('') : cell.source);
-                    }
-                    if (cellCnt === cells.length - 1 && aceChecks === 0) {
-                      hideHoverMsg(viewModel);
-                    }
-                  }, 10);
-                });
-              }
-
-              if (loaded.paragraphs) {
-                //zeppelin
-                if (loaded.name) {
-                  viewModel.selectedNotebook().name(loaded.name);
-                }
-                loaded.paragraphs.forEach(paragraph => {
-                  if (paragraph.text) {
-                    const content = paragraph.text.split('\n');
-                    if (content[0].indexOf('%md') > -1) {
-                      content.shift();
-                      addMarkdown(content.join('\n'));
-                    } else if (
-                      content[0].indexOf('%sql') > -1 ||
-                      content[0].indexOf('%hive') > -1
-                    ) {
-                      content.shift();
-                      addSql(content.join('\n'));
-                    } else if (content[0].indexOf('%pyspark') > -1) {
-                      content.shift();
-                      addPySpark(content.join('\n'));
-                    } else {
-                      if (content[0].indexOf('%spark') > -1) {
-                        content.shift();
-                      }
-                      addScala(content.join('\n'));
-                    }
-                  }
-                });
-              }
-            }
-          } catch (e) {
-            hideHoverMsg(viewModel);
-            replaceAce(raw);
-          }
-        };
-
-        const handleFileSelect = evt => {
-          evt.stopPropagation();
-          evt.preventDefault();
-          const dt = evt.dataTransfer;
-          const files = dt.files;
-          if (files.length > 0) {
-            showHoverMsg();
-          } else {
-            hideHoverMsg(viewModel);
-          }
-
-          for (let i = 0, f; (f = files[i]); i++) {
-            const reader = new FileReader();
-            reader.onload = (function (file) {
-              return function (e) {
-                $('.hoverText').html("<i class='fa fa-spinner fa-spin'></i>");
-                parseExternalJSON(e.target.result);
-              };
-            })(f);
-            reader.readAsText(f);
-          }
-        };
-
-        const handleDragOver = function (evt) {
-          evt.stopPropagation();
-          evt.preventDefault();
-          evt.dataTransfer.dropEffect = 'copy';
-        };
-
-        const dropZone = $(window.EDITOR_BINDABLE_ELEMENT)[0];
-        dropZone.addEventListener('dragenter', showHoverMsg, false);
-        dropZone.addEventListener('dragover', handleDragOver, false);
-        dropZone.addEventListener('drop', handleFileSelect, false);
-
-        let isDraggingOverText = false;
-
-        $(window.EDITOR_BINDABLE_ELEMENT)
-          .find('.hoverText')
-          .on('dragenter', e => {
-            e.preventDefault();
-            e.stopPropagation();
-            e.stopImmediatePropagation();
-            isDraggingOverText = true;
-          });
-
-        $(window.EDITOR_BINDABLE_ELEMENT)
-          .find('.hoverText')
-          .on('dragleave', e => {
-            e.preventDefault();
-            e.stopPropagation();
-            e.stopImmediatePropagation();
-            isDraggingOverText = false;
-          });
-
-        $(window.EDITOR_BINDABLE_ELEMENT)
-          .find('.hoverMsg')
-          .on('dragleave', e => {
-            if (!isDraggingOverText) {
-              hideHoverMsg(viewModel);
-            }
-          });
-      }
-
-      if (window.EDITOR_ENABLE_QUERY_SCHEDULING) {
-        viewModel = new window.EditorViewModel(
-          window.EDITOR_ID,
-          window.NOTEBOOKS_JSON,
-          window.EDITOR_VIEW_MODEL_OPTIONS,
-          window.CoordinatorEditorViewModel,
-          window.RunningCoordinatorModel
-        );
-      } else {
-        viewModel = new window.EditorViewModel(
-          window.EDITOR_ID,
-          window.NOTEBOOKS_JSON,
-          window.EDITOR_VIEW_MODEL_OPTIONS
-        );
-      }
-      ko.applyBindings(viewModel, $(window.EDITOR_BINDABLE_ELEMENT)[0]);
-      viewModel.init();
-
-      sqlWorkerHandler.registerWorkers();
-
-      viewModel.selectedNotebook.subscribe(newVal => {
-        huePubSub.publish('selected.notebook.changed', newVal);
-      });
-
-      let wasResultFullScreenMode = false;
-      let isAssistAvailable = viewModel.assistAvailable();
-      let wasLeftPanelVisible = viewModel.isLeftPanelVisible();
-      let wasRightPanelVisible = viewModel.isRightPanelVisible();
-
-      const exitPlayerMode = () => {
-        if (!wasResultFullScreenMode) {
-          viewModel.selectedNotebook().isPresentationMode(false);
-        } else {
-          viewModel.isResultFullScreenMode(false);
-        }
-        wasResultFullScreenMode = false;
-      };
-
-      viewModel.isResultFullScreenMode.subscribe(newValue => {
-        wasResultFullScreenMode = newValue;
-        huePubSub.publish('editor.presentation.operate.toggle', newValue);
-      });
-
-      viewModel.isLeftPanelVisible.subscribe(value => {
-        huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-      });
-
-      let ignoreNextUnload = false;
-
-      huePubSub.subscribe(IGNORE_NEXT_UNLOAD_EVENT, () => {
-        ignoreNextUnload = true;
-      });
-
-      // Close the notebook snippets when leaving the page
-      window.onbeforeunload = function (e) {
-        if (ignoreNextUnload) {
-          ignoreNextUnload = false;
-          return;
-        }
-        if (!viewModel.selectedNotebook().avoidClosing) {
-          viewModel.selectedNotebook().close();
-        }
-      };
-      $(window).data('beforeunload', window.onbeforeunload);
-
-      $('.preview-sample').css('right', 10 + hueUtils.scrollbarWidth() + 'px');
-
-      const saveKeyHandler = () => {
-        if (viewModel.canSave()) {
-          viewModel.saveNotebook();
-        } else {
-          $('#saveAsModal' + window.EDITOR_SUFFIX).modal('show');
-        }
-      };
-
-      const newKeyHandler = () => {
-        if (!viewModel.editorMode()) {
-          viewModel.selectedNotebook().newSnippet();
-        } else {
-          viewModel.newNotebook(
-            viewModel.editorType(),
-            null,
-            viewModel.selectedNotebook()
-              ? viewModel.selectedNotebook().snippets()[0].currentQueryTab()
-              : null
-          );
-        }
-      };
-
-      const initKeydownBindings = () => {
-        $(window).bind('keydown.editor', 'ctrl+s alt+s meta+s', e => {
-          e.preventDefault();
-          saveKeyHandler();
-          return false;
-        });
-        $(window).bind('keydown.editor', 'ctrl+shift+p alt+shift+p meta+shift+p', e => {
-          e.preventDefault();
-          huePubSub.publish('editor.presentation.toggle');
-          return false;
-        });
-        $(window).bind('keydown.editor', 'ctrl+e alt+e meta+e', e => {
-          e.preventDefault();
-          newKeyHandler();
-          return false;
-        });
-      };
-
-      if (document.location.href.indexOf('editor') >= 0) {
-        initKeydownBindings();
-      }
-
-      $(document).bind('keyup', e => {
-        if (
-          e.keyCode === 191 &&
-          e.shiftKey &&
-          !$(e.target).is('input') &&
-          !$(e.target).is('textarea')
-        ) {
-          $('#helpModal' + window.EDITOR_SUFFIX).modal('show');
-        }
-
-        if (
-          e.keyCode === 191 &&
-          !e.shiftKey &&
-          !$(e.target).is('input') &&
-          !$(e.target).is('textarea')
-        ) {
-          if (
-            viewModel.editorMode() &&
-            viewModel.selectedNotebook().snippets()[0].currentQueryTab() === 'queryResults'
-          ) {
-            e.preventDefault();
-            huePubSub.publish(SHOW_GRID_SEARCH_EVENT);
-            return false;
-          }
-        }
-      });
-
-      let initialResizePosition = 100;
-
-      const draggableHelper = (el, e, ui, setSize) => {
-        const _snippet = ko.dataFor(el.parents('.snippet')[0]);
-        const _cm = $('#snippet_' + _snippet.id()).data('editor');
-        const _newSize = _snippet.aceSize() + (ui.offset.top - initialResizePosition);
-        _cm.setSize('99%', _newSize);
-        if (setSize) {
-          _snippet.aceSize(_newSize);
-        }
-      };
-
-      const getDraggableOptions = minY => {
-        return {
-          axis: 'y',
-          start: function (e, ui) {
-            initialResizePosition = ui.offset.top;
-            huePubSub.publish(HIDE_FIXED_HEADERS_EVENT);
-          },
-          drag: function (e, ui) {
-            draggableHelper($(this), e, ui);
-          },
-          stop: function (e, ui) {
-            draggableHelper($(this), e, ui, true);
-            huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-            ui.helper.first().removeAttr('style');
-          },
-          containment: [0, minY, 4000, minY + 400]
-        };
-      };
-
-      $('.resize-panel a').each(function () {
-        $(this).draggable(getDraggableOptions($(this).parents('.snippet').offset().top + 128));
-      });
-
-      // ======== PubSub ========
-
-      let splitDraggableTimeout = -1;
-      huePubSub.subscribe(
-        'split.draggable.position',
-        () => {
-          window.clearTimeout(splitDraggableTimeout);
-          splitDraggableTimeout = window.setTimeout(() => {
-            huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-          }, 200);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'app.gained.focus',
-        app => {
-          if (app === 'editor') {
-            huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-            huePubSub.publish('hue.scrollleft.show');
-            viewModel.notifyDialectChange(
-              viewModel.editorType(),
-              viewModel.getSnippetViewSettings(viewModel.editorType()).sqlDialect
-            );
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'current.query.tab.switched',
-        tab => {
-          if (tab !== 'queryResults') {
-            $('.hue-datatable-search').hide();
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_EDITOR_ID);
-
-      if (viewModel.isOptimizerEnabled()) {
-        if (window.OPTIMIZER_AUTO_UPLOAD_QUERIES) {
-          huePubSub.subscribe(
-            'editor.upload.query',
-            query_id => {
-              viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
-            },
-            HUE_PUB_SUB_EDITOR_ID
-          );
-        }
-
-        if (window.OPTIMIZER_AUTO_UPLOAD_DDL) {
-          huePubSub.subscribe(
-            'editor.upload.table.stats',
-            options => {
-              viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
-            },
-            HUE_PUB_SUB_EDITOR_ID
-          );
-        }
-
-        if (window.OPTIMIZER_QUERY_HISTORY_UPLOAD_LIMIT !== 0) {
-          huePubSub.subscribe(
-            'editor.upload.history',
-            () => {
-              viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
-            },
-            HUE_PUB_SUB_EDITOR_ID
-          );
-        }
-      }
-
-      huePubSub.subscribe(
-        'get.selected.notebook',
-        () => {
-          huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        SHOW_LEFT_ASSIST_EVENT,
-        () => {
-          if (!viewModel.isLeftPanelVisible() && viewModel.assistAvailable()) {
-            viewModel.isLeftPanelVisible(true);
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'assist.set.manual.visibility',
-        () => {
-          wasLeftPanelVisible = viewModel.isLeftPanelVisible();
-          wasRightPanelVisible = viewModel.isRightPanelVisible();
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.presentation.operate.toggle',
-        value => {
-          viewModel.isEditing(!viewModel.isEditing());
-          if (value) {
-            $('.jHueNotify').remove();
-            isAssistAvailable = viewModel.assistAvailable();
-            wasLeftPanelVisible = viewModel.isLeftPanelVisible();
-            wasRightPanelVisible = viewModel.isRightPanelVisible();
-
-            if (wasResultFullScreenMode) {
-              huePubSub.publish('both.assists.hide', true);
-            } else {
-              huePubSub.publish('right.assist.hide', true);
-            }
-
-            viewModel.assistWithoutStorage(true);
-            viewModel.assistAvailable(false);
-            viewModel.isLeftPanelVisible(true);
-            viewModel.isRightPanelVisible(false);
-            window.setTimeout(() => {
-              viewModel.assistWithoutStorage(false);
-            }, 0);
-            $('.navigator').hide();
-            $('.add-snippet').hide();
-
-            if (window.BANNER_TOP_HTML) {
-              $('.main-content').attr('style', 'top: 31px !important');
-            } else {
-              $('.main-content').css('top', '1px');
-            }
-            window.setTimeout(() => {
-              huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-            }, 200);
-            $(window).bind('keydown', 'esc', exitPlayerMode);
-          } else {
-            huePubSub.publish(HIDE_FIXED_HEADERS_EVENT);
-            huePubSub.publish('both.assists.show', true);
-            viewModel.assistWithoutStorage(true);
-            viewModel.isLeftPanelVisible(wasLeftPanelVisible);
-            viewModel.isRightPanelVisible(wasRightPanelVisible);
-            viewModel.assistAvailable(isAssistAvailable);
-            window.setTimeout(() => {
-              viewModel.assistWithoutStorage(false);
-            }, 0);
-            $('.navigator').show();
-            $('.add-snippet').show();
-            if (window.BANNER_TOP_HTML) {
-              $('.main-content').css('top', '112px');
-            } else {
-              $('.main-content').css('top', '74px');
-            }
-            window.setTimeout(() => {
-              huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-            }, 200);
-            $(window).unbind('keydown', exitPlayerMode);
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'show.retry.modal',
-        data => {
-          $('#retryModal' + window.EDITOR_SUFFIX).modal('show');
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'hide.retry.modal',
-        data => {
-          $('#retryModal' + window.EDITOR_SUFFIX).modal('hide');
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'open.link',
-        link => {
-          $(window).unbind('keydown.editor');
-          if (link.indexOf('editor') >= 0) {
-            initKeydownBindings();
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.presentation.toggle',
-        () => {
-          viewModel.selectedNotebook().isPresentationMode(!viewModel.isPresentationMode());
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_EDITOR_ID);
-
-      huePubSub.subscribe(
-        'render.jqcron',
-        () => {
-          if (typeof window.renderJqCron !== 'undefined') {
-            window.renderJqCron();
-          }
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'submit.popup.return',
-        data => {
-          viewModel.selectedNotebook().viewSchedulerId(data.job_id);
-          $('.submit-modal-editor').modal('hide');
-          huePubSub.publish('show.jobs.panel', { id: data.job_id, interface: data.type });
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'jobbrowser.data',
-        jobs => {
-          viewModel.withActiveSnippet(snippet => {
-            if (!snippet || snippet.dialect() === DIALECT.impala) {
-              return;
-            }
-            if (jobs.length > 0) {
-              let progress = 0;
-              let parent;
-              jobs.forEach(job => {
-                const id = job.shortId || job.id;
-                const el = $('.jobs-overlay li:contains(' + id + ')');
-                if (!el.length) {
-                  return;
-                }
-                const context = ko.contextFor(el[0]);
-                parent = context.$parent;
-                const _job = context.$data;
-                progress = parseInt(job.mapsPercentComplete);
-                if (isNaN(progress)) {
-                  progress = parseInt(job.progress);
-                }
-                if (!isNaN(progress)) {
-                  _job.percentJob(progress);
-                } else {
-                  progress = 0;
-                }
-              });
-              if (parent && parent.jobs().length === 1) {
-                parent.progress(Math.max(progress, parent.progress()));
-              }
-            }
-          });
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'editor.get.active.risks',
-        callback => {
-          const result = {
-            editor: undefined,
-            risks: {}
-          };
-          if (viewModel.selectedNotebook()) {
-            if (viewModel.selectedNotebook().snippets().length === 1) {
-              result.editor = viewModel.selectedNotebook().snippets()[0].ace();
-              result.risks = viewModel.selectedNotebook().snippets()[0].complexity() || {};
-            } else {
-              viewModel
-                .selectedNotebook()
-                .snippets()
-                .every(snippet => {
-                  if (snippet.inFocus()) {
-                    result.editor = snippet.ace();
-                    result.risks = snippet.complexity() || {};
-                    return false;
-                  }
-                  return true;
-                });
-            }
-          }
-          callback(result);
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      huePubSub.subscribe(
-        'recalculate.name.description.width',
-        () => {
-          hueUtils.waitForRendered(
-            '.editorComponents .hue-title-bar .query-name',
-            el => {
-              return el.is(':visible');
-            },
-            () => {
-              let cumulativeWidth = 0;
-              $('.editorComponents .hue-title-bar ul li:not(.skip-width-calculation)').each(
-                function () {
-                  cumulativeWidth += $(this).outerWidth();
-                }
-              );
-              $('.notebook-name-desc').css(
-                'max-width',
-                ($('.editorComponents .hue-title-bar').width() -
-                  cumulativeWidth -
-                  $('.editorComponents .hue-title-bar .pull-right').width() -
-                  120) /
-                  2 +
-                  'px'
-              );
-            }
-          );
-        },
-        HUE_PUB_SUB_EDITOR_ID
-      );
-
-      $(document).on('updateResultHeaders', e => {
-        huePubSub.publish(HIDE_FIXED_HEADERS_EVENT);
-        window.setTimeout(() => {
-          huePubSub.publish(REDRAW_FIXED_HEADERS_EVENT);
-        }, 200);
-      });
-
-      $(document).on('showAuthModal', (e, data) => {
-        viewModel.authSessionUsername(window.LOGGED_USERNAME);
-        viewModel.authSessionMessage(data['message']);
-        viewModel.authSessionPassword('');
-        viewModel.authSessionType(data['type']);
-        viewModel.authSessionCallback(data['callback']);
-        $('#authModal' + window.EDITOR_SUFFIX).modal('show');
-      });
-
-      $(document).on('hideHistoryModal', e => {
-        $('#clearHistoryModal' + window.EDITOR_SUFFIX).modal('hide');
-      });
-
-      $(document).on('editorSizeChanged', () => {
-        window.setTimeout(() => {
-          huePubSub.publish(REDRAW_CHART_EVENT);
-        }, 50);
-      });
-
-      $(document).on('redrawResults', () => {
-        window.setTimeout(() => {
-          huePubSub.publish(REDRAW_CHART_EVENT);
-        }, 50);
-      });
-
-      $(document).on('renderDataError', (e, options) => {
-        huePubSub.publish(SHOW_NORMAL_RESULT_EVENT);
-      });
-
-      let hideTimeout = -1;
-      $(document).on('hideAutocomplete', () => {
-        window.clearTimeout(hideTimeout);
-        hideTimeout = window.setTimeout(() => {
-          const $aceAutocomplete = $('.ace_editor.ace_autocomplete');
-          if ($aceAutocomplete.is(':visible')) {
-            $aceAutocomplete.hide();
-          }
-        }, 100);
-      });
-
-      $(window).on('resize', () => {
-        huePubSub.publish('recalculate.name.description.width');
-      });
-    }
-  });
-};

+ 1 - 1
desktop/core/src/desktop/js/catalog/api.ts

@@ -16,7 +16,7 @@
 
 import { Cancellable, CancellablePromise } from 'api/cancellablePromise';
 import { DefaultApiResponse, extractErrorMessage, post, successResponseIsError } from 'api/utils';
-import { closeSession, ExecutionHandle } from 'apps/notebook2/execution/api';
+import { closeSession, ExecutionHandle } from 'apps/editor/execution/api';
 import DataCatalogEntry, {
   Analysis,
   FieldSample,

+ 1 - 1
desktop/core/src/desktop/js/components/SqlText.vue

@@ -28,7 +28,7 @@
   import Component from 'vue-class-component';
   import { Prop, Watch } from 'vue-property-decorator';
 
-  import { formatSql } from 'apps/notebook2/api';
+  import { formatSql } from 'apps/editor/api';
   import { hueLocalStorage } from 'utils/storageUtils';
 
   interface Ace {

+ 2 - 7
desktop/core/src/desktop/js/hue.js

@@ -65,8 +65,7 @@ import SidePanelViewModel from 'sidePanelViewModel';
 import TopNavViewModel from 'topNavViewModel';
 
 // TODO: Remove from global scope
-import EditorViewModel from 'apps/notebook/editorViewModel'; // In history, indexer, importer, editor etc.
-import EditorViewModel2 from 'apps/notebook2/editorViewModel'; // In history, indexer, importer, editor etc.
+import NotebookViewModel from 'apps/notebook/NotebookViewModel'; // In history, indexer, importer, editor etc.
 import HdfsAutocompleter from 'utils/hdfsAutocompleter';
 import SqlAutocompleter from 'sql/sqlAutocompleter';
 import sqlStatementsParser from 'parse/sqlStatementsParser'; // In search.ko and notebook.ko
@@ -88,11 +87,7 @@ window.dataCatalog = dataCatalog;
 window.DOCUMENT_TYPE_I18n = DOCUMENT_TYPE_I18n;
 window.DOCUMENT_TYPES = DOCUMENT_TYPES;
 window.Dropzone = Dropzone;
-if (window.ENABLE_NOTEBOOK_2) {
-  window.EditorViewModel = EditorViewModel2;
-} else {
-  window.EditorViewModel = EditorViewModel;
-}
+window.NotebookViewModel = NotebookViewModel;
 window.filesize = filesize;
 window.getLastKnownConfig = getLastKnownConfig;
 window.HdfsAutocompleter = HdfsAutocompleter;

+ 1 - 1
desktop/core/src/desktop/js/jest/jest.init.js

@@ -18,7 +18,7 @@
 import 'core-js/stable';
 import 'regenerator-runtime/runtime';
 
-import 'apps/notebook2/execution/sessionManager';
+import 'apps/editor/execution/sessionManager';
 import './jquery.setup';
 import './sqlTestUtils';
 

+ 1 - 1
desktop/core/src/desktop/js/ko/bindings/ace/aceGutterHandler.js

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import huePubSub from 'utils/huePubSub';
-import { EXECUTABLE_UPDATED_EVENT } from 'apps/notebook2/execution/executable';
+import { EXECUTABLE_UPDATED_EVENT } from 'apps/editor/execution/executable';
 import { ACTIVE_STATEMENT_CHANGED_EVENT } from 'ko/bindings/ace/aceLocationHandler';
 import AceAnchoredRange from 'ko/bindings/ace/aceAnchoredRange';
 

+ 4 - 10
desktop/core/src/desktop/js/ko/bindings/ace/aceLocationHandler.js

@@ -17,7 +17,7 @@
 import $ from 'jquery';
 import ace from 'ext/aceHelper';
 
-import { DIALECT } from 'apps/notebook2/snippet';
+import { DIALECT } from 'apps/editor/snippet';
 import dataCatalog from 'catalog/dataCatalog';
 import AssistStorageEntry from 'ko/components/assist/assistStorageEntry';
 import sqlStatementsParser from 'parse/sqlStatementsParser';
@@ -65,7 +65,7 @@ class AceLocationHandler {
     self.attachSqlWorker();
     self.attachMouseListeners();
 
-    self.dialect = () => (window.ENABLE_NOTEBOOK_2 ? self.snippet.dialect() : self.snippet.type());
+    self.dialect = () => self.snippet.type();
 
     self.verifyThrottle = -1;
 
@@ -526,7 +526,7 @@ class AceLocationHandler {
         }
       }
 
-      if (cursorChange && activeStatement && !window.ENABLE_NOTEBOOK_2) {
+      if (cursorChange && activeStatement) {
         // Don't update when cursor stays in the same statement
         if (isPointInside(activeStatement.location, cursorLocation)) {
           return;
@@ -629,7 +629,6 @@ class AceLocationHandler {
     let cursorChangePaused = false; // On change the cursor is also moved, this limits the calls while typing
 
     let lastStart;
-    let lastEnd;
     let lastCursorPosition;
     const changeSelectionListener = self.editor.on('changeSelection', () => {
       if (cursorChangePaused) {
@@ -652,15 +651,10 @@ class AceLocationHandler {
 
         // The active statement is initially the top one in the selection, batch execution updates this.
         const newStart = self.editor.getSelectionRange().start;
-        const newEnd = self.editor.getSelectionRange().end;
-        if (
-          (self.snippet.isSqlDialect() && (!lastStart || !equalPositions(lastStart, newStart))) ||
-          (window.ENABLE_NOTEBOOK_2 && (!lastEnd || !equalPositions(lastEnd, newEnd)))
-        ) {
+        if (self.snippet.isSqlDialect() && (!lastStart || !equalPositions(lastStart, newStart))) {
           window.clearTimeout(updateThrottle);
           updateActiveStatement(true);
           lastStart = newStart;
-          lastEnd = newEnd;
         }
       }, 100);
     });

+ 7 - 18
desktop/core/src/desktop/js/ko/bindings/ace/ko.aceEditor.js

@@ -18,7 +18,6 @@ import $ from 'jquery';
 import * as ko from 'knockout';
 import ace from 'ext/aceHelper';
 
-import AceLocationHandlerV2 from 'apps/notebook2/components/aceEditor/AceLocationHandler';
 import AceLocationHandler, {
   REFRESH_STATEMENT_LOCATIONS_EVENT
 } from 'ko/bindings/ace/aceLocationHandler';
@@ -69,18 +68,12 @@ registerBinding(NAME, {
       resizePubSub.remove();
     });
 
-    const aceLocationHandler = window.ENABLE_NOTEBOOK_2
-      ? new AceLocationHandlerV2({
-          editor: editor,
-          editorId: $el.attr('id'),
-          executor: snippet.executor
-        })
-      : new AceLocationHandler({
-          editor: editor,
-          editorId: $el.attr('id'),
-          snippet: snippet,
-          i18n: { expandStar: options.expandStar, contextTooltip: options.contextTooltip }
-        });
+    const aceLocationHandler = new AceLocationHandler({
+      editor: editor,
+      editorId: $el.attr('id'),
+      snippet: snippet,
+      i18n: { expandStar: options.expandStar, contextTooltip: options.contextTooltip }
+    });
 
     const aceGutterHandler = new AceGutterHandler({
       editor: editor,
@@ -453,11 +446,7 @@ registerBinding(NAME, {
       // automagically change snippet type
       // TODO: Remove completely, check if used in code, '% dialect'
       const firstLine = editor.session.getLine(0);
-      if (
-        !window.ENABLE_NOTEBOOK_2 &&
-        firstLine.indexOf('%') === 0 &&
-        firstLine.charAt(firstLine.length - 1) === ' '
-      ) {
+      if (firstLine.indexOf('%') === 0 && firstLine.charAt(firstLine.length - 1) === ' ') {
         const availableSnippets = snippet.availableSnippets;
         let removeFirstLine = false;
         for (let i = 0; i < availableSnippets.length; i++) {

+ 1 - 1
desktop/core/src/desktop/js/ko/components/assist/ko.rightAssistPanel.js

@@ -21,7 +21,7 @@ import {
   ASSIST_LANG_REF_SHOW_TOPIC_EVENT,
   SHOW_RIGHT_ASSIST_EVENT
 } from './events';
-import { ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT } from 'apps/notebook2/events';
+import { ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT } from 'apps/editor/events';
 import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';

+ 4 - 4
desktop/core/src/desktop/js/ko/components/contextPopover/ko.quickQueryContext.js

@@ -19,14 +19,14 @@ import * as ko from 'knockout';
 import { MULTI_NAME as SIMPLE_ACE_MULTI } from 'ko/components/simpleAceEditor/ko.simpleAceEditor';
 import { CONTEXT_SELECTOR_COMPONENT } from 'ko/components/ko.contextSelector';
 import { HUE_DROP_DOWN_COMPONENT } from 'ko/components/ko.dropDown';
-import { SIMPLE_RESULT_GRID_COMPONENT } from 'apps/notebook2/components/resultGrid/ko.simpleResultGrid';
+import { SIMPLE_RESULT_GRID_COMPONENT } from 'apps/editor/components/resultGrid/ko.simpleResultGrid';
 
-import 'apps/notebook2/components/ExecutableActionsKoBridge.vue';
+import 'apps/editor/components/ExecutableActionsKoBridge.vue';
 
 import componentUtils from 'ko/components/componentUtils';
 import DisposableComponent from 'ko/components/DisposableComponent';
-import Executor from 'apps/notebook2/execution/executor';
-import SqlExecutable from 'apps/notebook2/execution/sqlExecutable';
+import Executor from 'apps/editor/execution/executor';
+import SqlExecutable from 'apps/editor/execution/sqlExecutable';
 import sqlStatementsParser from 'parse/sqlStatementsParser';
 import { CONFIG_REFRESHED_EVENT, filterEditorConnectors } from 'utils/hueConfig';
 

+ 2 - 2
desktop/core/src/desktop/js/ko/components/ko.historyPanel.js

@@ -18,7 +18,7 @@ import $ from 'jquery';
 import * as ko from 'knockout';
 
 import dataCatalog from 'catalog/dataCatalog';
-import EditorViewModel from 'apps/notebook/editorViewModel';
+import NotebookViewModel from 'apps/notebook/NotebookViewModel';
 import componentUtils from './componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
@@ -169,7 +169,7 @@ class HistoryPanel {
       self.historyPanelVisible(false);
     });
 
-    self.editorViewModel = new EditorViewModel(null, '', {
+    self.editorViewModel = new NotebookViewModel(null, '', {
       user: window.LOGGED_USERNAME,
       userId: window.LOGGED_USER_ID,
       languages: [

+ 1 - 1
desktop/core/src/desktop/js/ko/components/ko.sessionAuthModal.js

@@ -20,7 +20,7 @@ import * as ko from 'knockout';
 import componentUtils from './componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 
 export const SHOW_EVENT = 'show.session.auth.modal';
 export const SHOWN_EVENT = 'session.auth.modal.shown';

+ 1 - 1
desktop/core/src/desktop/js/ko/components/ko.sessionAuthModal.test.js

@@ -18,7 +18,7 @@ import { SHOWN_EVENT, SHOW_EVENT } from './ko.sessionAuthModal';
 import huePubSub from 'utils/huePubSub';
 
 import 'ext/bootstrap.2.3.2.min';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 import { simulateInput } from 'jest/koTestUtils';
 
 describe('ko.sessionAuthModal.js', () => {

+ 1 - 1
desktop/core/src/desktop/js/ko/components/ko.sessionPanel.js

@@ -24,7 +24,7 @@ import apiHelper from 'api/apiHelper';
 import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 
 export const NAME = 'session-panel';
 export const SESSION_PANEL_SHOW_EVENT = 'session.panel.show';

+ 1 - 1
desktop/core/src/desktop/js/ko/components/ko.sessionPanel.test.js

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import huePubSub from 'utils/huePubSub';
-import sessionManager from 'apps/notebook2/execution/sessionManager';
+import sessionManager from 'apps/editor/execution/sessionManager';
 import { koSetup } from 'jest/koTestUtils';
 import { NAME, SESSION_PANEL_SHOW_EVENT } from './ko.sessionPanel';
 

+ 1 - 1
desktop/core/src/desktop/js/sidePanelViewModel.js

@@ -19,7 +19,7 @@ import * as ko from 'knockout';
 
 import hueAnalytics from 'utils/hueAnalytics';
 import huePubSub from 'utils/huePubSub';
-import { ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT } from 'apps/notebook2/events';
+import { ACTIVE_SNIPPET_CONNECTOR_CHANGED_EVENT } from 'apps/editor/events';
 import { SHOW_LEFT_ASSIST_EVENT, SHOW_RIGHT_ASSIST_EVENT } from 'ko/components/assist/events';
 import { getFromLocalStorage, setInLocalStorage } from 'utils/storageUtils';
 

+ 2 - 2
desktop/core/src/desktop/js/sql/autocompleteResults.js

@@ -25,7 +25,7 @@ import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 import sqlUtils from 'sql/sqlUtils';
 import { matchesType } from 'sql/reference/typeUtils';
-import { DIALECT } from 'apps/notebook2/snippet';
+import { DIALECT } from 'apps/editor/snippet';
 import { cancelActiveRequest } from 'api/apiUtils';
 import { findBrowserConnector, getRootFilePath } from 'utils/hueConfig';
 import {
@@ -253,7 +253,7 @@ class AutocompleteResults {
    */
   constructor(options) {
     this.snippet = options.snippet;
-    this.dialect = () => (window.ENABLE_NOTEBOOK_2 ? this.snippet.dialect() : this.snippet.type());
+    this.dialect = () => this.snippet.type();
     this.editor = options.editor;
     this.temporaryOnly =
       options.snippet.autocompleteSettings && options.snippet.autocompleteSettings.temporaryOnly;

+ 1 - 1
desktop/core/src/desktop/js/sql/sqlUtils.ts

@@ -24,7 +24,7 @@ import { isReserved } from 'sql/reference/sqlReferenceRepository';
 import {
   CommentDetails,
   Suggestion
-} from 'apps/notebook2/components/aceEditor/autocomplete/AutocompleteResults';
+} from 'apps/editor/components/aceEditor/autocomplete/AutocompleteResults';
 import { Compute, Connector, Namespace } from 'types/config';
 
 const identifierEquals = (a?: string, b?: string): boolean =>

+ 0 - 24
desktop/core/src/desktop/static/desktop/js/ko.editor.js

@@ -1,24 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-  var EditorViewModel = function () {
-    console.log('ko editor model loaded');
-  };
-
-  ko.components.register('editor', {
-    viewModel: EditorViewModel,
-    template: { require: 'text!/ko_editor' }
-  });

+ 0 - 24
desktop/core/src/desktop/static/desktop/js/ko.metastore.js

@@ -1,24 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-  var EditorViewModel = function () {
-    console.log('ko metastore model loaded');
-  };
-
-  ko.components.register('metastore', {
-    viewModel: EditorViewModel,
-    template: { require: 'text!/ko_metastore' }
-  });

+ 0 - 3
desktop/core/src/desktop/templates/hue.mako

@@ -139,9 +139,6 @@ ${ hueIcons.symbols() }
             <select data-bind="options: clusters, optionsText: 'name', value: 'id'" class="input-small" style="margin-top:8px">
             </select>
           % endif
-          <!-- ko if: window.ENABLE_NOTEBOOK_2 -->
-            <!-- ko component: 'quick-query-action' --><!-- /ko -->
-          <!-- /ko -->
           <!-- ko component: 'hue-history-panel' --><!-- /ko -->
           <!-- ko if: hasJobBrowser -->
             <!-- ko component: { name: 'hue-job-browser-links', params: { onePageViewModel: onePageViewModel }} --><!-- /ko -->

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -2863,7 +2863,7 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
             self.jobId(resp.handle.id);
             $('#importerNotebook').html($('#importerNotebook-progress').html());
 
-            self.editorVM = new EditorViewModel(resp.history_uuid, '', {
+            self.editorVM = new window.NotebookViewModel(resp.history_uuid, '', {
               user: '${ user.username }',
               userId: ${ user.id },
               languages: [{name: "Java", type: "java"}, {name: "Hive SQL", type: "hive"}], // TODO reuse

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/indexer.mako

@@ -842,7 +842,7 @@ ${ commonheader(_("Solr Indexes"), "search", user, request, "60px") | n,unicode
           self.editorId(resp.history_id);
           self.jobId(resp.handle.id);
           $('#notebook').html($('#notebook-progress').html());
-          self.editorVM = new EditorViewModel(resp.history_uuid, '', {
+          self.editorVM = new window.NotebookViewModel(resp.history_uuid, '', {
             user: '${ user.username }',
             userId: ${ user.id },
             languages: [{name: "Java SQL", type: "java"}],

+ 0 - 16
desktop/libs/notebook/src/notebook/templates/editor.mako

@@ -18,34 +18,18 @@
 
   from desktop.views import commonfooter, commonshare
   from desktop import conf
-
-  from notebook.conf import ENABLE_NOTEBOOK_2
 %>
 
 <%namespace name="configKoComponents" file="/config_ko_components.mako" />
 <%namespace name="editorComponents" file="editor_components.mako" />
-<%namespace name="editorComponents2" file="editor_components2.mako" />
 <%namespace name="notebookKoComponents" file="/common_notebook_ko_components.mako" />
 <%namespace name="hueAceAutocompleter" file="/hue_ace_autocompleter.mako" />
 
 <div id="editorComponents" class="editorComponents notebook">
-% if ENABLE_NOTEBOOK_2.get():
-<div style="display: flex; flex-direction:column; height: 100%; width: 100%">
-  <div style="flex: 0 0 auto;">
-  ${ editorComponents2.includes(is_embeddable=is_embeddable, suffix='editor') }
-  ${ editorComponents2.topBar(suffix='editor') }
-  </div>
-  <div style="flex: 1;">
-  ${ editorComponents2.commonHTML(is_embeddable=is_embeddable, suffix='editor') }
-  </div>
-  ${ editorComponents2.commonJS(is_embeddable=is_embeddable, suffix='editor') }
-</div>
-% else:
   ${ editorComponents.includes(is_embeddable=is_embeddable, suffix='editor') }
   ${ editorComponents.topBar(suffix='editor') }
   ${ editorComponents.commonHTML(is_embeddable=is_embeddable, suffix='editor') }
   ${ editorComponents.commonJS(is_embeddable=is_embeddable, suffix='editor') }
-% endif
 </div>
 
 % if not is_embeddable:

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor2.mako

@@ -41,7 +41,7 @@
 % endif
 <script src="${ static('desktop/js/ko.common-dashboard.js') }" type="text/javascript" charset="utf-8"></script>
 
-% for bundle in get_hue_bundles('notebook'):
+% for bundle in get_hue_bundles('editor'):
   ${ render_bundle(bundle) | n,unicode }
 % endfor
 

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_m.mako

@@ -300,7 +300,7 @@ ${ commonheader_m(editor_type, editor_type, user, request, "68px") | n,unicode }
       }
     }
 
-    viewModel = new EditorViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS);
+    viewModel = new window.NotebookViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS);
     ko.applyBindings(viewModel);
     viewModel.init();
   });

+ 0 - 1
desktop/libs/notebook/src/notebook/templates/notebook.mako

@@ -19,7 +19,6 @@
   from desktop.views import commonfooter, commonshare
 
   from django.utils.translation import ugettext as _
-  from notebook.conf import ENABLE_NOTEBOOK_2
 %>
 
 <%namespace name="configKoComponents" file="/config_ko_components.mako" />

+ 1 - 0
webpack.config.js

@@ -26,6 +26,7 @@ const config = {
   devtool: false,
   entry: {
     hue: ['./desktop/core/src/desktop/js/hue.js'],
+    editor: ['./desktop/core/src/desktop/js/apps/editor/app.js'],
     notebook: ['./desktop/core/src/desktop/js/apps/notebook/app.js'],
     tableBrowser: ['./desktop/core/src/desktop/js/apps/tableBrowser/app.js'],
     jobBrowser: ['./desktop/core/src/desktop/js/apps/jobBrowser/app.js']

+ 1 - 1
webpack.config.npm.js

@@ -47,7 +47,7 @@ const npmSetupPlugins = [
 const webComponentsConfig = Object.assign({}, defaultConfig, {
   entry: {
     'er-diagram': [`${JS_ROOT}/components/er-diagram/webcomp.ts`],
-    'query-editor': [`${JS_ROOT}/apps/notebook2/components/aceEditor/QueryEditorWebComponent.ts`]
+    'query-editor': [`${JS_ROOT}/apps/editor/components/aceEditor/QueryEditorWebComponent.ts`]
   },
   output: {
     path: `${DIST_DIR}/components`