Browse Source

[ozone] adding warnings for illegal volume and bucket name (#3247)

Ayush Goyal 2 years ago
parent
commit
901544a8b9
1 changed files with 22 additions and 0 deletions
  1. 22 0
      apps/filebrowser/src/filebrowser/templates/listdir_components.mako

+ 22 - 0
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -501,6 +501,12 @@ else:
         <div id="smallFileSystemNameAlert" class="hide" style="position: absolute; left: 10px;">
         <div id="smallFileSystemNameAlert" class="hide" style="position: absolute; left: 10px;">
           <span class="label label-important"><span class="newName"></span> ${_('File system requires namesize to be 3 or more characters')}</span>
           <span class="label label-important"><span class="newName"></span> ${_('File system requires namesize to be 3 or more characters')}</span>
         </div>
         </div>
+        <div id="volumeBucketNameAlert" class="hide" style="position: absolute; left: 10px;">
+          <span class="label label-important"><span class="newName"></span> ${_('Volume and Bucket name should be 3 to 63 characters.')}</span>
+        </div>
+        <div id="upperCaseVolumeBucketNameAlert" class="hide" style="position: absolute; left: 10px;">
+          <span class="label label-important"><span class="newName"></span> ${_('Upper case characters are not supported for Volume and Bucket names.')}</span>
+        </div>
         <a class="btn" href="#" data-dismiss="modal">${_('Cancel')}</a>
         <a class="btn" href="#" data-dismiss="modal">${_('Cancel')}</a>
         <input class="btn btn-primary" type="submit" value="${_('Create')}" />
         <input class="btn btn-primary" type="submit" value="${_('Create')}" />
       </div>
       </div>
@@ -1854,6 +1860,20 @@ else:
           resetPrimaryButtonsStatus(); //globally available
           resetPrimaryButtonsStatus(); //globally available
           return false;
           return false;
         }
         }
+        if (self.isOFSRoot() || self.isOFSVol()) {
+          if ($("#newDirectoryNameInput").val().length < 3 || $("#newDirectoryNameInput").val().length > 63) {
+            $("#volumeBucketNameAlert").show();
+            $("#newDirectoryNameInput").addClass("fieldError");
+            resetPrimaryButtonsStatus(); //globally available
+            return false;
+          }
+          if ($("#newDirectoryNameInput").val() !== $("#newDirectoryNameInput").val().toLowerCase()) {
+            $("#upperCaseVolumeBucketNameAlert").show();
+            $("#newDirectoryNameInput").addClass("fieldError");
+            resetPrimaryButtonsStatus(); //globally available
+            return false;
+          }
+        }
         $(formElement).ajaxSubmit({
         $(formElement).ajaxSubmit({
           dataType:  'json',
           dataType:  'json',
           success: function() {
           success: function() {
@@ -2442,6 +2462,8 @@ else:
         $("#directoryNameRequiredAlert").hide();
         $("#directoryNameRequiredAlert").hide();
         $("#directoryNameExistsAlert").hide();
         $("#directoryNameExistsAlert").hide();
         $("#smallFileSystemNameAlert").hide();
         $("#smallFileSystemNameAlert").hide();
+        $("#volumeBucketNameAlert").hide();
+        $("#upperCaseVolumeBucketNameAlert").hide();
       });
       });
 
 
       $("#newFileNameInput").focus(function () {
       $("#newFileNameInput").focus(function () {