You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by di...@apache.org on 2016/04/13 16:37:02 UTC

ambari git commit: AMBARI-15844: Add conf property UI to show warning of potential duplications among all confType for the service (dili)

Repository: ambari
Updated Branches:
  refs/heads/trunk b4adae5cc -> fbb314a71


AMBARI-15844: Add conf property UI to show warning of potential duplications among all confType for the service (dili)


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

Branch: refs/heads/trunk
Commit: fbb314a710dc8a7225f3aaf95800fbb9f795d57a
Parents: b4adae5
Author: Di Li <di...@apache.org>
Authored: Wed Apr 13 10:34:23 2016 -0400
Committer: Di Li <di...@apache.org>
Committed: Wed Apr 13 10:34:23 2016 -0400

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  4 +-
 .../common/configs/addPropertyWindow.hbs        | 15 ++++++-
 .../configs/service_configs_by_category_view.js | 43 +++++++++++++++++---
 3 files changed, 54 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fbb314a7/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index d9064ea..5f95cb8 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1977,7 +1977,9 @@ Em.I18n.translations = {
   'services.service.config.failSaveConfigHostOverrides':'Failure in saving service configuration overrides',
   'services.service.config.addPropertyWindow.error.required':'This is required',
   'services.service.config.addPropertyWindow.error.derivedKey':'This property is already defined',
-  'services.service.config.addPropertyWindow.error.derivedKey.specific':'Property "{0}" is already defined',
+  'services.service.config.addPropertyWindow.error.derivedKey.location':'This property is already defined in other configuration file(s) {0}',
+  'services.service.config.addPropertyWindow.error.derivedKey.infile':'This property is already defined in this configuration file',
+  'services.service.config.addPropertyWindow.error.derivedKey.specific':'Property "{0}" is already defined in this configuration file',
   'services.service.config.addPropertyWindow.error.format':'Key and value should be separated by "=" sign',
   'services.service.config.addPropertyWindow.error.lineNumber':'Line {0}: ',
   'services.service.config.addPropertyWindow.filterKeyLink' : 'Find property',

http://git-wip-us.apache.org/repos/asf/ambari/blob/fbb314a7/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/addPropertyWindow.hbs b/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
index 61572fd..659435c 100644
--- a/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
+++ b/ambari-web/app/templates/common/configs/addPropertyWindow.hbs
@@ -54,12 +54,23 @@
   {{else}}
     <div {{bindAttr class="view.serviceConfigObj.isKeyError:error :each-row :control-group"}}>
       <label class="control-label">{{t common.key}}</label>
-
       <div class="controls">
         {{view Ember.TextField valueBinding="view.serviceConfigObj.name" class="input-block-level"}}
+
         {{#if view.serviceConfigObj.isKeyError}}
-          <span class="help-inline">{{view.serviceConfigObj.errorMessage}}</span>
+          <span class="help-inline">
+            <i class="icon-exclamation-sign"></i>
+            {{view.serviceConfigObj.errorMessage}}
+          </span>
+        {{else}}
+          {{#if view.serviceConfigObj.isKeyWarning}}
+            <span class="help-inline">
+              <i class="icon-warning-sign"></i>
+              {{view.serviceConfigObj.warningMessage}}
+            </span>
+          {{/if}}
         {{/if}}
+
         {{#if view.serviceConfigObj.showFilterLink}}
           {{#if view.notMisc}}
           <a href="#" class="btn-padding" {{action filterByKey target="view" }}>

http://git-wip-us.apache.org/repos/asf/ambari/blob/fbb314a7/ambari-web/app/views/common/configs/service_configs_by_category_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
index b5d5b45..ecd96b0 100644
--- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js
+++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
@@ -380,10 +380,30 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
 
         var configsOfFile = service.get('configs').filterProperty('filename', siteFileName);
 
+        /**
+         * Find duplications within the same confType
+         * Result in error, as no duplicated property keys are allowed in the same configType
+         * */
         function isDuplicatedConfigKey(name) {
           return configsOfFile.findProperty('name', name);
         }
 
+        /**
+         * find duplications in all confTypes of the service
+         * Result in warning, to remind user the existence of a same-named property
+         * */
+        function isDuplicatedConfigKeyinConfigs(name) {
+          var files = [];
+          var configFiles = service.get('configs').mapProperty('filename').uniq();
+          configFiles.forEach(function(configFile){
+            var configsOfFile = service.get('configs').filterProperty('filename', configFile);
+            if(configsOfFile.findProperty('name', name)){
+              files.push(configFile);
+            }
+          }, this);
+          return files;
+        }
+
         var serviceConfigObj = Ember.Object.create({
           isBulkMode: isBulkMode,
           bulkConfigValue: '',
@@ -399,23 +419,36 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
             var name = this.get('name');
             if (name.trim() != '') {
               if (validator.isValidConfigKey(name)) {
-                if (!isDuplicatedConfigKey(name)) {
-                  this.set('showFilterLink', false);
-                  this.set('isKeyError', false);
-                  this.set('errorMessage', '');
+                if (!isDuplicatedConfigKey(name)) { //no duplication within the same confType
+                  var files = isDuplicatedConfigKeyinConfigs(name);
+                  if (files.length > 0) {
+                    //still check for a warning, if there are duplications across confTypes
+                    this.set('showFilterLink', true);
+                    this.set('isKeyWarning', true);
+                    this.set('isKeyError', false);
+                    this.set('warningMessage', Em.I18n.t('services.service.config.addPropertyWindow.error.derivedKey.location').format(files.join(" ")));
+                  } else {
+                    this.set('showFilterLink', false);
+                    this.set('isKeyError', false);
+                    this.set('isKeyWarning', false);
+                    this.set('errorMessage', '');
+                  }
                 } else {
                   this.set('showFilterLink', true);
                   this.set('isKeyError', true);
-                  this.set('errorMessage', Em.I18n.t('services.service.config.addPropertyWindow.error.derivedKey'));
+                  this.set('isKeyWarning', false);
+                  this.set('errorMessage', Em.I18n.t('services.service.config.addPropertyWindow.error.derivedKey.infile'));
                 }
               } else {
                 this.set('showFilterLink', false);
                 this.set('isKeyError', true);
+                this.set('isKeyWarning', false);
                 this.set('errorMessage', Em.I18n.t('form.validator.configKey'));
               }
             } else {
               this.set('showFilterLink', false);
               this.set('isKeyError', true);
+              this.set('isKeyWarning', false);
               this.set('errorMessage', Em.I18n.t('services.service.config.addPropertyWindow.error.required'));
             }
           }.observes('name')