浏览代码

HUE-6777 [fb] Drag & drop upload not enabled if editor was loaded before

Enrico Berti 8 年之前
父节点
当前提交
543a6197ac

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

@@ -204,11 +204,11 @@ ${ fb_components.menubar() }
       </div>
     </div>
   </div>
+  <div class="hoverMsg hide">
+    <p class="hoverText"></p>
+  </div>
 </div>
 
-<div class="hoverMsg hide">
-  <p class="hoverText"></p>
-</div>
 
 %if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }

+ 8 - 8
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -2141,12 +2141,12 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
       // Drag and drop uploads from anywhere on filebrowser screen
       if (window.FileReader) {
         var showHoverMsg = function (msg) {
-          $('.hoverText').html(msg);
-          $('.hoverMsg').removeClass('hide');
+          $('.filebrowser .hoverText').html(msg);
+          $('.filebrowser .hoverMsg').removeClass('hide');
         };
 
         var hideHoverMsg = function () {
-          $('.hoverMsg').addClass('hide');
+          $('.filebrowser .hoverMsg').addClass('hide');
         };
 
         var _isDraggingOverText = false,
@@ -2170,14 +2170,14 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
           }
         });
 
-        $('.hoverText').on('dragenter', function (e) {
+        $('.filebrowser .hoverText').on('dragenter', function (e) {
           e.preventDefault();
           e.stopPropagation();
           e.stopImmediatePropagation();
           _isDraggingOverText = true;
         });
 
-        $('.hoverText').on('dragleave', function (e) {
+        $('.filebrowser .hoverText').on('dragleave', function (e) {
           e.preventDefault();
           e.stopPropagation();
           e.stopImmediatePropagation();
@@ -2185,7 +2185,7 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
           _isExternalFile = true;
         });
 
-        $('.hoverMsg').on('dragleave', function (e) {
+        $('.filebrowser .hoverMsg').on('dragleave', function (e) {
           if (!_isDraggingOverText) {
             hideHoverMsg();
           }
@@ -2216,7 +2216,7 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
                 '<div class="progress-row-bar" data-dz-uploadprogress></div>' +
                 '</div>',
             drop: function (e) {
-              $('.hoverMsg').addClass('hide');
+              $('.filebrowser .hoverMsg').addClass('hide');
 
               // Ensure dropped item was a file
               if (e.dataTransfer.files.length > 0) {
@@ -2266,7 +2266,7 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
             }
           };
           if (ops.path.toLowerCase() !== 's3a://') {
-            _dropzone = new Dropzone($('.hoverMsg')[0], options);
+            _dropzone = new Dropzone($('.filebrowser .hoverMsg')[0], options);
 
             _dropzone.on('queuecomplete', function () {
               setTimeout(function () {

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

@@ -1959,17 +1959,17 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       dt = e.dataTransfer;
     }
     if (!isLeftNavOpen && (!dt || (dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') != -1 : dt.types.contains('Files'))))) {
-      $(".hoverMsg").removeClass("hide");
+      $('#${ bindableElement }').find(".hoverMsg").removeClass("hide");
     }
   };
 
   var hideHoverMsg = function (vm) {
     if (vm.editorMode()){
-      $(".hoverText").html("${_('Drop a SQL file here')}");
+      $('#${ bindableElement }').find(".hoverText").html("${_('Drop a SQL file here')}");
     } else {
-      $(".hoverText").html("${_('Drop iPython/Zeppelin notebooks here')}");
+      $('#${ bindableElement }').find(".hoverText").html("${_('Drop iPython/Zeppelin notebooks here')}");
     }
-    $(".hoverMsg").addClass("hide");
+    $('#${ bindableElement }').find(".hoverMsg").addClass("hide");
   };
 
   function renderMarkdown(text, snippetId) {
@@ -3033,21 +3033,21 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
       var isDraggingOverText = false;
 
-      $(".hoverText").on("dragenter", function (e) {
+      $('#${ bindableElement }').find(".hoverText").on("dragenter", function (e) {
         e.preventDefault();
         e.stopPropagation();
         e.stopImmediatePropagation();
         isDraggingOverText = true;
       });
 
-      $(".hoverText").on("dragleave", function (e) {
+      $('#${ bindableElement }').find(".hoverText").on("dragleave", function (e) {
         e.preventDefault();
         e.stopPropagation();
         e.stopImmediatePropagation();
         isDraggingOverText = false;
       });
 
-      $(".hoverMsg").on("dragleave", function (e) {
+      $('#${ bindableElement }').find(".hoverMsg").on("dragleave", function (e) {
         if (!isDraggingOverText) {
           hideHoverMsg(viewModel);
         }