You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2016/09/01 12:47:50 UTC

ambari git commit: AMBARI-18295. Dependent Configurations popup isn't changed after the subsequent property changes (akovalenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk dd7424f34 -> 169d8dbbf


AMBARI-18295. Dependent Configurations popup isn't changed after the subsequent property changes  (akovalenko)


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

Branch: refs/heads/trunk
Commit: 169d8dbbfd7c0f0e21e3f99f3c6e52f622f87aac
Parents: dd7424f
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Thu Sep 1 15:38:57 2016 +0300
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Thu Sep 1 15:38:57 2016 +0300

----------------------------------------------------------------------
 .../common/configs/config_recommendations.js    | 19 +---------
 .../modal_popups/dependent_configs_list.hbs     |  4 +-
 ambari-web/app/views.js                         |  1 +
 .../views/common/configs/config_diff_view.js    | 40 ++++++++++++++++++++
 .../configs/config_recommendations_test.js      |  7 +---
 5 files changed, 46 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/169d8dbb/ambari-web/app/mixins/common/configs/config_recommendations.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/config_recommendations.js b/ambari-web/app/mixins/common/configs/config_recommendations.js
index c86aebb..79d6f5d 100644
--- a/ambari-web/app/mixins/common/configs/config_recommendations.js
+++ b/ambari-web/app/mixins/common/configs/config_recommendations.js
@@ -96,17 +96,6 @@ App.ConfigRecommendations = Em.Mixin.create({
     Em.assert('name and fileName should be defined', name && fileName);
     var site = App.config.getConfigTagFromFileName(fileName);
     var service = App.config.get('serviceByConfigTypeMap')[site];
-    var trimAndSort = function (value) {
-      if (value == null) {
-        return [];
-      }
-      var values = value.split("\n").filter(function (item) {
-        return item != "";
-      }).sort().join("\n");
-      return difflib.stringAsLines(values);
-    };
-    var initialValues = trimAndSort(initialValue);
-    var recommendedValues = trimAndSort(recommendedValue);
 
     var recommendation = {
       saveRecommended: true,
@@ -124,13 +113,7 @@ App.ConfigRecommendations = Em.Mixin.create({
       allowChangeGroup: false,//TODO groupName!= "Default" && (service.get('serviceName') != this.get('selectedService.serviceName'))
       //TODO&& (App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')).length > 1), //TODO
       serviceDisplayName: service.get('displayName'),
-      recommendedValue: recommendedValue,
-
-      diff: new Handlebars.SafeString(diffview.buildView({
-        baseTextLines: initialValues,
-        newTextLines: recommendedValues,
-        opcodes: new difflib.SequenceMatcher(initialValues, recommendedValues).get_opcodes()
-      }).outerHTML)
+      recommendedValue: recommendedValue
     };
     this.get('recommendations').pushObject(recommendation);
     return recommendation;

http://git-wip-us.apache.org/repos/asf/ambari/blob/169d8dbb/ambari-web/app/templates/common/modal_popups/dependent_configs_list.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/modal_popups/dependent_configs_list.hbs b/ambari-web/app/templates/common/modal_popups/dependent_configs_list.hbs
index 18dbe99..6a2d93b 100644
--- a/ambari-web/app/templates/common/modal_popups/dependent_configs_list.hbs
+++ b/ambari-web/app/templates/common/modal_popups/dependent_configs_list.hbs
@@ -53,11 +53,11 @@
         <td class="config-dependency-filename">{{recommendation.propertyFileName}}</td>
         <td>
           <div>
-            {{recommendation.diff}}
+            {{view App.ConfigDiffView configBinding="recommendation"}}
           </div>
         </td>
       </tr>
     {{/each}}
     </tbody>
   </table>
-</div>
+</span>

http://git-wip-us.apache.org/repos/asf/ambari/blob/169d8dbb/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 904edb7..6ba6486 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -67,6 +67,7 @@ require('views/common/configs/compare_property_view');
 require('views/common/configs/config_history_flow');
 require('views/common/configs/selectable_popup_body_view');
 require('views/common/configs/custom_category_views/notification_configs_view');
+require('views/common/configs/config_diff_view');
 require('views/common/configs/widgets/config_text_field');
 require('views/common/configs/widgets/plain_config_text_field');
 require('views/common/configs/widgets/config_widget_view');

http://git-wip-us.apache.org/repos/asf/ambari/blob/169d8dbb/ambari-web/app/views/common/configs/config_diff_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_diff_view.js b/ambari-web/app/views/common/configs/config_diff_view.js
new file mode 100644
index 0000000..135efb7
--- /dev/null
+++ b/ambari-web/app/views/common/configs/config_diff_view.js
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+var App = require('app');
+
+App.ConfigDiffView = Em.View.extend({
+  template: Em.Handlebars.compile('{{view.diff}}'),
+  diff: function () {
+    var trimAndSort = function (value) {
+      if (value == null) {
+        return [];
+      }
+      var values = value.split("\n").filter(function (item) {
+        return item != "";
+      }).sort().join("\n");
+      return difflib.stringAsLines(values);
+    };
+    var initialValues = trimAndSort(this.get('config.initialValue'));
+    var recommendedValues = trimAndSort(this.get('config.recommendedValue'));
+    return new Handlebars.SafeString(diffview.buildView({
+      baseTextLines: initialValues,
+      newTextLines: recommendedValues,
+      opcodes: new difflib.SequenceMatcher(initialValues, recommendedValues).get_opcodes()
+    }).outerHTML);
+  }.property('config.initialValues', 'config.recommendedValues')
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/169d8dbb/ambari-web/test/mixins/common/configs/config_recommendations_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/config_recommendations_test.js b/ambari-web/test/mixins/common/configs/config_recommendations_test.js
index 5de60e0..baa8ed6 100644
--- a/ambari-web/test/mixins/common/configs/config_recommendations_test.js
+++ b/ambari-web/test/mixins/common/configs/config_recommendations_test.js
@@ -56,7 +56,6 @@ describe('App.ConfigRecommendations', function() {
         allowChangeGroup: false,
         serviceDisplayName: 'sDisplayName',
         recommendedValue: 'pRecommended',
-		diff: {}
       });
       expect(instanceObject.getRecommendation('pName', 'pFile', 'pGroup')).to.eql(res);
     });
@@ -131,8 +130,7 @@ describe('App.ConfigRecommendations', function() {
 					serviceName: 'sName',
 					allowChangeGroup: false,
 					serviceDisplayName: 'sDisplayName',
-					recommendedValue: 'pRecommended',
-					diff: {}
+					recommendedValue: 'pRecommended'
 				}
 			},
 			{
@@ -152,8 +150,7 @@ describe('App.ConfigRecommendations', function() {
 					serviceName: 'sName',
 					allowChangeGroup: false,
 					serviceDisplayName: 'sDisplayName',
-					recommendedValue: undefined,
-					diff: {}
+					recommendedValue: undefined
 				}
 			}
 		];