Browse Source

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

Enrico Berti 8 năm trước cách đây
mục cha
commit
8502b9a987

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

@@ -515,7 +515,7 @@ ${ assist.assistPanel() }
     var onePageViewModel = (function () {
     var onePageViewModel = (function () {
 
 
       var EMBEDDABLE_PAGE_URLS = {
       var EMBEDDABLE_PAGE_URLS = {
-        editor: '/notebook/editor_embeddable',
+        editor: '/notebook/editor?is_embeddable=true',
         notebook: '/notebook/notebook_embeddable',
         notebook: '/notebook/notebook_embeddable',
         metastore: '/metastore/tables/?is_embeddable=true',
         metastore: '/metastore/tables/?is_embeddable=true',
         dashboard: '/dashboard/embeddable/new_search',
         dashboard: '/dashboard/embeddable/new_search',
@@ -903,6 +903,10 @@ ${ assist.assistPanel() }
           self.currentApp('useradmin_configurations');
           self.currentApp('useradmin_configurations');
         });
         });
 
 
+        page('/notebook/editor', function(ctx){
+          self.currentApp('editor');
+        });
+
         page('/', function(ctx){
         page('/', function(ctx){
         });
         });
 
 

+ 8 - 3
desktop/libs/notebook/src/notebook/templates/editor.mako

@@ -25,10 +25,12 @@
 <%namespace name="notebookKoComponents" file="/common_notebook_ko_components.mako" />
 <%namespace name="notebookKoComponents" file="/common_notebook_ko_components.mako" />
 <%namespace name="hueAceAutocompleter" file="hue_ace_autocompleter.mako" />
 <%namespace name="hueAceAutocompleter" file="hue_ace_autocompleter.mako" />
 
 
+%if not is_embeddable:
 ${ commonheader(_('Editor'), editor_type, user, request, "68px") | n,unicode }
 ${ commonheader(_('Editor'), editor_type, user, request, "68px") | n,unicode }
+%endif
 
 
 <span id="editorComponents" class="editorComponents notebook">
 <span id="editorComponents" class="editorComponents notebook">
-${ editorComponents.includes() }
+${ editorComponents.includes(is_embeddable) }
 
 
 <style type="text/css">
 <style type="text/css">
   .snippet {
   .snippet {
@@ -37,16 +39,19 @@ ${ editorComponents.includes() }
 </style>
 </style>
 
 
 ${ editorComponents.topBar() }
 ${ editorComponents.topBar() }
-${ editorComponents.commonHTML() }
+${ editorComponents.commonHTML(is_embeddable) }
 
 
+%if not is_embeddable:
 ${ assist.assistPanel() }
 ${ assist.assistPanel() }
 ${ assist.assistJSModels() }
 ${ assist.assistJSModels() }
+%endif
+
 ${ configKoComponents.config() }
 ${ configKoComponents.config() }
 ${ notebookKoComponents.aceKeyboardShortcuts() }
 ${ notebookKoComponents.aceKeyboardShortcuts() }
 ${ notebookKoComponents.downloadSnippetResults() }
 ${ notebookKoComponents.downloadSnippetResults() }
 ${ hueAceAutocompleter.hueAceAutocompleter() }
 ${ hueAceAutocompleter.hueAceAutocompleter() }
 
 
-${ editorComponents.commonJS() }
+${ editorComponents.commonJS(is_embeddable) }
 </span>
 </span>
 
 
 ${ commonfooter(request, messages) | n,unicode }
 ${ commonfooter(request, messages) | n,unicode }

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

@@ -401,7 +401,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 </%def>
 </%def>
 
 
 
 
-<%def name="commonHTML(with_assist='true')">
+<%def name="commonHTML(is_embeddable=False)">
 
 
 <div id="detailsModal" class="modal transparent-modal hide" data-backdrop="true" style="width:980px;margin-left:-510px!important">
 <div id="detailsModal" class="modal transparent-modal hide" data-backdrop="true" style="width:980px;margin-left:-510px!important">
   <div class="modal-header">
   <div class="modal-header">
@@ -473,7 +473,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 </div>
 </div>
 % endif
 % endif
 
 
-% if with_assist == 'true':
+% if not is_embeddable:
 <a title="${_('Toggle Assist')}" class="pointer show-assist" data-bind="visible: !$root.isLeftPanelVisible() && $root.assistAvailable(), click: function() { $root.isLeftPanelVisible(true); huePubSub.publish('assist.set.manual.visibility'); }">
 <a title="${_('Toggle Assist')}" class="pointer show-assist" data-bind="visible: !$root.isLeftPanelVisible() && $root.assistAvailable(), click: function() { $root.isLeftPanelVisible(true); huePubSub.publish('assist.set.manual.visibility'); }">
   <i class="fa fa-chevron-right"></i>
   <i class="fa fa-chevron-right"></i>
 </a>
 </a>
@@ -490,7 +490,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 </div>
 </div>
 
 
 <script type="text/html" id="notebook">
 <script type="text/html" id="notebook">
-  % if with_assist == 'true':
+  % if not is_embeddable:
   <div class="assist-container left-panel" data-bind="visible: isLeftPanelVisible() && assistAvailable()">
   <div class="assist-container left-panel" data-bind="visible: isLeftPanelVisible() && assistAvailable()">
     <a title="${_('Toggle Assist')}" class="pointer hide-assist" data-bind="click: function() { isLeftPanelVisible(false); huePubSub.publish('assist.set.manual.visibility'); }">
     <a title="${_('Toggle Assist')}" class="pointer hide-assist" data-bind="click: function() { isLeftPanelVisible(false); huePubSub.publish('assist.set.manual.visibility'); }">
       <i class="fa fa-chevron-left"></i>
       <i class="fa fa-chevron-left"></i>

+ 0 - 47
desktop/libs/notebook/src/notebook/templates/editor_embeddable.mako

@@ -1,47 +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="editorComponents" class="editorComponents notebook">
-${ editorComponents.includes(is_embeddable=True) }
-
-<style type="text/css">
-  .snippet {
-    margin-right: 10px;
-  }
-</style>
-
-${ editorComponents.topBar() }
-${ editorComponents.commonHTML(with_assist='false') }
-
-${ configKoComponents.config() }
-${ notebookKoComponents.aceKeyboardShortcuts() }
-${ notebookKoComponents.downloadSnippetResults() }
-${ hueAceAutocompleter.hueAceAutocompleter() }
-
-${ editorComponents.commonJS(is_embeddable=True) }
-
-</span>

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

@@ -42,7 +42,6 @@ urlpatterns = patterns('notebook.views',
   url(r'^copy/?$', 'copy', name='copy'),
   url(r'^copy/?$', 'copy', name='copy'),
 
 
   url(r'^editor/?$', 'editor', name='editor'),
   url(r'^editor/?$', 'editor', name='editor'),
-  url(r'^editor_embeddable/?$', 'editor_embeddable', name='editor_embeddable'),
   url(r'^editor_m/?$', 'editor_m', name='editor_m'),
   url(r'^editor_m/?$', 'editor_m', name='editor_m'),
   url(r'^browse/(?P<database>\w+)/(?P<table>\w+)/(?P<partition_spec>.+?)?$', 'browse', name='browse'),
   url(r'^browse/(?P<database>\w+)/(?P<table>\w+)/(?P<partition_spec>.+?)?$', 'browse', name='browse'),
   url(r'^execute_and_watch/?$', 'execute_and_watch', name='execute_and_watch'),
   url(r'^execute_and_watch/?$', 'execute_and_watch', name='execute_and_watch'),

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

@@ -108,12 +108,11 @@ def editor(request, is_mobile=False, is_embeddable=False):
   template = 'editor.mako'
   template = 'editor.mako'
   if is_mobile:
   if is_mobile:
     template = 'editor_m.mako'
     template = 'editor_m.mako'
-  if is_embeddable:
-    template = 'editor_embeddable.mako'
 
 
   return render(template, request, {
   return render(template, request, {
       'editor_id': editor_id or None,
       'editor_id': editor_id or None,
       'notebooks_json': '{}',
       'notebooks_json': '{}',
+      'is_embeddable': request.GET.get('is_embeddable', False),
       'editor_type': editor_type,
       'editor_type': editor_type,
       'options_json': json.dumps({
       'options_json': json.dumps({
         'languages': get_ordered_interpreters(request.user),
         'languages': get_ordered_interpreters(request.user),