AMBARI-15177. [Better User Experience]Display of message when folder with 
length 255 is created. (dipayanb)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4e89a911
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4e89a911
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4e89a911

Branch: refs/heads/branch-2.2
Commit: 4e89a911657a34ccf035e16382bdc9152894adb8
Parents: f16fae9
Author: Dipayan Bhowmick <[email protected]>
Authored: Fri Feb 26 15:48:10 2016 +0530
Committer: Dipayan Bhowmick <[email protected]>
Committed: Fri Feb 26 15:50:50 2016 +0530

----------------------------------------------------------------------
 .../ui/app/components/new-directory.js          | 26 +++++++++++++----
 .../resources/ui/app/components/rename-modal.js | 30 ++++++++++++++++----
 2 files changed, 44 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4e89a911/contrib/views/files/src/main/resources/ui/app/components/new-directory.js
----------------------------------------------------------------------
diff --git 
a/contrib/views/files/src/main/resources/ui/app/components/new-directory.js 
b/contrib/views/files/src/main/resources/ui/app/components/new-directory.js
index c30cc8c..4494a4d 100644
--- a/contrib/views/files/src/main/resources/ui/app/components/new-directory.js
+++ b/contrib/views/files/src/main/resources/ui/app/components/new-directory.js
@@ -42,6 +42,25 @@ export default Ember.Component.extend(OperationModal, {
     this.set('hasError', true);
     this.set('errorMessage', message);
   },
+  validateFolderName: function(folderName) {
+    if(Ember.isBlank(folderName)) {
+      this.setError('Cannot be empty');
+      return false;
+    }
+
+    if(this.get('fileOperationService').isExistsInCurrentPath(folderName)) {
+      this.setError('Name already exists');
+      return false;
+    }
+
+    if(folderName.length > 255) {
+      this.setError(`Max limit for length of folder name is 255. Length: 
${folderName.length}`);
+      return false;
+    }
+
+    return true;
+  },
+
   actions: {
     didOpenModal: function() {
       this.set('folderName');
@@ -50,13 +69,8 @@ export default Ember.Component.extend(OperationModal, {
       }, 500);
     },
     create: function() {
-      if(Ember.isBlank(this.get('folderName'))) {
-        this.setError('Cannot be empty');
-        return false;
-      }
 
-      
if(this.get('fileOperationService').isExistsInCurrentPath(this.get('folderName')))
 {
-        this.setError('Name already exists');
+      if(!this.validateFolderName(this.get('folderName'))) {
         return false;
       }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4e89a911/contrib/views/files/src/main/resources/ui/app/components/rename-modal.js
----------------------------------------------------------------------
diff --git 
a/contrib/views/files/src/main/resources/ui/app/components/rename-modal.js 
b/contrib/views/files/src/main/resources/ui/app/components/rename-modal.js
index 09ae061..c763c4a 100644
--- a/contrib/views/files/src/main/resources/ui/app/components/rename-modal.js
+++ b/contrib/views/files/src/main/resources/ui/app/components/rename-modal.js
@@ -37,6 +37,29 @@ export default Ember.Component.extend(OperationModal, {
     }
   }),
 
+  validateErrors: function() {
+    let suggestedName = this.get('selectionName');
+    if (Ember.isBlank(suggestedName)) {
+      this.set('hasError', true);
+      this.set('errorMessage', 'Name cannot be blank');
+      return false;
+    }
+
+    if (this.get('selected.name') === suggestedName) {
+      this.set('hasError', true);
+      this.set('errorMessage', 'Name should be different');
+      return false;
+    }
+
+    if (suggestedName.length > 255) {
+      this.set('hasError', true);
+      this.set('errorMessage', `Max limit for length of file name is 255. 
Length: ${suggestedName.length}`);
+      return false;
+    }
+
+    return true;
+  },
+
   actions: {
     didOpenModal: function() {
       this.set('selectionName', this.get('selected.name'));
@@ -48,15 +71,10 @@ export default Ember.Component.extend(OperationModal, {
     },
 
     rename: function() {
-      if(Ember.isBlank(this.get('selectionName'))) {
+      if(!this.validateErrors()) {
         return false;
       }
 
-      if(this.get('selected.name') === this.get('selectionName')) {
-        this.set('hasError', true);
-        this.set('errorMessage', 'Name should be different');
-        return false;
-      }
       this.set('isUpdating', true);
       this.get('renameService').rename(this.get('selected.path'), 
this.get('selectionName'))
       .then((response) => {

Reply via email to