Преглед изворни кода

HUE-5579 [responsive] The file viewer breadcrumbs should point to the right file browser

Enrico Berti пре 9 година
родитељ
комит
59f565a055

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/display.mako

@@ -121,7 +121,7 @@ ${ fb_components.menubar() }
           </div>
         <!-- /ko -->
         % if breadcrumbs:
-          ${fb_components.breadcrumbs(path, breadcrumbs)}
+          ${fb_components.breadcrumbs(path, breadcrumbs, is_embeddable=is_embeddable)}
         %endif
         <div class="card-body" style="padding: 0">
             <!-- ko if: $root.file() && $root.file().stats.size() === 0 -->

+ 27 - 17
apps/filebrowser/src/filebrowser/templates/fb_components.mako

@@ -20,7 +20,7 @@ from django.utils.translation import ugettext as _
 from aws import get_client
 %>
 
-<%def name="breadcrumbs(path, breadcrumbs, from_listdir=False)">
+<%def name="breadcrumbs(path, breadcrumbs, from_listdir=False, is_embeddable=False)">
     % if from_listdir:
       <ul class="nav nav-pills hueBreadcrumbBar">
         %if path.lower().find('s3a://') == 0:
@@ -56,25 +56,35 @@ from aws import get_client
       </ul>
     % else:
       <ul class="nav nav-pills hueBreadcrumbBar">
+        %if is_embeddable:
+        <li><a href="javascript:void(0)" onclick="huePubSub.publish('open.link', '${url('filebrowser.views.view', path=urlencode(path))}?default_to_home')" class="homeLink"><i class="fa fa-home"></i> ${_('Home')}</a></li>
+        <li>
+          <ul class="hueBreadcrumb" style="padding-right:40px; padding-top: 12px">
+          % for breadcrumb_item in breadcrumbs:
+            <% label, f_url = breadcrumb_item['label'], breadcrumb_item['url'] %>
+            %if label[-1] == '/':
+            <li><a href="javascript:void(0)" onclick="huePubSub.publish('open.fb.folder', '${f_url}')"><span class="divider">${label}</span></a></li>
+            %else:
+            <li><a href="javascript:void(0)" onclick="huePubSub.publish('open.fb.folder', '${f_url}')">${label}</a><span class="divider">/</span></li>
+            %endif
+          % endfor
+          </ul>
+        </li>
+        %else:
         <li><a href="${url('filebrowser.views.view', path=urlencode(path))}?default_to_home" class="homeLink"><i class="fa fa-home"></i> ${_('Home')}</a></li>
         <li>
-            <ul class="hueBreadcrumb" style="padding-right:40px; padding-top: 12px">
-                    % for breadcrumb_item in breadcrumbs:
-                    <% label, f_url = breadcrumb_item['label'], breadcrumb_item['url'] %>
-                    %if label[-1] == '/':
-                            <li>
-                              <a href="${url('filebrowser.views.view', path=f_url)}">
-                                <span class="divider">${label}</span>
-                              </a>
-                            </li>
-                    %else:
-                            <li>
-                              <a href="${url('filebrowser.views.view', path=f_url)}">${label}</a>
-                              <span class="divider">/</span></li>
-                    %endif
-                    % endfor
-            </ul>
+          <ul class="hueBreadcrumb" style="padding-right:40px; padding-top: 12px">
+          % for breadcrumb_item in breadcrumbs:
+            <% label, f_url = breadcrumb_item['label'], breadcrumb_item['url'] %>
+            %if label[-1] == '/':
+            <li><a href="${url('filebrowser.views.view', path=f_url)}"><span class="divider">${label}</span></a></li>
+            %else:
+            <li><a href="${url('filebrowser.views.view', path=f_url)}">${label}</a><span class="divider">/</span></li>
+            %endif
+          % endfor
+          </ul>
         </li>
+        %endif
       </ul>
     % endif
 </%def>

+ 14 - 0
desktop/core/src/desktop/templates/responsive.mako

@@ -487,6 +487,12 @@ ${ assist.assistPanel() }
           self.currentApp('fileviewer');
         });
 
+        huePubSub.subscribe('open.fb.folder', function (path) {
+          hueUtils.removeURLParameter('path');
+          self.currentApp('filebrowser');
+          window.location.hash = path;
+        });
+
         huePubSub.subscribe('open.link', function (href) {
           if (href.startsWith('/notebook/editor')){
             if (location.getParameter('type') !== ''){
@@ -523,6 +529,9 @@ ${ assist.assistPanel() }
           else if (href.startsWith('/oozie/editor/bundle/new')){
             self.currentApp('oozie_bundle');
           }
+          else if (href.startsWith('/filebrowser')){
+            self.currentApp('filebrowser');
+          }
         });
 
         self.currentApp.subscribe(function (newVal) {
@@ -587,6 +596,11 @@ ${ assist.assistPanel() }
                 self.currentApp('filebrowser');
               }
               break;
+            case 'filebrowser':
+              var previousHash = window.location.hash;
+              self.currentApp(app);
+              window.location.hash = previousHash;
+              break;
             case 'editor':
               if (window.location.getParameter('type') !== '') {
                 self.changeEditorType(window.location.getParameter('type'));