Browse Source

HUE-8750 [fb] Fix go to Home

Jean-Francois Desjeans Gauthier 6 năm trước cách đây
mục cha
commit
eba720107f

+ 3 - 3
apps/filebrowser/src/filebrowser/templates/fb_components.mako

@@ -40,7 +40,7 @@ from aws import get_client
             </span>
           </li>
         %else:
-          <li><a class="pointer breadcrumb-link homeLink" data-bind="click: $root.openHome, attr:{'href': window.HUE_BASE_URL + '/filebrowser/view=${ urlencode(path) }?default_to_home'}">
+          <li><a class="pointer breadcrumb-link homeLink" data-bind="click: $root.openHome, attr:{'href': window.HUE_BASE_URL + '/filebrowser/view=${ urllib.quote(path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS) }?default_to_home'}">
             <i class="fa fa-home"></i> ${_('Home')}</a>
           </li>
         %endif
@@ -57,7 +57,7 @@ from aws import get_client
         </li>
         % if is_trash_enabled:
         <li class="pull-right">
-          <a class="pointer breadcrumb-link trashLink" data-bind="click: $root.openTrash, attr:{'href': window.HUE_BASE_URL + '/filebrowser/view=${ urlencode(path) }?default_to_trash'}" title="${_('View trash')}">
+          <a class="pointer breadcrumb-link trashLink" data-bind="click: $root.openTrash, attr:{'href': window.HUE_BASE_URL + '/filebrowser/view=${ urllib.quote(path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS) }?default_to_trash'}" title="${_('View trash')}">
             <i class="fa fa-trash-o"></i> ${_('Trash')}
           </a>
         </li>
@@ -65,7 +65,7 @@ from aws import get_client
       </ul>
     % else:
       <ul class="nav nav-pills hue-breadcrumbs-bar">
-        <li><a data-bind="attr: {href: window.HUE_BASE_URL + '/filebrowser/view=${ urlencode(path) }?default_to_home'}" class="breadcrumb-link homeLink"><i class="fa fa-home"></i> ${_('Home')}</a></li>
+        <li><a data-bind="hueLink: window.HUE_BASE_URL + '/filebrowser/view=${ urllib.quote(path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS) }?default_to_home'" class="breadcrumb-link homeLink"><i class="fa fa-home"></i> ${_('Home')}</a></li>
         <li>
           <ul class="hue-breadcrumbs" style="padding-right:40px; padding-top: 12px">
           % for breadcrumb_item in breadcrumbs:

+ 3 - 7
apps/filebrowser/src/filebrowser/views.py

@@ -178,24 +178,20 @@ def view(request, path):
     decoded_path = urllib.unquote(path)
     if path != decoded_path:
       path = decoded_path
-    if request.GET.get('format') == 'json':
-      prefix = '' 
-    else:
-      prefix = '/hue'
     # default_to_home is set in bootstrap.js
     if 'default_to_home' in request.GET:
         home_dir_path = request.user.get_home_directory()
         if request.fs.isdir(home_dir_path):
-            return format_preserving_redirect(request, prefix + '/filebrowser/view=' + urllib.quote(home_dir_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS))
+            return format_preserving_redirect(request, '/filebrowser/view=' + urllib.quote(home_dir_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS))
 
     # default_to_home is set in bootstrap.js
     if 'default_to_trash' in request.GET:
         home_trash_path = _home_trash_path(request.fs, request.user, path)
         if request.fs.isdir(home_trash_path):
-            return format_preserving_redirect(request, prefix + '/filebrowser/view=' + urllib.quote(home_trash_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS))
+            return format_preserving_redirect(request, '/filebrowser/view=' + urllib.quote(home_trash_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS))
         trash_path = request.fs.trash_path(path)
         if request.fs.isdir(trash_path):
-            return format_preserving_redirect(request, prefix + '/filebrowser/view=' + urllib.quote(trash_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS))
+            return format_preserving_redirect(request, '/filebrowser/view=' + urllib.quote(trash_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS))
 
     try:
         stats = request.fs.stats(path)

+ 4 - 2
desktop/core/src/desktop/js/jquery/plugins/jquery.filechooser.js

@@ -272,8 +272,10 @@ Plugin.prototype.navigateTo = function(path) {
     .find('.filechooser-tree')
     .html('<i style="font-size: 24px; color: #DDD" class="fa fa-spinner fa-spin"></i>');
   let pageSize = '?pagesize=1000';
-  if (path.indexOf('?') > -1) {
-    pageSize = pageSize.replace(/\?/, '&');
+  var index = path.indexOf('?');
+  if (index > -1) {
+    pageSize = path.substring(index) + pageSize.replace(/\?/, '&');
+    path = path.substring(0, index);
   }
   $.getJSON('/filebrowser/view=' + encodeURIComponent(path) + pageSize, data => {
     $(_parent.element)