Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3694185EC for ; Fri, 26 Feb 2016 10:19:48 +0000 (UTC) Received: (qmail 90323 invoked by uid 500); 26 Feb 2016 10:19:48 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 90255 invoked by uid 500); 26 Feb 2016 10:19:48 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 90235 invoked by uid 99); 26 Feb 2016 10:19:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Feb 2016 10:19:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AB66ADFF85; Fri, 26 Feb 2016 10:19:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dbhowmick@apache.org To: commits@ambari.apache.org Date: Fri, 26 Feb 2016 10:19:49 -0000 Message-Id: <2e460eb357bc486389f0786745b53383@git.apache.org> In-Reply-To: <99ffd027b4034abc82f193671eb6b857@git.apache.org> References: <99ffd027b4034abc82f193671eb6b857@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] ambari git commit: AMBARI-15177. [Better User Experience]Display of message when folder with length 255 is created. (dipayanb) 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 Authored: Fri Feb 26 15:48:10 2016 +0530 Committer: Dipayan Bhowmick 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) => {