ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbhowm...@apache.org
Subject [2/3] ambari git commit: AMBARI-15177. [Better User Experience]Display of message when folder with length 255 is created. (dipayanb)
Date Fri, 26 Feb 2016 10:19:49 GMT
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/4e253f67
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4e253f67
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4e253f67

Branch: refs/heads/trunk
Commit: 4e253f6765cb2e4a7269547e72027bb1711f4034
Parents: 965c42f
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Fri Feb 26 15:48:10 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Fri Feb 26 15:48:10 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/4e253f67/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/4e253f67/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) => {


Mime
View raw message