Browse Source

HUE-1176 [jb] Land on same page as main action

Romain Rigaux 8 years ago
parent
commit
66f6383
2 changed files with 12 additions and 23 deletions
  1. 3 2
      desktop/core/src/desktop/api2.py
  2. 9 21
      desktop/core/src/desktop/templates/hue.mako

+ 3 - 2
desktop/core/src/desktop/api2.py

@@ -66,12 +66,13 @@ def api_error_handler(func):
 
 @api_error_handler
 def get_config(request):
-  app_config = ClusterConfig(request.user).get_apps()
+  cluster_config = ClusterConfig(request.user)
+  app_config = cluster_config.get_apps()
 
   return JsonResponse({
     'status': 0,
     'app_config': app_config,
-    'main_button_action': app_config['editor']['interpreters'][1],
+    'main_button_action': cluster_config.main_quick_action,
     'button_actions': [
       app for app in [
         app_config.get('editor'),

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

@@ -821,25 +821,6 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           { url: '/useradmin/users/add_ldap_users', app: 'useradmin_addldap' },
           { url: '/useradmin/users/edit/:user', app: 'useradmin_edituser' },
           { url: '/useradmin/users/new', app: 'useradmin_newuser' },
-          { url: '/', app: function () {
-            % if 'beeswax' in apps or 'impala' in apps:
-              page('/editor');
-            % elif SHOW_NOTEBOOKS.get():
-              page('/notebook');
-            % elif interpreters:
-              page('/editor');
-            % elif IS_DASHBOARD_ENABLED.get():
-              page('/dashboard/new_search');
-            % elif 'jobbrowser' in apps:
-              page('/jobbrowser/');
-            % else:
-              page('/home');
-            % endif
-          }},
-          { url: '*', app: function (ctx) {
-            console.error('Route not found', ctx);
-            self.loadApp('404');
-          }}
         ];
 
         pageMapping.forEach(function (mapping) {
@@ -850,7 +831,14 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           })
         });
 
-        page();
+        huePubSub.subscribe('cluster.config.set.config', function (clusterConfig) {
+          page('/', function() {  page(clusterConfig['main_button_action'].page); });
+          page('*', function (ctx) {
+            console.error('Route not found', ctx);
+            self.loadApp('404');
+          });
+          page();
+        });
 
         huePubSub.subscribe('open.link', function (href) {
           if (href.startsWith('/') && !href.startsWith('/hue')){
@@ -1036,7 +1024,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           } else {
             self.quickCreateActions([]);
           }
-                                                                                   
+
           self.hasJobBrowser(clusterConfig && clusterConfig['app_config'] && clusterConfig['app_config']['browser']);
         });