Browse Source

HUE-6091 [editor] Change the url to /hue/editor in Hue 4

Tweaked notebook a bit, ideally would becoe /hue/editor?type=notebook in next follow-up.
Romain Rigaux 8 years ago
parent
commit
f73af7f

+ 21 - 12
desktop/core/src/desktop/templates/hue.mako

@@ -107,7 +107,7 @@ ${ hueIcons.symbols() }
         </a>
 
         <div class="compose-action btn-group">
-          <button class="btn" data-bind="click: function(){ page('/notebook/editor'); onePageViewModel.changeEditorType('hive', true); }" title="${ _('Hive editor') }">${ _('Compose') }</button>
+          <button class="btn" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('hive', true); }" title="${ _('Hive editor') }">${ _('Compose') }</button>
           <button class="btn dropdown-toggle" data-toggle="dropdown">
             <span class="caret"></span>
           </button>
@@ -115,16 +115,16 @@ ${ hueIcons.symbols() }
           <ul class="dropdown-menu">
             % if 'beeswax' in apps and 'impala' in apps:
               <li class="dropdown-submenu">
-                <a title="${_('Query editor')}" data-rel="navigator-tooltip" href="javascript: void(0)" data-bind="click: function(){ page('/notebook/editor'); onePageViewModel.changeEditorType('hive', true); }"><i class="fa fa-fw fa-edit inline-block"></i> ${ _('Editor') }</a>
+                <a title="${_('Query editor')}" data-rel="navigator-tooltip" href="javascript: void(0)" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('hive', true); }"><i class="fa fa-fw fa-edit inline-block"></i> ${ _('Editor') }</a>
                 <ul class="dropdown-menu">
                   % if 'impala' in apps:
-                  <li><a href="javascript: void(0)" data-bind="click: function(){ page('/notebook/editor'); onePageViewModel.changeEditorType('impala', true); }"><img src="${ static(apps['impala'].icon_path) }" class="app-icon" alt="${ _('Impala icon') }"/> ${_('Impala Query')}</a></li>
+                  <li><a href="javascript: void(0)" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('impala', true); }"><img src="${ static(apps['impala'].icon_path) }" class="app-icon" alt="${ _('Impala icon') }"/> ${_('Impala Query')}</a></li>
                   % endif
                   % if 'beeswax' in apps:
-                  <li><a href="javascript: void(0)" data-bind="click: function(){ page('/notebook/editor'); onePageViewModel.changeEditorType('hive', true); }"><img src="${ static(apps['beeswax'].icon_path) }" class="app-icon" alt="${ _('Hive icon') }"/> ${_('Hive Query')}</a></li>
+                  <li><a href="javascript: void(0)" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('hive', true); }"><img src="${ static(apps['beeswax'].icon_path) }" class="app-icon" alt="${ _('Hive icon') }"/> ${_('Hive Query')}</a></li>
                   % endif
                   % if SHOW_NOTEBOOKS.get():
-                  <li><a href="javascript: void(0)" data-bind="click: function(){ opage('/notebook/notebook'); }"><i class="fa fa-fw fa-file-text-o inline-block"></i> ${ _('Notebook') }</a></li>
+                  <li><a href="javascript: void(0)" data-bind="click: function(){ page('/notebook'); }"><i class="fa fa-fw fa-file-text-o inline-block"></i> ${ _('Notebook') }</a></li>
                   % endif
                   % if interpreters:
                   <li class="divider"></li>
@@ -133,7 +133,7 @@ ${ hueIcons.symbols() }
                     <ul class="dropdown-menu">
                       % for interpreter in interpreters:
                         % if interpreter['name'] != 'Hive' and interpreter['name'] != 'Impala':
-                        <li><a  href="javascript: void(0)" data-bind="click: function(){ page('/notebook/editor'); onePageViewModel.changeEditorType('${ interpreter['type'] }', true); }"><span class="dropdown-no-icon">${ interpreter['name'] }</span></a></li>
+                        <li><a  href="javascript: void(0)" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('${ interpreter['type'] }', true); }"><span class="dropdown-no-icon">${ interpreter['name'] }</span></a></li>
                         % endif
                       % endfor
                       % if user.is_superuser:
@@ -233,7 +233,7 @@ ${ hueIcons.symbols() }
         <li class="header">&nbsp;</li>
         <li class="header" style="padding-left: 4px; border-bottom: 1px solid #DDD; padding-bottom: 3px;">${ _('Analyse') }</li>
         % if interpreters:
-        <li data-bind="click: function () { page('/notebook/editor'); onePageViewModel.changeEditorType('hive', true); }"><a href="javascript: void(0);">Editor</a></li>
+        <li data-bind="click: function () { page('/editor'); onePageViewModel.changeEditorType('hive', true); }"><a href="javascript: void(0);">Editor</a></li>
         % endif
         % if IS_DASHBOARD_ENABLED.get():
         <li data-bind="click: function () { page('/dashboard/new_search') }"><a href="javascript: void(0);">Dashboard</a></li>
@@ -512,8 +512,8 @@ ${ assist.assistPanel() }
     var onePageViewModel = (function () {
 
       var EMBEDDABLE_PAGE_URLS = {
-        editor: '/notebook/editor',
-        notebook: '/notebook/notebook',
+        editor: '/editor',
+        notebook: '/notebook',
         metastore: '/metastore/tables/',
         dashboard: '/dashboard/new_search',
         oozie_workflow: '/oozie/editor/workflow/new/',
@@ -801,7 +801,7 @@ ${ assist.assistPanel() }
           self.currentApp('useradmin_configurations');
         });
 
-        page('/notebook/editor', function (ctx) {
+        page('/editor', function (ctx) {
           self.currentApp('editor');
           if (window.location.getParameter('editor') !== '') {
             self.getActiveAppViewModel(function (viewModel) {
@@ -818,8 +818,17 @@ ${ assist.assistPanel() }
           self.changeEditorType('pig');
         });
 
-        page('/notebook/notebook', function(ctx){
+        page('/notebook', function(ctx){
           self.currentApp('notebook');
+          if (window.location.getParameter('notebook') !== '') {
+            self.getActiveAppViewModel(function (viewModel) {
+              viewModel.openNotebook(window.location.getParameter('notebook'));
+            });
+          } else {
+            self.getActiveAppViewModel(function (viewModel) {
+              viewModel.newNotebook('notebook');
+            });
+          }
         });
 
         page('/home', function(ctx){
@@ -901,7 +910,7 @@ ${ assist.assistPanel() }
         });
 
         page('/', function(ctx){
-          page('/notebook/editor');
+          page('/editor');
         });
 
         page('*', function(ctx){

+ 4 - 0
desktop/core/src/desktop/urls.py

@@ -141,6 +141,10 @@ dynamic_patterns += patterns('desktop.api2',
   (r'^desktop/api/search/entities_interactive/?$', 'search_entities_interactive'),
 )
 
+dynamic_patterns += patterns('notebook.views',
+  (r'^editor', 'editor'),
+)
+
 # Default Configurations
 dynamic_patterns += patterns('desktop.configuration.api',
   (r'^desktop/api/configurations/?$', 'default_configurations'),

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

@@ -2322,8 +2322,8 @@ var EditorViewModel = (function() {
       editor: '/notebook/editor',
       editorMobile: '/notebook/editor_m',
       notebook: '/notebook/notebook',
-      hue4: '/hue/notebook/editor',
-      hue4_notebook: '/hue/notebook/notebook'
+      hue4: '/hue/editor',
+      hue4_notebook: '/hue/notebook'
     }
 
     self.user = options.user;

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

@@ -64,7 +64,7 @@ def notebooks(request):
 
 @check_document_access_permission()
 def notebook(request, is_embeddable=False):
-  notebook_id = request.GET.get('notebook')
+  notebook_id = request.GET.get('notebook', request.GET.get('editor'))
 
   is_yarn_mode = False
   try:
@@ -98,6 +98,9 @@ def editor(request, is_mobile=False, is_embeddable=False):
   editor_id = request.GET.get('editor')
   editor_type = request.GET.get('type', 'hive')
 
+  if editor_type == 'notebook' or request.GET.get('notebook'):
+    return notebook(request)
+
   if editor_id:  # Open existing saved editor document
     document = Document2.objects.get(id=editor_id)
     editor_type = document.type.rsplit('-', 1)[-1]