Browse Source

HUE-6996 [frontend] Clicking on home doesn't allow to go back in history

Enrico Berti 8 years ago
parent
commit
4bed593

+ 3 - 3
apps/oozie/src/oozie/templates/navigation-bar.mako

@@ -88,21 +88,21 @@
                 % if is_editor:
                   <li class="${utils.is_selected(section, 'workflows')}">
                     % if is_embeddable:
-                    <a href="/home?type=oozie-workflow2">${ _('Workflows') }</a>
+                    <a href="/home/?type=oozie-workflow2">${ _('Workflows') }</a>
                     % else:
                     <a href="${url('oozie:list_editor_workflows')}">${ _('Workflows') }</a>
                     % endif
                   </li>
                   <li class="${utils.is_selected(section, 'coordinators')}">
                     % if is_embeddable:
-                    <a href="/home?type=oozie-coordinator2">${ _('Coordinators') }</a>
+                    <a href="/home/?type=oozie-coordinator2">${ _('Coordinators') }</a>
                     % else:
                     <a href="${url('oozie:list_editor_coordinators')}">${ _('Coordinators') }</a>
                     % endif
                   </li>
                   <li class="${utils.is_selected(section, 'bundles')}">
                     % if is_embeddable:
-                    <a href="/home?type=oozie-bundle2">${ _('Bundles') }</a>
+                    <a href="/home/?type=oozie-bundle2">${ _('Bundles') }</a>
                     % else:
                     <a href="${url('oozie:list_editor_bundles')}">${ _('Bundles') }</a>
                     % endif

+ 6 - 2
desktop/core/src/desktop/static/desktop/js/home2.vm.js

@@ -89,9 +89,13 @@ var HomeViewModel = (function () {
         self.activeEntry().entries([]);
         self.activeEntry().load();
         if (!newVal || newVal.type === 'all') {
-          hueUtils.removeURLParameter('type');
+          if (location.getParameter('type')) {
+            hueUtils.removeURLParameter('type');
+          }
         } else {
-          hueUtils.changeURLParameter('type', newVal.type);
+          if (!location.getParameter('type') || location.getParameter('type') !== newVal.type) {
+            hueUtils.changeURLParameter('type', newVal.type);
+          }
         }
       }
     });

+ 8 - 5
desktop/core/src/desktop/templates/common_home.mako

@@ -115,13 +115,16 @@
       loadUrlParam();
 
       viewModel.activeEntry.subscribe(function (newEntry) {
-        var filterType = window.location.pathname.indexOf('/home') > -1 && window.location.getParameter('type') != '' ? '&type=' + window.location.getParameter('type') : '';
-        if (typeof newEntry !== 'undefined' && newEntry.definition().uuid && ! newEntry.isRoot()) {
-          if (window.location.getParameter('uuid') == '' || window.location.getParameter('uuid') !== newEntry.definition().uuid){
-            hueUtils.changeURL('${ is_embeddable and '/hue' or ''}/home/?uuid=' + newEntry.definition().uuid + filterType);
+        var filterType = window.location.pathname.indexOf('/home') > -1 && window.location.getParameter('type') != '' ? 'type=' + window.location.getParameter('type') : '';
+        if (typeof newEntry !== 'undefined' && newEntry.definition().uuid && !newEntry.isRoot()) {
+          if (window.location.getParameter('uuid') === '' || window.location.getParameter('uuid') !== newEntry.definition().uuid){
+            hueUtils.changeURL('${ is_embeddable and '/hue' or ''}/home/?uuid=' + newEntry.definition().uuid + '&' + filterType);
           }
         } else if (typeof newEntry === 'undefined' || newEntry.isRoot()) {
-          hueUtils.changeURL('${ is_embeddable and '/hue' or ''}/home/' + (filterType ? '?' + filterType : ''));
+          var url = '${ is_embeddable and '/hue' or ''}/home/' + (filterType ? '?' + filterType : '');
+          if (window.location.pathname + window.location.search !== url) {
+            hueUtils.changeURL(url);
+          }
         }
       });
 

+ 7 - 7
desktop/core/src/desktop/templates/hue.mako

@@ -109,7 +109,7 @@ ${ hueIcons.symbols() }
           <span class="hamburger-box"><span class="hamburger-inner"></span></span>
         </a>
 
-        <a class="brand" data-bind="hueLink: '/home'" href="javascript: void(0);" title="${_('Documents')}">
+        <a class="brand" data-bind="hueLink: '/home/'" href="javascript: void(0);" title="${_('Documents')}">
           <svg style="height: 24px; width: 120px;"><use xlink:href="#hi-logo"></use></svg>
         </a>
 
@@ -902,7 +902,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
             location.href = '/accounts/logout';
           }},
           { url: '/dashboard/admin/collections', app: function (ctx) {
-            page('/home?type=search-dashboard');
+            page('/home/?type=search-dashboard');
           }},
           { url: '/dashboard/*', app: 'dashboard' },
           { url: '/desktop/dump_config', app: 'dump_config' },
@@ -989,18 +989,18 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
             page('/notebook?' + ctx.querystring);
           }},
           { url: '/notebook/notebooks', app: function (ctx) {
-            page('/home?' + ctx.querystring);
+            page('/home/?' + ctx.querystring);
           }},
           { url: '/oozie/editor/bundle/list', app: function (ctx) {
-            page('/home?type=oozie-bundle');
+            page('/home/?type=oozie-bundle');
           }},
           { url: '/oozie/editor/bundle/*', app: 'oozie_bundle' },
           { url: '/oozie/editor/coordinator/list', app: function (ctx) {
-            page('/home?type=oozie-coordinator');
+            page('/home/?type=oozie-coordinator');
           }},
           { url: '/oozie/editor/coordinator/*', app: 'oozie_coordinator' },
           { url: '/oozie/editor/workflow/list', app: function (ctx) {
-            page('/home?type=oozie-workflow');
+            page('/home/?type=oozie-workflow');
           }},
           { url: '/oozie/editor/workflow/*', app: 'oozie_workflow' },
           { url: '/oozie/list_oozie_info', app: 'oozie_info' },
@@ -1395,7 +1395,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
             var browserItems = [];
             browserItems.push({
               displayName: '${ _('Documents') }',
-              url: '/home',
+              url: '/home/',
               icon: 'documents'
             });
             if (appConfig['browser'] && appConfig['browser']['interpreters']) {

+ 1 - 1
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -89,7 +89,7 @@ from desktop.views import commonheader, commonfooter, _ko
       <i class="fa fa-file-o"></i>
     </a>
     <!-- ko if: IS_HUE_4 -->
-    <a class="btn" href="/home?type=search-dashboard" title="${ _('Dashboards') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
+    <a class="btn" href="/home/?type=search-dashboard" title="${ _('Dashboards') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
       <i class="fa fa-tags"></i>
     </a>
     <!-- /ko -->

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

@@ -265,7 +265,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
         <!-- /ko -->
 
         <!-- ko if: IS_HUE_4 -->
-        <a class="btn" data-bind="hueLink: '/home?type=' + (editorMode() ? 'query-' : '') + editorType(), attr: { 'title': editorMode() ? '${ _('Queries') }' : '${ _('Notebooks') }'  }" rel="tooltip" data-placement="bottom">
+        <a class="btn" data-bind="hueLink: '/home/?type=' + (editorMode() ? 'query-' : '') + editorType(), attr: { 'title': editorMode() ? '${ _('Queries') }' : '${ _('Notebooks') }'  }" rel="tooltip" data-placement="bottom">
           <i class="fa fa-tags"></i>
         </a>
         <!-- /ko -->
@@ -337,7 +337,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
             <a title="${ _('This is a history query') }"><i class="fa fa-fw fa-history"></i></a>
           </li>
           <li data-bind="visible: directoryUuid" style="display: none" class="no-horiz-padding muted">
-            <a title="${ _('Open directory of this query') }" data-bind="hueLink: '/home?uuid=' + directoryUuid()"
+            <a title="${ _('Open directory of this query') }" data-bind="hueLink: '/home/?uuid=' + directoryUuid()"
               class="pointer inactive-action" href="javascript:void(0)"><i class="fa fa-fw fa-folder-o"></i>
             </a>
           </li>