Эх сурвалжийг харах

HUE-6594 [fb] Avoid TypeError on clicking on create folder without a name

Romain Rigaux 8 жил өмнө
parent
commit
f8195fa

+ 21 - 19
desktop/core/src/desktop/static/desktop/js/jquery.filechooser.js

@@ -489,27 +489,29 @@
             _createFolderDetails.slideUp();
           });
           _folderBtn.click(function () {
-            $.ajax({
-              type: "POST",
-              url: "/filebrowser/mkdir",
-              data: {
-                name: _folderName.val(),
-                path: path
-              },
-              success: function (xhr, status) {
-                if (status == "success") {
-                  _parent.navigateTo(path);
-                  if (_uploadFileBtn) {
-                    _uploadFileBtn.removeClass("disabled");
+            if (_folderName.val().length > 0) {
+              $.ajax({
+                type: "POST",
+                url: "/filebrowser/mkdir",
+                data: {
+                  name: _folderName.val(),
+                  path: path
+                },
+                success: function (xhr, status) {
+                  if (status == "success") {
+                    _parent.navigateTo(path);
+                    if (_uploadFileBtn) {
+                      _uploadFileBtn.removeClass("disabled");
+                    }
+                    _createFolderBtn.removeClass("disabled");
+                    _createFolderDetails.slideUp();
                   }
-                  _createFolderBtn.removeClass("disabled");
-                  _createFolderDetails.slideUp();
+                },
+                error: function (xhr) {
+                  $(document).trigger("error", xhr.responseText);
                 }
-              },
-              error: function (xhr) {
-                $(document).trigger("error", xhr.responseText);
-              }
-            });
+              });
+            }
           });
 
           _createFolderDetails.appendTo(_actions);