Browse Source

HUE-6091 [core] Changed notebook to follow the is_embeddable format

Enrico Berti 8 years ago
parent
commit
435f5fb

+ 5 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -516,7 +516,7 @@ ${ assist.assistPanel() }
 
       var EMBEDDABLE_PAGE_URLS = {
         editor: '/notebook/editor?is_embeddable=true',
-        notebook: '/notebook/notebook_embeddable',
+        notebook: '/notebook/notebook?is_embeddable=true',
         metastore: '/metastore/tables/?is_embeddable=true',
         dashboard: '/dashboard/embeddable/new_search',
         oozie_workflow: '/oozie/editor/workflow/new/?is_embeddable=true',
@@ -907,6 +907,10 @@ ${ assist.assistPanel() }
           self.currentApp('editor');
         });
 
+        page('/notebook/notebook', function(ctx){
+          self.currentApp('notebook');
+        });
+
         page('/', function(ctx){
         });
 

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

@@ -54,4 +54,6 @@ ${ hueAceAutocompleter.hueAceAutocompleter() }
 ${ editorComponents.commonJS(is_embeddable) }
 </span>
 
+%if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }
+%endif

+ 10 - 3
desktop/libs/notebook/src/notebook/templates/notebook.mako

@@ -25,12 +25,14 @@
 <%namespace name="notebookKoComponents" file="/common_notebook_ko_components.mako" />
 <%namespace name="hueAceAutocompleter" file="hue_ace_autocompleter.mako" />
 
+%if not is_embeddable:
 ${ commonheader(_('Notebook'), app_name, user, request, "68px") | n,unicode }
+%endif
 
 <span id="notebookComponents" class="notebook">
-${ editorComponents.includes() }
+${ editorComponents.includes(is_embeddable) }
 ${ editorComponents.topBar() }
-<%editorComponents:commonHTML>
+<%editorComponents:commonHTML is_embeddable="${is_embeddable}">
   <%def name="addSnippetHTML()">
     <h1 class="empty" data-bind="visible: $root.availableSnippets().length == 0">${ _('There are no snippets configured.') }</h1>
 
@@ -49,15 +51,20 @@ ${ editorComponents.topBar() }
   </%def>
 </%editorComponents:commonHTML>
 
+%if not is_embeddable:
 ${ assist.assistPanel() }
 ${ assist.assistJSModels() }
+%endif
 ${ configKoComponents.config() }
 ${ notebookKoComponents.aceKeyboardShortcuts() }
 ${ notebookKoComponents.addSnippetMenu() }
 ${ notebookKoComponents.downloadSnippetResults() }
 ${ hueAceAutocompleter.hueAceAutocompleter() }
 
-${ editorComponents.commonJS(bindableElement='notebookComponents') }
+${ editorComponents.commonJS(is_embeddable=is_embeddable, bindableElement='notebookComponents') }
 
 </span>
+
+%if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }
+%endif

+ 0 - 58
desktop/libs/notebook/src/notebook/templates/notebook_embeddable.mako

@@ -1,58 +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.
-<%!
-  from desktop.views import commonheader, commonfooter
-  from desktop import conf
-  from django.utils.translation import ugettext as _
-%>
-
-<%namespace name="assist" file="/assist.mako" />
-<%namespace name="configKoComponents" file="/config_ko_components.mako" />
-<%namespace name="editorComponents" file="editor_components.mako" />
-<%namespace name="notebookKoComponents" file="/common_notebook_ko_components.mako" />
-<%namespace name="hueAceAutocompleter" file="hue_ace_autocompleter.mako" />
-
-<span id="notebookComponents" class="editorComponents notebook">
-${ editorComponents.includes(is_embeddable=True) }
-${ editorComponents.topBar() }
-<%editorComponents:commonHTML with_assist='false'>
-  <%def name="addSnippetHTML()">
-    <h1 class="empty" data-bind="visible: $root.availableSnippets().length == 0">${ _('There are no snippets configured.') }</h1>
-
-    <!-- ko if: $root.availableSnippets().length > 0 -->
-    <h1 class="empty" data-bind="visible: snippets().length == 0">${ _('Add a snippet to start your new notebook') }</h1>
-
-    <div class="add-snippet" data-bind="component: {
-      name: 'add-snippet-menu',
-      params: {
-        notebook: $data,
-        availableSnippets: $root.availableSnippets
-      }
-    }">
-    </div>
-    <!-- /ko -->
-  </%def>
-</%editorComponents:commonHTML>
-
-${ configKoComponents.config() }
-${ notebookKoComponents.aceKeyboardShortcuts() }
-${ notebookKoComponents.addSnippetMenu() }
-${ notebookKoComponents.downloadSnippetResults() }
-${ hueAceAutocompleter.hueAceAutocompleter() }
-
-${ editorComponents.commonJS(is_embeddable=True, bindableElement='notebookComponents') }
-
-</span>

+ 2 - 5
desktop/libs/notebook/src/notebook/views.py

@@ -73,13 +73,10 @@ def notebook(request, is_embeddable=False):
   except:
     LOG.exception('Spark is not enabled')
 
-  template = 'notebook.mako'
-  if is_embeddable:
-    template = 'notebook_embeddable.mako'
-
-  return render(template, request, {
+  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),
           'session_properties': SparkApi.get_properties(),