Pārlūkot izejas kodu

[editor] Remove mako variables for editor id and notebooks as well as the old notebooks listing page (#3657)

In this commit I'm removing the editor_id and notebooks that gets set from the backend when opening the editor. The editor ID is now taken from the url parameter and notebooks isn't actually used anymore.

As part of this I'm also removing the notebooks listing page which should be considered dead code as it's no longer reachable from the UI or via URL.

This is part of the effort of removing inline script and our goal of moving towards CSR.
Johan Åhlén 1 gadu atpakaļ
vecāks
revīzija
1f30a3a4b2

+ 4 - 7
desktop/core/src/desktop/js/apps/editor/EditorViewModel.js

@@ -35,13 +35,11 @@ import changeURLParameter from 'utils/url/changeURLParameter';
 import getParameter from 'utils/url/getParameter';
 
 export default class EditorViewModel {
-  constructor(editorId, notebooks, options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
+  constructor(options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
     // eslint-disable-next-line no-restricted-syntax
     console.log('Editor v2 enabled.');
 
-    this.editorId = editorId;
     this.snippetViewSettings = options.snippetViewSettings;
-    this.notebooks = notebooks;
 
     this.URLS = {
       editor: '/hue/editor',
@@ -313,14 +311,13 @@ export default class EditorViewModel {
   }
 
   async init() {
-    if (this.editorId) {
-      await this.openNotebook(this.editorId);
+    const editorId = getParameter('editor');
+    if (editorId) {
+      await this.openNotebook(editorId);
     } else if (getParameter('gist') !== '' || getParameter('type') !== '') {
       await this.newNotebook(getParameter('type'));
     } else if (getParameter('editor') !== '') {
       await this.openNotebook(getParameter('editor'));
-    } else if (this.notebooks.length > 0) {
-      this.loadNotebook(this.notebooks[0]); // Old way of loading json for /browse
     } else {
       await this.newNotebook();
     }

+ 30 - 0
desktop/core/src/desktop/js/apps/editor/EditorViewModel.test.js

@@ -0,0 +1,30 @@
+// 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 EditorViewModel from './EditorViewModel';
+import changeURLParameter from 'utils/url/changeURLParameter';
+
+describe('EditorViewModel.js', () => {
+  it('should load the document if opened with an ID in the "editor" url parameter', async () => {
+    changeURLParameter('editor', '123');
+    const vm = new EditorViewModel({});
+    const spy = jest.spyOn(vm, 'openNotebook').mockImplementation(() => Promise.resolve());
+
+    await vm.init();
+
+    expect(spy).toHaveBeenCalledWith('123');
+  });
+});

+ 1 - 7
desktop/core/src/desktop/js/apps/editor/app.js

@@ -303,18 +303,12 @@ huePubSub.subscribe('app.dom.loaded', app => {
 
     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
-      );
+      viewModel = new EditorViewModel(window.EDITOR_VIEW_MODEL_OPTIONS);
     }
     ko.applyBindings(viewModel, $(window.EDITOR_BINDABLE_ELEMENT)[0]);
     viewModel.init();

+ 4 - 5
desktop/core/src/desktop/js/apps/notebook/NotebookViewModel.js

@@ -37,7 +37,7 @@ import getParameter from 'utils/url/getParameter';
 import UUID from 'utils/string/UUID';
 
 export default class NotebookViewModel {
-  constructor(editor_id, notebooks, options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
+  constructor(options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
     const self = this;
 
     self.URLS = {
@@ -450,14 +450,13 @@ export default class NotebookViewModel {
     };
 
     self.init = function () {
-      if (editor_id) {
-        self.openNotebook(editor_id);
+      const editorId = options?.editorId || getParameter('editor');
+      if (editorId) {
+        self.openNotebook(editorId);
       } else if (getParameter('gist') !== '') {
         self.newNotebook(getParameter('type'));
       } else if (getParameter('editor') !== '') {
         self.openNotebook(getParameter('editor'));
-      } else if (notebooks.length > 0) {
-        self.loadNotebook(notebooks[0]); // Old way of loading json for /browse
       } else if (getParameter('type') !== '') {
         self.newNotebook(getParameter('type'));
       } else {

+ 39 - 0
desktop/core/src/desktop/js/apps/notebook/NotebookViewModel.test.js

@@ -0,0 +1,39 @@
+// 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 NotebookViewModel from './NotebookViewModel';
+import changeURLParameter from 'utils/url/changeURLParameter';
+
+describe('NotebookViewModel.js', () => {
+  it('should load the document if opened with an ID in the "editor" url parameter', async () => {
+    changeURLParameter('editor', '123');
+    const vm = new NotebookViewModel({});
+    const spy = jest.spyOn(vm, 'openNotebook').mockImplementation(() => Promise.resolve());
+
+    vm.init();
+
+    expect(spy).toHaveBeenCalledWith('123');
+  });
+
+  it('should load the document if opened with an "editorId" option', async () => {
+    const vm = new NotebookViewModel({ editorId: '234' });
+    const spy = jest.spyOn(vm, 'openNotebook').mockImplementation(() => Promise.resolve());
+
+    vm.init();
+
+    expect(spy).toHaveBeenCalledWith('234');
+  });
+});

+ 1 - 7
desktop/core/src/desktop/js/apps/notebook/app.js

@@ -542,18 +542,12 @@ huePubSub.subscribe('app.dom.loaded', app => {
 
     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
-      );
+      viewModel = new NotebookViewModel(window.EDITOR_VIEW_MODEL_OPTIONS);
     }
     ko.applyBindings(viewModel, $(window.EDITOR_BINDABLE_ELEMENT)[0]);
     viewModel.init();

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

@@ -169,7 +169,7 @@ class HistoryPanel {
       self.historyPanelVisible(false);
     });
 
-    self.editorViewModel = new NotebookViewModel(null, '', {
+    self.editorViewModel = new NotebookViewModel({
       user: window.LOGGED_USERNAME,
       userId: window.LOGGED_USER_ID,
       languages: [

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

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

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

@@ -846,7 +846,8 @@ ${ 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 window.NotebookViewModel(resp.history_uuid, '', {
+          self.editorVM = new window.NotebookViewModel({
+            editorId: resp.history_uuid,
             user: '${ user.username }',
             userId: ${ user.id },
             languages: [{name: "Java SQL", type: "java"}],

+ 0 - 4
desktop/libs/notebook/src/notebook/templates/editor2.mako

@@ -1289,10 +1289,6 @@ There is no bridge to KO for components using this integration. Example using in
 
   window.EDITOR_ENABLE_QUERY_SCHEDULING = '${ ENABLE_QUERY_SCHEDULING.get() }' === 'True';
 
-  window.EDITOR_ID = ${ editor_id or 'null' };
-
-  window.NOTEBOOKS_JSON = ${ notebooks_json | n,unicode };
-
   window.SQL_ANALYZER_AUTO_UPLOAD_QUERIES = '${ OPTIMIZER.AUTO_UPLOAD_QUERIES.get() }' === 'True';
 
   window.SQL_ANALYZER_AUTO_UPLOAD_DDL = '${ OPTIMIZER.AUTO_UPLOAD_DDL.get() }' === 'True';

+ 0 - 4
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -2260,10 +2260,6 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
 
   window.EDITOR_ENABLE_QUERY_SCHEDULING = '${ ENABLE_QUERY_SCHEDULING.get() }' === 'True';
 
-  window.EDITOR_ID = ${ editor_id or 'null' };
-
-  window.NOTEBOOKS_JSON = ${ notebooks_json | n,unicode };
-
   window.SQL_ANALYZER_AUTO_UPLOAD_QUERIES = '${ OPTIMIZER.AUTO_UPLOAD_QUERIES.get() }' === 'True';
 
   window.SQL_ANALYZER_AUTO_UPLOAD_DDL = '${ OPTIMIZER.AUTO_UPLOAD_DDL.get() }' === 'True';

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

@@ -173,6 +173,7 @@ ${ commonheader_m(editor_type, editor_type, user, request, "68px") | n,unicode }
   ace.config.set("basePath", "${ static('desktop/js/ace') }");
 
   var VIEW_MODEL_OPTIONS = $.extend(${ options_json | n,unicode }, {
+    editorId: ${ editor_id or 'null' },
     user: '${ user.username }',
     userId: ${ user.id },
     assistAvailable: true,
@@ -305,7 +306,7 @@ ${ commonheader_m(editor_type, editor_type, user, request, "68px") | n,unicode }
       }
     }
 
-    viewModel = new window.NotebookViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS);
+    viewModel = new window.NotebookViewModel(VIEW_MODEL_OPTIONS);
     ko.applyBindings(viewModel);
     viewModel.init();
   });

+ 0 - 302
desktop/libs/notebook/src/notebook/templates/notebooks.mako

@@ -1,302 +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 sys
-  from desktop.views import commonheader, commonfooter, commonimportexport, _ko
-  if sys.version_info[0] > 2:
-    from django.utils.translation import gettext as _
-  else:
-    from django.utils.translation import ugettext as _
-%>
-<%namespace name="actionbar" file="actionbar.mako" />
-
-${ commonheader(_("Notebooks"), "spark", user, request, "60px") | n,unicode }
-
-
-<div class="navbar hue-title-bar" data-bind="visible: ! $root.isPresentationMode()">
-  <div class="navbar-inner">
-    <div class="container-fluid">
-      <div class="nav-collapse">
-        <ul class="nav editor-nav">
-          <li class="app-header">
-              <a href="${ url('notebook:editor') }?type=${ editor_type }" title="${ _('%s Editor') % editor_type.title() }" style="cursor: pointer">
-              % if editor_type == 'impala':
-                <img src="${ static('impala/art/icon_impala_48.png') }" class="app-icon" alt="${ _('Impala icon') }" />
-                ${ _('Impala Queries') }
-              % elif editor_type == 'rdbms':
-                <img src="${ static('rdbms/art/icon_rdbms_48.png') }" class="app-icon" alt="${ _('DBQuery icon') }" />
-                ${ _('SQL Queries') }
-              % elif editor_type == 'pig':
-                <img src="${ static('pig/art/icon_pig_48.png') }" class="app-icon" alt="${ _('Pig icon') }" />
-                ${ _('Pig Scripts') }
-              % elif editor_type in ('beeswax', 'hive'):
-                <img src="${ static('beeswax/art/icon_beeswax_48.png') }" class="app-icon" alt="${ _('Hive icon') }" />
-                ${ _('Hive Queries') }
-              % else:
-                <img src="${ static('rdbms/art/icon_rdbms_48.png') }" class="app-icon" alt="${ _('DBQuery icon') }" />
-                ${ _('Notebooks') }
-              % endif
-              </a>
-          </li>
-        </ul>
-      </div>
-    </div>
-  </div>
-</div>
-
-
-<div id="editor">
-
-<div class="container-fluid margin-top-20">
-  <div class="card card-small">
-  <%actionbar:render>
-    <%def name="search()">
-      <input id="filterInput" type="text" class="input-xlarge search-query" placeholder="${_('Search for name, description, etc...')}">
-    </%def>
-
-    <%def name="actions()">
-      <div class="btn-toolbar" style="display: inline; vertical-align: middle">
-        <a data-bind="click: function(e){ atLeastOneSelected() ? copy(e) : void(0) }, css: {'btn': true, 'disabled': ! atLeastOneSelected()}">
-          <i class="fa fa-files-o"></i> ${ _('Copy') }
-        </a>
-
-        <a data-bind="click: function() { atLeastOneSelected() ? $('#deleteNotebook').modal('show') : void(0) }, css: {'btn': true, 'disabled': ! atLeastOneSelected() }">
-          <i class="fa fa-times"></i> ${ _('Delete') }
-        </a>
-
-        <a class="share-link btn" rel="tooltip" data-placement="bottom" style="margin-left:20px" data-bind="click: function(e){ oneSelected() ? prepareShareModal(e) : void(0) },
-          attr: {'data-original-title': '${ _ko("Share") } ' + name},
-          css: {'disabled': ! oneSelected(), 'btn': true}">
-          <i class="fa fa-users"></i> ${ _('Share') }
-        </a>
-
-        <a data-bind="click: function() { atLeastOneSelected() ? exportDocuments() : void(0) }, css: {'btn': true, 'disabled': ! atLeastOneSelected() }">
-          <i class="fa fa-download"></i> ${ _('Export') }
-        </a>
-      </div>
-    </%def>
-
-    <%def name="creation()">
-      % if editor_type != 'notebook':
-        <a href="${ url('notebook:editor') }?type=${ editor_type }" class="btn">
-      % else:
-        <a href="${ url('notebook:new') }" class="btn">
-      % endif
-        <i class="fa fa-plus-circle"></i> ${ _('Create') }
-      </a>
-      <a data-bind="click: function() { $('#import-documents').modal('show'); }" class="btn">
-        <i class="fa fa-upload"></i> ${ _('Import') }
-      </a>
-    </%def>
-  </%actionbar:render>
-
-
-  <table id="notebookTable" class="table datatables">
-    <thead>
-      <tr>
-        <th width="1%"><div data-bind="click: selectAll, css: { 'hue-checkbox': true, 'fa': true, 'fa-check': allSelected}" class="select-all"></div></th>
-        <th>${ _('Name') }</th>
-        <th>${ _('Description') }</th>
-        <th>${ _('Owner') }</th>
-        <th style="width: 170px">${ _('Last Modified') }</th>
-      </tr>
-    </thead>
-    <tbody data-bind="foreach: { data: jobs }">
-      <tr>
-        <td data-bind="click: $root.handleSelect" class="center" style="cursor: default" data-row-selector-exclude="true">
-          <div class="hue-checkbox fa" data-bind="multiCheck: '#notebookTable', css: {'fa-check': isSelected }" data-row-selector-exclude="true"></div>
-          <a data-bind="attr: { 'href': absoluteUrl }" data-row-selector="true"></a>
-        </td>
-        <td data-bind="text: name"></td>
-        <td data-bind="text: description"></td>
-        <td data-bind="text: owner"></td>
-        <td data-bind="text: localeFormat(last_modified), attr: { 'data-sort-value': last_modified_ts }" data-type="date"></td>
-      </tr>
-    </tbody>
-  </table>
-
-  </div>
-</div>
-
-
-<div class="hueOverlay" data-bind="visible: isLoading">
-  <i class="fa fa-spinner fa-spin big-spinner"></i>
-</div>
-
-<div id="submit-notebook-modal" class="modal hide"></div>
-
-<div id="deleteNotebook" class="modal hide fade">
-  <form id="deleteNotebookForm" method="POST" data-bind="submit: delete2">
-    ${ csrf_token(request) | n,unicode }
-    <div class="modal-header">
-      <button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">&times;</span></button>
-
-      % if editor_type == 'pig':
-      <h2 id="deleteNotebookMessage" class="modal-title">${ _('Delete the selected script(s)?') }</h2>
-      % elif editor_type in ('beeswax', 'hive', 'rdbms', 'impala'):
-      <!-- ko if: selectedJobs().length == 1 -->
-      <h2 id="deleteNotebookMessage" class="modal-title">${ _('Delete the selected query?') }</h2>
-      <!-- /ko -->
-      <!-- ko if: selectedJobs().length >1 -->
-      <h2 id="deleteNotebookMessage" class="modal-title">${ _('Delete the selected queries?') }</h2>
-      <!-- /ko -->
-      % else:
-      <h2 id="deleteNotebookMessage" class="modal-title">${ _('Delete the selected notebook(s)?') }</h2>
-      % endif
-    </div>
-    <div class="modal-footer">
-      <a href="javascript: void(0)" class="btn" data-dismiss="modal">${ _('No') }</a>
-      <input type="submit" class="btn btn-danger" value="${ _('Yes') }"/>
-    </div>
-  </form>
-</div>
-</div>
-
-${ commonimportexport(request) | n,unicode }
-
-<script src="${ static('desktop/ext/js/datatables-paging-0.1.js') }" type="text/javascript" charset="utf-8"></script>
-
-<script type="text/javascript">
-  var Editor = function () {
-    var self = this;
-
-    self.jobs = ko.mapping.fromJS(${ notebooks_json | n });
-    self.selectedJobs = ko.computed(function() {
-      return $.grep(self.jobs(), function(job) { return job.isSelected(); });
-    });
-    self.isLoading = ko.observable(false);
-
-    self.oneSelected = ko.computed(function() {
-      return self.selectedJobs().length == 1;
-    });
-    self.atLeastOneSelected = ko.computed(function() {
-      return self.selectedJobs().length >= 1;
-    });
-    self.allSelected = ko.observable(false);
-
-    self.handleSelect = function(notebook) {
-      notebook.isSelected(! notebook.isSelected());
-    };
-
-    self.selectAll = function() {
-      self.allSelected(! self.allSelected());
-      ko.utils.arrayForEach(self.jobs(), function (job) {
-        job.isSelected(self.allSelected());
-      });
-    };
-
-    self.datatable = null;
-
-    self.delete2 = function() {
-      $.post("${ url('notebook:delete') }", {
-        "notebooks": ko.mapping.toJSON(self.selectedJobs)
-      }, function() {
-        window.location.reload();
-        $('#deleteNotebook').modal('hide');
-      }).fail(function (xhr, textStatus, errorThrown) {
-        huePubSub.publish('hue.global.error', {message: xhr.responseText});
-      });
-    };
-
-    self.copy = function() {
-      $.post("${ url('notebook:copy') }", {
-        "notebooks": ko.mapping.toJSON(self.selectedJobs)
-      }, function(data) {
-        window.location.reload();
-      }).fail(function (xhr, textStatus, errorThrown) {
-        huePubSub.publish('hue.global.error', {message: xhr.responseText});
-      });
-    };
-
-    self.exportDocuments = function() {
-      $('#export-documents').find('input[name=\'documents\']').val(ko.mapping.toJSON($.map(self.selectedJobs(), function(doc) { return doc.id(); })));
-      $('#export-documents').find('form').submit();
-    };
-
-    self.prepareShareModal = function() {
-      huePubSub.publish('doc.show.share.modal', self.selectedJobs()[0].uuid());
-    };
-  };
-
-  var viewModel;
-
-  $(document).ready(function () {
-    viewModel = new Editor();
-    ko.applyBindings(viewModel, $("#editor")[0]);
-
-    $(document).on("showSubmitPopup", function(event, data){
-      $('#submit-notebook-modal').html(data);
-      $('#submit-notebook-modal').modal('show');
-      $('#submit-notebook-moda').on('hidden', function () {
-        huePubSub.publish('hide.datepicker');
-      });
-    });
-
-    var oTable = $("#notebookTable").dataTable({
-      "sPaginationType":"bootstrap",
-      'iDisplayLength':50,
-      "bLengthChange":false,
-      "sDom": "<'row'r>t<'row-fluid'<'dt-pages'p><'dt-records'i>>",
-      "aoColumns":[
-        { "bSortable":false },
-        null,
-        null,
-        null,
-        { "sSortDataType":"dom-sort-value", "sType":"numeric" }
-      ],
-      "aaSorting":[
-        [4, 'desc'],
-        [1, 'asc' ]
-      ],
-      "oLanguage":{
-        "sEmptyTable":"${_('No data available')}",
-        "sInfo":"${_('Showing _START_ to _END_ of _TOTAL_ entries')}",
-        "sInfoEmpty":"${_('Showing 0 to 0 of 0 entries')}",
-        "sInfoFiltered":"${_('(filtered from _MAX_ total entries)')}",
-        "sZeroRecords":"${_('No matching records')}",
-        "oPaginate":{
-          "sFirst":"${_('First')}",
-          "sLast":"${_('Last')}",
-          "sNext":"${_('Next')}",
-          "sPrevious":"${_('Previous')}"
-        },
-        "bDestroy": true
-      },
-      "fnDrawCallback":function (oSettings) {
-        $("a[data-row-selector='true']").jHueRowSelector();
-      }
-    });
-
-    viewModel.datatable = oTable;
-
-    $("#filterInput").keydown(function (e) {
-      if (e.which == 13) {
-        e.preventDefault();
-        return false;
-      }
-    });
-
-    $("#filterInput").keyup(function () {
-      oTable.fnFilter($(this).val());
-    });
-
-    $("a[data-row-selector='true']").jHueRowSelector();
-  });
-</script>
-
-
-${ commonfooter(request, messages) | n,unicode }

+ 0 - 1
desktop/libs/notebook/src/notebook/urls.py

@@ -30,7 +30,6 @@ urlpatterns = [
   re_path(r'^$', notebook_views.notebook, name='index'),
   re_path(r'^notebook/?$', notebook_views.notebook, name='notebook'),
   re_path(r'^notebook_embeddable/?$', notebook_views.notebook_embeddable, name='notebook_embeddable'),
-  re_path(r'^notebooks/?$', notebook_views.notebooks, name='notebooks'),
   re_path(r'^new/?$', notebook_views.new, name='new'),
   re_path(r'^download/?$', notebook_views.download, name='download'),
   re_path(r'^install_examples/?$', notebook_views.install_examples, name='install_examples'),

+ 0 - 41
desktop/libs/notebook/src/notebook/views.py

@@ -15,15 +15,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from builtins import object
 import json
 import logging
 import sys
 
 from django.urls import reverse
-from django.db.models import Q
 from django.shortcuts import redirect
-from django.views.decorators.clickjacking import xframe_options_exempt
 from django.views.decorators.http import require_POST
 
 from beeswax.data_export import DOWNLOAD_COOKIE_AGE
@@ -34,7 +31,6 @@ from desktop.lib import export_csvxls
 from desktop.lib.connectors.models import Connector
 from desktop.lib.django_util import render, JsonResponse
 from desktop.lib.exceptions_renderable import PopupException
-from desktop.lib.json_utils import JSONEncoderForHTML
 from desktop.models import Document2, Document, FilesystemException, _get_gist_document
 from desktop.views import serve_403_error
 from metadata.conf import has_optimizer, has_catalog, has_workload_analytics
@@ -51,39 +47,8 @@ if sys.version_info[0] > 2:
 else:
   from django.utils.translation import ugettext as _
 
-
 LOG = logging.getLogger()
 
-
-def notebooks(request):
-  editor_type = request.GET.get('type', 'notebook')
-
-  if editor_type != 'notebook':
-    if USE_NEW_EDITOR.get():
-      notebooks = [doc.to_dict() for doc in Document2.objects.documents(
-          user=request.user).search_documents(types=['query-%s' % editor_type])]
-    else:
-      notebooks = [
-        d.content_object.to_dict()
-          for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra__startswith='query'))
-          if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type
-      ]
-  else:
-    if USE_NEW_EDITOR.get():
-      notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['notebook'])]
-    else:
-      notebooks = [
-        d.content_object.to_dict()
-          for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook'))
-          if not d.content_object.is_history
-      ]
-
-  return render('notebooks.mako', request, {
-      'notebooks_json': json.dumps(notebooks, cls=JSONEncoderForHTML),
-      'editor_type': editor_type
-  })
-
-
 @check_document_access_permission
 def notebook(request, is_embeddable=False):
   if not SHOW_NOTEBOOKS.get() or not request.user.has_hue_permission(action="access", app='notebook'):
@@ -99,8 +64,6 @@ def notebook(request, is_embeddable=False):
     LOG.exception('Spark is not enabled')
 
   return render('notebook.mako', request, {
-      'editor_id': notebook_id or None,
-      'notebooks_json': '{}',
       'is_embeddable': request.GET.get('is_embeddable', False),
       'options_json': json.dumps({
           'languages': get_ordered_interpreters(request.user),
@@ -148,8 +111,6 @@ def editor(request, is_mobile=False, is_embeddable=False):
     template = 'editor_m.mako'
 
   return render(template, request, {
-      'editor_id': editor_id or None,
-      'notebooks_json': '{}',
       'is_embeddable': request.GET.get('is_embeddable', False),
       'editor_type': editor_type,
       'options_json': json.dumps({
@@ -208,7 +169,6 @@ def browse(request, database, table, partition_spec=None):
         compute=compute
     )
     return render('editor2.mako' if ENABLE_HUE_5.get() else 'editor.mako', request, {
-        'notebooks_json': json.dumps([editor.get_data()]),
         'options_json': json.dumps({
             'languages': get_ordered_interpreters(request.user),
             'mode': 'editor',
@@ -295,7 +255,6 @@ def execute_and_watch(request):
     raise PopupException(_('Action %s is unknown') % action)
 
   return render('editor2.mako' if ENABLE_HUE_5.get() else 'editor.mako', request, {
-      'notebooks_json': json.dumps([editor.get_data()]),
       'options_json': json.dumps({
           'languages': [{"name": "%s SQL" % editor_type.title(), "type": editor_type}],
           'mode': 'editor',